【问题标题】:How can I change emacs helm-find-file default action on directory to be go inside the directory instead of open in in dired?如何将目录上的 emacs helm-find-file 默认操作更改为进入目录而不是在目录中打开?
【发布时间】:2014-12-26 02:44:27
【问题描述】:

我正在使用 emacs prelude。

我最近决定从 ido 转向 helm。

所以我在emacs前奏中启用了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 在 find-file 中的 grep 功能。

无论如何我可以更改默认顺序以使其可能在底部列出... 并在ret 进入目录而不是打开目录?

【问题讨论】:

    标签: emacs emacs-prelude emacs-helm


    【解决方案1】:

    你要找的函数是(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
    • 第一个项目是指第一个不是 / 的项目。或 /.. 这就是您使用 ret ret ret 到达最终目的地的意思吗?
    • @nivekuil 你能帮忙吗:stackoverflow.com/questions/28175154/… ?
    • 要使 TAB 在终端中工作,您还需要 (define-key helm-map (kbd "C-i") 'helm-execute-persistent-action)。见:tuhdo.github.io/helm-intro.html
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-20
    • 1970-01-01
    • 2020-03-07
    • 2017-08-26
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多