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