Mercurial > hg > xemacs-beta
comparison man/lispref/help.texi @ 0:376386a54a3c r19-14
Import from CVS: tag r19-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:45:50 +0200 |
parents | |
children | 461c7ba8286a |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:376386a54a3c |
---|---|
1 @c -*-texinfo-*- | |
2 @c This is part of the XEmacs Lisp Reference Manual. | |
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | |
4 @c See the file lispref.texi for copying conditions. | |
5 @setfilename ../../info/help.info | |
6 @node Documentation, Files, Modes, Top | |
7 @chapter Documentation | |
8 @cindex documentation strings | |
9 | |
10 XEmacs Lisp has convenient on-line help facilities, most of which | |
11 derive their information from the documentation strings associated with | |
12 functions and variables. This chapter describes how to write good | |
13 documentation strings for your Lisp programs, as well as how to write | |
14 programs to access documentation. | |
15 | |
16 Note that the documentation strings for XEmacs are not the same thing | |
17 as the XEmacs manual. Manuals have their own source files, written in | |
18 the Texinfo language; documentation strings are specified in the | |
19 definitions of the functions and variables they apply to. A collection | |
20 of documentation strings is not sufficient as a manual because a good | |
21 manual is not organized in that fashion; it is organized in terms of | |
22 topics of discussion. | |
23 | |
24 @menu | |
25 * Documentation Basics:: Good style for doc strings. | |
26 Where to put them. How XEmacs stores them. | |
27 * Accessing Documentation:: How Lisp programs can access doc strings. | |
28 * Keys in Documentation:: Substituting current key bindings. | |
29 * Describing Characters:: Making printable descriptions of | |
30 non-printing characters and key sequences. | |
31 * Help Functions:: Subroutines used by XEmacs help facilities. | |
32 * Obsoleteness:: Upgrading Lisp functionality over time. | |
33 @end menu | |
34 | |
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 | |
41 A documentation string is written using the Lisp syntax for strings, | |
42 with double-quote characters surrounding the text of the string. This | |
43 is because it really is a Lisp string object. The string serves as | |
44 documentation when it is written in the proper place in the definition | |
45 of a function or variable. In a function definition, the documentation | |
46 string follows the argument list. In a variable definition, the | |
47 documentation string follows the initial value of the variable. | |
48 | |
49 When you write a documentation string, make the first line a complete | |
50 sentence (or two complete sentences) since some commands, such as | |
51 @code{apropos}, show only the first line of a multi-line documentation | |
52 string. Also, you should not indent the second line of a documentation | |
53 string, if you have one, because that looks odd when you use @kbd{C-h f} | |
54 (@code{describe-function}) or @kbd{C-h v} (@code{describe-variable}). | |
55 @xref{Documentation Tips}. | |
56 | |
57 Documentation strings may contain several special substrings, which | |
58 stand for key bindings to be looked up in the current keymaps when the | |
59 documentation is displayed. This allows documentation strings to refer | |
60 to the keys for related commands and be accurate even when a user | |
61 rearranges the key bindings. (@xref{Accessing Documentation}.) | |
62 | |
63 Within the Lisp world, a documentation string is accessible through | |
64 the function or variable that it describes: | |
65 | |
66 @itemize @bullet | |
67 @item | |
68 The documentation for a function is stored in the function definition | |
69 itself (@pxref{Lambda Expressions}). The function | |
70 @code{documentation} knows how to extract it. | |
71 | |
72 @item | |
73 @kindex variable-documentation | |
74 The documentation for a variable is stored in the variable's property | |
75 list under the property name @code{variable-documentation}. The | |
76 function @code{documentation-property} knows how to extract it. | |
77 @end itemize | |
78 | |
79 @cindex @file{DOC} (documentation) file | |
80 @cindex @file{emacs/etc/DOC-@var{version}} | |
81 @cindex @file{etc/DOC-@var{version}} | |
82 To save space, the documentation for preloaded functions and variables | |
83 (including primitive functions and autoloaded functions) is stored in | |
84 the @dfn{internal doc file} @file{emacs/etc/DOC-@var{version}}. The | |
85 documentation for functions and variables loaded during the XEmacs | |
86 session from byte-compiled files is stored in those very same | |
87 byte-compiled files (@pxref{Docs and Compilation}). | |
88 | |
89 XEmacs does not keep documentation strings in memory unless necessary. | |
90 Instead, XEmacs maintains, for preloaded symbols, an integer offset into | |
91 the internal doc file, and for symbols loaded from byte-compiled files, | |
92 a list containing the filename of the byte-compiled file and an integer | |
93 offset, in place of the documentation string. The functions | |
94 @code{documentation} and @code{documentation-property} use that | |
95 information to read the documentation from the appropriate file; this is | |
96 transparent to the user. | |
97 | |
98 For information on the uses of documentation strings, see @ref{Help, , | |
99 Help, emacs, The XEmacs Reference Manual}. | |
100 | |
101 @c Wordy to prevent overfull hbox. --rjc 15mar92 | |
102 The @file{emacs/lib-src} directory contains two utilities that you can | |
103 use to print nice-looking hardcopy for the file | |
104 @file{emacs/etc/DOC-@var{version}}. These are @file{sorted-doc.c} and | |
105 @file{digest-doc.c}. | |
106 | |
107 @node Accessing Documentation | |
108 @section Access to Documentation Strings | |
109 | |
110 @defun documentation-property symbol property &optional verbatim | |
111 This function returns the documentation string that is recorded in | |
112 @var{symbol}'s property list under property @var{property}. It | |
113 retrieves the text from a file if necessary, and runs | |
114 @code{substitute-command-keys} to substitute actual key bindings. (This | |
115 substitution is not done if @var{verbatim} is non-@code{nil}; the | |
116 @var{verbatim} argument exists only as of Emacs 19.) | |
117 | |
118 @smallexample | |
119 @group | |
120 (documentation-property 'command-line-processed | |
121 'variable-documentation) | |
122 @result{} "t once command line has been processed" | |
123 @end group | |
124 @group | |
125 (symbol-plist 'command-line-processed) | |
126 @result{} (variable-documentation 188902) | |
127 @end group | |
128 @end smallexample | |
129 @end defun | |
130 | |
131 @defun documentation function &optional verbatim | |
132 This function returns the documentation string of @var{function}. It | |
133 reads the text from a file if necessary. Then (unless @var{verbatim} is | |
134 non-@code{nil}) it calls @code{substitute-command-keys}, to return a | |
135 value containing the actual (current) key bindings. | |
136 | |
137 The function @code{documentation} signals a @code{void-function} error | |
138 if @var{function} has no function definition. However, it is ok if | |
139 the function definition has no documentation string. In that case, | |
140 @code{documentation} returns @code{nil}. | |
141 @end defun | |
142 | |
143 @c Wordy to prevent overfull hboxes. --rjc 15mar92 | |
144 Here is an example of using the two functions, @code{documentation} and | |
145 @code{documentation-property}, to display the documentation strings for | |
146 several symbols in a @samp{*Help*} buffer. | |
147 | |
148 @smallexample | |
149 @group | |
150 (defun describe-symbols (pattern) | |
151 "Describe the XEmacs Lisp symbols matching PATTERN. | |
152 All symbols that have PATTERN in their name are described | |
153 in the `*Help*' buffer." | |
154 (interactive "sDescribe symbols matching: ") | |
155 (let ((describe-func | |
156 (function | |
157 (lambda (s) | |
158 @end group | |
159 @group | |
160 ;; @r{Print description of symbol.} | |
161 (if (fboundp s) ; @r{It is a function.} | |
162 (princ | |
163 (format "%s\t%s\n%s\n\n" s | |
164 (if (commandp s) | |
165 (let ((keys (where-is-internal s))) | |
166 (if keys | |
167 (concat | |
168 "Keys: " | |
169 (mapconcat 'key-description | |
170 keys " ")) | |
171 "Keys: none")) | |
172 "Function") | |
173 @end group | |
174 @group | |
175 (or (documentation s) | |
176 "not documented")))) | |
177 | |
178 (if (boundp s) ; @r{It is a variable.} | |
179 @end group | |
180 @group | |
181 (princ | |
182 (format "%s\t%s\n%s\n\n" s | |
183 (if (user-variable-p s) | |
184 "Option " "Variable") | |
185 @end group | |
186 @group | |
187 (or (documentation-property | |
188 s 'variable-documentation) | |
189 "not documented"))))))) | |
190 sym-list) | |
191 @end group | |
192 | |
193 @group | |
194 ;; @r{Build a list of symbols that match pattern.} | |
195 (mapatoms (function | |
196 (lambda (sym) | |
197 (if (string-match pattern (symbol-name sym)) | |
198 (setq sym-list (cons sym sym-list)))))) | |
199 @end group | |
200 | |
201 @group | |
202 ;; @r{Display the data.} | |
203 (with-output-to-temp-buffer "*Help*" | |
204 (mapcar describe-func (sort sym-list 'string<)) | |
205 (print-help-return-message)))) | |
206 @end group | |
207 @end smallexample | |
208 | |
209 The @code{describe-symbols} function works like @code{apropos}, | |
210 but provides more information. | |
211 | |
212 @smallexample | |
213 @group | |
214 (describe-symbols "goal") | |
215 | |
216 ---------- Buffer: *Help* ---------- | |
217 goal-column Option | |
218 *Semipermanent goal column for vertical motion, as set by C-x C-n, or nil. | |
219 @end group | |
220 @c Do not blithely break or fill these lines. | |
221 @c That makes them incorrect. | |
222 | |
223 @group | |
224 set-goal-column Command: C-x C-n | |
225 Set the current horizontal position as a goal for C-n and C-p. | |
226 @end group | |
227 @c DO NOT put a blank line here! That is factually inaccurate! | |
228 @group | |
229 Those commands will move to this position in the line moved to | |
230 rather than trying to keep the same horizontal position. | |
231 With a non-nil argument, clears out the goal column | |
232 so that C-n and C-p resume vertical motion. | |
233 The goal column is stored in the variable `goal-column'. | |
234 @end group | |
235 | |
236 @group | |
237 temporary-goal-column Variable | |
238 Current goal column for vertical motion. | |
239 It is the column where point was | |
240 at the start of current run of vertical motion commands. | |
241 When the `track-eol' feature is doing its job, the value is 9999. | |
242 ---------- Buffer: *Help* ---------- | |
243 @end group | |
244 @end smallexample | |
245 | |
246 @defun Snarf-documentation filename | |
247 This function is used only during XEmacs initialization, just before | |
248 the runnable XEmacs is dumped. It finds the file offsets of the | |
249 documentation strings stored in the file @var{filename}, and records | |
250 them in the in-core function definitions and variable property lists in | |
251 place of the actual strings. @xref{Building XEmacs}. | |
252 | |
253 XEmacs finds the file @var{filename} in the @file{xemacs/lib-src} | |
254 directory. When the dumped XEmacs is later executed, the same file is | |
255 found in the directory @code{doc-directory}. Usually @var{filename} is | |
256 @file{"DOC-@var{version}"}, but this can be changed by modifying the | |
257 variable @code{internal-doc-file-name}. | |
258 @end defun | |
259 | |
260 @defvar internal-doc-file-name | |
261 This variable holds the name of the file containing documentation | |
262 strings of built-in symbols, usually @file{"DOC-@var{version}"}. The | |
263 full pathname of the internal doc file is @samp{(concat doc-directory | |
264 internal-doc-file-name)}. | |
265 @end defvar | |
266 | |
267 @defvar doc-directory | |
268 This variable holds the name of the directory which contains the | |
269 @dfn{internal doc file} that contains documentation strings for built-in | |
270 and preloaded functions and variables. | |
271 | |
272 In most cases, this is the same as @code{exec-directory}. They may be | |
273 different when you run XEmacs from the directory where you built it, | |
274 without actually installing it. See @code{exec-directory} in @ref{Help | |
275 Functions}. | |
276 | |
277 In older Emacs versions, @code{exec-directory} was used for this. | |
278 @end defvar | |
279 | |
280 @defvar data-directory | |
281 This variable holds the name of the directory in which XEmacs finds | |
282 certain system independent documentation and text files that come | |
283 with XEmacs. In older Emacs versions, @code{exec-directory} was used for | |
284 this. | |
285 @end defvar | |
286 | |
287 @node Keys in Documentation | |
288 @section Substituting Key Bindings in Documentation | |
289 @cindex documentation, keys in | |
290 @cindex keys in documentation strings | |
291 @cindex substituting keys in documentation | |
292 | |
293 When documentation strings refer to key sequences, they should use the | |
294 current, actual key bindings. They can do so using certain special text | |
295 sequences described below. Accessing documentation strings in the usual | |
296 way substitutes current key binding information for these special | |
297 sequences. This works by calling @code{substitute-command-keys}. You | |
298 can also call that function yourself. | |
299 | |
300 Here is a list of the special sequences and what they mean: | |
301 | |
302 @table @code | |
303 @item \[@var{command}] | |
304 stands for a key sequence that will invoke @var{command}, or @samp{M-x | |
305 @var{command}} if @var{command} has no key bindings. | |
306 | |
307 @item \@{@var{mapvar}@} | |
308 stands for a summary of the value of @var{mapvar}, which should be a | |
309 keymap. The summary is made by @code{describe-bindings}. | |
310 | |
311 @item \<@var{mapvar}> | |
312 stands for no text itself. It is used for a side effect: it specifies | |
313 @var{mapvar} as the keymap for any following @samp{\[@var{command}]} | |
314 sequences in this documentation string. | |
315 | |
316 @item \= | |
317 quotes the following character and is discarded; this @samp{\=\=} puts | |
318 @samp{\=} into the output, and @samp{\=\[} puts @samp{\[} into the output. | |
319 @end table | |
320 | |
321 @strong{Please note:} Each @samp{\} must be doubled when written in a | |
322 string in XEmacs Lisp. | |
323 | |
324 @defun substitute-command-keys string | |
325 This function scans @var{string} for the above special sequences and | |
326 replaces them by what they stand for, returning the result as a string. | |
327 This permits display of documentation that refers accurately to the | |
328 user's own customized key bindings. | |
329 @end defun | |
330 | |
331 Here are examples of the special sequences: | |
332 | |
333 @smallexample | |
334 @group | |
335 (substitute-command-keys | |
336 "To abort recursive edit, type: \\[abort-recursive-edit]") | |
337 @result{} "To abort recursive edit, type: C-]" | |
338 @end group | |
339 | |
340 @group | |
341 (substitute-command-keys | |
342 "The keys that are defined for the minibuffer here are: | |
343 \\@{minibuffer-local-must-match-map@}") | |
344 @result{} "The keys that are defined for the minibuffer here are: | |
345 @end group | |
346 | |
347 ? minibuffer-completion-help | |
348 SPC minibuffer-complete-word | |
349 TAB minibuffer-complete | |
350 LFD minibuffer-complete-and-exit | |
351 RET minibuffer-complete-and-exit | |
352 C-g abort-recursive-edit | |
353 " | |
354 | |
355 @group | |
356 (substitute-command-keys | |
357 "To abort a recursive edit from the minibuffer, type\ | |
358 \\<minibuffer-local-must-match-map>\\[abort-recursive-edit].") | |
359 @result{} "To abort a recursive edit from the minibuffer, type C-g." | |
360 @end group | |
361 | |
362 @group | |
363 (substitute-command-keys | |
364 "Substrings of the form \\=\\@{MAPVAR@} are replaced by summaries | |
365 \(made by describe-bindings) of the value of MAPVAR, taken as a keymap. | |
366 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR | |
367 as the keymap for future \\=\\[COMMAND] substrings. | |
368 \\=\\= quotes the following character and is discarded; | |
369 thus, \\=\\=\\=\\= puts \\=\\= into the output, | |
370 and \\=\\=\\=\\[ puts \\=\\[ into the output.") | |
371 @result{} "Substrings of the form \@{MAPVAR@} are replaced by summaries | |
372 (made by describe-bindings) of the value of MAPVAR, taken as a keymap. | |
373 Substrings of the form \<MAPVAR> specify to use the value of MAPVAR | |
374 as the keymap for future \[COMMAND] substrings. | |
375 \= quotes the following character and is discarded; | |
376 thus, \=\= puts \= into the output, | |
377 and \=\[ puts \[ into the output." | |
378 @end group | |
379 @end smallexample | |
380 | |
381 @node Describing Characters | |
382 @section Describing Characters for Help Messages | |
383 | |
384 These functions convert events, key sequences or characters to textual | |
385 descriptions. These descriptions are useful for including arbitrary | |
386 text characters or key sequences in messages, because they convert | |
387 non-printing and whitespace characters to sequences of printing | |
388 characters. The description of a non-whitespace printing character is | |
389 the character itself. | |
390 | |
391 @defun key-description sequence | |
392 @cindex XEmacs event standard notation | |
393 This function returns a string containing the XEmacs standard notation | |
394 for the input events in @var{sequence}. The argument @var{sequence} may | |
395 be a string, vector or list. @xref{Events}, for more information about | |
396 valid events. See also the examples for @code{single-key-description}, | |
397 below. | |
398 @end defun | |
399 | |
400 @defun single-key-description key | |
401 @cindex event printing | |
402 @cindex character printing | |
403 @cindex control character printing | |
404 @cindex meta character printing | |
405 This function returns a string describing @var{key} in the standard | |
406 XEmacs notation for keyboard input. A normal printing character appears | |
407 as itself, but a control character turns into a string starting with | |
408 @samp{C-}, a meta character turns into a string starting with @samp{M-}, | |
409 and space, linefeed, etc.@: appear as @samp{SPC}, @samp{LFD}, etc. A | |
410 symbol appears as the name of the symbol. An event that is a list | |
411 appears as the name of the symbol in the @sc{car} of the list. | |
412 | |
413 @smallexample | |
414 @group | |
415 (single-key-description ?\C-x) | |
416 @result{} "C-x" | |
417 @end group | |
418 @group | |
419 (key-description "\C-x \M-y \n \t \r \f123") | |
420 @result{} "C-x SPC M-y SPC LFD SPC TAB SPC RET SPC C-l 1 2 3" | |
421 @end group | |
422 @group | |
423 (single-key-description 'kp_next) | |
424 @result{} "kp_next" | |
425 @end group | |
426 @group | |
427 (single-key-description '(shift button1)) | |
428 @result{} "Sh-button1" | |
429 @end group | |
430 @end smallexample | |
431 @end defun | |
432 | |
433 @defun text-char-description character | |
434 This function returns a string describing @var{character} in the | |
435 standard XEmacs notation for characters that appear in text---like | |
436 @code{single-key-description}, except that control characters are | |
437 represented with a leading caret (which is how control characters in | |
438 XEmacs buffers are usually displayed). | |
439 | |
440 @smallexample | |
441 @group | |
442 (text-char-description ?\C-c) | |
443 @result{} "^C" | |
444 @end group | |
445 @group | |
446 (text-char-description ?\M-m) | |
447 @result{} "M-m" | |
448 @end group | |
449 @group | |
450 (text-char-description ?\C-\M-m) | |
451 @result{} "M-^M" | |
452 @end group | |
453 @end smallexample | |
454 @end defun | |
455 | |
456 @node Help Functions | |
457 @section Help Functions | |
458 | |
459 XEmacs provides a variety of on-line help functions, all accessible to | |
460 the user as subcommands of the prefix @kbd{C-h}, or on some keyboards, | |
461 @kbd{help}. For more information about them, see @ref{Help, , Help, | |
462 emacs, The XEmacs Reference Manual}. Here we describe some | |
463 program-level interfaces to the same information. | |
464 | |
465 @deffn Command apropos regexp &optional do-all predicate | |
466 This function finds all symbols whose names contain a match for the | |
467 regular expression @var{regexp}, and returns a list of them | |
468 (@pxref{Regular Expressions}). It also displays the symbols in a buffer | |
469 named @samp{*Help*}, each with a one-line description. | |
470 | |
471 @c Emacs 19 feature | |
472 If @var{do-all} is non-@code{nil}, then @code{apropos} also shows | |
473 key bindings for the functions that are found. | |
474 | |
475 If @var{predicate} is non-@code{nil}, it should be a function to be | |
476 called on each symbol that has matched @var{regexp}. Only symbols for | |
477 which @var{predicate} returns a non-@code{nil} value are listed or | |
478 displayed. | |
479 | |
480 In the first of the following examples, @code{apropos} finds all the | |
481 symbols with names containing @samp{exec}. In the second example, it | |
482 finds and returns only those symbols that are also commands. | |
483 (We don't show the output that results in the @samp{*Help*} buffer.) | |
484 | |
485 @smallexample | |
486 @group | |
487 (apropos "exec") | |
488 @result{} (Buffer-menu-execute command-execute exec-directory | |
489 exec-path execute-extended-command execute-kbd-macro | |
490 executing-kbd-macro executing-macro) | |
491 @end group | |
492 | |
493 @group | |
494 (apropos "exec" nil 'commandp) | |
495 @result{} (Buffer-menu-execute execute-extended-command) | |
496 @end group | |
497 @ignore | |
498 @group | |
499 ---------- Buffer: *Help* ---------- | |
500 Buffer-menu-execute | |
501 Function: Save and/or delete buffers marked with | |
502 M-x Buffer-menu-save or M-x Buffer-menu-delete commands. | |
503 execute-extended-command ESC x | |
504 Function: Read function name, then read its | |
505 arguments and call it. | |
506 ---------- Buffer: *Help* ---------- | |
507 @end group | |
508 @end ignore | |
509 @end smallexample | |
510 | |
511 @code{apropos} is used by various user-level commands, such as @kbd{C-h | |
512 a} (@code{hyper-apropos}), a graphical front-end to @code{apropos}; and | |
513 @kbd{C-h A} (@code{command-apropos}), which does an apropos over only | |
514 those functions which are user commands. @code{command-apropos} calls | |
515 @code{apropos}, specifying a @var{predicate} to restrict the output to | |
516 symbols that are commands. The call to @code{apropos} looks like this: | |
517 | |
518 @smallexample | |
519 (apropos string t 'commandp) | |
520 @end smallexample | |
521 @end deffn | |
522 | |
523 @c Emacs 19 feature | |
524 @c super-apropos is obsolete - function absorbed by apropos --mrb | |
525 @ignore | |
526 @deffn Command super-apropos regexp &optional do-all | |
527 This function differs from @code{apropos} in that it searches | |
528 documentation strings as well as symbol names for matches for | |
529 @var{regexp}. By default, it searches the documentation strings only | |
530 for preloaded functions and variables. If @var{do-all} is | |
531 non-@code{nil}, it scans the names and documentation strings of all | |
532 functions and variables. | |
533 @end deffn | |
534 @end ignore | |
535 | |
536 @defvar help-map | |
537 The value of this variable is a local keymap for characters following the | |
538 Help key, @kbd{C-h}. | |
539 @end defvar | |
540 | |
541 @deffn {Prefix Command} help-command | |
542 This symbol is not a function; its function definition is actually the | |
543 keymap known as @code{help-map}. It is defined in @file{help.el} as | |
544 follows: | |
545 | |
546 @smallexample | |
547 @group | |
548 (define-key global-map "\C-h" 'help-command) | |
549 (fset 'help-command help-map) | |
550 @end group | |
551 @end smallexample | |
552 @end deffn | |
553 | |
554 @defun print-help-return-message &optional function | |
555 This function builds a string that explains how to restore the previous | |
556 state of the windows after a help command. After building the message, | |
557 it applies @var{function} to it if @var{function} is non-@code{nil}. | |
558 Otherwise it calls @code{message} to display it in the echo area. | |
559 | |
560 This function expects to be called inside a | |
561 @code{with-output-to-temp-buffer} special form, and expects | |
562 @code{standard-output} to have the value bound by that special form. | |
563 For an example of its use, see the long example in @ref{Accessing | |
564 Documentation}. | |
565 @end defun | |
566 | |
567 @defvar help-char | |
568 The value of this variable is the help character---the character that | |
569 XEmacs recognizes as meaning Help. By default, it is the character | |
570 @samp{?\^H} (ASCII 8), which is @kbd{C-h}. When XEmacs reads this | |
571 character, if @code{help-form} is non-@code{nil} Lisp expression, it | |
572 evaluates that expression, and displays the result in a window if it is | |
573 a string. | |
574 | |
575 @code{help-char} can be a character or a key description such as | |
576 @code{help} or @code{(meta h)}. | |
577 | |
578 Usually the value of @code{help-form}'s value is @code{nil}. Then the | |
579 help character has no special meaning at the level of command input, and | |
580 it becomes part of a key sequence in the normal way. The standard key | |
581 binding of @kbd{C-h} is a prefix key for several general-purpose help | |
582 features. | |
583 | |
584 The help character is special after prefix keys, too. If it has no | |
585 binding as a subcommand of the prefix key, it runs | |
586 @code{describe-prefix-bindings}, which displays a list of all the | |
587 subcommands of the prefix key. | |
588 @end defvar | |
589 | |
590 @defvar help-form | |
591 If this variable is non-@code{nil}, its value is a form to evaluate | |
592 whenever the character @code{help-char} is read. If evaluating the form | |
593 produces a string, that string is displayed. | |
594 | |
595 A command that calls @code{next-command-event} or @code{next-event} | |
596 probably should bind @code{help-form} to a non-@code{nil} expression | |
597 while it does input. (The exception is when @kbd{C-h} is meaningful | |
598 input.) Evaluating this expression should result in a string that | |
599 explains what the input is for and how to enter it properly. | |
600 | |
601 Entry to the minibuffer binds this variable to the value of | |
602 @code{minibuffer-help-form} (@pxref{Minibuffer Misc}). | |
603 @end defvar | |
604 | |
605 @defvar prefix-help-command | |
606 This variable holds a function to print help for a prefix character. | |
607 The function is called when the user types a prefix key followed by the | |
608 help character, and the help character has no binding after that prefix. | |
609 The variable's default value is @code{describe-prefix-bindings}. | |
610 @end defvar | |
611 | |
612 @defun describe-prefix-bindings | |
613 This function calls @code{describe-bindings} to display a list of all | |
614 the subcommands of the prefix key of the most recent key sequence. The | |
615 prefix described consists of all but the last event of that key | |
616 sequence. (The last event is, presumably, the help character.) | |
617 @end defun | |
618 | |
619 The following two functions are found in the library @file{helper}. | |
620 They are for modes that want to provide help without relinquishing | |
621 control, such as the ``electric'' modes. You must load that library | |
622 with @code{(require 'helper)} in order to use them. Their names begin | |
623 with @samp{Helper} to distinguish them from the ordinary help functions. | |
624 | |
625 @deffn Command Helper-describe-bindings | |
626 This command pops up a window displaying a help buffer containing a | |
627 listing of all of the key bindings from both the local and global keymaps. | |
628 It works by calling @code{describe-bindings}. | |
629 @end deffn | |
630 | |
631 @deffn Command Helper-help | |
632 This command provides help for the current mode. It prompts the user | |
633 in the minibuffer with the message @samp{Help (Type ? for further | |
634 options)}, and then provides assistance in finding out what the key | |
635 bindings are, and what the mode is intended for. It returns @code{nil}. | |
636 | |
637 This can be customized by changing the map @code{Helper-help-map}. | |
638 @end deffn | |
639 | |
640 @ignore @c Not in XEmacs currently | |
641 @c Emacs 19 feature | |
642 @defmac make-help-screen fname help-line help-text help-map | |
643 This macro defines a help command named @var{fname} that acts like a | |
644 prefix key that shows a list of the subcommands it offers. | |
645 | |
646 When invoked, @var{fname} displays @var{help-text} in a window, then | |
647 reads and executes a key sequence according to @var{help-map}. The | |
648 string @var{help-text} should describe the bindings available in | |
649 @var{help-map}. | |
650 | |
651 The command @var{fname} is defined to handle a few events itself, by | |
652 scrolling the display of @var{help-text}. When @var{fname} reads one of | |
653 those special events, it does the scrolling and then reads another | |
654 event. When it reads an event that is not one of those few, and which | |
655 has a binding in @var{help-map}, it executes that key's binding and | |
656 then returns. | |
657 | |
658 The argument @var{help-line} should be a single-line summary of the | |
659 alternatives in @var{help-map}. In the current version of Emacs, this | |
660 argument is used only if you set the option @code{three-step-help} to | |
661 @code{t}. | |
662 @end defmac | |
663 | |
664 @defopt three-step-help | |
665 If this variable is non-@code{nil}, commands defined with | |
666 @code{make-help-screen} display their @var{help-line} strings in the | |
667 echo area at first, and display the longer @var{help-text} strings only | |
668 if the user types the help character again. | |
669 @end defopt | |
670 @end ignore | |
671 | |
672 @node Obsoleteness | |
673 @section Obsoleteness | |
674 | |
675 As you add functionality to a package, you may at times want to | |
676 replace an older function with a new one. To preserve compatibility | |
677 with existing code, the older function needs to still exist; but | |
678 users of that function should be told to use the newer one instead. | |
679 XEmacs Lisp lets you mark a function or variable as @dfn{obsolete}, | |
680 and indicate what should be used instead. | |
681 | |
682 @defun make-obsolete function new | |
683 This function indicates that @var{function} is an obsolete function, | |
684 and the function @var{new} should be used instead. The byte compiler | |
685 will issue a warning to this effect when it encounters a usage of the | |
686 older function, and the help system will also note this in the function's | |
687 documentation. @var{new} can also be a string (if there is not a single | |
688 function with the same functionality any more), and should be a descriptive | |
689 statement, such as "use @var{foo} or @var{bar} instead" or "this function is | |
690 unnecessary". | |
691 @end defun | |
692 | |
693 @defun make-obsolete-variable variable new | |
694 This is like @code{make-obsolete} but is for variables instead of functions. | |
695 @end defun | |
696 | |
697 @defun define-obsolete-function-alias oldfun newfun | |
698 This function combines @code{make-obsolete} and @code{define-function}, | |
699 declaring @var{oldfun} to be an obsolete variant of @var{newfun} and | |
700 defining @var{oldfun} as an alias for @var{newfun}. | |
701 @end defun | |
702 | |
703 @defun define-obsolete-variable-alias oldvar newvar | |
704 This is like @code{define-obsolete-function-alias} but for variables. | |
705 @end defun | |
706 | |
707 Note that you should not normally put obsoleteness information | |
708 explicitly in a function or variable's doc string. The obsoleteness | |
709 information that you specify using the above functions will be displayed | |
710 whenever the doc string is displayed, and by adding it explicitly the | |
711 result is redundancy. | |
712 | |
713 Also, if an obsolete function is substantially the same as a newer one | |
714 but is not actually an alias, you should consider omitting the doc | |
715 string entirely (use a null string @samp{""} as the doc string). That | |
716 way, the user is told about the obsoleteness and is forced to look at | |
717 the documentation of the new function, making it more likely that he | |
718 will use the new function. | |
719 | |
720 @defun function-obsoleteness-doc function | |
721 If @var{function} is obsolete, this function returns a string describing | |
722 this. This is the message that is printed out during byte compilation | |
723 or in the function's documentation. If @var{function} is not obsolete, | |
724 @code{nil} is returned. | |
725 @end defun | |
726 | |
727 @defun variable-obsoleteness-doc variable | |
728 This is like @code{function-obsoleteness-doc} but for variables. | |
729 @end defun | |
730 | |
731 The obsoleteness information is stored internally by putting a property | |
732 @code{byte-obsolete-info} (for functions) or | |
733 @code{byte-obsolete-variable} (for variables) on the symbol that | |
734 specifies the obsolete function or variable. For more information, see | |
735 the implementation of @code{make-obsolete} and | |
736 @code{make-obsolete-variable} in | |
737 @file{lisp/bytecomp/bytecomp-runtime.el}. |