How can I change emacs helm-find-file default action on directory to be go inside the directory instead of open in in dired?

偶尔善良 提交于 2019-12-04 10:51:22

问题


I am using emacs prelude.

I recently decided to switch to helm from ido.

So I enabled helm and helm-everywhere in emacs prelude,

Everything works perfectly, except the default behavior of helm-find-file

In Ido, I could hit retto go down the selected directory, but I have to hit right or c-j in helm. Also, helm-find-files would list . and .. at the very top for every directory. This means in ido, I can just hit ret ret ret until I get to the final destination if there aren't many directories along the path.

But in helm, I had to type some chars, hit c-j type at least 1 char, hit c-j and so on. I cannot even hit c-j continuously.

I don't want to switch back to ido because I really love helm's grep feature in find-file.

Is there anyway I can change the default order to have it maybe list . and .. at the bottom and ret to enter directory instead of open dired?


回答1:


The function you're looking for is (helm-execute-persistent-action), which is bound to C-z by default. Some people like to switch this with tab:

(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-z") 'helm-select-action)

You can bind it to ret if you like, but it won't open files the way you expect it to.

As for your other question, I don't know if helm has a way to set the default selection position, but to select the first item from the top you could do something like this:

(define-key helm-map (kbd "C-j")
  (lambda ()
    (interactive)
    (helm-move-selection-common :where 'edge :direction 'previous)
    (helm-move-selection-common :where 'line :direction 'next)
    (helm-move-selection-common :where 'line :direction 'next)
    (helm-execute-persistent-action)))


来源:https://stackoverflow.com/questions/27652371/how-can-i-change-emacs-helm-find-file-default-action-on-directory-to-be-go-insid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!