branch: master commit c697c1d55a95daa5bbe214153c8bbc71ba5b9ba9 Author: Leo Liu <sdl....@gmail.com> Commit: Leo Liu <sdl....@gmail.com>
Fix #127: Improve ggtags-make-project in finding tag files --- README.rst | 4 +++- ggtags.el | 56 ++++++++++++++++++++++++++++++-------------------------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/README.rst b/README.rst index 819ae1e..5bb0eb2 100644 --- a/README.rst +++ b/README.rst @@ -319,6 +319,8 @@ NEWS #. ``ggtags-navigation-mode`` is more discreet in displaying lighter when ``ggtags-enable-navigation-keys`` is set to nil. +#. ``ggtags-make-project`` tries harder to find TAG files respecting + ``GTAGSDBPATH``. [2015-12-15 Tue] 0.8.11 +++++++++++++++++++++++ @@ -385,7 +387,7 @@ NEWS [2014-04-12 Sat] 0.8.3 ++++++++++++++++++++++ -#. Tweak mode-line ligter in ``ggtags-navigation-mode``. +#. Tweak mode-line lighter in ``ggtags-navigation-mode``. [2014-04-05 Sat] 0.8.2 ++++++++++++++++++++++ diff --git a/ggtags.el b/ggtags.el index 1c72845..58b15d4 100644 --- a/ggtags.el +++ b/ggtags.el @@ -465,32 +465,36 @@ Set to `nil' to disable tag highlighting." (defun ggtags-make-project (root) (cl-check-type root string) - (pcase (nthcdr 5 (file-attributes (expand-file-name "GTAGS" root))) - (`(,mtime ,_ ,tag-size . ,_) - (let* ((default-directory (file-name-as-directory root)) - (rtags-size (nth 7 (file-attributes "GRTAGS"))) - (has-refs - (when rtags-size - (and (or (> rtags-size (* 32 1024)) - (with-demoted-errors "ggtags-make-project: %S" - (not (equal "" (ggtags-process-string "global" "-crs"))))) - 'has-refs))) - ;; http://thread.gmane.org/gmane.comp.gnu.global.bugs/1518 - (has-path-style - (and (ggtags-process-succeed-p "global" "--path-style" "shorter" "--help") - 'has-path-style)) - ;; http://thread.gmane.org/gmane.comp.gnu.global.bugs/1542 - (has-color (and (ggtags-process-succeed-p "global" "--color" "--help") - 'has-color))) - (puthash default-directory - (ggtags-project--make :root default-directory - :tag-size tag-size - :has-refs has-refs - :has-path-style has-path-style - :has-color has-color - :mtime (float-time mtime) - :timestamp (float-time)) - ggtags-projects))))) + (let* ((default-directory (file-name-as-directory root)) + ;; NOTE: use of GTAGSDBPATH is not recommended. -- GLOBAL(1) + ;; ROOT and DB can be different directories due to GTAGSDBPATH. + (dbdir (concat (file-remote-p root) + (ggtags-process-string "global" "-p")))) + (pcase (nthcdr 5 (file-attributes (expand-file-name "GTAGS" dbdir))) + (`(,mtime ,_ ,tag-size . ,_) + (let* ((rtags-size (nth 7 (file-attributes (expand-file-name "GRTAGS" dbdir)))) + (has-refs + (when rtags-size + (and (or (> rtags-size (* 32 1024)) + (with-demoted-errors "ggtags-make-project: %S" + (not (equal "" (ggtags-process-string "global" "-crs"))))) + 'has-refs))) + ;; http://thread.gmane.org/gmane.comp.gnu.global.bugs/1518 + (has-path-style + (and (ggtags-process-succeed-p "global" "--path-style" "shorter" "--help") + 'has-path-style)) + ;; http://thread.gmane.org/gmane.comp.gnu.global.bugs/1542 + (has-color (and (ggtags-process-succeed-p "global" "--color" "--help") + 'has-color))) + (puthash default-directory + (ggtags-project--make :root default-directory + :tag-size tag-size + :has-refs has-refs + :has-path-style has-path-style + :has-color has-color + :mtime (float-time mtime) + :timestamp (float-time)) + ggtags-projects)))))) (defun ggtags-project-expired-p (project) (or (< (ggtags-project-timestamp project) 0)