elisp - Update gtag file in emacs for a single file once on saving -
my configuration copied http://www.emacswiki.org/emacs/gnuglobal#toc4 . purpose update existing tag file 1 time save source file. result same expected.
the total configuration is:
(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 changes in 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 %s" filename)) (defun gtags-update-hook() "update gtags file (insert )ncrementally upon saving file" (when gtags-mode ;;it re-create past error.. (when (gtags-root-dir) (gtags-update-current-file)))) (add-hook 'after-save-hook 'gtags-update-hook)
update
my understanding tags update via command
(gtags-update-single filename) (message "gtags updated %s" filename))
once file in buffer saved. means new added or renamed or removed function updated tag file. in test, see output message(the tags in ededemo directory ):
wrote /other/projectbase/cplusproject/ededemo/src/main.cpp gtags updated ./src/main.cpp
each time function renamed or added after c-x c-s. m-x gtags-find-tag not find new added function. there wrong in understanding?
this line responsible/broken:
(when gtags-;-*- mode: ${1:mode} -*-
looking @ wiki page, can't fathom how managed end that.
the docstring comment corrupted. re-create whole function again.
emacs elisp gnu-global
No comments:
Post a Comment