help.texi 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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. 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. minibuffer-temporary-goal-position Variable
  213. not documented
  214. @end group
  215. @group
  216. set-goal-column Keys: C-x C-n
  217. Set the current horizontal position as a goal for C-n and C-p.
  218. @end group
  219. @c DO NOT put a blank line here! That is factually inaccurate!
  220. @group
  221. Those commands will move to this position in the line moved to
  222. rather than trying to keep the same horizontal position.
  223. With a non-nil argument ARG, clears out the goal column
  224. so that C-n and C-p resume vertical motion.
  225. The goal column is stored in the variable ‘goal-column’.
  226. (fn ARG)
  227. @end group
  228. @group
  229. temporary-goal-column Variable
  230. Current goal column for vertical motion.
  231. It is the column where point was at the start of the current run
  232. of vertical motion commands.
  233. When moving by visual lines via the function ‘line-move-visual’, it is a cons
  234. cell (COL . HSCROLL), where COL is the x-position, in pixels,
  235. divided by the default column width, and HSCROLL is the number of
  236. columns by which window is scrolled from left margin.
  237. When the ‘track-eol’ feature is doing its job, the value is
  238. ‘most-positive-fixnum’.
  239. ---------- Buffer: *Help* ----------
  240. @end group
  241. @end smallexample
  242. @anchor{Definition of Snarf-documentation}
  243. @defun Snarf-documentation filename
  244. This function is used when building Emacs, just before the runnable
  245. Emacs is dumped. It finds the positions of the documentation strings
  246. stored in the file @var{filename}, and records those positions into
  247. memory in the function definitions and variable property lists.
  248. @xref{Building Emacs}.
  249. Emacs reads the file @var{filename} from the @file{emacs/etc} directory.
  250. When the dumped Emacs is later executed, the same file will be looked
  251. for in the directory @code{doc-directory}. Usually @var{filename} is
  252. @code{"DOC"}.
  253. @end defun
  254. @defvar doc-directory
  255. This variable holds the name of the directory which should contain the
  256. file @code{"DOC"} that contains documentation strings for
  257. built-in and preloaded functions and variables.
  258. In most cases, this is the same as @code{data-directory}. They may be
  259. different when you run Emacs from the directory where you built it,
  260. without actually installing it. @xref{Definition of data-directory}.
  261. @end defvar
  262. @node Keys in Documentation
  263. @section Substituting Key Bindings in Documentation
  264. @cindex documentation, keys in
  265. @cindex keys in documentation strings
  266. @cindex substituting keys in documentation
  267. @cindex key substitution sequence
  268. When documentation strings refer to key sequences, they should use the
  269. current, actual key bindings. They can do so using certain special text
  270. sequences described below. Accessing documentation strings in the usual
  271. way substitutes current key binding information for these special
  272. sequences. This works by calling @code{substitute-command-keys}. You
  273. can also call that function yourself.
  274. Here is a list of the special sequences and what they mean:
  275. @table @code
  276. @item \[@var{command}]
  277. stands for a key sequence that will invoke @var{command}, or @samp{M-x
  278. @var{command}} if @var{command} has no key bindings.
  279. @item \@{@var{mapvar}@}
  280. stands for a summary of the keymap which is the value of the variable
  281. @var{mapvar}. The summary is made using @code{describe-bindings}.
  282. @item \<@var{mapvar}>
  283. stands for no text itself. It is used only for a side effect: it
  284. specifies @var{mapvar}'s value as the keymap for any following
  285. @samp{\[@var{command}]} sequences in this documentation string.
  286. @item ‘
  287. @itemx `
  288. (left single quotation mark and grave accent) both stand for a left quote.
  289. @item ’
  290. @itemx '
  291. (right single quotation mark and apostrophe) both stand for a right quote.
  292. @item \=
  293. quotes the following character and is discarded; thus, @samp{\=`} puts
  294. @samp{`} into the output, @samp{\=\[} puts @samp{\[} into the output,
  295. and @samp{\=\=} puts @samp{\=} into the output.
  296. @end table
  297. @strong{Please note:} Each @samp{\} must be doubled when written in a
  298. string in Emacs Lisp.
  299. @defvar text-quoting-style
  300. @cindex curved quotes
  301. @cindex curly quotes
  302. The value of this variable is a symbol that specifies the style Emacs
  303. should use for single quotes in the wording of help and messages.
  304. If the variable's value is @code{curve}, the style is
  305. @t{‘like this’} with curved single quotes. If the value is
  306. @code{straight}, the style is @t{'like this'} with straight
  307. apostrophes. If the value is @code{grave}, the style is @t{`like
  308. this'} with grave accent and apostrophe, the standard style
  309. before Emacs version 25. The default value @code{nil}
  310. acts like @code{curve} if curved single quotes are displayable, and
  311. like @code{grave} otherwise.
  312. @end defvar
  313. @defun substitute-command-keys string
  314. This function scans @var{string} for the above special sequences and
  315. replaces them by what they stand for, returning the result as a string.
  316. This permits display of documentation that refers accurately to the
  317. user's own customized key bindings.
  318. @cindex advertised binding
  319. If a command has multiple bindings, this function normally uses the
  320. first one it finds. You can specify one particular key binding by
  321. assigning an @code{:advertised-binding} symbol property to the
  322. command, like this:
  323. @smallexample
  324. (put 'undo :advertised-binding [?\C-/])
  325. @end smallexample
  326. @noindent
  327. The @code{:advertised-binding} property also affects the binding shown
  328. in menu items (@pxref{Menu Bar}). The property is ignored if it
  329. specifies a key binding that the command does not actually have.
  330. @end defun
  331. Here are examples of the special sequences:
  332. @smallexample
  333. @group
  334. (substitute-command-keys
  335. "To abort recursive edit, type `\\[abort-recursive-edit]'.")
  336. @result{} "To abort recursive edit, type ‘C-]’."
  337. @end group
  338. @group
  339. (substitute-command-keys
  340. "The keys that are defined for the minibuffer here are:
  341. \\@{minibuffer-local-must-match-map@}")
  342. @result{} "The keys that are defined for the minibuffer here are:
  343. @end group
  344. ? minibuffer-completion-help
  345. SPC minibuffer-complete-word
  346. TAB minibuffer-complete
  347. C-j minibuffer-complete-and-exit
  348. RET minibuffer-complete-and-exit
  349. C-g abort-recursive-edit
  350. "
  351. @group
  352. (substitute-command-keys
  353. "To abort a recursive edit from the minibuffer, type \
  354. `\\<minibuffer-local-must-match-map>\\[abort-recursive-edit]'.")
  355. @result{} "To abort a recursive edit from the minibuffer, type ‘C-g’."
  356. @end group
  357. @end smallexample
  358. There are other special conventions for the text in documentation
  359. strings---for instance, you can refer to functions, variables, and
  360. sections of this manual. @xref{Documentation Tips}, for details.
  361. @node Describing Characters
  362. @section Describing Characters for Help Messages
  363. @cindex describe characters and events
  364. These functions convert events, key sequences, or characters to
  365. textual descriptions. These descriptions are useful for including
  366. arbitrary text characters or key sequences in messages, because they
  367. convert non-printing and whitespace characters to sequences of printing
  368. characters. The description of a non-whitespace printing character is
  369. the character itself.
  370. @defun key-description sequence &optional prefix
  371. @cindex Emacs event standard notation
  372. This function returns a string containing the Emacs standard notation
  373. for the input events in @var{sequence}. If @var{prefix} is
  374. non-@code{nil}, it is a sequence of input events leading up to
  375. @var{sequence} and is included in the return value. Both arguments
  376. may be strings, vectors or lists. @xref{Input Events}, for more
  377. information about valid events.
  378. @smallexample
  379. @group
  380. (key-description [?\M-3 delete])
  381. @result{} "M-3 <delete>"
  382. @end group
  383. @group
  384. (key-description [delete] "\M-3")
  385. @result{} "M-3 <delete>"
  386. @end group
  387. @end smallexample
  388. See also the examples for @code{single-key-description}, below.
  389. @end defun
  390. @defun single-key-description event &optional no-angles
  391. @cindex event printing
  392. @cindex character printing
  393. @cindex control character printing
  394. @cindex meta character printing
  395. This function returns a string describing @var{event} in the standard
  396. Emacs notation for keyboard input. A normal printing character
  397. appears as itself, but a control character turns into a string
  398. starting with @samp{C-}, a meta character turns into a string starting
  399. with @samp{M-}, and space, tab, etc., appear as @samp{SPC},
  400. @samp{TAB}, etc. A function key symbol appears inside angle brackets
  401. @samp{<@dots{}>}. An event that is a list appears as the name of the
  402. symbol in the @sc{car} of the list, inside angle brackets.
  403. If the optional argument @var{no-angles} is non-@code{nil}, the angle
  404. brackets around function keys and event symbols are omitted; this is
  405. for compatibility with old versions of Emacs which didn't use the
  406. brackets.
  407. @smallexample
  408. @group
  409. (single-key-description ?\C-x)
  410. @result{} "C-x"
  411. @end group
  412. @group
  413. (key-description "\C-x \M-y \n \t \r \f123")
  414. @result{} "C-x SPC M-y SPC C-j SPC TAB SPC RET SPC C-l 1 2 3"
  415. @end group
  416. @group
  417. (single-key-description 'delete)
  418. @result{} "<delete>"
  419. @end group
  420. @group
  421. (single-key-description 'C-mouse-1)
  422. @result{} "<C-mouse-1>"
  423. @end group
  424. @group
  425. (single-key-description 'C-mouse-1 t)
  426. @result{} "C-mouse-1"
  427. @end group
  428. @end smallexample
  429. @end defun
  430. @defun text-char-description character
  431. This function returns a string describing @var{character} in the
  432. standard Emacs notation for characters that appear in text---like
  433. @code{single-key-description}, except that control characters are
  434. represented with a leading caret (which is how control characters in
  435. Emacs buffers are usually displayed). Another difference is that
  436. @code{text-char-description} recognizes the 2**7 bit as the Meta
  437. character, whereas @code{single-key-description} uses the 2**27 bit
  438. for Meta.
  439. @smallexample
  440. @group
  441. (text-char-description ?\C-c)
  442. @result{} "^C"
  443. @end group
  444. @group
  445. (text-char-description ?\M-m)
  446. @result{} "\xed"
  447. @end group
  448. @group
  449. (text-char-description ?\C-\M-m)
  450. @result{} "\x8d"
  451. @end group
  452. @group
  453. (text-char-description (+ 128 ?m))
  454. @result{} "M-m"
  455. @end group
  456. @group
  457. (text-char-description (+ 128 ?\C-m))
  458. @result{} "M-^M"
  459. @end group
  460. @end smallexample
  461. @end defun
  462. @deffn Command read-kbd-macro string &optional need-vector
  463. This function is used mainly for operating on keyboard macros, but it
  464. can also be used as a rough inverse for @code{key-description}. You
  465. call it with a string containing key descriptions, separated by spaces;
  466. it returns a string or vector containing the corresponding events.
  467. (This may or may not be a single valid key sequence, depending on what
  468. events you use; @pxref{Key Sequences}.) If @var{need-vector} is
  469. non-@code{nil}, the return value is always a vector.
  470. @end deffn
  471. @node Help Functions
  472. @section Help Functions
  473. @cindex help functions
  474. Emacs provides a variety of built-in help functions, all accessible to
  475. the user as subcommands of the prefix @kbd{C-h}. For more information
  476. about them, see @ref{Help, , Help, emacs, The GNU Emacs Manual}. Here
  477. we describe some program-level interfaces to the same information.
  478. @deffn Command apropos pattern &optional do-all
  479. This function finds all meaningful symbols whose names contain a
  480. match for the apropos pattern @var{pattern}. An apropos pattern is
  481. either a word to match, a space-separated list of words of which at
  482. least two must match, or a regular expression (if any special regular
  483. expression characters occur). A symbol is meaningful if it has a
  484. definition as a function, variable, or face, or has properties.
  485. The function returns a list of elements that look like this:
  486. @example
  487. (@var{symbol} @var{score} @var{function-doc} @var{variable-doc}
  488. @var{plist-doc} @var{widget-doc} @var{face-doc} @var{group-doc})
  489. @end example
  490. Here, @var{score} is an integer measure of how important the symbol
  491. seems to be as a match. Each of the remaining elements is a
  492. documentation string, or @code{nil}, for @var{symbol} as a function,
  493. variable, etc.
  494. It also displays the symbols in a buffer named @file{*Apropos*}, each
  495. with a one-line description taken from the beginning of its
  496. documentation string.
  497. If @var{do-all} is non-@code{nil}, or if the user option
  498. @code{apropos-do-all} is non-@code{nil}, then @code{apropos} also
  499. shows key bindings for the functions that are found; it also shows
  500. @emph{all} interned symbols, not just meaningful ones (and it lists
  501. them in the return value as well).
  502. @end deffn
  503. @defvar help-map
  504. The value of this variable is a local keymap for characters following the
  505. Help key, @kbd{C-h}.
  506. @end defvar
  507. @deffn {Prefix Command} help-command
  508. This symbol is not a function; its function definition cell holds the
  509. keymap known as @code{help-map}. It is defined in @file{help.el} as
  510. follows:
  511. @smallexample
  512. @group
  513. (define-key global-map (string help-char) 'help-command)
  514. (fset 'help-command help-map)
  515. @end group
  516. @end smallexample
  517. @end deffn
  518. @defopt help-char
  519. The value of this variable is the help character---the character that
  520. Emacs recognizes as meaning Help. By default, its value is 8, which
  521. stands for @kbd{C-h}. When Emacs reads this character, if
  522. @code{help-form} is a non-@code{nil} Lisp expression, it evaluates that
  523. expression, and displays the result in a window if it is a string.
  524. Usually the value of @code{help-form} is @code{nil}. Then the
  525. help character has no special meaning at the level of command input, and
  526. it becomes part of a key sequence in the normal way. The standard key
  527. binding of @kbd{C-h} is a prefix key for several general-purpose help
  528. features.
  529. The help character is special after prefix keys, too. If it has no
  530. binding as a subcommand of the prefix key, it runs
  531. @code{describe-prefix-bindings}, which displays a list of all the
  532. subcommands of the prefix key.
  533. @end defopt
  534. @defopt help-event-list
  535. The value of this variable is a list of event types that serve as
  536. alternative help characters. These events are handled just like the
  537. event specified by @code{help-char}.
  538. @end defopt
  539. @defvar help-form
  540. If this variable is non-@code{nil}, its value is a form to evaluate
  541. whenever the character @code{help-char} is read. If evaluating the form
  542. produces a string, that string is displayed.
  543. A command that calls @code{read-event}, @code{read-char-choice}, or
  544. @code{read-char} probably should bind @code{help-form} to a
  545. non-@code{nil} expression while it does input. (The time when you
  546. should not do this is when @kbd{C-h} has some other meaning.)
  547. Evaluating this expression should result in a string that explains
  548. what the input is for and how to enter it properly.
  549. Entry to the minibuffer binds this variable to the value of
  550. @code{minibuffer-help-form} (@pxref{Definition of minibuffer-help-form}).
  551. @end defvar
  552. @defvar prefix-help-command
  553. This variable holds a function to print help for a prefix key. The
  554. function is called when the user types a prefix key followed by the help
  555. character, and the help character has no binding after that prefix. The
  556. variable's default value is @code{describe-prefix-bindings}.
  557. @end defvar
  558. @deffn Command describe-prefix-bindings
  559. This function calls @code{describe-bindings} to display a list of all
  560. the subcommands of the prefix key of the most recent key sequence. The
  561. prefix described consists of all but the last event of that key
  562. sequence. (The last event is, presumably, the help character.)
  563. @end deffn
  564. The following two functions are meant for modes that want to provide
  565. help without relinquishing control, such as the electric modes.
  566. Their names begin with @samp{Helper} to distinguish them from the
  567. ordinary help functions.
  568. @deffn Command Helper-describe-bindings
  569. This command pops up a window displaying a help buffer containing a
  570. listing of all of the key bindings from both the local and global keymaps.
  571. It works by calling @code{describe-bindings}.
  572. @end deffn
  573. @deffn Command Helper-help
  574. This command provides help for the current mode. It prompts the user
  575. in the minibuffer with the message @samp{Help (Type ? for further
  576. options)}, and then provides assistance in finding out what the key
  577. bindings are, and what the mode is intended for. It returns @code{nil}.
  578. @vindex Helper-help-map
  579. This can be customized by changing the map @code{Helper-help-map}.
  580. @end deffn
  581. @defvar data-directory
  582. @anchor{Definition of data-directory}
  583. This variable holds the name of the directory in which Emacs finds
  584. certain documentation and text files that come with Emacs.
  585. @end defvar
  586. @defun help-buffer
  587. This function returns the name of the help buffer, which is normally
  588. @file{*Help*}; if such a buffer does not exist, it is first created.
  589. @end defun
  590. @vindex help-window-select
  591. @defmac with-help-window buffer-name body@dots{}
  592. This macro evaluates @var{body} like @code{with-output-to-temp-buffer}
  593. (@pxref{Temporary Displays}), inserting any output produced by its forms
  594. into a buffer named @var{buffer-name}. (Usually, @var{buffer-name}
  595. should be the value returned by the function @code{help-buffer}.) It
  596. also puts the specified buffer into Help mode and displays a message
  597. telling the user how to quit and scroll the help window. It selects the
  598. help window if the current value of the user option
  599. @code{help-window-select} has been set accordingly. It returns the last
  600. value in @var{body}.
  601. @end defmac
  602. @defun help-setup-xref item interactive-p
  603. This function updates the cross reference data in the @file{*Help*}
  604. buffer, which is used to regenerate the help information when the user
  605. clicks on the @samp{Back} or @samp{Forward} buttons. Most commands
  606. that use the @file{*Help*} buffer should invoke this function before
  607. clearing the buffer. The @var{item} argument should have the form
  608. @code{(@var{function} . @var{args})}, where @var{function} is a function
  609. to call, with argument list @var{args}, to regenerate the help buffer.
  610. The @var{interactive-p} argument is non-@code{nil} if the calling
  611. command was invoked interactively; in that case, the stack of items
  612. for the @file{*Help*} buffer's @samp{Back} buttons is cleared.
  613. @end defun
  614. @xref{describe-symbols example}, for an example of using
  615. @code{help-buffer}, @code{with-help-window}, and
  616. @code{help-setup-xref}.
  617. @defmac make-help-screen fname help-line help-text help-map
  618. This macro defines a help command named @var{fname} that acts like a
  619. prefix key that shows a list of the subcommands it offers.
  620. When invoked, @var{fname} displays @var{help-text} in a window, then
  621. reads and executes a key sequence according to @var{help-map}. The
  622. string @var{help-text} should describe the bindings available in
  623. @var{help-map}.
  624. The command @var{fname} is defined to handle a few events itself, by
  625. scrolling the display of @var{help-text}. When @var{fname} reads one of
  626. those special events, it does the scrolling and then reads another
  627. event. When it reads an event that is not one of those few, and which
  628. has a binding in @var{help-map}, it executes that key's binding and
  629. then returns.
  630. The argument @var{help-line} should be a single-line summary of the
  631. alternatives in @var{help-map}. In the current version of Emacs, this
  632. argument is used only if you set the option @code{three-step-help} to
  633. @code{t}.
  634. This macro is used in the command @code{help-for-help} which is the
  635. binding of @kbd{C-h C-h}.
  636. @end defmac
  637. @defopt three-step-help
  638. If this variable is non-@code{nil}, commands defined with
  639. @code{make-help-screen} display their @var{help-line} strings in the
  640. echo area at first, and display the longer @var{help-text} strings only
  641. if the user types the help character again.
  642. @end defopt