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