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