我的配置是从http://www.emacswiki.org/emacs/GnuGlobal#toc4复制的。目的是在保存源文件后更新现有的标记文件。但结果与预期相同。
完整的配置是:
(gtags-mode 1)
(defun gtags-root-dir ()
"Returns GTAGS root directory or nil if doesn't exist."
(with-temp-buffer
(if (zerop (call-process "global" nil t nil "-pr"))
(buffer-substring (point-min) (1- (point-max)))
nil)))
(defun gtags-update-single(filename)
"Update Gtags database for changes in a single file"
(interactive)
(start-process "update-gtags" "update-gtags" "bash" "-c" (concat "cd " (gtags-root-dir) " ; gtags --single-update " filename )))
(defun gtags-update-current-file()
(interactive)
(defvar filename)
(setq filename (replace-regexp-in-string (gtags-root-dir) "." (buffer-file-name (current-buffer))))
(gtags-update-single filename)
(message "Gtags updated for %s" filename))
(defun gtags-update-hook()
"Update GTAGS file (insert )ncrementally upon saving a file"
(when gtags-mode ;;It is copy past error..
(when (gtags-root-dir)
(gtags-update-current-file))))
(add-hook 'after-save-hook 'gtags-update-hook)更新
我的理解是,标记将通过命令进行更新。
(gtags-update-single filename)
(message "Gtags updated for %s" filename))一旦缓冲区中的文件被保存。这意味着一个新添加或重命名或删除的函数将被更新到标记文件中。在我的测试中,我确实看到了输出消息(标签位于ededemo目录中):
Wrote /other/projectbase/cplusproject/ededemo/src/main.cpp
Gtags updated for ./src/main.cpp每次函数都在c s之后重命名或添加。但是M find -tag无法找到我新添加的函数。理解有什么不对吗?
发布于 2014-06-21 13:44:35
这条线显然是有责任的/坏的:
(when gtags-;-*- mode: ${1:mode} -*-看看Wiki页面,我无法理解你是如何做到这一点的。
docstring注释也已损坏。再把整个功能复制一遍。
https://stackoverflow.com/questions/24342154
复制相似问题