Discussion:
Get function description
(too old to reply)
Daniel Cerqueira
2024-03-06 19:43:56 UTC
Permalink
I am using Emacs LISP and I want to get the description of some Elisp
function.

How can I do that?
Aidan Kehoe
2024-03-06 20:07:19 UTC
Permalink
Post by Daniel Cerqueira
I am using Emacs LISP and I want to get the description of some Elisp
function.
How can I do that?
F1 f function-name RET

For example, F1 f car RET brings up a buffer documenting that function:

car is a built-in function in ‘C source code’.

(car LIST)

Return the car of LIST. If LIST is nil, return nil.
Error if LIST is not nil and not a cons cell. See also ‘car-safe’.

See Info node ‘(elisp)Cons Cells’ for a discussion of related basic
Lisp concepts such as car, cdr, cons cell and list.

Other relevant functions are documented in the list group.
Probably introduced at or before Emacs version 1.2.
This function does not change global state, including the match data.

Also helpful for under-documented functions is M-x find-function RET , which
will bring you to the source code of a function. E.g. M-x find-function RET
find-file RET loads files.el and brings the cursor to the (defun ...) that
defines #'find-file.
--
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after fourteen pints of stout’
(C. Moore)
Lawrence D'Oliveiro
2024-03-06 21:04:00 UTC
Permalink
Post by Aidan Kehoe
F1 f function-name RET
CTRL/H or F1 is the prefix for all the help functions. E.g. CTRL/H-a to do
an apropos search of command names, CTRL/H-c to get help for a key
sequence, and of course CTRL/H-? to see what all the help functions are.
Daniel Cerqueira
2024-03-07 10:18:06 UTC
Permalink
Post by Aidan Kehoe
Post by Daniel Cerqueira
I am using Emacs LISP and I want to get the description of some Elisp
function.
How can I do that?
F1 f function-name RET
car is a built-in function in ‘C source code’.
(car LIST)
Return the car of LIST. If LIST is nil, return nil.
Error if LIST is not nil and not a cons cell. See also ‘car-safe’.
See Info node ‘(elisp)Cons Cells’ for a discussion of related basic
Lisp concepts such as car, cdr, cons cell and list.
Other relevant functions are documented in the list group.
Probably introduced at or before Emacs version 1.2.
This function does not change global state, including the match data.
Also helpful for under-documented functions is M-x find-function RET , which
will bring you to the source code of a function. E.g. M-x find-function RET
find-file RET loads files.el and brings the cursor to the (defun ...) that
defines #'find-file.
Thanks. I did not explain my issue correctly.

I want to, in Elisp code, get a string of a function description. Similar to
Common LISP `description` function.
Tim Landscheidt
2024-03-07 14:43:36 UTC
Permalink
Post by Daniel Cerqueira
[…]
I want to, in Elisp code, get a string of a function description. Similar to
Common LISP `description` function.
I don't know Common Lisp, but in Emacs Lisp you can:

| ELISP> (defun tl-dummy nil (and t nil))
| tl-dummy
| ELISP> (pp-to-string (symbol-function 'tl-dummy))
| "(closure
| (t)
| nil
| (and t nil))
| "
| ELISP>

But this will not work either for autoloaded functions nor
functions defined in C:

| ELISP> (pp-to-string (symbol-function 'rpm-spec-mode))
| "(autoload \"rpm-spec-mode\" \"RPM spec mode.\" t nil)
| "
| ELISP> (pp-to-string (symbol-function 'car))
| "#<subr car>"
| ELISP>

Tim
Aidan Kehoe
2024-03-07 15:16:31 UTC
Permalink
Post by Daniel Cerqueira
Post by Aidan Kehoe
Post by Daniel Cerqueira
I am using Emacs LISP and I want to get the description of some Elisp
function.
How can I do that?
F1 f function-name RET
car is a built-in function in ‘C source code’.
(car LIST)
Return the car of LIST. If LIST is nil, return nil.
Error if LIST is not nil and not a cons cell. See also ‘car-safe’.
See Info node ‘(elisp)Cons Cells’ for a discussion of related basic
Lisp concepts such as car, cdr, cons cell and list.
Other relevant functions are documented in the list group.
Probably introduced at or before Emacs version 1.2.
This function does not change global state, including the match data.
Also helpful for under-documented functions is M-x find-function RET , which
will bring you to the source code of a function. E.g. M-x find-function RET
find-file RET loads files.el and brings the cursor to the (defun ...) that
defines #'find-file.
Thanks. I did not explain my issue correctly.
I want to, in Elisp code, get a string of a function description. Similar to
Common LISP `description` function.
There’s nothing exactly like the Common Lisp #'describe function, but
#'help-function-arglist may go part of the way to what you would like.
--
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after fourteen pints of stout’
(C. Moore)
Loading...