leoliu pushed a commit to branch master in repository elpa. commit f1433826604516b6f759d37b0e8fd2d8aa29ce8e Author: Leo Liu <sdl....@gmail.com> Date: Tue Mar 4 09:13:48 2014 +0800
Combine ggtags-global-column and tag name search Cannot rely on ggtags-global-column entirely because the source text may or may not include the whole source line depending on plugin and output format. See discussion http://thread.gmane.org/gmane.comp.gnu.global.bugs/1675 --- ggtags.el | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ggtags.el b/ggtags.el index a01e286..a68347e 100644 --- a/ggtags.el +++ b/ggtags.el @@ -940,7 +940,6 @@ Global and Emacs." (defun ggtags-global-column (start) ;; START is the beginning position of source text. (when-let (mbeg (text-property-any start (line-end-position) 'global-color t)) - (setq ggtags-current-tag-name nil) (- mbeg start))) ;;; NOTE: Must not match the 'Global started at Mon Jun 3 10:24:13' @@ -1144,15 +1143,22 @@ Global and Emacs." (defun ggtags-move-to-tag (&optional name) "Move to NAME tag in current line." - (let ((orig (point)) - (tag (or name ggtags-current-tag-name))) - (beginning-of-line) - (if (and tag (re-search-forward - (concat "\\_<" (regexp-quote tag) "\\_>") - (line-end-position) - t)) - (goto-char (match-beginning 0)) - (goto-char orig)))) + (let ((tag (or name ggtags-current-tag-name))) + ;; Do nothing if on the tag already i.e. by `ggtags-global-column'. + (unless (or (not tag) (looking-at (concat (regexp-quote tag) "\\_>"))) + (let ((orig (point)) + (regexps (mapcar (lambda (fmtstr) + (format fmtstr (regexp-quote tag))) + '("\\_<%s\\_>" "%s\\_>" "%s")))) + (beginning-of-line) + (if (loop for re in regexps + ;; Note: tag might not agree with current + ;; major-mode's symbol, so try harder. For + ;; example, in `php-mode' $cacheBackend is + ;; a symbol, but cacheBackend is a tag. + thereis (re-search-forward re (line-end-position) t)) + (goto-char (match-beginning 0)) + (goto-char orig)))))) (defun ggtags-navigation-mode-cleanup (&optional buf time) (let ((buf (or buf ggtags-global-last-buffer)))