Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 844
LoveProgramming Avatar asked Dec 26 '14 02:12

LoveProgramming


1 Answers

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)))
like image 194
nivekuil Avatar answered Oct 19 '22 00:10

nivekuil