【问题标题】:emacs ow can I helm-find with default directory pre-specified?emacs ow 我可以使用预先指定的默认目录进行 helm-find 吗?
【发布时间】:2015-01-28 02:05:58
【问题描述】:

我主要使用 emacs 做笔记。我所有的笔记都在: ~/Dropbox/Uni/Notes

我想绑定一个键盘快捷键(例如 C-f12)来执行 helm-find,该 helm-find 始终在与源缓冲区无关的上述目录中开始。

我试过了:

(global-set-key (kbd "C-<f2>") (lambda () (interactive) (helm-find "~/Dropbox/Uni/Notes/")))

但是当我运行它时,它仍然提示我输入“DefaultDirectory”,它通常与当前缓冲区相同。

?

[编辑]
我做了一个修改:

(global-set-key (kbd "<C-f2>")
    (lambda ()
      (interactive)
      (find-file "~/Dropbox/Uni/Notes/leo.org")
      (helm-find nil)))

这会打开一个文件,然后当我进行 helm-find 时,它与 leo.org 的位置相关。但最好有更好的解决方案。

[编辑] 以下解决方案完美运行。

【问题讨论】:

    标签: emacs elisp emacs-helm


    【解决方案1】:

    给你:

    (defmacro helm-find-note (dir)
      `(defun ,(intern (format "helm-find-note-%s" dir)) ()
         (interactive)
         (let ((default-directory ,dir))
           (helm-find nil))))
    
    (global-set-key (kbd "C-M-3") (helm-find-note "~/Downloads"))
    

    【讨论】:

    • 递归文件搜索不是一个简单的任务,如果你想快速。例如,请参阅projectile
    • 编辑后,这正是我想要的,谢谢! =]
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-10
    相关资源
    最近更新 更多