Gtags config in emacs

;; GNU global
(setq gtags-suggested-key-mapping t)
(require 'gtags)
(add-hook 'c-mode-common-hook 'gtags-mode)
(add-hook 'c++-mode-common-hook 'gtags-mode)
(add-hook 'java-mode-common-hook 'gtags-mode)
(add-hook 'gtags-select-mode-hook
      '(lambda ()
         (setq hl-line-face 'underline)
         (hl-line-mode 1)))

(define-key gtags-select-mode-map "RET" 'gtags-select-tag)

(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"
  (call-process "global" nil nil nil "-u"))
(defun gtags-update-hook ()
  (when (gtags-root-dir)
    (gtags-update)))
;(add-hook 'after-save-hook #'gtags-update-hook)


你可能感兴趣的:(lambda,emacs)