]> code.delx.au - gnu-emacs/blob - lisp/help-fns.el
Merge branch 'emacs-25-merge'
[gnu-emacs] / lisp / help-fns.el
1 ;;; help-fns.el --- Complex help functions -*- lexical-binding: t -*-
2
3 ;; Copyright (C) 1985-1986, 1993-1994, 1998-2015 Free Software
4 ;; Foundation, Inc.
5
6 ;; Maintainer: emacs-devel@gnu.org
7 ;; Keywords: help, internal
8 ;; Package: emacs
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; This file contains those help commands which are complicated, and
28 ;; which may not be used in every session. For example
29 ;; `describe-function' will probably be heavily used when doing elisp
30 ;; programming, but not if just editing C files. Simpler help commands
31 ;; are in help.el
32
33 ;;; Code:
34
35 (require 'cl-lib)
36 (require 'help-mode)
37
38 (defvar help-fns-describe-function-functions nil
39 "List of functions to run in help buffer in `describe-function'.
40 Those functions will be run after the header line and argument
41 list was inserted, and before the documentation will be inserted.
42 The functions will receive the function name as argument.")
43
44 ;; Functions
45
46 (defvar describe-function-orig-buffer nil
47 "Buffer that was current when `describe-function' was invoked.
48 Functions on `help-fns-describe-function-functions' can use this
49 to get buffer-local values.")
50
51 ;;;###autoload
52 (defun describe-function (function)
53 "Display the full documentation of FUNCTION (a symbol)."
54 (interactive
55 (let ((fn (function-called-at-point))
56 (enable-recursive-minibuffers t)
57 val)
58 (setq val (completing-read (if fn
59 (format "Describe function (default %s): " fn)
60 "Describe function: ")
61 obarray 'fboundp t nil nil
62 (and fn (symbol-name fn))))
63 (list (if (equal val "")
64 fn (intern val)))))
65 (or (and function (symbolp function))
66 (user-error "You didn't specify a function symbol"))
67 (or (fboundp function)
68 (user-error "Symbol's function definition is void: %s" function))
69
70 ;; We save describe-function-orig-buffer on the help xref stack, so
71 ;; it is restored by the back/forward buttons. 'help-buffer'
72 ;; expects (current-buffer) to be a help buffer when processing
73 ;; those buttons, so we can't change the current buffer before
74 ;; calling that.
75 (let ((describe-function-orig-buffer
76 (or describe-function-orig-buffer
77 (current-buffer))))
78
79 (help-setup-xref
80 (list (lambda (function buffer)
81 (let ((describe-function-orig-buffer
82 (if (buffer-live-p buffer) buffer)))
83 (describe-function function)))
84 function describe-function-orig-buffer)
85 (called-interactively-p 'interactive))
86
87 (save-excursion
88 (with-help-window (help-buffer)
89 (prin1 function)
90 ;; Use " is " instead of a colon so that
91 ;; it is easier to get out the function name using forward-sexp.
92 (princ " is ")
93 (describe-function-1 function)
94 (with-current-buffer standard-output
95 ;; Return the text we displayed.
96 (buffer-string))))
97 ))
98
99
100 ;; Could be this, if we make symbol-file do the work below.
101 ;; (defun help-C-file-name (subr-or-var kind)
102 ;; "Return the name of the C file where SUBR-OR-VAR is defined.
103 ;; KIND should be `var' for a variable or `subr' for a subroutine."
104 ;; (symbol-file (if (symbolp subr-or-var) subr-or-var
105 ;; (subr-name subr-or-var))
106 ;; (if (eq kind 'var) 'defvar 'defun)))
107 ;;;###autoload
108 (defun help-C-file-name (subr-or-var kind)
109 "Return the name of the C file where SUBR-OR-VAR is defined.
110 KIND should be `var' for a variable or `subr' for a subroutine."
111 (let ((docbuf (get-buffer-create " *DOC*"))
112 (name (if (eq 'var kind)
113 (concat "V" (symbol-name subr-or-var))
114 (concat "F" (subr-name (advice--cd*r subr-or-var))))))
115 (with-current-buffer docbuf
116 (goto-char (point-min))
117 (if (eobp)
118 (insert-file-contents-literally
119 (expand-file-name internal-doc-file-name doc-directory)))
120 (let ((file (catch 'loop
121 (while t
122 (let ((pnt (search-forward (concat "\1f" name "\n"))))
123 (re-search-backward "\1fS\\(.*\\)")
124 (let ((file (match-string 1)))
125 (if (member file build-files)
126 (throw 'loop file)
127 (goto-char pnt))))))))
128 (if (string-match "^ns.*\\(\\.o\\|obj\\)\\'" file)
129 (setq file (replace-match ".m" t t file 1))
130 (if (string-match "\\.\\(o\\|obj\\)\\'" file)
131 (setq file (replace-match ".c" t t file))))
132 (if (string-match "\\.\\(c\\|m\\)\\'" file)
133 (concat "src/" file)
134 file)))))
135
136 (defcustom help-downcase-arguments nil
137 "If non-nil, argument names in *Help* buffers are downcased."
138 :type 'boolean
139 :group 'help
140 :version "23.2")
141
142 (defun help-highlight-arg (arg)
143 "Highlight ARG as an argument name for a *Help* buffer.
144 Return ARG in face `help-argument-name'; ARG is also downcased
145 if the variable `help-downcase-arguments' is non-nil."
146 (propertize (if help-downcase-arguments (downcase arg) arg)
147 'face 'help-argument-name))
148
149 (defun help-do-arg-highlight (doc args)
150 (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table)
151 (modify-syntax-entry ?\- "w")
152 (dolist (arg args)
153 (setq doc (replace-regexp-in-string
154 ;; This is heuristic, but covers all common cases
155 ;; except ARG1-ARG2
156 (concat "\\<" ; beginning of word
157 "\\(?:[a-z-]*-\\)?" ; for xxx-ARG
158 "\\("
159 (regexp-quote arg)
160 "\\)"
161 "\\(?:es\\|s\\|th\\)?" ; for ARGth, ARGs
162 "\\(?:-[a-z0-9-]+\\)?" ; for ARG-xxx, ARG-n
163 "\\(?:-[{([<`\"‘].*?\\)?"; for ARG-{x}, (x), <x>, [x], `x', ‘x’
164 "\\>") ; end of word
165 (help-highlight-arg arg)
166 doc t t 1)))
167 doc))
168
169 (defun help-highlight-arguments (usage doc &rest args)
170 (when (and usage (string-match "^(" usage))
171 (with-temp-buffer
172 (insert usage)
173 (goto-char (point-min))
174 (let ((case-fold-search nil)
175 (next (not (or args (looking-at "\\["))))
176 (opt nil))
177 ;; Make a list of all arguments
178 (skip-chars-forward "^ ")
179 (while next
180 (or opt (not (looking-at " &")) (setq opt t))
181 (if (not (re-search-forward " \\([\\[(]*\\)\\([^] &).]+\\)" nil t))
182 (setq next nil)
183 (setq args (cons (match-string 2) args))
184 (when (and opt (string= (match-string 1) "("))
185 ;; A pesky CL-style optional argument with default value,
186 ;; so let's skip over it
187 (search-backward "(")
188 (goto-char (scan-sexps (point) 1)))))
189 ;; Highlight arguments in the USAGE string
190 (setq usage (help-do-arg-highlight (buffer-string) args))
191 ;; Highlight arguments in the DOC string
192 (setq doc (and doc (help-do-arg-highlight doc args))))))
193 ;; Return value is like the one from help-split-fundoc, but highlighted
194 (cons usage doc))
195
196 ;; The following function was compiled from the former functions
197 ;; `describe-simplify-lib-file-name' and `find-source-lisp-file' with
198 ;; some excerpts from `describe-function-1' and `describe-variable'.
199 ;; The only additional twists provided are (1) locate the defining file
200 ;; for autoloaded functions, and (2) give preference to files in the
201 ;; "install directory" (directories found via `load-path') rather than
202 ;; to files in the "compile directory" (directories found by searching
203 ;; the loaddefs.el file). We autoload it because it's also used by
204 ;; `describe-face' (instead of `describe-simplify-lib-file-name').
205
206 ;;;###autoload
207 (defun find-lisp-object-file-name (object type)
208 "Guess the file that defined the Lisp object OBJECT, of type TYPE.
209 OBJECT should be a symbol associated with a function, variable, or face;
210 alternatively, it can be a function definition.
211 If TYPE is `defvar', search for a variable definition.
212 If TYPE is `defface', search for a face definition.
213 If TYPE is not a symbol, search for a function definition.
214
215 The return value is the absolute name of a readable file where OBJECT is
216 defined. If several such files exist, preference is given to a file
217 found via `load-path'. The return value can also be `C-source', which
218 means that OBJECT is a function or variable defined in C. If no
219 suitable file is found, return nil."
220 (let* ((autoloaded (autoloadp type))
221 (file-name (or (and autoloaded (nth 1 type))
222 (symbol-file
223 ;; FIXME: Why do we have this weird "If TYPE is the
224 ;; value returned by `symbol-function' for a function
225 ;; symbol" exception?
226 object (or (if (symbolp type) type) 'defun)))))
227 (cond
228 (autoloaded
229 ;; An autoloaded function: Locate the file since `symbol-function'
230 ;; has only returned a bare string here.
231 (setq file-name
232 (locate-file file-name load-path '(".el" ".elc") 'readable)))
233 ((and (stringp file-name)
234 (string-match "[.]*loaddefs.el\\'" file-name))
235 ;; An autoloaded variable or face. Visit loaddefs.el in a buffer
236 ;; and try to extract the defining file. The following form is
237 ;; from `describe-function-1' and `describe-variable'.
238 (let ((location
239 (condition-case nil
240 (find-function-search-for-symbol object nil file-name)
241 (error nil))))
242 (when (cdr location)
243 (with-current-buffer (car location)
244 (goto-char (cdr location))
245 (when (re-search-backward
246 "^;;; Generated autoloads from \\(.*\\)" nil t)
247 (setq file-name
248 (locate-file
249 (file-name-sans-extension
250 (match-string-no-properties 1))
251 load-path '(".el" ".elc") 'readable))))))))
252
253 (cond
254 ((and (not file-name) (subrp type))
255 ;; A built-in function. The form is from `describe-function-1'.
256 (if (get-buffer " *DOC*")
257 (help-C-file-name type 'subr)
258 'C-source))
259 ((and (not file-name) (symbolp object)
260 (integerp (get object 'variable-documentation)))
261 ;; A variable defined in C. The form is from `describe-variable'.
262 (if (get-buffer " *DOC*")
263 (help-C-file-name object 'var)
264 'C-source))
265 ((not (stringp file-name))
266 ;; If we don't have a file-name string by now, we lost.
267 nil)
268 ;; Now, `file-name' should have become an absolute file name.
269 ;; For files loaded from ~/.foo.elc, try ~/.foo.
270 ;; This applies to config files like ~/.emacs,
271 ;; which people sometimes compile.
272 ((let (fn)
273 (and (string-match "\\`\\..*\\.elc\\'"
274 (file-name-nondirectory file-name))
275 (string-equal (file-name-directory file-name)
276 (file-name-as-directory (expand-file-name "~")))
277 (file-readable-p (setq fn (file-name-sans-extension file-name)))
278 fn)))
279 ;; When the Elisp source file can be found in the install
280 ;; directory, return the name of that file.
281 ((let ((lib-name
282 (if (string-match "[.]elc\\'" file-name)
283 (substring-no-properties file-name 0 -1)
284 file-name)))
285 (or (and (file-readable-p lib-name) lib-name)
286 ;; The library might be compressed.
287 (and (file-readable-p (concat lib-name ".gz")) lib-name))))
288 ((let* ((lib-name (file-name-nondirectory file-name))
289 ;; The next form is from `describe-simplify-lib-file-name'.
290 (file-name
291 ;; Try converting the absolute file name to a library
292 ;; name, convert that back to a file name and see if we
293 ;; get the original one. If so, they are equivalent.
294 (if (equal file-name (locate-file lib-name load-path '("")))
295 (if (string-match "[.]elc\\'" lib-name)
296 (substring-no-properties lib-name 0 -1)
297 lib-name)
298 file-name))
299 ;; The next three forms are from `find-source-lisp-file'.
300 (src-file (locate-library file-name t nil 'readable)))
301 (and src-file (file-readable-p src-file) src-file))))))
302
303 (defun help-fns--key-bindings (function)
304 (when (commandp function)
305 (let ((pt2 (with-current-buffer standard-output (point)))
306 (remapped (command-remapping function)))
307 (unless (memq remapped '(ignore undefined))
308 (let ((keys (where-is-internal
309 (or remapped function) overriding-local-map nil nil))
310 non-modified-keys)
311 (if (and (eq function 'self-insert-command)
312 (vectorp (car-safe keys))
313 (consp (aref (car keys) 0)))
314 (princ "It is bound to many ordinary text characters.\n")
315 ;; Which non-control non-meta keys run this command?
316 (dolist (key keys)
317 (if (member (event-modifiers (aref key 0)) '(nil (shift)))
318 (push key non-modified-keys)))
319 (when remapped
320 (princ "Its keys are remapped to ")
321 (princ (if (symbolp remapped)
322 (format-message "`%s'" remapped)
323 "an anonymous command"))
324 (princ ".\n"))
325
326 (when keys
327 (princ (if remapped
328 "Without this remapping, it would be bound to "
329 "It is bound to "))
330 ;; If lots of ordinary text characters run this command,
331 ;; don't mention them one by one.
332 (if (< (length non-modified-keys) 10)
333 (princ (mapconcat 'key-description keys ", "))
334 (dolist (key non-modified-keys)
335 (setq keys (delq key keys)))
336 (if keys
337 (progn
338 (princ (mapconcat 'key-description keys ", "))
339 (princ ", and many ordinary text characters"))
340 (princ "many ordinary text characters"))))
341 (when (or remapped keys non-modified-keys)
342 (princ ".")
343 (terpri)))))
344
345 (with-current-buffer standard-output
346 (fill-region-as-paragraph pt2 (point))
347 (unless (looking-back "\n\n" (- (point) 2))
348 (terpri))))))
349
350 (defun help-fns--compiler-macro (function)
351 (let ((handler (function-get function 'compiler-macro)))
352 (when handler
353 (insert "\nThis function has a compiler macro")
354 (if (symbolp handler)
355 (progn
356 (insert (format-message " `%s'" handler))
357 (save-excursion
358 (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")
359 nil t)
360 (help-xref-button 1 'help-function handler)))
361 ;; FIXME: Obsolete since 24.4.
362 (let ((lib (get function 'compiler-macro-file)))
363 (when (stringp lib)
364 (insert (format-message " in `%s'" lib))
365 (save-excursion
366 (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")
367 nil t)
368 (help-xref-button 1 'help-function-cmacro function lib)))))
369 (insert ".\n"))))
370
371 (defun help-fns--signature (function doc real-def real-function buffer)
372 "Insert usage at point and return docstring. With highlighting."
373 (if (keymapp function)
374 doc ; If definition is a keymap, skip arglist note.
375 (let* ((advertised (gethash real-def advertised-signature-table t))
376 (arglist (if (listp advertised)
377 advertised (help-function-arglist real-def)))
378 (usage (help-split-fundoc doc function)))
379 (if usage (setq doc (cdr usage)))
380 (let* ((use (cond
381 ((and usage (not (listp advertised))) (car usage))
382 ((listp arglist)
383 (help--make-usage-docstring function arglist))
384 ((stringp arglist) arglist)
385 ;; Maybe the arglist is in the docstring of a symbol
386 ;; this one is aliased to.
387 ((let ((fun real-function))
388 (while (and (symbolp fun)
389 (setq fun (symbol-function fun))
390 (not (setq usage (help-split-fundoc
391 (documentation fun)
392 function)))))
393 usage)
394 (car usage))
395 ((or (stringp real-def)
396 (vectorp real-def))
397 (format "\nMacro: %s"
398 (help--docstring-quote
399 (format-kbd-macro real-def))))
400 (t "[Missing arglist. Please make a bug report.]")))
401 ;; Insert "`X", not "(\` X)", when documenting `X.
402 (use1 (replace-regexp-in-string
403 "\\`(\\\\=\\\\\\\\=` \\([^\n ]*\\))\\'"
404 "\\\\=`\\1" use t))
405 (high (if buffer
406 (let (subst-use1 subst-doc)
407 (with-current-buffer buffer
408 (setq subst-use1 (substitute-command-keys use1))
409 (setq subst-doc (substitute-command-keys doc)))
410 (help-highlight-arguments subst-use1 subst-doc))
411 (cons use1 doc))))
412 (let ((fill-begin (point))
413 (high-usage (car high))
414 (high-doc (cdr high)))
415 (insert high-usage "\n")
416 (fill-region fill-begin (point))
417 high-doc)))))
418
419 (defun help-fns--parent-mode (function)
420 ;; If this is a derived mode, link to the parent.
421 (let ((parent-mode (and (symbolp function)
422 (get function
423 'derived-mode-parent))))
424 (when parent-mode
425 (insert (substitute-command-keys "\nParent mode: `"))
426 (let ((beg (point)))
427 (insert (format "%s" parent-mode))
428 (make-text-button beg (point)
429 'type 'help-function
430 'help-args (list parent-mode)))
431 (insert (substitute-command-keys "'.\n")))))
432
433 (defun help-fns--obsolete (function)
434 ;; Ignore lambda constructs, keyboard macros, etc.
435 (let* ((obsolete (and (symbolp function)
436 (get function 'byte-obsolete-info)))
437 (use (car obsolete)))
438 (when obsolete
439 (insert "\nThis "
440 (if (eq (car-safe (symbol-function function)) 'macro)
441 "macro"
442 "function")
443 " is obsolete")
444 (when (nth 2 obsolete)
445 (insert (format " since %s" (nth 2 obsolete))))
446 (insert (cond ((stringp use) (concat ";\n" use))
447 (use (format-message ";\nuse `%s' instead." use))
448 (t "."))
449 "\n"))))
450
451 ;; We could use `symbol-file' but this is a wee bit more efficient.
452 (defun help-fns--autoloaded-p (function file)
453 "Return non-nil if FUNCTION has previously been autoloaded.
454 FILE is the file where FUNCTION was probably defined."
455 (let* ((file (file-name-sans-extension (file-truename file)))
456 (load-hist load-history)
457 (target (cons t function))
458 found)
459 (while (and load-hist (not found))
460 (and (caar load-hist)
461 (equal (file-name-sans-extension (caar load-hist)) file)
462 (setq found (member target (cdar load-hist))))
463 (setq load-hist (cdr load-hist)))
464 found))
465
466 (defun help-fns--interactive-only (function)
467 "Insert some help blurb if FUNCTION should only be used interactively."
468 ;; Ignore lambda constructs, keyboard macros, etc.
469 (and (symbolp function)
470 (not (eq (car-safe (symbol-function function)) 'macro))
471 (let* ((interactive-only
472 (or (get function 'interactive-only)
473 (if (boundp 'byte-compile-interactive-only-functions)
474 (memq function
475 byte-compile-interactive-only-functions)))))
476 (when interactive-only
477 (insert "\nThis function is for interactive use only"
478 ;; Cf byte-compile-form.
479 (cond ((stringp interactive-only)
480 (format ";\nin Lisp code %s" interactive-only))
481 ((and (symbolp 'interactive-only)
482 (not (eq interactive-only t)))
483 (format-message ";\nin Lisp code use `%s' instead."
484 interactive-only))
485 (t "."))
486 "\n")))))
487
488 (defun help-fns-short-filename (filename)
489 (let* ((abbrev (abbreviate-file-name filename))
490 (short abbrev))
491 (dolist (dir load-path)
492 (let ((rel (file-relative-name filename dir)))
493 (if (< (length rel) (length short))
494 (setq short rel)))
495 (let ((rel (file-relative-name abbrev dir)))
496 (if (< (length rel) (length short))
497 (setq short rel))))
498 short))
499
500 ;;;###autoload
501 (defun describe-function-1 (function)
502 (let* ((advised (and (symbolp function)
503 (featurep 'nadvice)
504 (advice--p (advice--symbol-function function))))
505 ;; If the function is advised, use the symbol that has the
506 ;; real definition, if that symbol is already set up.
507 (real-function
508 (or (and advised
509 (advice--cd*r (advice--symbol-function function)))
510 function))
511 ;; Get the real definition.
512 (def (if (symbolp real-function)
513 (or (symbol-function real-function)
514 (signal 'void-function (list real-function)))
515 real-function))
516 (aliased (or (symbolp def)
517 ;; Advised & aliased function.
518 (and advised (symbolp real-function))))
519 (real-def (cond
520 (aliased (let ((f real-function))
521 (while (and (fboundp f)
522 (symbolp (symbol-function f)))
523 (setq f (symbol-function f)))
524 f))
525 ((subrp def) (intern (subr-name def)))
526 (t def)))
527 (sig-key (if (subrp def)
528 (indirect-function real-def)
529 real-def))
530 (file-name (find-lisp-object-file-name function def))
531 (pt1 (with-current-buffer (help-buffer) (point)))
532 (beg (if (and (or (byte-code-function-p def)
533 (keymapp def)
534 (memq (car-safe def) '(macro lambda closure)))
535 (stringp file-name)
536 (help-fns--autoloaded-p function file-name))
537 (if (commandp def)
538 "an interactive autoloaded "
539 "an autoloaded ")
540 (if (commandp def) "an interactive " "a "))))
541
542 ;; Print what kind of function-like object FUNCTION is.
543 (princ (cond ((or (stringp def) (vectorp def))
544 "a keyboard macro")
545 ((subrp def)
546 (if (eq 'unevalled (cdr (subr-arity def)))
547 (concat beg "special form")
548 (concat beg "built-in function")))
549 ;; Aliases are Lisp functions, so we need to check
550 ;; aliases before functions.
551 (aliased
552 (format-message "an alias for `%s'" real-def))
553 ((autoloadp def)
554 (format "%s autoloaded %s"
555 (if (commandp def) "an interactive" "an")
556 (if (eq (nth 4 def) 'keymap) "keymap"
557 (if (nth 4 def) "Lisp macro" "Lisp function"))))
558 ((or (eq (car-safe def) 'macro)
559 ;; For advised macros, def is a lambda
560 ;; expression or a byte-code-function-p, so we
561 ;; need to check macros before functions.
562 (macrop function))
563 (concat beg "Lisp macro"))
564 ((byte-code-function-p def)
565 (concat beg "compiled Lisp function"))
566 ((eq (car-safe def) 'lambda)
567 (concat beg "Lisp function"))
568 ((eq (car-safe def) 'closure)
569 (concat beg "Lisp closure"))
570 ((keymapp def)
571 (let ((is-full nil)
572 (elts (cdr-safe def)))
573 (while elts
574 (if (char-table-p (car-safe elts))
575 (setq is-full t
576 elts nil))
577 (setq elts (cdr-safe elts)))
578 (concat beg (if is-full "keymap" "sparse keymap"))))
579 (t "")))
580
581 (if (and aliased (not (fboundp real-def)))
582 (princ ",\nwhich is not defined. Please make a bug report.")
583 (with-current-buffer standard-output
584 (save-excursion
585 (save-match-data
586 (when (re-search-backward (substitute-command-keys
587 "alias for `\\([^`']+\\)'")
588 nil t)
589 (help-xref-button 1 'help-function real-def)))))
590
591 (when file-name
592 ;; We used to add .el to the file name,
593 ;; but that's completely wrong when the user used load-file.
594 (princ (format-message " in `%s'"
595 (if (eq file-name 'C-source)
596 "C source code"
597 (help-fns-short-filename file-name))))
598 ;; Make a hyperlink to the library.
599 (with-current-buffer standard-output
600 (save-excursion
601 (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")
602 nil t)
603 (help-xref-button 1 'help-function-def function file-name))))
604 (princ ".")
605 (with-current-buffer (help-buffer)
606 (fill-region-as-paragraph (save-excursion (goto-char pt1) (forward-line 0) (point))
607 (point)))
608 (terpri)(terpri)
609
610 (let ((doc-raw (documentation function t))
611 (key-bindings-buffer (current-buffer)))
612
613 ;; If the function is autoloaded, and its docstring has
614 ;; key substitution constructs, load the library.
615 (and (autoloadp real-def) doc-raw
616 help-enable-auto-load
617 (string-match "\\([^\\]=\\|[^=]\\|\\`\\)\\\\[[{<]" doc-raw)
618 (autoload-do-load real-def))
619
620 (help-fns--key-bindings function)
621 (with-current-buffer standard-output
622 (let ((doc (help-fns--signature function doc-raw sig-key
623 real-function key-bindings-buffer)))
624 (run-hook-with-args 'help-fns-describe-function-functions function)
625 (insert "\n"
626 (or doc "Not documented."))
627 ;; Avoid asking the user annoying questions if she decides
628 ;; to save the help buffer, when her locale's codeset
629 ;; isn't UTF-8.
630 (unless (memq text-quoting-style '(straight grave))
631 (set-buffer-file-coding-system 'utf-8))))))))
632
633 ;; Add defaults to `help-fns-describe-function-functions'.
634 (add-hook 'help-fns-describe-function-functions #'help-fns--obsolete)
635 (add-hook 'help-fns-describe-function-functions #'help-fns--interactive-only)
636 (add-hook 'help-fns-describe-function-functions #'help-fns--parent-mode)
637 (add-hook 'help-fns-describe-function-functions #'help-fns--compiler-macro)
638
639 \f
640 ;; Variables
641
642 ;;;###autoload
643 (defun variable-at-point (&optional any-symbol)
644 "Return the bound variable symbol found at or before point.
645 Return 0 if there is no such symbol.
646 If ANY-SYMBOL is non-nil, don't insist the symbol be bound."
647 (with-syntax-table emacs-lisp-mode-syntax-table
648 (or (condition-case ()
649 (save-excursion
650 (skip-chars-forward "'")
651 (or (not (zerop (skip-syntax-backward "_w")))
652 (eq (char-syntax (following-char)) ?w)
653 (eq (char-syntax (following-char)) ?_)
654 (forward-sexp -1))
655 (skip-chars-forward "'")
656 (let ((obj (read (current-buffer))))
657 (and (symbolp obj) (boundp obj) obj)))
658 (error nil))
659 (let* ((str (find-tag-default))
660 (sym (if str (intern-soft str))))
661 (if (and sym (or any-symbol (boundp sym)))
662 sym
663 (save-match-data
664 (when (and str (string-match "\\`\\W*\\(.*?\\)\\W*\\'" str))
665 (setq sym (intern-soft (match-string 1 str)))
666 (and (or any-symbol (boundp sym)) sym)))))
667 0)))
668
669 (defun describe-variable-custom-version-info (variable)
670 (let ((custom-version (get variable 'custom-version))
671 (cpv (get variable 'custom-package-version))
672 (output nil))
673 (if custom-version
674 (setq output
675 (format "This variable was introduced, or its default value was changed, in\nversion %s of Emacs.\n"
676 custom-version))
677 (when cpv
678 (let* ((package (car-safe cpv))
679 (version (if (listp (cdr-safe cpv))
680 (car (cdr-safe cpv))
681 (cdr-safe cpv)))
682 (pkg-versions (assq package customize-package-emacs-version-alist))
683 (emacsv (cdr (assoc version pkg-versions))))
684 (if (and package version)
685 (setq output
686 (format (concat "This variable was introduced, or its default value was changed, in\nversion %s of the %s package"
687 (if emacsv
688 (format " that is part of Emacs %s" emacsv))
689 ".\n")
690 version package))))))
691 output))
692
693 ;;;###autoload
694 (defun describe-variable (variable &optional buffer frame)
695 "Display the full documentation of VARIABLE (a symbol).
696 Returns the documentation as a string, also.
697 If VARIABLE has a buffer-local value in BUFFER or FRAME
698 \(default to the current buffer and current frame),
699 it is displayed along with the global value."
700 (interactive
701 (let ((v (variable-at-point))
702 (enable-recursive-minibuffers t)
703 val)
704 (setq val (completing-read (if (symbolp v)
705 (format
706 "Describe variable (default %s): " v)
707 "Describe variable: ")
708 obarray
709 (lambda (vv)
710 (or (get vv 'variable-documentation)
711 (and (boundp vv) (not (keywordp vv)))))
712 t nil nil
713 (if (symbolp v) (symbol-name v))))
714 (list (if (equal val "")
715 v (intern val)))))
716 (let (file-name)
717 (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
718 (unless (frame-live-p frame) (setq frame (selected-frame)))
719 (if (not (symbolp variable))
720 (message "You did not specify a variable")
721 (save-excursion
722 (let ((valvoid (not (with-current-buffer buffer (boundp variable))))
723 (permanent-local (get variable 'permanent-local))
724 val val-start-pos locus)
725 ;; Extract the value before setting up the output buffer,
726 ;; in case `buffer' *is* the output buffer.
727 (unless valvoid
728 (with-selected-frame frame
729 (with-current-buffer buffer
730 (setq val (symbol-value variable)
731 locus (variable-binding-locus variable)))))
732 (help-setup-xref (list #'describe-variable variable buffer)
733 (called-interactively-p 'interactive))
734 (with-help-window (help-buffer)
735 (with-current-buffer buffer
736 (prin1 variable)
737 (setq file-name (find-lisp-object-file-name variable 'defvar))
738
739 (if file-name
740 (progn
741 (princ (format-message
742 " is a variable defined in `%s'.\n"
743 (if (eq file-name 'C-source)
744 "C source code"
745 (file-name-nondirectory file-name))))
746 (with-current-buffer standard-output
747 (save-excursion
748 (re-search-backward (substitute-command-keys
749 "`\\([^`']+\\)'")
750 nil t)
751 (help-xref-button 1 'help-variable-def
752 variable file-name)))
753 (if valvoid
754 (princ "It is void as a variable.")
755 (princ "Its ")))
756 (if valvoid
757 (princ " is void as a variable.")
758 (princ (substitute-command-keys "'s ")))))
759 (unless valvoid
760 (with-current-buffer standard-output
761 (setq val-start-pos (point))
762 (princ "value is ")
763 (let ((from (point))
764 (line-beg (line-beginning-position))
765 (print-rep
766 (let ((rep
767 (let ((print-quoted t))
768 (prin1-to-string val))))
769 (if (and (symbolp val) (not (booleanp val)))
770 (format-message "`%s'" rep)
771 rep))))
772 (if (< (+ (length print-rep) (point) (- line-beg)) 68)
773 (insert print-rep)
774 (terpri)
775 (pp val)
776 (if (< (point) (+ 68 (line-beginning-position 0)))
777 (delete-region from (1+ from))
778 (delete-region (1- from) from)))
779 (let* ((sv (get variable 'standard-value))
780 (origval (and (consp sv)
781 (condition-case nil
782 (eval (car sv))
783 (error :help-eval-error)))))
784 (when (and (consp sv)
785 (not (equal origval val))
786 (not (equal origval :help-eval-error)))
787 (princ "\nOriginal value was \n")
788 (setq from (point))
789 (pp origval)
790 (if (< (point) (+ from 20))
791 (delete-region (1- from) from)))))))
792 (terpri)
793 (when locus
794 (cond
795 ((bufferp locus)
796 (princ (format "Local in buffer %s; "
797 (buffer-name buffer))))
798 ((framep locus)
799 (princ (format "It is a frame-local variable; ")))
800 ((terminal-live-p locus)
801 (princ (format "It is a terminal-local variable; ")))
802 (t
803 (princ (format "It is local to %S" locus))))
804 (if (not (default-boundp variable))
805 (princ "globally void")
806 (let ((global-val (default-value variable)))
807 (with-current-buffer standard-output
808 (princ "global value is ")
809 (if (eq val global-val)
810 (princ "the same.")
811 (terpri)
812 ;; Fixme: pp can take an age if you happen to
813 ;; ask for a very large expression. We should
814 ;; probably print it raw once and check it's a
815 ;; sensible size before prettyprinting. -- fx
816 (let ((from (point)))
817 (pp global-val)
818 ;; See previous comment for this function.
819 ;; (help-xref-on-pp from (point))
820 (if (< (point) (+ from 20))
821 (delete-region (1- from) from)))))))
822 (terpri))
823
824 ;; If the value is large, move it to the end.
825 (with-current-buffer standard-output
826 (when (> (count-lines (point-min) (point-max)) 10)
827 ;; Note that setting the syntax table like below
828 ;; makes forward-sexp move over a `'s' at the end
829 ;; of a symbol.
830 (set-syntax-table emacs-lisp-mode-syntax-table)
831 (goto-char val-start-pos)
832 ;; The line below previously read as
833 ;; (delete-region (point) (progn (end-of-line) (point)))
834 ;; which suppressed display of the buffer local value for
835 ;; large values.
836 (when (looking-at "value is") (replace-match ""))
837 (save-excursion
838 (insert "\n\nValue:")
839 (set (make-local-variable 'help-button-cache)
840 (point-marker)))
841 (insert "value is shown ")
842 (insert-button "below"
843 'action help-button-cache
844 'follow-link t
845 'help-echo "mouse-2, RET: show value")
846 (insert ".\n")))
847 (terpri)
848
849 (let* ((alias (condition-case nil
850 (indirect-variable variable)
851 (error variable)))
852 (obsolete (get variable 'byte-obsolete-variable))
853 (use (car obsolete))
854 (safe-var (get variable 'safe-local-variable))
855 (doc (or (documentation-property
856 variable 'variable-documentation)
857 (documentation-property
858 alias 'variable-documentation)))
859 (extra-line nil))
860
861 ;; Mention if it's a local variable.
862 (cond
863 ((and (local-variable-if-set-p variable)
864 (or (not (local-variable-p variable))
865 (with-temp-buffer
866 (local-variable-if-set-p variable))))
867 (setq extra-line t)
868 (princ " Automatically becomes ")
869 (if permanent-local
870 (princ "permanently "))
871 (princ "buffer-local when set.\n"))
872 ((not permanent-local))
873 ((bufferp locus)
874 (setq extra-line t)
875 (princ
876 (substitute-command-keys
877 " This variable's buffer-local value is permanent.\n")))
878 (t
879 (setq extra-line t)
880 (princ (substitute-command-keys
881 " This variable's value is permanent \
882 if it is given a local binding.\n"))))
883
884 ;; Mention if it's an alias.
885 (unless (eq alias variable)
886 (setq extra-line t)
887 (princ (format-message
888 " This variable is an alias for `%s'.\n"
889 alias)))
890
891 (when obsolete
892 (setq extra-line t)
893 (princ " This variable is obsolete")
894 (if (nth 2 obsolete)
895 (princ (format " since %s" (nth 2 obsolete))))
896 (princ (cond ((stringp use) (concat ";\n " use))
897 (use (format-message ";\n use `%s' instead."
898 (car obsolete)))
899 (t ".")))
900 (terpri))
901
902 (when (member (cons variable val)
903 (with-current-buffer buffer
904 file-local-variables-alist))
905 (setq extra-line t)
906 (if (member (cons variable val)
907 (with-current-buffer buffer
908 dir-local-variables-alist))
909 (let ((file (and (buffer-file-name buffer)
910 (not (file-remote-p
911 (buffer-file-name buffer)))
912 (dir-locals-find-file
913 (buffer-file-name buffer))))
914 (is-directory nil))
915 (princ (substitute-command-keys
916 " This variable's value is directory-local"))
917 (when (consp file) ; result from cache
918 ;; If the cache element has an mtime, we
919 ;; assume it came from a file.
920 (if (nth 2 file)
921 (setq file (expand-file-name
922 dir-locals-file (car file)))
923 ;; Otherwise, assume it was set directly.
924 (setq file (car file)
925 is-directory t)))
926 (if (null file)
927 (princ ".\n")
928 (princ ", set ")
929 (let ((files (file-expand-wildcards file)))
930 (princ (substitute-command-keys
931 (cond
932 (is-directory "for the directory\n `")
933 ;; Many files matched.
934 ((cdr files)
935 (setq file (file-name-directory (car files)))
936 (format "by a file\n matching `%s' in the directory\n `"
937 dir-locals-file))
938 (t (setq file (car files))
939 "by the file\n `"))))
940 (with-current-buffer standard-output
941 (insert-text-button
942 file 'type 'help-dir-local-var-def
943 'help-args (list variable file))))
944 (princ (substitute-command-keys "'.\n"))))
945 (princ (substitute-command-keys
946 " This variable's value is file-local.\n"))))
947
948 (when (memq variable ignored-local-variables)
949 (setq extra-line t)
950 (princ " This variable is ignored as a file-local \
951 variable.\n"))
952
953 ;; Can be both risky and safe, eg auto-fill-function.
954 (when (risky-local-variable-p variable)
955 (setq extra-line t)
956 (princ " This variable may be risky if used as a \
957 file-local variable.\n")
958 (when (assq variable safe-local-variable-values)
959 (princ (substitute-command-keys
960 " However, you have added it to \
961 `safe-local-variable-values'.\n"))))
962
963 (when safe-var
964 (setq extra-line t)
965 (princ " This variable is safe as a file local variable ")
966 (princ "if its value\n satisfies the predicate ")
967 (princ (if (byte-code-function-p safe-var)
968 "which is a byte-compiled expression.\n"
969 (format-message "`%s'.\n" safe-var))))
970
971 (if extra-line (terpri))
972 (princ "Documentation:\n")
973 (with-current-buffer standard-output
974 (insert (or doc "Not documented as a variable."))))
975
976 ;; Make a link to customize if this variable can be customized.
977 (when (custom-variable-p variable)
978 (let ((customize-label "customize"))
979 (terpri)
980 (terpri)
981 (princ (concat "You can " customize-label " this variable."))
982 (with-current-buffer standard-output
983 (save-excursion
984 (re-search-backward
985 (concat "\\(" customize-label "\\)") nil t)
986 (help-xref-button 1 'help-customize-variable variable))))
987 ;; Note variable's version or package version.
988 (let ((output (describe-variable-custom-version-info variable)))
989 (when output
990 (terpri)
991 (terpri)
992 (princ output))))
993
994 (with-current-buffer standard-output
995 ;; Return the text we displayed.
996 (buffer-string))))))))
997
998
999 (defvar help-xref-stack-item)
1000
1001 ;;;###autoload
1002 (defun describe-symbol (symbol &optional buffer frame)
1003 "Display the full documentation of SYMBOL.
1004 Will show the info of SYMBOL as a function, variable, and/or face.
1005 Optional arguments BUFFER and FRAME specify for which buffer and
1006 frame to show the information about SYMBOL; they default to the
1007 current buffer and the selected frame, respectively."
1008 (interactive
1009 (let* ((v-or-f (symbol-at-point))
1010 (found (cl-some (lambda (x) (funcall (nth 1 x) v-or-f))
1011 describe-symbol-backends))
1012 (v-or-f (if found v-or-f (function-called-at-point)))
1013 (found (or found v-or-f))
1014 (enable-recursive-minibuffers t)
1015 (val (completing-read (if found
1016 (format
1017 "Describe symbol (default %s): " v-or-f)
1018 "Describe symbol: ")
1019 obarray
1020 (lambda (vv)
1021 (cl-some (lambda (x) (funcall (nth 1 x) vv))
1022 describe-symbol-backends))
1023 t nil nil
1024 (if found (symbol-name v-or-f)))))
1025 (list (if (equal val "")
1026 v-or-f (intern val)))))
1027 (if (not (symbolp symbol))
1028 (user-error "You didn't specify a function or variable"))
1029 (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
1030 (unless (frame-live-p frame) (setq frame (selected-frame)))
1031 (with-current-buffer (help-buffer)
1032 ;; Push the previous item on the stack before clobbering the output buffer.
1033 (help-setup-xref nil nil)
1034 (let* ((docs
1035 (nreverse
1036 (delq nil
1037 (mapcar (pcase-lambda (`(,name ,testfn ,descfn))
1038 (when (funcall testfn symbol)
1039 ;; Don't record the current entry in the stack.
1040 (setq help-xref-stack-item nil)
1041 (cons name
1042 (funcall descfn symbol buffer frame))))
1043 describe-symbol-backends))))
1044 (single (null (cdr docs))))
1045 (while (cdr docs)
1046 (goto-char (point-min))
1047 (let ((inhibit-read-only t)
1048 (name (caar docs)) ;Name of doc currently at BOB.
1049 (doc (cdr (cadr docs)))) ;Doc to add at BOB.
1050 (when doc
1051 (insert doc)
1052 (delete-region (point)
1053 (progn (skip-chars-backward " \t\n") (point)))
1054 (insert "\n\n"
1055 (eval-when-compile
1056 (propertize "\n" 'face '(:height 0.1 :inverse-video t)))
1057 "\n")
1058 (when name
1059 (insert (symbol-name symbol)
1060 " is also a " name "." "\n\n"))))
1061 (setq docs (cdr docs)))
1062 (unless single
1063 ;; Don't record the `describe-variable' item in the stack.
1064 (setq help-xref-stack-item nil)
1065 (help-setup-xref (list #'describe-symbol symbol) nil))
1066 (goto-char (point-min)))))
1067
1068 ;;;###autoload
1069 (defun describe-syntax (&optional buffer)
1070 "Describe the syntax specifications in the syntax table of BUFFER.
1071 The descriptions are inserted in a help buffer, which is then displayed.
1072 BUFFER defaults to the current buffer."
1073 (interactive)
1074 (setq buffer (or buffer (current-buffer)))
1075 (help-setup-xref (list #'describe-syntax buffer)
1076 (called-interactively-p 'interactive))
1077 (with-help-window (help-buffer)
1078 (let ((table (with-current-buffer buffer (syntax-table))))
1079 (with-current-buffer standard-output
1080 (describe-vector table 'internal-describe-syntax-value)
1081 (while (setq table (char-table-parent table))
1082 (insert "\nThe parent syntax table is:")
1083 (describe-vector table 'internal-describe-syntax-value))))))
1084
1085 (defun help-describe-category-set (value)
1086 (insert (cond
1087 ((null value) "default")
1088 ((char-table-p value) "deeper char-table ...")
1089 (t (condition-case nil
1090 (category-set-mnemonics value)
1091 (error "invalid"))))))
1092
1093 ;;;###autoload
1094 (defun describe-categories (&optional buffer)
1095 "Describe the category specifications in the current category table.
1096 The descriptions are inserted in a buffer, which is then displayed.
1097 If BUFFER is non-nil, then describe BUFFER's category table instead.
1098 BUFFER should be a buffer or a buffer name."
1099 (interactive)
1100 (setq buffer (or buffer (current-buffer)))
1101 (help-setup-xref (list #'describe-categories buffer)
1102 (called-interactively-p 'interactive))
1103 (with-help-window (help-buffer)
1104 (let* ((table (with-current-buffer buffer (category-table)))
1105 (docs (char-table-extra-slot table 0)))
1106 (if (or (not (vectorp docs)) (/= (length docs) 95))
1107 (error "Invalid first extra slot in this category table\n"))
1108 (with-current-buffer standard-output
1109 (insert "Legend of category mnemonics (see the tail for the longer description)\n")
1110 (let ((pos (point)) (items 0) lines n)
1111 (dotimes (i 95)
1112 (if (aref docs i) (setq items (1+ items))))
1113 (setq lines (1+ (/ (1- items) 4)))
1114 (setq n 0)
1115 (dotimes (i 95)
1116 (let ((elt (aref docs i)))
1117 (when elt
1118 (string-match ".*" elt)
1119 (setq elt (match-string 0 elt))
1120 (if (>= (length elt) 17)
1121 (setq elt (concat (substring elt 0 14) "...")))
1122 (if (< (point) (point-max))
1123 (move-to-column (* 20 (/ n lines)) t))
1124 (insert (+ i ?\s) ?: elt)
1125 (if (< (point) (point-max))
1126 (forward-line 1)
1127 (insert "\n"))
1128 (setq n (1+ n))
1129 (if (= (% n lines) 0)
1130 (goto-char pos))))))
1131 (goto-char (point-max))
1132 (insert "\n"
1133 "character(s)\tcategory mnemonics\n"
1134 "------------\t------------------")
1135 (describe-vector table 'help-describe-category-set)
1136 (insert "Legend of category mnemonics:\n")
1137 (dotimes (i 95)
1138 (let ((elt (aref docs i)))
1139 (when elt
1140 (if (string-match "\n" elt)
1141 (setq elt (substring elt (match-end 0))))
1142 (insert (+ i ?\s) ": " elt "\n"))))
1143 (while (setq table (char-table-parent table))
1144 (insert "\nThe parent category table is:")
1145 (describe-vector table 'help-describe-category-set))))))
1146
1147 \f
1148 ;;; Replacements for old lib-src/ programs. Don't seem especially useful.
1149
1150 ;; Replaces lib-src/digest-doc.c.
1151 ;;;###autoload
1152 (defun doc-file-to-man (file)
1153 "Produce an nroff buffer containing the doc-strings from the DOC file."
1154 (interactive (list (read-file-name "Name of DOC file: " doc-directory
1155 internal-doc-file-name t)))
1156 (or (file-readable-p file)
1157 (error "Cannot read file `%s'" file))
1158 (pop-to-buffer (generate-new-buffer "*man-doc*"))
1159 (setq buffer-undo-list t)
1160 (insert ".TH \"Command Summary for GNU Emacs\"\n"
1161 ".AU Richard M. Stallman\n")
1162 (insert-file-contents file)
1163 (let (notfirst)
1164 (while (search-forward "\1f" nil 'move)
1165 (if (looking-at "S")
1166 (delete-region (1- (point)) (line-end-position))
1167 (delete-char -1)
1168 (if notfirst
1169 (insert "\n.DE\n")
1170 (setq notfirst t))
1171 (insert "\n.SH ")
1172 (insert (if (looking-at "F") "Function " "Variable "))
1173 (delete-char 1)
1174 (forward-line 1)
1175 (insert ".DS L\n"))))
1176 (insert "\n.DE\n")
1177 (setq buffer-undo-list nil)
1178 (nroff-mode))
1179
1180 ;; Replaces lib-src/sorted-doc.c.
1181 ;;;###autoload
1182 (defun doc-file-to-info (file)
1183 "Produce a texinfo buffer with sorted doc-strings from the DOC file."
1184 (interactive (list (read-file-name "Name of DOC file: " doc-directory
1185 internal-doc-file-name t)))
1186 (or (file-readable-p file)
1187 (error "Cannot read file `%s'" file))
1188 (let ((i 0) type name doc alist)
1189 (with-temp-buffer
1190 (insert-file-contents file)
1191 ;; The characters "@{}" need special treatment.
1192 (while (re-search-forward "[@{}]" nil t)
1193 (backward-char)
1194 (insert "@")
1195 (forward-char 1))
1196 (goto-char (point-min))
1197 (while (search-forward "\1f" nil t)
1198 (unless (looking-at "S")
1199 (setq type (char-after)
1200 name (buffer-substring (1+ (point)) (line-end-position))
1201 doc (buffer-substring (line-beginning-position 2)
1202 (if (search-forward "\1f" nil 'move)
1203 (1- (point))
1204 (point)))
1205 alist (cons (list name type doc) alist))
1206 (backward-char 1))))
1207 (pop-to-buffer (generate-new-buffer "*info-doc*"))
1208 (setq buffer-undo-list t)
1209 ;; Write the output header.
1210 (insert "\\input texinfo @c -*-texinfo-*-\n"
1211 "@setfilename emacsdoc.info\n"
1212 "@settitle Command Summary for GNU Emacs\n"
1213 "@finalout\n"
1214 "\n@node Top\n"
1215 "@unnumbered Command Summary for GNU Emacs\n\n"
1216 "@table @asis\n\n"
1217 "@iftex\n"
1218 "@global@let@ITEM@item\n"
1219 "@def@item{@filbreak@vskip5pt@ITEM}\n"
1220 "@font@tensy cmsy10 scaled @magstephalf\n"
1221 "@font@teni cmmi10 scaled @magstephalf\n"
1222 "@def\\{{@tensy@char110}}\n" ; this backslash goes with cmr10
1223 "@def|{{@tensy@char106}}\n"
1224 "@def@{{{@tensy@char102}}\n"
1225 "@def@}{{@tensy@char103}}\n"
1226 "@def<{{@teni@char62}}\n"
1227 "@def>{{@teni@char60}}\n"
1228 "@chardef@@64\n"
1229 "@catcode43=12\n"
1230 "@tableindent-0.2in\n"
1231 "@end iftex\n")
1232 ;; Sort the array by name; within each name, by type (functions first).
1233 (setq alist (sort alist (lambda (e1 e2)
1234 (if (string-equal (car e1) (car e2))
1235 (<= (cadr e1) (cadr e2))
1236 (string-lessp (car e1) (car e2))))))
1237 ;; Print each function.
1238 (dolist (e alist)
1239 (insert "\n@item "
1240 (if (char-equal (cadr e) ?\F) "Function" "Variable")
1241 " @code{" (car e) "}\n@display\n"
1242 (nth 2 e)
1243 "\n@end display\n")
1244 ;; Try to avoid a save size overflow in the TeX output routine.
1245 (if (zerop (setq i (% (1+ i) 100)))
1246 (insert "\n@end table\n@table @asis\n")))
1247 (insert "@end table\n"
1248 "@bye\n")
1249 (setq buffer-undo-list nil)
1250 (texinfo-mode)))
1251
1252 (provide 'help-fns)
1253
1254 ;;; help-fns.el ends here