How to look up CL function definitions inside emacs
Asked Answered
P

4

6

Is there a way to see the arguments for a common lisp function and its documentation from within emacs? Or also to see a list of all available functions?

Patio answered 21/10, 2013 at 1:47 Comment(0)
F
10

SLIME automatically loads eldoc-mode - this is the mode that displays function arguments in the minibuffer. If you mean cl library of Emacs Lisp, you can load it using M-xeldoc-mode.

Another useful SLIME feature is the C-c C-d C-d - this pops a new buffer with documentation about the function.

These are very useful too:

  • C-c C-w C-aslime-who-specializes
  • C-c C-w C-bslime-who-binds
  • C-c C-w C-cslime-who-calls
  • C-c C-w RETslime-who-macroexpands
  • C-c C-w C-rslime-who-references
  • C-c C-w C-sslime-who-sets
  • C-c C-w C-wslime-calls-who
  • C-c C-w aslime-who-specializes
  • C-c C-w bslime-who-binds
  • C-c C-w cslime-who-calls
  • C-c C-w mslime-who-macroexpands
  • C-c C-w rslime-who-references
  • C-c C-w sslime-who-sets
  • C-c C-w wslime-calls-who

It should be obvious what they do from their names.

Addidionally, there's an auto-complete plugin for SLIME which can show documentation and function arguments in a drop-down menu (well, sort of), visually similar to how Visual Studio or Eclipse do it. I think it's called ac-slime and is installable through ELPA.

Fiber answered 21/10, 2013 at 8:6 Comment(2)
by CL I meant Common Lisp, not any elisp stuff. Are these you mention primarily for elisp?Patio
@OpenLearner nope, only the part related to eldoc-mode, the rest are the SLIME bindings. If you have SLIME installed you can find all these (and more) bindings by doing C-h m (or M-x describe-mode). Or C-h b (M-x describe-keybindings).Fiber
E
2

You can get the documentation of a function with documentation. (Following examples for getting information about the function list.)

(documentation 'list 'function)
"Returns constructs and returns a list of its arguments."

To get the argument-list, there is typically an implementation dependent function arglist in some package. You can search this function with (apropos 'arglist). This will give you a list of all interned symbols whose names contain arglist.

For example in CMUCL it is (swank-backend::arglist 'list), in CLISP it is just (arglist 'list), etc.

N.B. If you use SLIME, you should see the available arguments below anyway.

Ergot answered 21/10, 2013 at 6:53 Comment(3)
how would I use (documenation to for example lookup documenation for format?Patio
You can use it like this: (documentation 'format 'function).Ergot
most implementations also have an ARGLIST function somewhere.Thaumatrope
B
0

Sort of. The manual GNU Emacs Common Lisp Emulation comes with GNU Emacs -- it is CL in the main (dir-level) Info menu. Consult the function index for the list of documented functions. But the documentation is somewhat incomplete, and it documents only the Emacs implementation, which sometimes differs from the Common Lisp spec.

Consult the Common Lisp documentation for precise info about the language.

Bicolor answered 21/10, 2013 at 1:55 Comment(0)
L
0

Everything below is from http://cl-cookbook.sourceforge.net/emacs-ide.html

Q2. Viewing HyperSpec from within Emacs

Q2 I like having access to the HyperSpec when I'm in Emacs, but why does it have to use an external browser? Why can't I just see the HyperSpec in Emacs?

A2 If you use the Emacs add-on package W3 (or W3M which provides similar functionality), you can display HTML pages inside of Emacs. Once you have W3 and the HyperSpec both installed, use code similar to the following to access the HyperSpec from the Shift-F1 key:

(global-set-key [(shift f1)]
    '(lambda ()
       (interactive)
       (let ((browse-url-browser-function 
                        'browse-url-w3)
               (common-lisp-hyperspec-root            
                        "file://c:/home/docs/Hyperspec/")
                           (common-lisp-hyperspec-symbol-table 
                         (concat common-lisp-hyperspec-root 
                                     "Data/Map_Sym.txt"))
                (hyperspec-prog 
                         "c:/home/site/ilisp/extra/hyperspec"))
         (load-library hyperspec-prog)
         (common-lisp-hyperspec 
                    (thing-at-point 'symbol)))))

Note that the "let" in the above code sets the browse-url-browser-function to W3 for just the HyperSpec. You can either set the variable globally (if you want to always use W3 or some other specific browser) or locally (if you want to use a specific browser and not the default one).

Lyly answered 21/10, 2013 at 8:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.