*** empty log message ***
authorEric S. Raymond <esr@snark.thyrsus.com>
Sun, 8 Dec 1991 10:11:17 +0000 (10:11 +0000)
committerEric S. Raymond <esr@snark.thyrsus.com>
Sun, 8 Dec 1991 10:11:17 +0000 (10:11 +0000)
lisp/progmodes/etags.el

index 705a688..15181e8 100644 (file)
@@ -136,6 +136,51 @@ File names returned are absolute."
              default
            spec))))
 
+(defun find-tag-noselect (tagname exact &optional next)
+  "Find a tag and return its buffer, but don't select or display it."
+  (let (buffer file linebeg startpos)
+    (save-excursion
+      (visit-tags-table-buffer)
+      (if (not next)
+         (goto-char (point-min))
+       (setq tagname last-tag))
+      (setq last-tag tagname)
+      (while (progn
+              (if (not (search-forward
+                        (if exact (concat tagname "(") tagname)
+                        nil t))
+                  (error "No %sentries containing %s"
+                         (if next "more " "") tagname))
+              (not (looking-at "[^\n\177]*\177"))))
+      (search-forward "\177")
+      (setq file (expand-file-name (file-of-tag)
+                                  (file-name-directory tags-file-name)))
+      (setq linebeg
+           (buffer-substring (1- (point))
+                             (save-excursion (beginning-of-line) (point))))
+      (search-forward ",")
+      (setq startpos (read (current-buffer)))
+      (prog1
+         (set-buffer (find-file-noselect file))
+       (widen)
+       (push-mark)
+       (let ((offset 1000)
+             found
+             (pat (concat "^" (regexp-quote linebeg))))
+         (or startpos (setq startpos (point-min)))
+         (while (and (not found)
+                     (progn
+                       (goto-char (- startpos offset))
+                       (not (bobp))))
+           (setq found
+                 (re-search-forward pat (startpos offset) t))
+           (setq offset (* 3 offset)))
+         (or found
+             (re-search-forward pat nil t)
+             (error "%s not found in %s" pat file)))
+       (beginning-of-line)))
+    ))
+
 ;;;###autoload
 (defun find-tag (tagname &optional next other-window)
   "Find tag (in current tag table) whose name contains TAGNAME.