emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[ELPA-diffs] /srv/bzr/emacs/elpa r347: * ggtags.el: improve handling of


From: Leo Liu
Subject: [ELPA-diffs] /srv/bzr/emacs/elpa r347: * ggtags.el: improve handling of GTAGSLIBPATH in ggtags-tag-names
Date: Thu, 07 Feb 2013 02:16:58 +0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 347
committer: Leo Liu <address@hidden>
branch nick: elpa
timestamp: Thu 2013-02-07 02:16:58 +0800
message:
  * ggtags.el: improve handling of GTAGSLIBPATH in ggtags-tag-names
modified:
  packages/ggtags/ggtags.el
=== modified file 'packages/ggtags/ggtags.el'
--- a/packages/ggtags/ggtags.el 2013-02-02 15:38:27 +0000
+++ b/packages/ggtags/ggtags.el 2013-02-06 18:16:58 +0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2013  Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <address@hidden>
-;; Version: 0.5
+;; Version: 0.6
 ;; Keywords: tools, convenience
 ;; Created: 2013-01-29
 ;; URL: https://github.com/leoliu/ggtags
@@ -69,6 +69,10 @@
 
 (defvar ggtags-current-tag-name nil)
 
+;; Used by ggtags-global-mode
+(defvar ggtags-global-error "match"
+  "Stem of message to print when no matches are found.")
+
 (defmacro ggtags-ignore-file-error (&rest body)
   (declare (indent 0))
   `(condition-case nil
@@ -92,6 +96,9 @@
         (float-time (nth 5 (file-attributes file)))
       -1)))
 
+(defun ggtags-get-libpath ()
+  (split-string (or (getenv "GTAGSLIBPATH") "") ":" t))
+
 (defun ggtags-cache-get (key)
   (assoc key ggtags-cache))
 
@@ -142,6 +149,19 @@
                   (error "%s" (comment-string-strip (buffer-string) t t))))))
         (error "Aborted"))))
 
+(defun ggtags-tag-names-1 (root &optional prefix)
+  (when root
+    (if (ggtags-cache-stale-p root)
+        (let* ((default-directory (file-name-as-directory root))
+               (tags (with-demoted-errors
+                       (split-string
+                        (with-output-to-string
+                          (call-process "global" nil (list standard-output nil)
+                                        nil "-c" (or prefix "")))))))
+          (and tags (ggtags-cache-set root tags))
+          tags)
+      (cadr (ggtags-cache-get root)))))
+
 ;;;###autoload
 (defun ggtags-tag-names (&optional prefix)
   "Get a list of tag names starting with PREFIX."
@@ -150,16 +170,9 @@
       (if (zerop (call-process "global" nil nil nil "-u"))
           (ggtags-cache-mark-dirty root nil)
         (message "ggtags: error running 'global -u'")))
-    (if (ggtags-cache-stale-p root)
-        (let ((tags (ggtags-ignore-file-error
-                      (split-string
-                       (with-output-to-string
-                         (call-process "global" nil (list standard-output nil)
-                                       nil "-cT" (or prefix "")))))))
-          (when tags
-            (ggtags-cache-set root tags))
-          tags)
-      (cadr (ggtags-cache-get root)))))
+    (apply 'append (mapcar (lambda (r)
+                             (ggtags-tag-names-1 r prefix))
+                           (cons root (ggtags-get-libpath))))))
 
 (defun ggtags-read-tag (quick)
   (ggtags-ensure-root-directory)
@@ -356,8 +369,7 @@
   "Kill all buffers visiting files in the root directory."
   (interactive "p")
   (ggtags-check-root-directory)
-  (let ((gtagslibpath (split-string (or (getenv "GTAGSLIBPATH") "") ":" t))
-        (root (ggtags-root-directory))
+  (let ((root (ggtags-root-directory))
         (count 0)
         (some (lambda (pred list)
                 (loop for x in list when (funcall pred x) return it))))
@@ -367,7 +379,7 @@
                        (buffer-file-name buf))))
         (when (and file (funcall some (apply-partially #'file-in-directory-p
                                                        (file-truename file))
-                                 (cons root gtagslibpath)))
+                                 (cons root (ggtags-get-libpath))))
           (and (kill-buffer buf)
                (incf count)))))
     (and interactive
@@ -442,10 +454,6 @@
     (forward-line (1- line))
     (ggtags-move-to-tag name)))
 
-;; NOTE: `ggtags-build-imenu-index' is signficantly faster and more
-;; precise than the similar feature provided by cc mode. Tested with
-;; ClassFileWriter.java of the rhino project.
-
 ;;;###autoload
 (defun ggtags-build-imenu-index ()
   "A function suitable for `imenu-create-index-function'."


reply via email to

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