例如,我的 .emacs 中有这个设置
(defun gtags-create-or-update ()
"Create or update the gnu global tag file."
(interactive)
(if (y-or-n-p-with-timeout
(format "Run gtags to create/update tag file for code at %s (default no)? "
default-directory)
5 nil) ; default - no run
(unless (= 0 (call-process "global" nil nil nil " -p")) ; tagfile doesn't exist?
(let ((olddir default-directory)
(topdir (read-directory-name
"gtags: top of source tree: " default-directory)))
(cd topdir)
(shell-command "gtags -v")
;; (shell-command "gtags && echo 'created tagfile'")
(cd olddir)) ; restore
;; tagfile already exists; update it
(shell-command "global -uv"))))
;; (shell-command "global -u && echo 'updated tagfile'")))
(add-hook 'c-mode-common-hook
(lambda ()
(require 'gtags)
(gtags-mode t)
(gtags-create-or-update)))
当我gtags-create-or-update
显式运行时,emacs 会在 minibuffer 中提示我是否创建/更新标记文件。但是,当我打开 ac/cpp 文件时,它总是会弹出一个 GUI 窗口询问我是或否,这非常烦人。我想知道为什么会这样。