changeset 6244:3ad3a0150b6d

(etags-tags-completion-table): Let the line number or char pos be empty. (etags-snarf-tag): Look for line number as well as char pos. Let either be empty; return both. (etags-goto-tag-location): Arg also contains line number. If char pos is nil, use line number.
author Roland McGrath <roland@gnu.org>
date Tue, 08 Mar 1994 05:49:24 +0000
parents 25d0943a4f4e
children c05d1d7bc400
files lisp/progmodes/etags.el
diffstat 1 files changed, 25 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/etags.el	Tue Mar 08 05:37:15 1994 +0000
+++ b/lisp/progmodes/etags.el	Tue Mar 08 05:49:24 1994 +0000
@@ -935,7 +935,8 @@
       ;;   \7 is the char to start searching at.
       (while (re-search-forward
 	      "^\\(\\(.+[^-a-zA-Z0-9_$]+\\)?\\([-a-zA-Z0-9_$]+\\)\
-\[^-a-zA-Z0-9_$]*\\)\177\\(\\([^\n\001]+\\)\001\\)?\\([0-9]+\\),\\([0-9]+\\)\n"
+\[^-a-zA-Z0-9_$]*\\)\177\\(\\([^\n\001]+\\)\001\\)?\
+\\([0-9]+\\)?,\\([0-9]+\\)?\n"
 	      nil t)
 	(intern	(if (match-beginning 5)
 		    ;; There is an explicit tag name.
@@ -946,29 +947,36 @@
     table))
 
 (defun etags-snarf-tag ()
-  (let (tag-text startpos)
+  (let (tag-text line startpos)
     (search-forward "\177")
     (setq tag-text (buffer-substring (1- (point))
 				     (save-excursion (beginning-of-line)
 						     (point))))
     ;; Skip explicit tag name if present.
     (search-forward "\001" (save-excursion (forward-line 1) (point)) t)
-    (search-forward ",")
-    (setq startpos (string-to-int (buffer-substring
+    (if (looking-at "[0-9]")
+	(setq line (string-to-int (buffer-substring
 				   (point)
 				   (progn (skip-chars-forward "0-9")
-					  (point)))))
+					  (point))))))
+    (search-forward ",")
+    (if (looking-at "[0-9]")
+	(setq startpos (string-to-int (buffer-substring
+				       (point)
+				       (progn (skip-chars-forward "0-9")
+					      (point))))))
     ;; Leave point on the next line of the tags file.
     (forward-line 1)
-    (cons tag-text startpos)))
+    (cons tag-text (cons line startpos))))
 
-;; TAG-INFO is a cons (TEXT . POSITION) where TEXT is the initial part of a
-;; line containing the tag and POSITION is the character position of TEXT
-;; within the file (starting from 1).  If the tag isn't exactly at the
-;; given position then look around that position using a search window
-;; which expands until it hits the start of file.
+;; TAG-INFO is a cons (TEXT LINE . POSITION) where TEXT is the initial part
+;; of a line containing the tag and POSITION is the character position of
+;; TEXT within the file (starting from 1); LINE is the line number.  Either
+;; LINE or POSITION may be nil; POSITION is used if present.  If the tag
+;; isn't exactly at the given position then look around that position using
+;; a search window which expands until it hits the start of file.
 (defun etags-goto-tag-location (tag-info)
-  (let ((startpos (cdr tag-info))
+  (let ((startpos (cdr (cdr tag-info)))
 	;; This constant is 1/2 the initial search window.
 	;; There is no sense in making it too small,
 	;; since just going around the loop once probably
@@ -978,6 +986,11 @@
 	(pat (concat (if (eq selective-display t)
 			 "\\(^\\|\^m\\)" "^")
 		     (regexp-quote (car tag-info)))))
+    ;; If no char pos was given, try the given line number.
+    (or startpos
+	(if (car (cdr tag-info))
+	    (setq startpos (progn (goto-line (car (cdr tag-info)))
+				  (point)))))
     (or startpos
 	(setq startpos (point-min)))
     ;; First see if the tag is right at the specified location.