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