我想在org-mode中使用这样的功能:在退出emacs之前(当org-mode运行时)它会问我:"你想在退出之前运行函数vc-dir吗?" 我试过这个:
(add-hook 'kill-emacs-hook 'vc-dir)
但它错了:"参数数量错误"
也试过这里找到:
(defadvice save-buffers-kill-emacs (before update-mod-flag activate) (vc-dir))
同样的错误.
那么如何让它以简单的方式工作:vc-dir总是在退出时运行.
或者如何让它与警告信息一起工作(最好的方法)?
谢谢!
vc-dir接受一个参数("dir").
所以你可以这样做:
(add-hook 'kill-emacs-hook (lambda () (vc-dir "your-dir-here")))
当然这不会阻止emacs退出:vc-dir打开缓冲区但不"等待"用户输入.对于您想要的交互式方法,您可以执行以下操作:
(add-hook 'kill-emacs-query-functions (lambda () (if (y-or-n-p "Do you want to run function vc-dir before exit?") (progn (vc-dir "your-directory") nil) t)))
更改"your-directory"
的default-directory
,如果你想用上次访问缓存为VC-目录.