Permalink
Browse files

Fix not to jump to the declartion but the function itself.

Commit 45d2980 does not fix it fully.

It is possible that the function declaration does not contain a semicolon in
the end of the first line (for example, arguments are written in seperated
lines).
In such cases, text-to-search-for matches for both the declaration and the
function itself, search will stop at the declartion.

This commit works around for these cases. It searches backward instead. Thus
it only works if the selected tag is the only tag in the file. The better
solution would be to refer the line number in the TAGS file. (TODO)
  • Loading branch information...
1 parent 04b420b commit 735f5ff630a1f2f5f813d608635b5761ef4fb605 @winfred-lu committed Feb 6, 2013
Showing with 13 additions and 6 deletions.
  1. +13 −6 vendor/etags-select.el
View
@@ -325,7 +325,7 @@ to do."
Use the C-u prefix to prevent the etags-select window from closing."
(interactive "P")
(let ((case-fold-search (etags-select-case-fold-search))
- tagname tag-point text-to-search-for filename filename-point (search-count 1))
+ tagname tag-point text-to-search-for filename filename-point (search-count 1) multiple-tag)
(save-excursion
(goto-char (point-min))
(re-search-forward "Finding tag: \\(.*\\)$")
@@ -344,6 +344,10 @@ Use the C-u prefix to prevent the etags-select window from closing."
(goto-char tag-point)
(while (re-search-backward (concat "^.*?\\]\\s-+" text-to-search-for) filename-point t)
(setq search-count (1+ search-count)))
+ (when (or (> search-count 1)
+ (end-of-line)
+ (re-search-forward (concat "^.*?\\]\\s-+" text-to-search-for) (point-max) t))
+ (setq multiple-tag t))
(goto-char tag-point)
(unless arg
(kill-buffer etags-select-buffer-name)
@@ -358,11 +362,14 @@ Use the C-u prefix to prevent the etags-select window from closing."
(find-file-other-window filename)
(find-file filename))
(goto-char (point-min))
- (while (> search-count 0)
- (unless (re-search-forward (concat "^\\s-*" text-to-search-for) nil t)
- (message "TAGS file out of date ... stopping at closest match")
- (setq search-count 1))
- (setq search-count (1- search-count)))
+ (if (and (not multiple-tag) (eq search-count 1))
+ (while (re-search-forward (concat "^\\s-*" text-to-search-for) nil t)
+ (ignore multiple-tag))
+ (while (> search-count 0)
+ (unless (re-search-forward (concat "^\\s-*" text-to-search-for) nil t)
+ (message "TAGS file out of date ... stopping at closest match")
+ (setq search-count 1))
+ (setq search-count (1- search-count))))
(beginning-of-line)
(re-search-forward tagname)
(goto-char (match-beginning 0))

0 comments on commit 735f5ff

Please sign in to comment.