[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Proposed feature - Optionally generate gtags for gtags-visit-rootdir
From: |
Earl Chew |
Subject: |
Re: Proposed feature - Optionally generate gtags for gtags-visit-rootdir |
Date: |
Sun, 11 Oct 2015 11:10:53 -0700 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 8/10/2015 21:15, Shigio YAMAGUCHI wrote:
I agree with you.
No problem with 1).
What do you think about this attempt ?
Earl
--- gtags.el.orig 2015-10-11 10:28:05.269639542 -0700
+++ gtags.el 2015-10-11 11:06:05.468301202 -0700
@@ -197,12 +197,19 @@
"Root directory of source tree.")
(defvar gtags-global-command nil
"Command name of global.")
+(defvar gtags-command nil
+ "Command name of gtags.")
;; Set global's command name
(setq gtags-global-command (getenv "GTAGSGLOBAL"))
(if (or (not gtags-global-command) (equal gtags-global-command ""))
(setq gtags-global-command "global"))
+;; Set global's command name
+(setq gtags-command (getenv "GTAGS"))
+(if (or (not gtags-command) (equal gtags-command ""))
+ (setq gtags-command "gtags"))
+
;; Key mapping of gtags-mode.
(if gtags-suggested-key-mapping
(progn
@@ -512,9 +519,9 @@
;;
;; interactive command
;;
-(defun gtags-visit-rootdir ()
+(defun gtags-visit-rootdir (arg)
"Tell tags commands the root directory of source tree."
- (interactive)
+ (interactive "P")
(let (path input default-path)
(setq path gtags-rootdir)
(if (not path)
@@ -530,7 +537,21 @@
(if (not (file-directory-p input))
(message "%s is not directory." input)
(setq gtags-rootdir (expand-file-name input))
- (setenv "GTAGSROOT" gtags-rootdir)))))
+ (setenv "GTAGSROOT" gtags-rootdir)
+ (when arg
+ (let (stdout)
+ (message "Building gtags %s" gtags-rootdir)
+ (gtags-push-tramp-environment)
+ (setq stdout
+ (shell-command-to-string
+ (format "exec %s"
+ (shell-quote-argument gtags-command))))
+ (gtags-pop-tramp-environment)
+ (message "Built gtags %s%s"
+ gtags-rootdir
+ (if (= 0 (length stdout))
+ ""
+ (concat ": " stdout)))))))))
(defun gtags-find-tag (&optional other-win)
"Input tag name and move to the definition."