help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Go to Emacs-Lisp Definition


From: Andreas Politz
Subject: Re: Go to Emacs-Lisp Definition
Date: Tue, 22 Sep 2009 14:45:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Nordlöw <per.nordlow@gmail.com> writes:

> Has anyone implemented a go to (lookup) definition of an Emacs-Lisp
> symbol: function, variable, face, etc kind of like find-tag but using
> Emacs own symbol database (hash-table)?
>
> I know that I can achieve this in Vanilla Emacs with C-h f,v, but
> direct jump (M-.) would be more user efficient!
>

Take a look at how `find-function' does it.  Here is the most
simple implementation I can think of.

(defun find-symbol (symbol)
  "Find the definition of SYMBOL, defaults to the symbol at point.
Prefer functions over variables over faces."
  (interactive
   (list (let ((symbol (thing-at-point 'symbol)))
           (intern (completing-read
                    (concat "Find symbol"
                            (and symbol
                                 (format " (default %s)" symbol))
                            ": ") obarray
                    #'(lambda (sym)
                        (or (fboundp sym)
                            (boundp sym)
                            (facep sym))) t)))))
  (find-function-do-it
   symbol
   (cond
    ((fboundp symbol) nil)
    ((boundp symbol) 'defvar)
    (t 'defface)) 'switch-to-buffer))
    
                       
-ap





reply via email to

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