emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

find-tag-default


From: Juri Linkov
Subject: find-tag-default
Date: Thu, 13 May 2004 09:37:53 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

I noticed that grep.el has a copy of find-tag-default function from
etags.el, for the reason not to load etags.el at run-time.

The function find-tag-default is a quite general function, which is
used by other Emacs Lisp files, so it could be moved from etags.el to
simple.el (without renaming), thus allowing other files to use it
without loading etags.el.

find-tag-default could be used also as an additional attempt to find a
function or variable name around point in functions describe-function,
describe-variable.  This is useful when a function or variable name is
located in a buffer not in Emacs Lisp mode, such as message or article
mode, where it is not quoted and has trailing punctuation.
(For example, try to type C-h f on function names in this paragraph.)

Index: emacs/lisp/help.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/help.el,v
retrieving revision 1.264
diff -u -w -b -r1.264 help.el
--- emacs/lisp/help.el  27 Apr 2004 06:35:25 -0000      1.264
+++ emacs/lisp/help.el  13 May 2004 06:11:20 -0000
@@ -237,7 +237,7 @@
 (defun function-called-at-point ()
   "Return a function around point or else called by the list containing point.
 If that doesn't give a function, return nil."
-  (with-syntax-table emacs-lisp-mode-syntax-table
+  (or (with-syntax-table emacs-lisp-mode-syntax-table
     (or (condition-case ()
            (save-excursion
              (or (not (zerop (skip-syntax-backward "_w")))
@@ -262,7 +262,10 @@
                    (error "Probably not a Lisp function call"))
                (let ((obj (read (current-buffer))))
                  (and (symbolp obj) (fboundp obj) obj))))
-         (error nil)))))
+              (error nil))))
+      (let* ((str (find-tag-default))
+             (obj (if str (intern str))))
+        (and (symbolp obj) (fboundp obj) obj))))
 
 
 ;;; `User' help functions

Index: emacs/lisp/help-fns.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/help-fns.el,v
retrieving revision 1.48
diff -u -w -b -r1.48 help-fns.el
--- emacs/lisp/help-fns.el      11 May 2004 23:50:25 -0000      1.48
+++ emacs/lisp/help-fns.el      13 May 2004 06:11:21 -0000
@@ -456,7 +456,7 @@
 (defun variable-at-point ()
   "Return the bound variable symbol found around point.
 Return 0 if there is no such symbol."
-  (condition-case ()
+  (or (condition-case ()
       (with-syntax-table emacs-lisp-mode-syntax-table
        (save-excursion
          (or (not (zerop (skip-syntax-backward "_w")))
@@ -465,9 +465,12 @@
              (forward-sexp -1))
          (skip-chars-forward "'")
          (let ((obj (read (current-buffer))))
-           (or (and (symbolp obj) (boundp obj) obj)
-               0))))
-    (error 0)))
+                (and (symbolp obj) (boundp obj) obj))))
+        (error nil))
+      (let* ((str (find-tag-default))
+             (obj (if str (intern str))))
+        (and (symbolp obj) (boundp obj) obj))
+      0))
 
 ;;;###autoload
 (defun describe-variable (variable &optional buffer)

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]