If you don't insist on using mouse in Emacs, implementing your request using keyboard is straightforward. For example, if you want to copy some filename while running the helm-find-files
command, customize helm-find-files-actions
:
(with-eval-after-load "helm-files"
(add-to-list 'helm-find-files-actions '("Copy filename" . kill-new) :append)
(setq helm-source-find-files (helm-make-source "Find Files" 'helm-source-ffiles)))
then you can use the new action "Copy filename" from helm's action menu, that is, type TAB (helm-select-action
) in a helm session.
If you like, you can even assign a shortcut key (e.g., C-c m) for it, so that you can invoke that action without switching to helm's action menu.
(defun helm-ff-run-copy-filename ()
(interactive)
(with-helm-alive-p
(helm-exit-and-execute-action 'kill-new)))
(with-eval-after-load "helm-files"
(define-key helm-find-files-map (kbd "C-c m") #'helm-ff-run-copy-filename))
For other helm commands, customize corresponding action, for example, for helm-recentf
command, customize helm-type-file-actions
similarly.