* Go to Emacs-Lisp Definition
@ 2009-09-22 9:13 Nordlöw
2009-09-22 9:21 ` Helmut Eller
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Nordlöw @ 2009-09-22 9:13 UTC (permalink / raw)
To: help-gnu-emacs
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!
Thanks,
Per Nordlöw
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Go to Emacs-Lisp Definition
2009-09-22 9:13 Go to Emacs-Lisp Definition Nordlöw
@ 2009-09-22 9:21 ` Helmut Eller
2009-09-22 14:25 ` Andreas Röhler
2009-09-22 9:39 ` Stefan Kamphausen
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Helmut Eller @ 2009-09-22 9:21 UTC (permalink / raw)
To: help-gnu-emacs
* Nordlöw [2009-09-22 11:13+0200] 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!
I have this in my .emacs. It's some random elisp hacking stuff.
Pick what you need.
Helmut
(defun elisp-disassemble (function)
(interactive (list (function-called-at-point)))
(disassemble function))
(defun elisp-pp (sexp)
(with-output-to-temp-buffer "*Pp Eval Output*"
(pp sexp)
(with-current-buffer standard-output
(emacs-lisp-mode))))
(defun elisp-macroexpand (form)
(interactive (list (form-at-point 'sexp)))
(elisp-pp (macroexpand form)))
(defun elisp-macroexpand-all (form)
(interactive (list (form-at-point 'sexp)))
(elisp-pp (cl-macroexpand-all form)))
(defun elisp-push-point-marker ()
(require 'etags)
(cond ((featurep 'xemacs)
(push-tag-mark))
(t (ring-insert find-tag-marker-ring (point-marker)))))
(defun elisp-pop-found-function ()
(interactive)
(cond ((featurep 'xemacs) (pop-tag-mark nil))
(t (pop-tag-mark))))
(defun elisp-find-definition (name)
"Jump to the definition of the function (or variable) at point."
(interactive (list (thing-at-point 'symbol)))
(cond (name
(let ((symbol (intern-soft name))
(search (lambda (fun sym)
(let* ((r (save-excursion (funcall fun sym)))
(buffer (car r))
(point (cdr r)))
(cond ((not point)
(error "Found no definition for %s in %s"
name buffer))
(t
(switch-to-buffer buffer)
(goto-char point)
(recenter 1)))))))
(cond ((fboundp symbol)
(elisp-push-point-marker)
(funcall search 'find-function-noselect symbol))
((boundp symbol)
(elisp-push-point-marker)
(funcall search 'find-variable-noselect symbol))
(t
(message "Symbol not bound: %S" symbol)))))
(t (message "No symbol at point"))))
(defun elisp-bytecompile-and-load ()
(interactive)
(or buffer-file-name
(error "The buffer must be saved in a file first"))
(require 'bytecomp)
;; Recompile if file or buffer has changed since last compilation.
(when (and (buffer-modified-p)
(y-or-n-p (format "save buffer %s first? " (buffer-name))))
(save-buffer))
(let ((filename (expand-file-name buffer-file-name)))
(with-temp-buffer
(byte-compile-file filename t))))
(defvar elisp-extra-keys
'(((kbd "C-c d") 'elisp-disassemble)
((kbd "C-c m") 'elisp-macroexpand)
((kbd "C-c M") 'elisp-macroexpand-all)
((kbd "C-c C-c") 'compile-defun)
((kbd "C-c C-k") 'elisp-bytecompile-and-load)
((kbd "C-c C-l") 'load-file)
((kbd "C-c p") 'pp-eval-last-sexp)
((kbd "M-.") 'elisp-find-definition)
((kbd "M-,") 'elisp-pop-found-function)
((kbd "C-c <") 'list-callers)))
(dolist (binding elisp-extra-keys)
(let ((key (eval (car binding))) (val (eval (cadr binding))))
(define-key emacs-lisp-mode-map key val)
(define-key lisp-interaction-mode-map key val)))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Go to Emacs-Lisp Definition
2009-09-22 9:13 Go to Emacs-Lisp Definition Nordlöw
2009-09-22 9:21 ` Helmut Eller
@ 2009-09-22 9:39 ` Stefan Kamphausen
2009-09-22 11:59 ` Andreas Röhler
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Stefan Kamphausen @ 2009-09-22 9:39 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
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!
not sure, whether I understand your intentions but maybe find-function
and find-variable are your friends.
Regards,
Stefan
--
Stefan Kamphausen --- http://www.skamphausen.de
a blessed +42 regexp of confusion (weapon in hand)
You hit. The format string crumbles and turns to dust.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Go to Emacs-Lisp Definition
2009-09-22 9:13 Go to Emacs-Lisp Definition Nordlöw
2009-09-22 9:21 ` Helmut Eller
2009-09-22 9:39 ` Stefan Kamphausen
@ 2009-09-22 11:59 ` Andreas Röhler
2009-09-22 12:45 ` Andreas Politz
2009-09-22 22:40 ` Bernardo
4 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2009-09-22 11:59 UTC (permalink / raw)
To: Nordlöw; +Cc: help-gnu-emacs
Nordlöw wrote:
> 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!
>
> Thanks,
> Per Nordlöw
>
>
with output following C-h v or C-h f
I use `jump-to-form' - bound here to f12:
(defun jump-to-form ()
(interactive)
(if (featurep 'xemacs)
(progn
(forward-char 1)
(let ((name (symbol-atpt))
(file (progn (search-forward "\"" nil t 1)(thing-at-point
'filename))))
(forward-char 1)
(help-find-source-or-scroll-up (point))
(switch-to-buffer (current-buffer))
(kill-new name)
(search-forward name)))
(other-window 1)
(forward-button 1)
;; (find-file (filename-atpt))
(push-button)))
;;;;;;;;;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Go to Emacs-Lisp Definition
2009-09-22 9:13 Go to Emacs-Lisp Definition Nordlöw
` (2 preceding siblings ...)
2009-09-22 11:59 ` Andreas Röhler
@ 2009-09-22 12:45 ` Andreas Politz
2009-09-22 22:40 ` Bernardo
4 siblings, 0 replies; 7+ messages in thread
From: Andreas Politz @ 2009-09-22 12:45 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Go to Emacs-Lisp Definition
2009-09-22 9:21 ` Helmut Eller
@ 2009-09-22 14:25 ` Andreas Röhler
0 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2009-09-22 14:25 UTC (permalink / raw)
To: Helmut Eller; +Cc: help-gnu-emacs
Helmut Eller wrote:
> * Nordlöw [2009-09-22 11:13+0200] 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!
>>
>
> I have this in my .emacs. It's some random elisp hacking stuff.
> Pick what you need.
>
> Helmut
>
> (defun elisp-disassemble (function)
>
...
It's great, thanks a lot. May you ask at emacs-devel to include it? -
my suggestion.
Took it into Emacs Lisp Bill Board
http://repo.or.cz/w/elbb.git
or better
http://repo.or.cz/w/elbb.git?a=tree;f=code;hb=HEAD
Andreas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Go to Emacs-Lisp Definition
2009-09-22 9:13 Go to Emacs-Lisp Definition Nordlöw
` (3 preceding siblings ...)
2009-09-22 12:45 ` Andreas Politz
@ 2009-09-22 22:40 ` Bernardo
4 siblings, 0 replies; 7+ messages in thread
From: Bernardo @ 2009-09-22 22:40 UTC (permalink / raw)
To: emacs help
> 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!
(possibly) outside Emacs:
etags *.el
inside Emacs:
M-x visit-tags-table RET /usr/share/emacs/23.1/lisp/TAGS RET
and M-. and friends should work
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-09-22 22:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-22 9:13 Go to Emacs-Lisp Definition Nordlöw
2009-09-22 9:21 ` Helmut Eller
2009-09-22 14:25 ` Andreas Röhler
2009-09-22 9:39 ` Stefan Kamphausen
2009-09-22 11:59 ` Andreas Röhler
2009-09-22 12:45 ` Andreas Politz
2009-09-22 22:40 ` Bernardo
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.