emacs ow can I helm-find with default directory pre-specified?

核能气质少年 提交于 2019-12-13 18:29:38

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/28175154/emacs-ow-can-i-helm-find-with-default-directory-pre-specified

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!