Today’s re-additions to my .emacs file:
(defun my-help () "If function given tries to `describe-function' if variable uses 'describe-variable', otherwise uses `manual-entry' to display manpage of a `current-word'." (interactive) (let ((var (variable-at-point))) (if (symbolp var) (describe-variable var) (let ((fn (function-called-at-point))) (if fn (describe-function fn) (man (current-word))))))) (global-set-key [f1] 'my-help)
This function was one I found somewhere online, and is incredibly useful. It will attempt to give help on the word at point, no matter what it is. If it is a variable, it will call the describe-variable function. If it is a function, it will call describe-function to give documentation. If it isn’t a elisp variable of function, it will return the results of the ‘man’ command on the word, which is still useful in programming if you have packages such as manpages-dev. While these commands are all possible individually, having one key that does whatever it should to give documentation, instead of having to choose documentation functions, makes my life so much easier when reading elisp.
Tags: emacs elisp
While coding in Emacs Lisp, give a try the built-in `eldoc-mode` which ’displays information about a
function or variable in the text where point is’.
You probably don’t find references on that topic in an “elisp - best practices”-book, but… It is possible to have a function and a variable with the same name. Maybe you should take care for that?