14

I use C-h f heavily, but this is all functions in Emacs. I'm often only interested in interactive functions, i.e. commands.

Is there an equivalent for commands? Ideally I'd like ido completion too.

  • 1
    Next question, why is this not in Emacs? – Jonathan Leech-Pepin Sep 30 '14 at 13:45
  • 1
    @JonathanLeech-Pepin: Proposed, but rejected by Emacs Dev. – Drew Oct 1 '14 at 1:40
12

Yes. Library help-fns+.el defines command describe-command.

And it redefines describe-function so that it does describe-command if you give it a prefix arg.

The library binds describe-command to C-h c (describe-key-briefly is moved to C-h C-c).

The same library defines other help commands, such as describe-file, describe-buffer, describe-keymap, and describe-option-of-type. Here is more info about the library.

  • 1
    I really like help-fns+, but it's adding a big space and a generic comment on every function I look at: imgur.com/NiDlkjS -- any ideas? – Wilfred Hughes Nov 29 '14 at 12:05
  • @WilfredHughes: Should be OK now. (Should also be mirrored on MELPA within 24 hrs.) – Drew Nov 29 '14 at 18:25
  • Drew's link from the comment @ 18:25 is broken. emacswiki.org/emacs/download/help-fns%2b.el works. – Realraptor Sep 4 at 19:39
  • 1
    @Realraptor: Thanks. EmacsWiki URLs changed a few years ago. – Drew Sep 4 at 19:42
9

apropos-command might be sufficiently close.

It doesn’t offer describe-function’s tab completion, but it lets you search only through commands, and it takes you to their doc page.

8

if you have smex installed, just call smex. Start to type, when the right one comes up, press C-h f.

7

I can't find this built-in. It is fairly easy to make a wrapper around describe-function that only completes command names when called interactively. In the implementation below, I duplicated the interactive form from describe-function and changed the fboundp test to commandp. As an added bonus, this function offers all function names when called with a prefix argument. Change if current-prefix-arg to if (not current-prefix-arg) to make describing all functions the default.

(defun describe-command (function &optional all-functions)
  "Display the full documentation of FUNCTION (a symbol).
When called interactively with a prefix argument, prompt for all functions,
not just interactive commands, like `describe-function'."
  (interactive (if current-prefix-arg
                   (eval (car (cdr (interactive-form 'describe-function))))
                 (list (let ((fn (function-called-at-point))
                             (enable-recursive-minibuffers t)
                             val)
                         (setq val (completing-read (if (and fn (commandp fn))
                                                        (format "Describe command (default %s): " fn)
                                                      "Describe command: ")
                                                    obarray 'commandp t nil nil
                                                    (and fn (commandp fn)
                                                         (symbol-name fn))))
                         (if (equal val "") fn (intern val)))
                       current-prefix-arg)))
  (describe-function function))

I haven't tested this with ido but it should integrate normally.

  • Quick test shows that it works with IDO. Copied to *scratch*, evaluated then ran M-x describe-command. Commands showed up in a vertical list thanks to ido-vertical. – Jonathan Leech-Pepin Sep 30 '14 at 13:44
  • Shouldn't the last line be (describe-function command)? – npostavs Sep 3 '18 at 18:42
5

If you are using helm and helm-M-x, you can press C-j on the commands to pop up their documentation.

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.