I'm already used to press C-h f and type a function name to ask for help on that function. But if the function name is already under the cursor (e.g. while visiting the .emacs configuration file), is there a way to avoid typing the whole thing again?
My current favorite reference defun (requires popup.el):
(require 'popup) (defun describe-thing-in-popup () (interactive) (let* ((thing (symbol-at-point)) (help-xref-following t) (description (save-window-excursion (with-temp-buffer (help-mode) (help-xref-interned thing) (buffer-string))))) (popup-tip description :point (point) :around t :height 20 :scroll-bar t :margin t)))
Use that with your key binding of choice for unobtrusive help reference for
If you type
C-h f <RET>, it describes the function called by the innermost Lisp expression in the buffer around point, provided that function name is a valid, defined Lisp function. (That name appears as the default while you enter the argument.
In addition to what others have said, if you use library
help-fns+.el then the defaulting is a bit better - the cursor needs only to be near the symbol (e.g. function name) that you want to use.
(The vanilla Emacs behavior picks up only the symbol used for the function call surrounding the cursor, even if the cursor is on top of another function name that you want to investigate. Not too good for a language that passes functions around as arguments etc.)
There are also other enhancements to the Emacs help functions in
As Sean Alfred commented above, the default for C-h f is to already preselect the function at point as the default.
But you could also use
helm-apropos which is part of the standard helm package (available from package repositories, e.g. from MELPA).
Helm apropos will preselect the function under the cursor, and I find it one of the nicest tool to locate documentation.
Just hitting RET should be enough. Alternatively, try the following snippet to define a function that describes the function at point:
(defun my-describe-function-at-point () (interactive) (describe-function (function-called-at-point)))
I get Elisp documentation with lispy. There, C-1 toggles the inline doc for current function. Here's how it looks:
If the docstring is very large,
*Help* window is used instead.