Update docs for a bunch of 24.3 changes.
[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.
ecc6530d 6@node Documentation
b8d4c8d0
GM
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
b8d4c8d0
GM
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,
43with double-quote characters surrounding the text of the string. This
44is because it really is a Lisp string object. The string serves as
45documentation when it is written in the proper place in the definition
46of a function or variable. In a function definition, the documentation
47string follows the argument list. In a variable definition, the
48documentation string follows the initial value of the variable.
49
50 When you write a documentation string, make the first line a
8376d7c2
CY
51complete sentence (or two complete sentences) that briefly describes
52what the function or variable does. Some commands, such as
53@code{apropos}, show only the first line of a multi-line documentation
54string. Also, you should not indent the second line of a
55documentation string, if it has one, because that looks odd when you
b8d4c8d0
GM
56use @kbd{C-h f} (@code{describe-function}) or @kbd{C-h v}
57(@code{describe-variable}) to view the documentation string. There
8376d7c2
CY
58are many other conventions for documentation strings; see
59@ref{Documentation Tips}.
b8d4c8d0 60
48de8b12
CY
61 Documentation strings can contain several special text sequences,
62referring to key bindings which are looked up in the current keymaps
63when the user views the documentation. This allows the help commands
64to display the correct keys even if a user rearranges the default key
65bindings. @xref{Keys in Documentation}.
66
67 In the documentation string of an autoloaded command
68(@pxref{Autoload}), these special text sequences have an additional
69special effect: they cause @kbd{C-h f} (@code{describe-function}) on
70the command to trigger autoloading. (This is needed for correctly
71setting up the hyperlinks in the @file{*Help*} buffer).
b8d4c8d0
GM
72
73@vindex emacs-lisp-docstring-fill-column
74 Emacs Lisp mode fills documentation strings to the width
75specified by @code{emacs-lisp-docstring-fill-column}.
76
8376d7c2
CY
77 Exactly where a documentation string is stored depends on how its
78function or variable was defined or loaded into memory:
b8d4c8d0
GM
79
80@itemize @bullet
81@item
82@kindex function-documentation
8376d7c2
CY
83When you define a function (@pxref{Lambda Expressions}, and
84@pxref{Function Documentation}), the documentation string is stored in
85the function definition itself. You can also put function
86documentation in the @code{function-documentation} property of a
87function name. That is useful for function definitions which can't
88hold a documentation string, such as keyboard macros.
b8d4c8d0
GM
89
90@item
91@kindex variable-documentation
8376d7c2
CY
92When you define a variable with a @code{defvar} or related form
93(@pxref{Defining Variables}), the documentation is stored in the
94variable's @code{variable-documentation} property.
b8d4c8d0
GM
95
96@cindex @file{DOC-@var{version}} (documentation) file
8376d7c2
CY
97@item
98To save memory, the documentation for preloaded functions and
99variables (including primitive functions and autoloaded functions) is
100not kept in memory, but in the file
101@file{emacs/etc/DOC-@var{version}}, where @var{version} is the Emacs
102version number (@pxref{Version Info}).
103
104@item
105When a function or variable is loaded from a byte-compiled file during
106the Emacs session, its documentation string is not loaded into memory.
107Instead, Emacs looks it up in the byte-compiled file as needed.
108@xref{Docs and Compilation}.
109@end itemize
110
111@noindent
112Regardless of where the documentation string is stored, you can
113retrieve it using the @code{documentation} or
114@code{documentation-property} function, described in the next section.
b8d4c8d0 115
b8d4c8d0
GM
116@node Accessing Documentation
117@section Access to Documentation Strings
118
119@defun documentation-property symbol property &optional verbatim
8376d7c2
CY
120This function returns the documentation string recorded in
121@var{symbol}'s property list under property @var{property}. It is
122most often used to look up the documentation strings of variables, for
123which @var{property} is @code{variable-documentation}. However, it
124can also be used to look up other kinds of documentation, such as for
125customization groups (but for function documentation, use the
126@code{documentation} command, below).
127
128If the value recorded in the property list refers to a documentation
129string stored in a @file{DOC-@var{version}} file or a byte-compiled
130file, it looks up that string and returns it. If the property value
131isn't @code{nil}, isn't a string, and doesn't refer to text in a file,
132then it is evaluated as a Lisp expression to obtain a string.
b8d4c8d0
GM
133
134The last thing this function does is pass the string through
8376d7c2
CY
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}.
b8d4c8d0
GM
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
049bcbcb
CY
157This function returns the documentation string of @var{function}. It
158handles macros, named keyboard macros, and special forms, as well as
159ordinary functions.
b8d4c8d0
GM
160
161If @var{function} is a symbol, this function first looks for the
162@code{function-documentation} property of that symbol; if that has a
163non-@code{nil} value, the documentation comes from that value (if the
164value is not a string, it is evaluated). If @var{function} is not a
165symbol, or if it has no @code{function-documentation} property, then
166@code{documentation} extracts the documentation string from the actual
167function definition, reading it from a file if called for.
168
169Finally, unless @var{verbatim} is non-@code{nil}, it calls
170@code{substitute-command-keys} so as to return a value containing the
171actual (current) key bindings.
172
173The function @code{documentation} signals a @code{void-function} error
174if @var{function} has no function definition. However, it is OK if
175the function definition has no documentation string. In that case,
176@code{documentation} returns @code{nil}.
177@end defun
178
179@defun face-documentation face
180This function returns the documentation string of @var{face} as a
181face.
182@end defun
183
184@c Wordy to prevent overfull hboxes. --rjc 15mar92
185Here is an example of using the two functions, @code{documentation} and
186@code{documentation-property}, to display the documentation strings for
2bb0eca1 187several symbols in a @file{*Help*} buffer.
b8d4c8d0
GM
188
189@anchor{describe-symbols example}
190@smallexample
191@group
192(defun describe-symbols (pattern)
193 "Describe the Emacs Lisp symbols matching PATTERN.
194All symbols that have PATTERN in their name are described
195in 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
b4d3bc10 225 (if (custom-variable-p s)
b8d4c8d0
GM
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.}
b2a77f6d
CY
245 (help-setup-xref (list 'describe-symbols pattern) (interactive-p))
246 (with-help-window (help-buffer)
247 (mapcar describe-func (sort sym-list 'string<)))))
b8d4c8d0
GM
248@end group
249@end smallexample
250
251 The @code{describe-symbols} function works like @code{apropos},
252but provides more information.
253
254@smallexample
255@group
256(describe-symbols "goal")
257
258---------- Buffer: *Help* ----------
259goal-column Option
f5c63335 260Semipermanent goal column for vertical motion, as set by @dots{}
b8d4c8d0
GM
261@end group
262@c Do not blithely break or fill these lines.
263@c That makes them incorrect.
264
265@group
266set-goal-column Keys: C-x C-n
267Set 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
271Those commands will move to this position in the line moved to
272rather than trying to keep the same horizontal position.
273With a non-nil argument, clears out the goal column
274so that C-n and C-p resume vertical motion.
275The goal column is stored in the variable `goal-column'.
276@end group
277
278@group
279temporary-goal-column Variable
280Current goal column for vertical motion.
281It is the column where point was
282at the start of current run of vertical motion commands.
283When the `track-eol' feature is doing its job, the value is 9999.
284---------- Buffer: *Help* ----------
285@end group
286@end smallexample
287
b8d4c8d0 288@anchor{Definition of Snarf-documentation}
8376d7c2
CY
289@defun Snarf-documentation filename
290This function is used when building Emacs, just before the runnable
291Emacs is dumped. It finds the positions of the documentation strings
292stored in the file @var{filename}, and records those positions into
293memory in the function definitions and variable property lists.
294@xref{Building Emacs}.
b8d4c8d0
GM
295
296Emacs reads the file @var{filename} from the @file{emacs/etc} directory.
297When the dumped Emacs is later executed, the same file will be looked
298for in the directory @code{doc-directory}. Usually @var{filename} is
299@code{"DOC-@var{version}"}.
300@end defun
301
b8d4c8d0
GM
302@defvar doc-directory
303This variable holds the name of the directory which should contain the
304file @code{"DOC-@var{version}"} that contains documentation strings for
305built-in and preloaded functions and variables.
306
307In most cases, this is the same as @code{data-directory}. They may be
308different when you run Emacs from the directory where you built it,
309without actually installing it. @xref{Definition of data-directory}.
b8d4c8d0
GM
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
319current, actual key bindings. They can do so using certain special text
320sequences described below. Accessing documentation strings in the usual
321way substitutes current key binding information for these special
322sequences. This works by calling @code{substitute-command-keys}. You
323can 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}]
329stands 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}@}
333stands 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}>
337stands for no text itself. It is used only for a side effect: it
338specifies @var{mapvar}'s value as the keymap for any following
339@samp{\[@var{command}]} sequences in this documentation string.
340
341@item \=
4baf28e6
AS
342quotes the following character and is discarded; thus, @samp{\=\[} puts
343@samp{\[} into the output, and @samp{\=\=} puts @samp{\=} into the
344output.
b8d4c8d0
GM
345@end table
346
347@strong{Please note:} Each @samp{\} must be doubled when written in a
348string in Emacs Lisp.
349
350@defun substitute-command-keys string
351This function scans @var{string} for the above special sequences and
352replaces them by what they stand for, returning the result as a string.
353This permits display of documentation that refers accurately to the
354user's own customized key bindings.
21ffa320
CY
355
356@cindex advertised binding
357If a command has multiple bindings, this function normally uses the
358first one it finds. You can specify one particular key binding by
359assigning an @code{:advertised-binding} symbol property to the
360command, like this:
361
362@smallexample
363(put 'undo :advertised-binding [?\C-/])
364@end smallexample
365
366@noindent
367The @code{:advertised-binding} property also affects the binding shown
368in menu items (@pxref{Menu Bar}). The property is ignored if it
369specifies a key binding that the command does not actually have.
b8d4c8d0
GM
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
389SPC minibuffer-complete-word
390TAB minibuffer-complete
391C-j minibuffer-complete-and-exit
392RET minibuffer-complete-and-exit
393C-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
405strings---for instance, you can refer to functions, variables, and
406sections 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
413textual descriptions. These descriptions are useful for including
414arbitrary text characters or key sequences in messages, because they
415convert non-printing and whitespace characters to sequences of printing
416characters. The description of a non-whitespace printing character is
417the character itself.
418
419@defun key-description sequence &optional prefix
420@cindex Emacs event standard notation
421This function returns a string containing the Emacs standard notation
422for the input events in @var{sequence}. If @var{prefix} is
423non-@code{nil}, it is a sequence of input events leading up to
424@var{sequence} and is included in the return value. Both arguments
425may be strings, vectors or lists. @xref{Input Events}, for more
426information 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
447This function returns a string describing @var{event} in the standard
448Emacs notation for keyboard input. A normal printing character
449appears as itself, but a control character turns into a string
450starting with @samp{C-}, a meta character turns into a string starting
451with @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
454symbol in the @sc{car} of the list, inside angle brackets.
455
456If the optional argument @var{no-angles} is non-@code{nil}, the angle
457brackets around function keys and event symbols are omitted; this is
458for compatibility with old versions of Emacs which didn't use the
459brackets.
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
486This function returns a string describing @var{character} in the
487standard Emacs notation for characters that appear in text---like
488@code{single-key-description}, except that control characters are
489represented with a leading caret (which is how control characters in
490Emacs buffers are usually displayed). Another difference is that
491@code{text-char-description} recognizes the 2**7 bit as the Meta
492character, whereas @code{single-key-description} uses the 2**27 bit
493for 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
0b128ac4 519@deffn Command read-kbd-macro string &optional need-vector
b8d4c8d0
GM
520This function is used mainly for operating on keyboard macros, but it
521can also be used as a rough inverse for @code{key-description}. You
522call it with a string containing key descriptions, separated by spaces;
523it returns a string or vector containing the corresponding events.
524(This may or may not be a single valid key sequence, depending on what
525events you use; @pxref{Key Sequences}.) If @var{need-vector} is
526non-@code{nil}, the return value is always a vector.
0b128ac4 527@end deffn
b8d4c8d0
GM
528
529@node Help Functions
530@section Help Functions
531
532 Emacs provides a variety of on-line help functions, all accessible to
533the user as subcommands of the prefix @kbd{C-h}. For more information
534about them, see @ref{Help, , Help, emacs, The GNU Emacs Manual}. Here
535we describe some program-level interfaces to the same information.
536
537@deffn Command apropos pattern &optional do-all
538This function finds all ``meaningful'' symbols whose names contain a
539match for the apropos pattern @var{pattern}. An apropos pattern is
540either a word to match, a space-separated list of words of which at
541least two must match, or a regular expression (if any special regular
542expression characters occur). A symbol is ``meaningful'' if it has a
543definition as a function, variable, or face, or has properties.
544
545The function returns a list of elements that look like this:
546
547@example
5d55b248 548(@var{symbol} @var{score} @var{function-doc} @var{variable-doc}
b8d4c8d0
GM
549 @var{plist-doc} @var{widget-doc} @var{face-doc} @var{group-doc})
550@end example
551
552Here, @var{score} is an integer measure of how important the symbol
8376d7c2
CY
553seems to be as a match. Each of the remaining elements is a
554documentation string, or @code{nil}, for @var{symbol} as a function,
555variable, etc.
b8d4c8d0 556
2bb0eca1 557It also displays the symbols in a buffer named @file{*Apropos*}, each
b8d4c8d0
GM
558with a one-line description taken from the beginning of its
559documentation string.
560
b8d4c8d0
GM
561If @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
563shows key bindings for the functions that are found; it also shows
564@emph{all} interned symbols, not just meaningful ones (and it lists
565them in the return value as well).
566@end deffn
567
568@defvar help-map
569The value of this variable is a local keymap for characters following the
570Help key, @kbd{C-h}.
571@end defvar
572
573@deffn {Prefix Command} help-command
574This symbol is not a function; its function definition cell holds the
575keymap known as @code{help-map}. It is defined in @file{help.el} as
576follows:
577
578@smallexample
579@group
3e99b825 580(define-key global-map (string help-char) 'help-command)
b8d4c8d0
GM
581(fset 'help-command help-map)
582@end group
583@end smallexample
584@end deffn
585
01f17ae2 586@defopt help-char
b8d4c8d0
GM
587The value of this variable is the help character---the character that
588Emacs recognizes as meaning Help. By default, its value is 8, which
589stands for @kbd{C-h}. When Emacs reads this character, if
590@code{help-form} is a non-@code{nil} Lisp expression, it evaluates that
591expression, and displays the result in a window if it is a string.
592
593Usually the value of @code{help-form} is @code{nil}. Then the
594help character has no special meaning at the level of command input, and
595it becomes part of a key sequence in the normal way. The standard key
596binding of @kbd{C-h} is a prefix key for several general-purpose help
597features.
598
599The help character is special after prefix keys, too. If it has no
600binding as a subcommand of the prefix key, it runs
601@code{describe-prefix-bindings}, which displays a list of all the
602subcommands of the prefix key.
01f17ae2 603@end defopt
b8d4c8d0 604
01f17ae2 605@defopt help-event-list
b8d4c8d0 606The value of this variable is a list of event types that serve as
16152b76 607alternative ``help characters''. These events are handled just like the
b8d4c8d0 608event specified by @code{help-char}.
01f17ae2 609@end defopt
b8d4c8d0
GM
610
611@defvar help-form
612If this variable is non-@code{nil}, its value is a form to evaluate
613whenever the character @code{help-char} is read. If evaluating the form
614produces a string, that string is displayed.
615
7e2734bc
GM
616A command that calls @code{read-event}, @code{read-char-choice}, or
617@code{read-char} probably should bind @code{help-form} to a
618non-@code{nil} expression while it does input. (The time when you
619should not do this is when @kbd{C-h} has some other meaning.)
620Evaluating this expression should result in a string that explains
621what the input is for and how to enter it properly.
b8d4c8d0
GM
622
623Entry 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
628This variable holds a function to print help for a prefix key. The
629function is called when the user types a prefix key followed by the help
630character, and the help character has no binding after that prefix. The
631variable's default value is @code{describe-prefix-bindings}.
632@end defvar
633
0b128ac4 634@deffn Command describe-prefix-bindings
b8d4c8d0
GM
635This function calls @code{describe-bindings} to display a list of all
636the subcommands of the prefix key of the most recent key sequence. The
637prefix described consists of all but the last event of that key
638sequence. (The last event is, presumably, the help character.)
0b128ac4 639@end deffn
b8d4c8d0
GM
640
641 The following two functions are meant for modes that want to provide
642help without relinquishing control, such as the ``electric'' modes.
643Their names begin with @samp{Helper} to distinguish them from the
644ordinary help functions.
645
646@deffn Command Helper-describe-bindings
647This command pops up a window displaying a help buffer containing a
648listing of all of the key bindings from both the local and global keymaps.
649It works by calling @code{describe-bindings}.
650@end deffn
651
652@deffn Command Helper-help
653This command provides help for the current mode. It prompts the user
654in the minibuffer with the message @samp{Help (Type ? for further
655options)}, and then provides assistance in finding out what the key
656bindings are, and what the mode is intended for. It returns @code{nil}.
657
53a1239b 658@vindex Helper-help-map
b8d4c8d0
GM
659This can be customized by changing the map @code{Helper-help-map}.
660@end deffn
661
b8d4c8d0
GM
662@defvar data-directory
663@anchor{Definition of data-directory}
664This variable holds the name of the directory in which Emacs finds
bbe45ef7 665certain documentation and text files that come with Emacs.
b8d4c8d0
GM
666@end defvar
667
77c7e2e1 668@defun help-buffer
b2a77f6d 669This function returns the name of the help buffer, which is normally
2bb0eca1 670@file{*Help*}; if such a buffer does not exist, it is first created.
77c7e2e1 671@end defun
b2a77f6d
CY
672
673@defmac with-help-window buffer-name body@dots{}
674This macro evaluates the @var{body} forms, inserting any output they
675produce 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
678function @code{help-buffer}.) It also puts the specified buffer into
679Help mode and displays a message telling the user how to quit and
680scroll the help window.
681@end defmac
682
77c7e2e1 683@defun help-setup-xref item interactive-p
2bb0eca1 684This function updates the cross reference data in the @file{*Help*}
b2a77f6d
CY
685buffer, which is used to regenerate the help information when the user
686clicks on the @samp{Back} or @samp{Forward} buttons. Most commands
2bb0eca1 687that use the @file{*Help*} buffer should invoke this function before
b2a77f6d 688clearing the buffer. The @var{item} argument should have the form
cd1181db 689@code{(@var{function} . @var{args})}, where @var{function} is a function
b2a77f6d
CY
690to call, with argument list @var{args}, to regenerate the help buffer.
691The @var{interactive-p} argument is non-@code{nil} if the calling
692command was invoked interactively; in that case, the stack of items
2bb0eca1 693for the @file{*Help*} buffer's @samp{Back} buttons is cleared.
77c7e2e1 694@end defun
b2a77f6d
CY
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
b8d4c8d0
GM
700@defmac make-help-screen fname help-line help-text help-map
701This macro defines a help command named @var{fname} that acts like a
702prefix key that shows a list of the subcommands it offers.
703
704When invoked, @var{fname} displays @var{help-text} in a window, then
705reads and executes a key sequence according to @var{help-map}. The
706string @var{help-text} should describe the bindings available in
707@var{help-map}.
708
709The command @var{fname} is defined to handle a few events itself, by
710scrolling the display of @var{help-text}. When @var{fname} reads one of
711those special events, it does the scrolling and then reads another
712event. When it reads an event that is not one of those few, and which
713has a binding in @var{help-map}, it executes that key's binding and
714then returns.
715
716The argument @var{help-line} should be a single-line summary of the
717alternatives in @var{help-map}. In the current version of Emacs, this
718argument is used only if you set the option @code{three-step-help} to
719@code{t}.
720
721This macro is used in the command @code{help-for-help} which is the
722binding of @kbd{C-h C-h}.
723@end defmac
724
725@defopt three-step-help
726If this variable is non-@code{nil}, commands defined with
727@code{make-help-screen} display their @var{help-line} strings in the
728echo area at first, and display the longer @var{help-text} strings only
729if the user types the help character again.
730@end defopt
731