------------------------------------------------------------ revno: 363 committer: Leo Liu <sdl....@gmail.com> branch nick: elpa timestamp: Fri 2013-03-08 18:50:44 +0800 message: * ggtags.el: Use new switch --path-style to global Use path-separator. modified: packages/ggtags/ggtags.el
=== modified file 'packages/ggtags/ggtags.el' --- a/packages/ggtags/ggtags.el 2013-02-06 18:16:58 +0000 +++ b/packages/ggtags/ggtags.el 2013-03-08 10:50:44 +0000 @@ -79,6 +79,14 @@ (progn ,@body) (file-error nil))) +;; http://thread.gmane.org/gmane.comp.gnu.global.bugs/1518 +(defvar ggtags-global-has-path-style ; introduced in global 6.2.8 + (ggtags-ignore-file-error + (and (string-match-p "^--path-style " + (shell-command-to-string "global --help")) + t)) + "Non-nil if `global' supports --path-style switch.") + (defmacro ggtags-ensure-global-buffer (&rest body) (declare (indent 0)) `(progn @@ -97,7 +105,8 @@ -1))) (defun ggtags-get-libpath () - (split-string (or (getenv "GTAGSLIBPATH") "") ":" t)) + (split-string (or (getenv "GTAGSLIBPATH") "") + (regexp-quote path-separator) t)) (defun ggtags-cache-get (key) (assoc key ggtags-cache)) @@ -185,6 +194,11 @@ (format (if default "Tag (default %s): " "Tag: ") default) tags nil t nil nil default))))) +(defvar ggtags-global-options + (concat "-v --result=grep" + (and ggtags-global-has-path-style " --path-style=shorter")) + "Options (as a string) for running `global'.") + ;;;###autoload (defun ggtags-find-tag (name &optional verbose) "Find definitions or references to tag NAME by context. @@ -200,11 +214,13 @@ (default-directory (ggtags-root-directory))) (compilation-start (if verbose - (format "global -v%s --result=grep \"%s\"" + (format "global %s %s \"%s\"" + ggtags-global-options (if (y-or-n-p "Kind (y for definition n for reference)? ") - "" "r") + "" "-r") name) - (format "global -v --result=grep --from-here=%d:%s \"%s\"" + (format "global %s --from-here=%d:%s \"%s\"" + ggtags-global-options (line-number-at-pos) (expand-file-name buffer-file-name) name))