1

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?

  • 4
    This is the default… just press C-h f RET. – Sean Allred Oct 28 '14 at 23:05
  • I feel quite stupid, I didn't try the obvious. Anyways, I learned a couple of very nice tricks from the answers below. – El Diego Efe Oct 29 '14 at 15:22
1

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 symbol-at-point.

8

From gnu.org:

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.

3

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 help-fns+.el.

2

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.

2

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)))
0

I get Elisp documentation with lispy. There, C-1 toggles the inline doc for current function. Here's how it looks:

image

If the docstring is very large, *Help* window is used instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.