* elisp programming - navigate through code?
@ 2014-03-29 16:49 Martin
2014-03-29 17:17 ` Thorsten Jolitz
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Martin @ 2014-03-29 16:49 UTC (permalink / raw)
To: GNU Emacs users list
Hi there,
This is now specially for elisp, but maybe its possible for other things to
(ruby on rails - ruby, javascript, coffeescript, ...)
Is there a way to navigate better through my code.
like having a function (foo arg1 arg2) putting the cursor to foo will
C-h f suggest I want to read the docstring for that. Thats good.
But now I'd like to navigate to the definition (which can be in the same
buffer or somewhere else). Is that possbile?
Thanks,
Martin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: elisp programming - navigate through code?
2014-03-29 16:49 elisp programming - navigate through code? Martin
@ 2014-03-29 17:17 ` Thorsten Jolitz
2014-03-29 18:10 ` Michael Heerdegen
2014-03-30 5:23 ` Alex Kost
2 siblings, 0 replies; 6+ messages in thread
From: Thorsten Jolitz @ 2014-03-29 17:17 UTC (permalink / raw)
To: help-gnu-emacs
Martin <kleinerdrache@gmx.at> writes:
> Hi there,
>
> This is now specially for elisp, but maybe its possible for other things to
> (ruby on rails - ruby, javascript, coffeescript, ...)
>
> Is there a way to navigate better through my code.
>
> like having a function (foo arg1 arg2) putting the cursor to foo will
> C-h f suggest I want to read the docstring for that. Thats good.
>
> But now I'd like to navigate to the definition (which can be in the same
> buffer or somewhere else). Is that possbile?
you can use tags
,--------------------------------------------------------------------
| http://www.gnu.org/software/emacs/manual/html_node/eintr/etags.html
`--------------------------------------------------------------------
or a function like this:
,---------------------------------------------------
| ;; jumps to the source of the symbol at point
| (defun tj/goto-symbol-definition ()
| "jump to the source of the symbol at point."
| (interactive)
| (require 'finder)
| (let ((thing (intern (thing-at-point 'symbol))))
| (if (functionp thing)
| (find-function thing)
| (find-variable thing))))
`---------------------------------------------------
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: elisp programming - navigate through code?
2014-03-29 16:49 elisp programming - navigate through code? Martin
2014-03-29 17:17 ` Thorsten Jolitz
@ 2014-03-29 18:10 ` Michael Heerdegen
2014-03-29 21:00 ` Thien-Thi Nguyen
2014-03-30 5:23 ` Alex Kost
2 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2014-03-29 18:10 UTC (permalink / raw)
To: help-gnu-emacs
Hi Martin,
> This is now specially for elisp, but maybe its possible for other
> things to
> (ruby on rails - ruby, javascript, coffeescript, ...)
>
> Is there a way to navigate better through my code.
>
> like having a function (foo arg1 arg2) putting the cursor to foo will
> C-h f suggest I want to read the docstring for that. Thats good.
>
> But now I'd like to navigate to the definition (which can be in the same
> buffer or somewhere else). Is that possbile?
For elisp, you can use something like this:
--8<---------------cut here---------------start------------->8---
(progn
(require 'thingatpt)
(defun my-find-symbol-at-point ()
"Find the definition of the symbol at point."
(interactive)
(let ((sym (symbol-at-point)))
(funcall (pcase sym
((pred facep) #'find-face)
((pred symbol-function) #'find-function)
(_ #'find-variable))
sym)))
(global-set-key [(shift return)] #'my-find-symbol-at-point))
--8<---------------cut here---------------end--------------->8---
Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: elisp programming - navigate through code?
2014-03-29 18:10 ` Michael Heerdegen
@ 2014-03-29 21:00 ` Thien-Thi Nguyen
2014-03-29 22:31 ` Michael Heerdegen
0 siblings, 1 reply; 6+ messages in thread
From: Thien-Thi Nguyen @ 2014-03-29 21:00 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 665 bytes --]
() Michael Heerdegen <michael_heerdegen@web.de>
() Sat, 29 Mar 2014 19:10:26 +0100
(let ((sym (symbol-at-point)))
(funcall (pcase sym
((pred facep) #'find-face)
((pred symbol-function) #'find-function)
(_ #'find-variable))
sym))
Any particular reason you use ‘pcase’ here instead of ‘cond’?
--
Thien-Thi Nguyen
GPG key: 4C807502
(if you're human and you know it)
read my lisp: (responsep (questions 'technical)
(not (via 'mailing-list)))
=> nil
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: elisp programming - navigate through code?
2014-03-29 21:00 ` Thien-Thi Nguyen
@ 2014-03-29 22:31 ` Michael Heerdegen
0 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2014-03-29 22:31 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: help-gnu-emacs
Thien-Thi Nguyen <ttn@gnu.org> writes:
> Any particular reason you use ‘pcase’ here instead of ‘cond’?
Yes, I want to get more used to it ;-). And this is a common use case,
since all "conditions" only depend on one value.
Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: elisp programming - navigate through code?
2014-03-29 16:49 elisp programming - navigate through code? Martin
2014-03-29 17:17 ` Thorsten Jolitz
2014-03-29 18:10 ` Michael Heerdegen
@ 2014-03-30 5:23 ` Alex Kost
2 siblings, 0 replies; 6+ messages in thread
From: Alex Kost @ 2014-03-30 5:23 UTC (permalink / raw)
To: Martin; +Cc: GNU Emacs users list
Martin (2014-03-29 20:49 +0400) wrote:
> Hi there,
>
> This is now specially for elisp, but maybe its possible for other things to
> (ruby on rails - ruby, javascript, coffeescript, ...)
>
> Is there a way to navigate better through my code.
>
> like having a function (foo arg1 arg2) putting the cursor to foo will
> C-h f suggest I want to read the docstring for that. Thats good.
>
> But now I'd like to navigate to the definition (which can be in the same
> buffer or somewhere else). Is that possbile?
You may install "elisp-slime-nav" package
(https://github.com/purcell/elisp-slime-nav). Can be found on MELPA.
It allows to move to the function/variable/face definition immediately.
--
Alex Kost
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-03-30 5:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-29 16:49 elisp programming - navigate through code? Martin
2014-03-29 17:17 ` Thorsten Jolitz
2014-03-29 18:10 ` Michael Heerdegen
2014-03-29 21:00 ` Thien-Thi Nguyen
2014-03-29 22:31 ` Michael Heerdegen
2014-03-30 5:23 ` Alex Kost
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.