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.

Malabarba
  • 22,878
  • 6
  • 78
  • 163
Wilfred Hughes
  • 6,890
  • 2
  • 29
  • 59

5 Answers5

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.

Drew
  • 75,699
  • 9
  • 109
  • 225
  • 1
    I really like help-fns+, but it's adding a big space and a generic comment on every function I look at: http://imgur.com/NiDlkjS -- any ideas? – Wilfred Hughes Nov 29 '14 at 12:05
  • @WilfredHughes: Should be [OK now](http://www.emacswiki.org/emacs-en/download/help-fns%2b.el). (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. https://www.emacswiki.org/emacs/download/help-fns%2b.el works. – Realraptor Sep 04 '19 at 19:39
  • 1
    @Realraptor: Thanks. EmacsWiki URLs changed a few years ago. – Drew Sep 04 '19 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.

Malabarba
  • 22,878
  • 6
  • 78
  • 163
8

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

Xah Lee
  • 1,756
  • 12
  • 11
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.

sam boosalis
  • 127
  • 1
  • 7
5

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

Marten
  • 159
  • 3