我主要使用emacs作为笔记。我的所有笔记都在: 〜/ Dropbox / Uni / Notes
我想绑一个键盘快捷键(例如C-f12)来执行一个helm-find,它总是从上面的dir开始,与源缓冲区无关。
我试过了:
(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的位置有关。但是更好的解决方案将是首选。
[编辑] 以下解决方案完美无缺
答案 0 :(得分: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"))