(require 'gtags)
(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 ()
"Make GTAGS incremental update"
(message "updating GLOBAL tags using gtags -i ..")
(call-process "gtags" nil nil nil "-i -f gtags.files")
(gtags-make-complete-list))
(defun gtags-update-global ()
"Make GTAGS incremental update"
(message "updating GLOBAL tags!!")
(call-process "global" nil nil nil "-u")
(gtags-make-complete-list))
(defun gtags-update-hook ()
(when (gtags-root-dir)
(when (memq major-mode (list 'php-mode 'c-mode 'org-mode 'javascript-mode 'js-mode 'emacs-lisp-mode))
(progn (message "global root : %s" (gtags-root-dir))(gtags-update-global)))))
(add-hook 'after-save-hook 'gtags-update-hook)
(defadvice gtags-find-tag (before gtags-make-complete-list activate)
"Make Global completion tags" (unless gtags-complete-list (gtags-make-complete-list)))
(add-hook 'php-mode-hook '(lambda () (gtags-mode t)))
(add-hook 'c-mode-hook '(lambda () (gtags-mode t)))
(provide 'rgr-gtags)
--
My Emacs Files At GitHub
No comments:
Post a Comment