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

1

10

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?

Americanize answered 26/12, 2014 at 2:44 Comment(0)
H
10

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)))
Harwell answered 26/12, 2014 at 4:24 Comment(5)
Thanks! The first one works great, but the second one always open the third item in list. Also, I tried helm-adaptive-mode but it does't seem to work with helm-find-fileAmericanize
By first item I meant the first item that isn't /. or /.. Is that what you meant by getting to the final destination with ret ret ret?Harwell
@Harwell would you be able to help with: #28175654 ?Rilda
See here emacs.stackexchange.com/questions/3798/…Roxannroxanna
To make TAB work in a terminal you also need (define-key helm-map (kbd "C-i") 'helm-execute-persistent-action). See: tuhdo.github.io/helm-intro.htmlWale

© 2022 - 2024 — McMap. All rights reserved.