emacs ow can I helm-find with default directory pr

2019-08-12 17:28发布

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条回答
\"骚年 ilove
2楼-- · 2019-08-12 18:00

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"))
查看更多
登录 后发表回答