emacs ow我可以用默认目录预先指定吗? [英] emacs ow can I helm-find with default directory pre-specified?
问题描述
〜/ Dropbox / Uni / Notes
我想绑一个键盘快捷键(例如C-f12)发现总是从上面的目录开始与源缓冲区无关。
我尝试过:
(global-set-key kbdC-f2)(lambda()(交互式)(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的位置。但是更好的解决方案将是首选。
下面的解决方案完美无缺。
你去:
(defmacro helm-find-note(dir)
`(defun,(intern(formathelm-find-note-%sdir))()
(interactive)
(let((default-directory,dir))
(helm-find nil))))
(全局设置密钥(kbdCM-3)(helm- find-note〜/ Downloads))
I use emacs for notes mainly. All my notes are in: ~/Dropbox/Uni/Notes
I want to tie a keyboard shortcut (e.g C-f12) to do a helm-find that always starts in the above dir irrelevant of the source buffer.
I have tried:
(global-set-key (kbd "C-<f2>") (lambda () (interactive) (helm-find "~/Dropbox/Uni/Notes/")))
But when I run it, it still prompts me for 'DefaultDirectory' which is usually the same as the current buffer.
?
[edit]
I made a hack-around:
(global-set-key (kbd "<C-f2>")
(lambda ()
(interactive)
(find-file "~/Dropbox/Uni/Notes/leo.org")
(helm-find nil)))
That opens a file and then when I do a helm-find, it's relative to leo.org's location. But a better solution would be preferred.
[edit] Below solution works perfectly.
Here you go:
(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"))
这篇关于emacs ow我可以用默认目录预先指定吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!