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