Minor improvements in manuals
[emacs.git] / doc / lispref / help.texi
blob33cc2f0d55b54898f3d8ac5a0313377ac77df9ff
1 @c -*- mode: texinfo; coding: utf-8 -*-
2 @c This is part of the GNU Emacs Lisp Reference Manual.
3 @c Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
4 @c Foundation, Inc.
5 @c See the file elisp.texi for copying conditions.
6 @node Documentation
7 @chapter Documentation
8 @cindex documentation strings
10   GNU Emacs has convenient built-in help facilities, most of which
11 derive their information from documentation strings associated with
12 functions and variables.  This chapter describes how to access
13 documentation strings in Lisp programs.
15   The contents of a documentation string should follow certain
16 conventions.  In particular, its first line should be a complete
17 sentence (or two complete sentences) that briefly describes what the
18 function or variable does.  @xref{Documentation Tips}, for how to
19 write good documentation strings.
21   Note that the documentation strings for Emacs are not the same thing
22 as the Emacs manual.  Manuals have their own source files, written in
23 the Texinfo language; documentation strings are specified in the
24 definitions of the functions and variables they apply to.  A collection
25 of documentation strings is not sufficient as a manual because a good
26 manual is not organized in that fashion; it is organized in terms of
27 topics of discussion.
29   For commands to display documentation strings, see @ref{Help, ,
30 Help, emacs, The GNU Emacs Manual}.
32 @menu
33 * Documentation Basics::      Where doc strings are defined and stored.
34 * Accessing Documentation::   How Lisp programs can access doc strings.
35 * Keys in Documentation::     Substituting current key bindings.
36 * Text Quoting Style::        Quotation marks in doc strings and messages.
37 * Describing Characters::     Making printable descriptions of
38                                 non-printing characters and key sequences.
39 * Help Functions::            Subroutines used by Emacs help facilities.
40 @end menu
42 @node Documentation Basics
43 @section Documentation Basics
44 @cindex documentation conventions
45 @cindex writing a documentation string
46 @cindex string, writing a doc string
48   A documentation string is written using the Lisp syntax for strings,
49 with double-quote characters surrounding the text.  It is, in fact, an
50 actual Lisp string.  When the string appears in the proper place in a
51 function or variable definition, it serves as the function's or
52 variable's documentation.
54 @cindex @code{function-documentation} property
55   In a function definition (a @code{lambda} or @code{defun} form), the
56 documentation string is specified after the argument list, and is
57 normally stored directly in the function object.  @xref{Function
58 Documentation}.  You can also put function documentation in the
59 @code{function-documentation} property of a function name
60 (@pxref{Accessing Documentation}).
62 @cindex @code{variable-documentation} property
63   In a variable definition (a @code{defvar} form), the documentation
64 string is specified after the initial value.  @xref{Defining
65 Variables}.  The string is stored in the variable's
66 @code{variable-documentation} property.
68 @cindex @file{DOC} (documentation) file
69   Sometimes, Emacs does not keep documentation strings in memory.
70 There are two such circumstances.  Firstly, to save memory, the
71 documentation for preloaded functions and variables (including
72 primitives) is kept in a file named @file{DOC}, in the directory
73 specified by @code{doc-directory} (@pxref{Accessing Documentation}).
74 Secondly, when a function or variable is loaded from a byte-compiled
75 file, Emacs avoids loading its documentation string (@pxref{Docs and
76 Compilation}).  In both cases, Emacs looks up the documentation string
77 from the file only when needed, such as when the user calls @kbd{C-h
78 f} (@code{describe-function}) for a function.
80   Documentation strings can contain special @dfn{key substitution
81 sequences}, referring to key bindings which are looked up only when
82 the user views the documentation.  This allows the help commands to
83 display the correct keys even if a user rearranges the default key
84 bindings.  @xref{Keys in Documentation}.
86   In the documentation string of an autoloaded command
87 (@pxref{Autoload}), these key-substitution sequences have an
88 additional special effect: they cause @kbd{C-h f} on the command to
89 trigger autoloading.  (This is needed for correctly setting up the
90 hyperlinks in the @file{*Help*} buffer.)
92 @node Accessing Documentation
93 @section Access to Documentation Strings
94 @cindex accessing documentation strings
96 @defun documentation-property symbol property &optional verbatim
97 This function returns the documentation string recorded in
98 @var{symbol}'s property list under property @var{property}.  It is
99 most often used to look up the documentation strings of variables, for
100 which @var{property} is @code{variable-documentation}.  However, it
101 can also be used to look up other kinds of documentation, such as for
102 customization groups (but for function documentation, use the
103 @code{documentation} function, below).
105 If the property value refers to a documentation string stored in the
106 @file{DOC} file or a byte-compiled file, this function looks up that
107 string and returns it.
109 If the property value isn't @code{nil}, isn't a string, and doesn't
110 refer to text in a file, then it is evaluated as a Lisp expression to
111 obtain a string.
113 Finally, this function passes the string through
114 @code{substitute-command-keys} to substitute key bindings (@pxref{Keys
115 in Documentation}).  It skips this step if @var{verbatim} is
116 non-@code{nil}.
118 @smallexample
119 @group
120 (documentation-property 'command-line-processed
121    'variable-documentation)
122      @result{} "Non-nil once command line has been processed"
123 @end group
124 @group
125 (symbol-plist 'command-line-processed)
126      @result{} (variable-documentation 188902)
127 @end group
128 @group
129 (documentation-property 'emacs 'group-documentation)
130      @result{} "Customization of the One True Editor."
131 @end group
132 @end smallexample
133 @end defun
135 @defun documentation function &optional verbatim
136 This function returns the documentation string of @var{function}.  It
137 handles macros, named keyboard macros, and special forms, as well as
138 ordinary functions.
140 If @var{function} is a symbol, this function first looks for the
141 @code{function-documentation} property of that symbol; if that has a
142 non-@code{nil} value, the documentation comes from that value (if the
143 value is not a string, it is evaluated).
145 If @var{function} is not a symbol, or if it has no
146 @code{function-documentation} property, then @code{documentation}
147 extracts the documentation string from the actual function definition,
148 reading it from a file if called for.
150 Finally, unless @var{verbatim} is non-@code{nil}, this function calls
151 @code{substitute-command-keys}.  The result is the documentation
152 string to return.
154 The @code{documentation} function signals a @code{void-function} error
155 if @var{function} has no function definition.  However, it is OK if
156 the function definition has no documentation string.  In that case,
157 @code{documentation} returns @code{nil}.
158 @end defun
160 @defun face-documentation face
161 This function returns the documentation string of @var{face} as a
162 face.
163 @end defun
165 Here is an example of using the two functions, @code{documentation} and
166 @code{documentation-property}, to display the documentation strings for
167 several symbols in a @file{*Help*} buffer.
169 @anchor{describe-symbols example}
170 @smallexample
171 @group
172 (defun describe-symbols (pattern)
173   "Describe the Emacs Lisp symbols matching PATTERN.
174 All symbols that have PATTERN in their name are described
175 in the *Help* buffer."
176   (interactive "sDescribe symbols matching: ")
177   (let ((describe-func
178          (function
179           (lambda (s)
180 @end group
181 @group
182             ;; @r{Print description of symbol.}
183             (if (fboundp s)             ; @r{It is a function.}
184                 (princ
185                  (format "%s\t%s\n%s\n\n" s
186                    (if (commandp s)
187                        (let ((keys (where-is-internal s)))
188                          (if keys
189                              (concat
190                               "Keys: "
191                               (mapconcat 'key-description
192                                          keys " "))
193                            "Keys: none"))
194                      "Function")
195 @end group
196 @group
197                    (or (documentation s)
198                        "not documented"))))
200             (if (boundp s)              ; @r{It is a variable.}
201 @end group
202 @group
203                 (princ
204                  (format "%s\t%s\n%s\n\n" s
205                    (if (custom-variable-p s)
206                        "Option " "Variable")
207 @end group
208 @group
209                    (or (documentation-property
210                          s 'variable-documentation)
211                        "not documented")))))))
212         sym-list)
213 @end group
215 @group
216     ;; @r{Build a list of symbols that match pattern.}
217     (mapatoms (function
218                (lambda (sym)
219                  (if (string-match pattern (symbol-name sym))
220                      (setq sym-list (cons sym sym-list))))))
221 @end group
223 @group
224     ;; @r{Display the data.}
225     (help-setup-xref (list 'describe-symbols pattern) (interactive-p))
226     (with-help-window (help-buffer)
227       (mapcar describe-func (sort sym-list 'string<)))))
228 @end group
229 @end smallexample
231   The @code{describe-symbols} function works like @code{apropos},
232 but provides more information.
234 @smallexample
235 @group
236 (describe-symbols "goal")
238 ---------- Buffer: *Help* ----------
239 goal-column     Option
240 Semipermanent goal column for vertical motion, as set by @dots{}
241 @end group
242 @c Do not blithely break or fill these lines.
243 @c That makes them incorrect.
245 @group
246 minibuffer-temporary-goal-position      Variable
247 not documented
248 @end group
250 @group
251 set-goal-column Keys: C-x C-n
252 Set the current horizontal position as a goal for C-n and C-p.
253 @end group
254 @c DO NOT put a blank line here!  That is factually inaccurate!
255 @group
256 Those commands will move to this position in the line moved to
257 rather than trying to keep the same horizontal position.
258 With a non-nil argument ARG, clears out the goal column
259 so that C-n and C-p resume vertical motion.
260 The goal column is stored in the variable ‘goal-column’.
262 (fn ARG)
263 @end group
265 @group
266 temporary-goal-column   Variable
267 Current goal column for vertical motion.
268 It is the column where point was at the start of the current run
269 of vertical motion commands.
271 When moving by visual lines via the function ‘line-move-visual’, it is a cons
272 cell (COL . HSCROLL), where COL is the x-position, in pixels,
273 divided by the default column width, and HSCROLL is the number of
274 columns by which window is scrolled from left margin.
276 When the ‘track-eol’ feature is doing its job, the value is
277 ‘most-positive-fixnum’.
278 ---------- Buffer: *Help* ----------
279 @end group
280 @end smallexample
282 @anchor{Definition of Snarf-documentation}
283 @defun Snarf-documentation filename
284 This function is used when building Emacs, just before the runnable
285 Emacs is dumped.  It finds the positions of the documentation strings
286 stored in the file @var{filename}, and records those positions into
287 memory in the function definitions and variable property lists.
288 @xref{Building Emacs}.
290 Emacs reads the file @var{filename} from the @file{emacs/etc} directory.
291 When the dumped Emacs is later executed, the same file will be looked
292 for in the directory @code{doc-directory}.  Usually @var{filename} is
293 @code{"DOC"}.
294 @end defun
296 @defvar doc-directory
297 This variable holds the name of the directory which should contain the
298 file @code{"DOC"} that contains documentation strings for
299 built-in and preloaded functions and variables.
301 In most cases, this is the same as @code{data-directory}.  They may be
302 different when you run Emacs from the directory where you built it,
303 without actually installing it.  @xref{Definition of data-directory}.
304 @end defvar
306 @node Keys in Documentation
307 @section Substituting Key Bindings in Documentation
308 @cindex documentation, keys in
309 @cindex keys in documentation strings
310 @cindex substituting keys in documentation
311 @cindex key substitution sequence
313   When documentation strings refer to key sequences, they should use the
314 current, actual key bindings.  They can do so using certain special text
315 sequences described below.  Accessing documentation strings in the usual
316 way substitutes current key binding information for these special
317 sequences.  This works by calling @code{substitute-command-keys}.  You
318 can also call that function yourself.
320   Here is a list of the special sequences and what they mean:
322 @table @code
323 @item \[@var{command}]
324 stands for a key sequence that will invoke @var{command}, or @samp{M-x
325 @var{command}} if @var{command} has no key bindings.
327 @item \@{@var{mapvar}@}
328 stands for a summary of the keymap which is the value of the variable
329 @var{mapvar}.  The summary is made using @code{describe-bindings}.
331 @item \<@var{mapvar}>
332 stands for no text itself.  It is used only for a side effect: it
333 specifies @var{mapvar}'s value as the keymap for any following
334 @samp{\[@var{command}]} sequences in this documentation string.
336 @item `
337 (grave accent) stands for a left quote.
338 This generates a left single quotation mark, an apostrophe, or a grave
339 accent depending on the value of @code{text-quoting-style}.
340 @xref{Text Quoting Style}.
342 @item '
343 (apostrophe) stands for a right quote.
344 This generates a right single quotation mark or an apostrophe
345 depending on the value of @code{text-quoting-style}.
347 @item \=
348 quotes the following character and is discarded; thus, @samp{\=`} puts
349 @samp{`} into the output, @samp{\=\[} puts @samp{\[} into the output,
350 and @samp{\=\=} puts @samp{\=} into the output.
351 @end table
353 @strong{Please note:} Each @samp{\} must be doubled when written in a
354 string in Emacs Lisp.
356 @defopt text-quoting-style
357 @cindex curved quotes
358 @cindex curly quotes
359 The value of this variable is a symbol that specifies the style Emacs
360 should use for single quotes in the wording of help and messages.  If
361 the variable's value is @code{curve}, the style is @t{‘like this’}
362 with curved single quotes.  If the value is @code{straight}, the style
363 is @t{'like this'} with straight apostrophes.  If the value is
364 @code{grave}, quotes are not translated and the style is @t{`like
365 this'} with grave accent and apostrophe, the standard style before
366 Emacs version 25.  The default value @code{nil} acts like @code{curve}
367 if curved single quotes seem to be displayable, and like @code{grave}
368 otherwise.
370 This option is useful on platforms that have problems with curved
371 quotes.  You can customize it freely according to your personal
372 preference.
373 @end defopt
375 @defun substitute-command-keys string
376 This function scans @var{string} for the above special sequences and
377 replaces them by what they stand for, returning the result as a string.
378 This permits display of documentation that refers accurately to the
379 user's own customized key bindings.
381 @cindex advertised binding
382 If a command has multiple bindings, this function normally uses the
383 first one it finds.  You can specify one particular key binding by
384 assigning an @code{:advertised-binding} symbol property to the
385 command, like this:
387 @smallexample
388 (put 'undo :advertised-binding [?\C-/])
389 @end smallexample
391 @noindent
392 The @code{:advertised-binding} property also affects the binding shown
393 in menu items (@pxref{Menu Bar}).  The property is ignored if it
394 specifies a key binding that the command does not actually have.
395 @end defun
397   Here are examples of the special sequences:
399 @smallexample
400 @group
401 (substitute-command-keys
402    "To abort recursive edit, type `\\[abort-recursive-edit]'.")
403 @result{} "To abort recursive edit, type ‘C-]’."
404 @end group
406 @group
407 (substitute-command-keys
408    "The keys that are defined for the minibuffer here are:
409   \\@{minibuffer-local-must-match-map@}")
410 @result{} "The keys that are defined for the minibuffer here are:
411 @end group
413 ?               minibuffer-completion-help
414 SPC             minibuffer-complete-word
415 TAB             minibuffer-complete
416 C-j             minibuffer-complete-and-exit
417 RET             minibuffer-complete-and-exit
418 C-g             abort-recursive-edit
421 @group
422 (substitute-command-keys
423    "To abort a recursive edit from the minibuffer, type \
424 `\\<minibuffer-local-must-match-map>\\[abort-recursive-edit]'.")
425 @result{} "To abort a recursive edit from the minibuffer, type ‘C-g’."
426 @end group
427 @end smallexample
429   There are other special conventions for the text in documentation
430 strings---for instance, you can refer to functions, variables, and
431 sections of this manual.  @xref{Documentation Tips}, for details.
433 @node Text Quoting Style
434 @section Text Quoting Style
436   Typically, grave accents and apostrophes are treated specially in
437 documentation strings and diagnostic messages, and translate to matching
438 single quotation marks (also called ``curved quotes'').  For example,
439 the documentation string @t{"Alias for `foo'."} and the function call
440 @code{(message "Alias for `foo'.")} both translate to @t{"Alias for
441 ‘foo’."}.  Less commonly, Emacs displays grave accents and apostrophes
442 as themselves, or as apostrophes only (e.g., @t{"Alias for 'foo'."}).
443 Documentation strings and message formats should be written so that
444 they display well with any of these styles.  For example, the
445 documentation string @t{"Alias for 'foo'."} is probably not what you
446 want, as it can display as @t{"Alias for ’foo’."}, an unusual style in
447 English.
449   Sometimes you may need to display a grave accent or apostrophe
450 without translation, regardless of text quoting style.  In a
451 documentation string, you can do this with escapes.  For example, in
452 the documentation string @t{"\\=`(a ,(sin 0)) ==> (a 0.0)"} the grave
453 accent is intended to denote Lisp code, so it is escaped and displays
454 as itself regardless of quoting style.  In a call to @code{message} or
455 @code{error}, you can avoid translation by using a format @t{"%s"}
456 with an argument that is a call to @code{format}.  For example,
457 @code{(message "%s" (format "`(a ,(sin %S)) ==> (a %S)" x (sin x)))}
458 displays a message that starts with grave accent regardless of text
459 quoting style.
461 @defopt text-quoting-style
462 @cindex curved quotes
463 @cindex curly quotes
464 The value of this user option is a symbol that specifies the style
465 Emacs should use for single quotes in the wording of help and
466 messages.  If the option's value is @code{curve}, the style is
467 @t{‘like this’} with curved single quotes.  If the value is
468 @code{straight}, the style is @t{'like this'} with straight
469 apostrophes.  If the value is @code{grave}, quotes are not translated
470 and the style is @t{`like this'} with grave accent and apostrophe, the
471 standard style before Emacs version 25.  The default value @code{nil}
472 acts like @code{curve} if curved single quotes seem to be displayable,
473 and like @code{grave} otherwise.
475 This option is useful on platforms that have problems with curved
476 quotes.  You can customize it freely according to your personal
477 preference.
478 @end defopt
480 @node Describing Characters
481 @section Describing Characters for Help Messages
482 @cindex describe characters and events
484   These functions convert events, key sequences, or characters to
485 textual descriptions.  These descriptions are useful for including
486 arbitrary text characters or key sequences in messages, because they
487 convert non-printing and whitespace characters to sequences of printing
488 characters.  The description of a non-whitespace printing character is
489 the character itself.
491 @defun key-description sequence &optional prefix
492 @cindex Emacs event standard notation
493 This function returns a string containing the Emacs standard notation
494 for the input events in @var{sequence}.  If @var{prefix} is
495 non-@code{nil}, it is a sequence of input events leading up to
496 @var{sequence} and is included in the return value.  Both arguments
497 may be strings, vectors or lists.  @xref{Input Events}, for more
498 information about valid events.
500 @smallexample
501 @group
502 (key-description [?\M-3 delete])
503      @result{} "M-3 <delete>"
504 @end group
505 @group
506 (key-description [delete] "\M-3")
507      @result{} "M-3 <delete>"
508 @end group
509 @end smallexample
511   See also the examples for @code{single-key-description}, below.
512 @end defun
514 @defun single-key-description event &optional no-angles
515 @cindex event printing
516 @cindex character printing
517 @cindex control character printing
518 @cindex meta character printing
519 This function returns a string describing @var{event} in the standard
520 Emacs notation for keyboard input.  A normal printing character
521 appears as itself, but a control character turns into a string
522 starting with @samp{C-}, a meta character turns into a string starting
523 with @samp{M-}, and space, tab, etc., appear as @samp{SPC},
524 @samp{TAB}, etc.  A function key symbol appears inside angle brackets
525 @samp{<@dots{}>}.  An event that is a list appears as the name of the
526 symbol in the @sc{car} of the list, inside angle brackets.
528 If the optional argument @var{no-angles} is non-@code{nil}, the angle
529 brackets around function keys and event symbols are omitted; this is
530 for compatibility with old versions of Emacs which didn't use the
531 brackets.
533 @smallexample
534 @group
535 (single-key-description ?\C-x)
536      @result{} "C-x"
537 @end group
538 @group
539 (key-description "\C-x \M-y \n \t \r \f123")
540      @result{} "C-x SPC M-y SPC C-j SPC TAB SPC RET SPC C-l 1 2 3"
541 @end group
542 @group
543 (single-key-description 'delete)
544      @result{} "<delete>"
545 @end group
546 @group
547 (single-key-description 'C-mouse-1)
548      @result{} "<C-mouse-1>"
549 @end group
550 @group
551 (single-key-description 'C-mouse-1 t)
552      @result{} "C-mouse-1"
553 @end group
554 @end smallexample
555 @end defun
557 @defun text-char-description character
558 This function returns a string describing @var{character} in the
559 standard Emacs notation for characters that appear in text---like
560 @code{single-key-description}, except that control characters are
561 represented with a leading caret (which is how control characters in
562 Emacs buffers are usually displayed).  Another difference is that
563 @code{text-char-description} recognizes the 2**7 bit as the Meta
564 character, whereas @code{single-key-description} uses the 2**27 bit
565 for Meta.
567 @smallexample
568 @group
569 (text-char-description ?\C-c)
570      @result{} "^C"
571 @end group
572 @group
573 (text-char-description ?\M-m)
574      @result{} "\xed"
575 @end group
576 @group
577 (text-char-description ?\C-\M-m)
578      @result{} "\x8d"
579 @end group
580 @group
581 (text-char-description (+ 128 ?m))
582      @result{} "M-m"
583 @end group
584 @group
585 (text-char-description (+ 128 ?\C-m))
586      @result{} "M-^M"
587 @end group
588 @end smallexample
589 @end defun
591 @deffn Command read-kbd-macro string &optional need-vector
592 This function is used mainly for operating on keyboard macros, but it
593 can also be used as a rough inverse for @code{key-description}.  You
594 call it with a string containing key descriptions, separated by spaces;
595 it returns a string or vector containing the corresponding events.
596 (This may or may not be a single valid key sequence, depending on what
597 events you use; @pxref{Key Sequences}.)  If @var{need-vector} is
598 non-@code{nil}, the return value is always a vector.
599 @end deffn
601 @node Help Functions
602 @section Help Functions
603 @cindex help functions
605   Emacs provides a variety of built-in help functions, all accessible to
606 the user as subcommands of the prefix @kbd{C-h}.  For more information
607 about them, see @ref{Help, , Help, emacs, The GNU Emacs Manual}.  Here
608 we describe some program-level interfaces to the same information.
610 @deffn Command apropos pattern &optional do-all
611 This function finds all meaningful symbols whose names contain a
612 match for the apropos pattern @var{pattern}.  An apropos pattern is
613 either a word to match, a space-separated list of words of which at
614 least two must match, or a regular expression (if any special regular
615 expression characters occur).  A symbol is meaningful if it has a
616 definition as a function, variable, or face, or has properties.
618 The function returns a list of elements that look like this:
620 @example
621 (@var{symbol} @var{score} @var{function-doc} @var{variable-doc}
622  @var{plist-doc} @var{widget-doc} @var{face-doc} @var{group-doc})
623 @end example
625 Here, @var{score} is an integer measure of how important the symbol
626 seems to be as a match.  Each of the remaining elements is a
627 documentation string, or @code{nil}, for @var{symbol} as a function,
628 variable, etc.
630 It also displays the symbols in a buffer named @file{*Apropos*}, each
631 with a one-line description taken from the beginning of its
632 documentation string.
634 If @var{do-all} is non-@code{nil}, or if the user option
635 @code{apropos-do-all} is non-@code{nil}, then @code{apropos} also
636 shows key bindings for the functions that are found; it also shows
637 @emph{all} interned symbols, not just meaningful ones (and it lists
638 them in the return value as well).
639 @end deffn
641 @defvar help-map
642 The value of this variable is a local keymap for characters following the
643 Help key, @kbd{C-h}.
644 @end defvar
646 @deffn {Prefix Command} help-command
647 This symbol is not a function; its function definition cell holds the
648 keymap known as @code{help-map}.  It is defined in @file{help.el} as
649 follows:
651 @smallexample
652 @group
653 (define-key global-map (string help-char) 'help-command)
654 (fset 'help-command help-map)
655 @end group
656 @end smallexample
657 @end deffn
659 @defopt help-char
660 The value of this variable is the help character---the character that
661 Emacs recognizes as meaning Help.  By default, its value is 8, which
662 stands for @kbd{C-h}.  When Emacs reads this character, if
663 @code{help-form} is a non-@code{nil} Lisp expression, it evaluates that
664 expression, and displays the result in a window if it is a string.
666 Usually the value of @code{help-form} is @code{nil}.  Then the
667 help character has no special meaning at the level of command input, and
668 it becomes part of a key sequence in the normal way.  The standard key
669 binding of @kbd{C-h} is a prefix key for several general-purpose help
670 features.
672 The help character is special after prefix keys, too.  If it has no
673 binding as a subcommand of the prefix key, it runs
674 @code{describe-prefix-bindings}, which displays a list of all the
675 subcommands of the prefix key.
676 @end defopt
678 @defopt help-event-list
679 The value of this variable is a list of event types that serve as
680 alternative help characters.  These events are handled just like the
681 event specified by @code{help-char}.
682 @end defopt
684 @defvar help-form
685 If this variable is non-@code{nil}, its value is a form to evaluate
686 whenever the character @code{help-char} is read.  If evaluating the form
687 produces a string, that string is displayed.
689 A command that calls @code{read-event}, @code{read-char-choice}, or
690 @code{read-char} probably should bind @code{help-form} to a
691 non-@code{nil} expression while it does input.  (The time when you
692 should not do this is when @kbd{C-h} has some other meaning.)
693 Evaluating this expression should result in a string that explains
694 what the input is for and how to enter it properly.
696 Entry to the minibuffer binds this variable to the value of
697 @code{minibuffer-help-form} (@pxref{Definition of minibuffer-help-form}).
698 @end defvar
700 @defvar prefix-help-command
701 This variable holds a function to print help for a prefix key.  The
702 function is called when the user types a prefix key followed by the help
703 character, and the help character has no binding after that prefix.  The
704 variable's default value is @code{describe-prefix-bindings}.
705 @end defvar
707 @deffn Command describe-prefix-bindings
708 This function calls @code{describe-bindings} to display a list of all
709 the subcommands of the prefix key of the most recent key sequence.  The
710 prefix described consists of all but the last event of that key
711 sequence.  (The last event is, presumably, the help character.)
712 @end deffn
714   The following two functions are meant for modes that want to provide
715 help without relinquishing control, such as the electric modes.
716 Their names begin with @samp{Helper} to distinguish them from the
717 ordinary help functions.
719 @deffn Command Helper-describe-bindings
720 This command pops up a window displaying a help buffer containing a
721 listing of all of the key bindings from both the local and global keymaps.
722 It works by calling @code{describe-bindings}.
723 @end deffn
725 @deffn Command Helper-help
726 This command provides help for the current mode.  It prompts the user
727 in the minibuffer with the message @samp{Help (Type ? for further
728 options)}, and then provides assistance in finding out what the key
729 bindings are, and what the mode is intended for.  It returns @code{nil}.
731 @vindex Helper-help-map
732 This can be customized by changing the map @code{Helper-help-map}.
733 @end deffn
735 @defvar data-directory
736 @anchor{Definition of data-directory}
737 This variable holds the name of the directory in which Emacs finds
738 certain documentation and text files that come with Emacs.
739 @end defvar
741 @defun help-buffer
742 This function returns the name of the help buffer, which is normally
743 @file{*Help*}; if such a buffer does not exist, it is first created.
744 @end defun
746 @vindex help-window-select
747 @defmac with-help-window buffer-name body@dots{}
748 This macro evaluates @var{body} like @code{with-output-to-temp-buffer}
749 (@pxref{Temporary Displays}), inserting any output produced by its forms
750 into a buffer named @var{buffer-name}.  (Usually, @var{buffer-name}
751 should be the value returned by the function @code{help-buffer}.)  It
752 also puts the specified buffer into Help mode and displays a message
753 telling the user how to quit and scroll the help window.  It selects the
754 help window if the current value of the user option
755 @code{help-window-select} has been set accordingly.  It returns the last
756 value in @var{body}.
757 @end defmac
759 @defun help-setup-xref item interactive-p
760 This function updates the cross reference data in the @file{*Help*}
761 buffer, which is used to regenerate the help information when the user
762 clicks on the @samp{Back} or @samp{Forward} buttons.  Most commands
763 that use the @file{*Help*} buffer should invoke this function before
764 clearing the buffer.  The @var{item} argument should have the form
765 @code{(@var{function} . @var{args})}, where @var{function} is a function
766 to call, with argument list @var{args}, to regenerate the help buffer.
767 The @var{interactive-p} argument is non-@code{nil} if the calling
768 command was invoked interactively; in that case, the stack of items
769 for the @file{*Help*} buffer's @samp{Back} buttons is cleared.
770 @end defun
772 @xref{describe-symbols example}, for an example of using
773 @code{help-buffer}, @code{with-help-window}, and
774 @code{help-setup-xref}.
776 @defmac make-help-screen fname help-line help-text help-map
777 This macro defines a help command named @var{fname} that acts like a
778 prefix key that shows a list of the subcommands it offers.
780 When invoked, @var{fname} displays @var{help-text} in a window, then
781 reads and executes a key sequence according to @var{help-map}.  The
782 string @var{help-text} should describe the bindings available in
783 @var{help-map}.
785 The command @var{fname} is defined to handle a few events itself, by
786 scrolling the display of @var{help-text}.  When @var{fname} reads one of
787 those special events, it does the scrolling and then reads another
788 event.  When it reads an event that is not one of those few, and which
789 has a binding in @var{help-map}, it executes that key's binding and
790 then returns.
792 The argument @var{help-line} should be a single-line summary of the
793 alternatives in @var{help-map}.  In the current version of Emacs, this
794 argument is used only if you set the option @code{three-step-help} to
795 @code{t}.
797 This macro is used in the command @code{help-for-help} which is the
798 binding of @kbd{C-h C-h}.
799 @end defmac
801 @defopt three-step-help
802 If this variable is non-@code{nil}, commands defined with
803 @code{make-help-screen} display their @var{help-line} strings in the
804 echo area at first, and display the longer @var{help-text} strings only
805 if the user types the help character again.
806 @end defopt