3

How can I add a custom action to helm-for-files? The helm wiki mentions that executing eshell commands is an available action for helm-find-files. So, if you are using helm-find-files, one way of creating custom actions is to create an eshell command. However, helm-for-files doesn't have it in the list of supported actions.

2

helm-for-files are only composed of these sources:

   '(helm-source-buffers-list
        helm-source-recentf
        helm-source-bookmarks
        helm-source-file-cache
        helm-source-files-in-current-dir
        helm-source-locate) 

helm-find-files is created from this source: helm-source-ffiles. So, it means you cannot share actions between two commands. Those are different.

2

It appears that you can customize helm-type-file-actions to, ah, customize which actions are available for a file.

It does not appear to be possible to customize the actions offered for differing kinds of files. Selected actions based based only on name of the files, well that would be fun but it's not in helm today. Predicting the emacs mode for a file is subtle, it really requires visiting file.

1

You can add custom actions to the list by creating an eshell alias. In the documentation on the wiki, it says

Completion is made on your Eshell aliases.

So you can do it 2 ways

  1. Create an alias in an eshell buffer by typing alias foo cat \$1Enter
  2. Creating a function in lisp, and then creating an alias for the function, for example:

    (defun myaction2 (file)
      (message 
        (concat "My custom action with file: " file)))

    evaluate that function, then in an eshell buffer type alias bar myaction2 \\$1Enter

Now in you when you activate your helm-find-files, you can select a file, and your custom actions will be under the action "Eshell command on file(s)", or you can hit the shortcut M-!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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