how do I jump to a function definition in emacs when using slime?
Asked Answered
W

1

11

I have installed slime using https://github.com/thephoeron/slime-pack and want to explore the common-lisp a bit more.

How do I access the source for a particular function in emacs?

for example, if I have a function:

(type-of 1)

and I want to visit the source of type-of, how can this be done?

Wyckoff answered 18/7, 2014 at 6:13 Comment(2)
I don't use the library you referenced, but I do use M-x find-function quite frequently. Does that work for you? There is also find-function-other-window and find-function-other-frame.Decalcomania
I had the error Directory /usr/bin/src/code does not exist, create it ?` but it worked after I installed Slime with Emacs' package manager.Tagliatelle
T
16

Meta .

It calls the function: slime-edit-definition

For jumping to functions inside your lisp implementation you may need to do something extra to point to the sources. In SBCL you have to sb-ext:set-sbcl-source-location to the correct place in .sbclrc:

(sb-ext:set-sbcl-source-location "/path/to/sbcl/")

You can edit .sbclrc with C-xC-f ~/.sbclrc in Emacs.

Teilo answered 18/7, 2014 at 9:10 Comment(6)
If you build SBCL yourself the source location is set automatically.Coverdale
This only works if the function was defined in a file you loaded. If you tey to do this with a definition you've sent to the REPL from your source via C-x e, you'll get Error: DEFINITION-SOURCE of function FOO-BAR did not contain meaningful information.Prevaricator
But, how to jump back?Glendaglenden
META comma allows you jump backTeilo
Link to the Slime doc :)Tagliatelle
And if the respective function is in a package, don’t forget to load that package in the REPL. Took me 5 minutes to realize this, I had just started Emacs.Fechter

© 2022 - 2024 — McMap. All rights reserved.