1

I'm using helm-mode in emacs to open files. However, when I try to copy the path of a file (say /home/user1/Documents/file1.txt) to paste it in terminal, I get a message saying

<down-mouse-1> is undefined

How can I defined the left-click and hold of mouse for copy in helm-mode?

2
  • Helm doesn't (and won't) support mouse according to github.com/emacs-helm/helm/issues/501#issuecomment-140496283. I think you can implement your needs as a helm action and add it to relevant helm source, then use keyboard to use it. Nowadays, it is easier to custom helm actions for many helm commands.
    – xuchunyang
    Sep 22, 2015 at 16:34
  • If thats the case can you tell me how to copy a path from helm-mode? Sep 22, 2015 at 16:59

1 Answer 1

2

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.

6
  • I'm not insistent on mouse. I need to copy the whole path not just the filename Sep 22, 2015 at 17:14
  • filename here means the full path of a file.
    – xuchunyang
    Sep 22, 2015 at 17:17
  • I get the following error when I put the first add-to-list in .emacs I get an error Warning (initialization): An error occurred while loading '/Users/user1/.emacs': Symbol's value as variable is void: helm-find-files-actions Sep 22, 2015 at 17:34
  • You can solve it by wrapping undefined variable, e.g., helm-find-files-actions and helm-find-files-map, within (with-eval-after-load "helm-files" ...).
    – xuchunyang
    Sep 22, 2015 at 17:47
  • Sorry I'm new to helm. It will help if you can modify your answer. Once it works I will accept your answer Sep 22, 2015 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.