bug-global
[Top][All Lists]
Advanced

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

[PATCH] Enhancement: Switch gtags-rootdir easily and interactively


From: Kazuo YAGI
Subject: [PATCH] Enhancement: Switch gtags-rootdir easily and interactively
Date: Wed, 02 Jul 2008 04:32:49 +0900
User-agent: Thunderbird 2.0.0.12 (X11/20080227)

Hi guys,

I'd like to suggest a enhancement for "gtags.el".
This patch is to let you switch gtags-rootdir easily and interactively.

I think it makes us easier to read various source trees,
and the attached image shows how to work "gtags-switch-rootdir" function.

I've confirmed that the patched gtags.el works in the environment below.
- GNU Emacs 22.1.1
- GNU GLOBAL 5.7.1 + gtags.el 2.4 patched

Thanks for reading,
- Kazuo YAGI
--- gtags.2.4.el        2008-04-21 09:23:06.000000000 +0900
+++ gtags.my.el 2008-07-02 03:54:01.000000000 +0900
@@ -87,6 +87,21 @@
   "Whether we are running XEmacs/Lucid Emacs")
 (defvar gtags-rootdir nil
   "Root directory of source tree.")
+(defvar gtags-rootdir-alist nil
+  "Root directory alist of source tree.")
+(defvar gtags-rootdir-alist-buffer-name "*gtags-rootdir-alist*"
+  "Buffer name for showing and hiding gtags-rootdir-alist.")
+;
+; If you hope to switch gtags-rootdir, please include and edit
+; the following code to your $HOME/.emacs:
+; 
+(setq gtags-rootdir-alist
+      '(("emacs 22.1"    . "/home/kyagi/src/emacs-22.1/")
+       ("emacs 22.2"    . "/home/kyagi/src/emacs-22.2/")
+       ("emacs 23"      . "/home/kyagi/src/emacs-23/")
+       ("rpm 4.4"       . "/home/kyagi/src/rpm-4.4/")
+       ("synergy 1.3.1" . "/home/kyagi/src/synergy-1.3.1/")
+        ))
 ;
 ; New key assignment to avoid conflicting with ordinary assignments.
 ;
@@ -254,6 +269,34 @@
        (setq gtags-rootdir (expand-file-name input))
        (setenv "GTAGSROOT" gtags-rootdir)))))
 
+(defun gtags-split-window-rootdir-alist ()
+  "Split the current window and show the gtags-rootdir-alist."
+  (split-window-vertically)
+  (other-window 1)
+  (switch-to-buffer gtags-rootdir-alist-buffer-name)
+  (let ((n 0) (rootdir) (dir))
+    (dolist (rootdir gtags-rootdir-alist)
+      (insert (format "%2d %-20s %-60s\n" n (car rootdir) (cdr rootdir)))
+      (setq n (1+ n)))))
+
+(defun gtags-delete-window-rootdir-alist ()
+  "Delete the window of the gtags-rootdir-alist."
+  (kill-buffer gtags-rootdir-alist-buffer-name)
+  (other-window 1)
+  (delete-other-windows))
+
+(defun gtags-switch-rootdir ()
+  "Switch the gtags-rootdir and change the directory to it."
+  (interactive)
+  (gtags-mode t)
+  (gtags-split-window-rootdir-alist)
+  (let ((n))
+    (setq n (string-to-number
+            (read-from-minibuffer "which gtags-rootdir do you want to 
visit?:")))
+    (setq gtags-rootdir (cdr (nth n gtags-rootdir-alist))))
+  (gtags-delete-window-rootdir-alist)
+  (cd gtags-rootdir))
+
 (defun gtags-find-tag ()
   "Input tag name and move to the definition."
   (interactive)

PNG image


reply via email to

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