help.texi 27 KB

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