如何将emacs helm-find-file的默认操作更改为进入目录而不是在dired中打开?

10

我正在使用emacs prelude。

最近我决定从ido切换到helm。

所以我在emacs prelude中启用了helmhelm-everywhere

一切都很完美,除了helm-find-file的默认行为

在ido中,我可以按ret来进入所选目录,但是在helm中我必须按rightc-j。 此外,helm-find-files会在每个目录的顶部列出...。 这意味着在ido中,如果路径上没有太多目录,我只需按ret ret ret即可到达最终目的地。

但是在helm中,我必须输入一些字符,按c-j输入至少1个字符,再按c-j等等。我甚至不能连续按c-j

我不想回到ido,因为我真的很喜欢helm在查找文件时的grep功能。

有没有办法可以更改默认顺序,让它可能将...列在底部,并使用ret进入目录而不是打开dired?

1个回答

10

你要找的函数是(helm-execute-persistent-action),默认情况下它的绑定键是C-z。有些人喜欢将其与tab键交换:

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

如果你愿意,可以将其绑定到ret,但它不会按照你期望的方式打开文件。

至于你的另一个问题,我不知道helm是否有一种设置默认选择位置的方法,但要选择从顶部开始的第一个项目,您可以执行以下操作:

(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)))

谢谢!第一个很好用,但第二个总是打开列表中的第三项。此外,我尝试了helm-adaptive-mode,但似乎它不能与helm-find-file一起使用。 - LoveProgramming
1
我所说的第一项是指不是/或/..的第一项。你所说的通过 ret ret ret 到达最终目的地,是指这个意思吗? - nivekuil
@nivekuil,你能帮忙解决这个问题吗:http://stackoverflow.com/questions/28175154/emacs-ow-can-i-helm-find-with-default-directory-pre-specified? - Leo Ufimtsev
1
请点击此处查看http://emacs.stackexchange.com/questions/3798/how-do-i-make-pressing-ret-in-helm-find-files-open-the-directory/7896#7896。 - f00860
为了使终端中的TAB键起作用,您还需要(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action)。请参见:http://tuhdo.github.io/helm-intro.html - Marcus Junius Brutus

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接