bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch for gtags.el] Enabled gtags-select-mode to use relative path


From: 山口将志
Subject: [patch for gtags.el] Enabled gtags-select-mode to use relative path
Date: Wed, 04 Oct 2006 19:41:54 +0900

gtags.el prints absolute paths in gtags-select-mode, so lines are too long
in my screen. So I've modified gtags.el.
  [gtags-goto-tag]
    - Absolute path or relative path is choosed by custom-variable.
  [gtags-select-it]
    - Swapped order of killing current buffer and opening selected file.
      If `delete' parameter is true, current buffer is killed and
      current directory changes before selected file is opened.
      So gtags-find-* in relative-path mode sometimes fails to jump
      directly into a file that was found as the only one file.

Regards.

$ diff -u  ~/archive/global-5.2/gtags.el ~/emacs/gtags.el
--- /home/XXX/archive/global-5.2/gtags.el    2006-08-08 22:39:56.000000000 +0900
+++ /home/XXX/emacs/gtags.el 2006-10-04 18:36:02.000000000 +0900
@@ -69,6 +69,10 @@
   "Whether we are running XEmacs/Lucid Emacs")
 (defvar gtags-rootdir nil
   "Root directory of source tree.")
+
+(defcustom gtags-select-abspath t
+  "Gtags print absolute path in gtags-select-mode"
+  :type 'boolean)
 ;
 ; New key assignment to avoid conflicting with ordinary assignments.
 ;
@@ -411,7 +415,8 @@
     (setq buffer (generate-new-buffer (generate-new-buffer-name (concat 
"*GTAGS SELECT* " prefix tagname))))
     (set-buffer buffer)
     (message "Searching %s ..." tagname)
-    (if (not (= 0 (call-process "global" nil t nil (concat "-ax" flag) 
tagname)))
+    (if (not (= 0 (call-process "global" nil t nil
+                                (concat (if gtags-select-abspath "-ax" "-x") 
flag) tagname)))
        (progn (message (buffer-substring (point-min)(1- (point-max))))
                (gtags-pop-context))
       (goto-char (point-min))
@@ -448,9 +453,10 @@
         (gtags-pop-context)
       (setq line (string-to-number (gtags-match-string 1)))
       (setq file (gtags-match-string 2))
-      (if delete (kill-buffer (current-buffer)))
-      ;; move to the context
-      (if gtags-read-only (find-file-read-only file) (find-file file))
+      (let ((prev-buf (current-buffer)))
+        ;; move to the context
+        (if gtags-read-only (find-file-read-only file) (find-file file))
+        (if delete (kill-buffer prev-buf)))
       (setq gtags-current-buffer (current-buffer))
       (goto-line line)
       (gtags-mode 1))))

-- 
Masashi YAMAGUCHI




reply via email to

[Prev in Thread] Current Thread [Next in Thread]