changeset 56826:c5624ad1554b

(find-tag-default): Moved from etags.el.
author Richard M. Stallman <rms@gnu.org>
date Sat, 28 Aug 2004 15:30:10 +0000
parents dcd7b1b4690d
children 12cc6bc5d550
files lisp/subr.el
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Sat Aug 28 14:00:38 2004 +0000
+++ b/lisp/subr.el	Sat Aug 28 15:30:10 2004 +0000
@@ -1969,6 +1969,27 @@
 		(setq parent (get parent 'derived-mode-parent))))
     parent))
 
+(defun find-tag-default ()
+  "Determine default tag to search for, based on text at point.
+If there is no plausible default, return nil."
+  (save-excursion
+    (while (looking-at "\\sw\\|\\s_")
+      (forward-char 1))
+    (if (or (re-search-backward "\\sw\\|\\s_"
+				(save-excursion (beginning-of-line) (point))
+				t)
+	    (re-search-forward "\\(\\sw\\|\\s_\\)+"
+			       (save-excursion (end-of-line) (point))
+			       t))
+	(progn (goto-char (match-end 0))
+	       (buffer-substring-no-properties
+                (point)
+                (progn (forward-sexp -1)
+                       (while (looking-at "\\s'")
+                         (forward-char 1))
+                       (point))))
+      nil)))
+
 (defmacro with-syntax-table (table &rest body)
   "Evaluate BODY with syntax table of current buffer set to TABLE.
 The syntax table of the current buffer is saved, BODY is evaluated, and the