]> code.delx.au - gnu-emacs/blob - lisp/help-fns.el
* lisp/help-fns.el (describe-function-1): Avoid reporting advised
[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-2016 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 (src-file (locate-library file-name t nil 'readable)))
300 (and src-file (file-readable-p src-file) src-file))))))
301
302 (defun help-fns--key-bindings (function)
303 (when (commandp function)
304 (let ((pt2 (with-current-buffer standard-output (point)))
305 (remapped (command-remapping function)))
306 (unless (memq remapped '(ignore undefined))
307 (let ((keys (where-is-internal
308 (or remapped function) overriding-local-map nil nil))
309 non-modified-keys)
310 (if (and (eq function 'self-insert-command)
311 (vectorp (car-safe keys))
312 (consp (aref (car keys) 0)))
313 (princ "It is bound to many ordinary text characters.\n")
314 ;; Which non-control non-meta keys run this command?
315 (dolist (key keys)
316 (if (member (event-modifiers (aref key 0)) '(nil (shift)))
317 (push key non-modified-keys)))
318 (when remapped
319 (princ "Its keys are remapped to ")
320 (princ (if (symbolp remapped)
321 (format-message "`%s'" remapped)
322 "an anonymous command"))
323 (princ ".\n"))
324
325 (when keys
326 (princ (if remapped
327 "Without this remapping, it would be bound to "
328 "It is bound to "))
329 ;; If lots of ordinary text characters run this command,
330 ;; don't mention them one by one.
331 (if (< (length non-modified-keys) 10)
332 (princ (mapconcat 'key-description keys ", "))
333 (dolist (key non-modified-keys)
334 (setq keys (delq key keys)))
335 (if keys
336 (progn
337 (princ (mapconcat 'key-description keys ", "))
338 (princ ", and many ordinary text characters"))
339 (princ "many ordinary text characters"))))
340 (when (or remapped keys non-modified-keys)
341 (princ ".")
342 (terpri)))))
343
344 (with-current-buffer standard-output
345 (fill-region-as-paragraph pt2 (point))
346 (unless (looking-back "\n\n" (- (point) 2))
347 (terpri))))))
348
349 (defun help-fns--compiler-macro (function)
350 (let ((handler (function-get function 'compiler-macro)))
351 (when handler
352 (insert "\nThis function has a compiler macro")
353 (if (symbolp handler)
354 (progn
355 (insert (format-message " `%s'" handler))
356 (save-excursion
357 (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")
358 nil t)
359 (help-xref-button 1 'help-function handler)))
360 ;; FIXME: Obsolete since 24.4.
361 (let ((lib (get function 'compiler-macro-file)))
362 (when (stringp lib)
363 (insert (format-message " in `%s'" lib))
364 (save-excursion
365 (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")
366 nil t)
367 (help-xref-button 1 'help-function-cmacro function lib)))))
368 (insert ".\n"))))
369
370 (defun help-fns--signature (function doc real-def real-function buffer)
371 "Insert usage at point and return docstring. With highlighting."
372 (if (keymapp function)
373 doc ; If definition is a keymap, skip arglist note.
374 (let* ((advertised (gethash real-def advertised-signature-table t))
375 (arglist (if (listp advertised)
376 advertised (help-function-arglist real-def)))
377 (usage (help-split-fundoc doc function)))
378 (if usage (setq doc (cdr usage)))
379 (let* ((use (cond
380 ((and usage (not (listp advertised))) (car usage))
381 ((listp arglist)
382 (help--make-usage-docstring function arglist))
383 ((stringp arglist) arglist)
384 ;; Maybe the arglist is in the docstring of a symbol
385 ;; this one is aliased to.
386 ((let ((fun real-function))
387 (while (and (symbolp fun)
388 (setq fun (symbol-function fun))
389 (not (setq usage (help-split-fundoc
390 (documentation fun)
391 function)))))
392 usage)
393 (car usage))
394 ((or (stringp real-def)
395 (vectorp real-def))
396 (format "\nMacro: %s"
397 (help--docstring-quote
398 (format-kbd-macro real-def))))
399 (t "[Missing arglist. Please make a bug report.]")))
400 ;; Insert "`X", not "(\` X)", when documenting `X.
401 (use1 (replace-regexp-in-string
402 "\\`(\\\\=\\\\\\\\=` \\([^\n ]*\\))\\'"
403 "\\\\=`\\1" use t))
404 (high (if buffer
405 (let (subst-use1 subst-doc)
406 (with-current-buffer buffer
407 (setq subst-use1 (substitute-command-keys use1))
408 (setq subst-doc (substitute-command-keys doc)))
409 (help-highlight-arguments subst-use1 subst-doc))
410 (cons use1 doc))))
411 (let ((fill-begin (point))
412 (high-usage (car high))
413 (high-doc (cdr high)))
414 (insert high-usage "\n")
415 (fill-region fill-begin (point))
416 high-doc)))))
417
418 (defun help-fns--parent-mode (function)
419 ;; If this is a derived mode, link to the parent.
420 (let ((parent-mode (and (symbolp function)
421 (get function
422 'derived-mode-parent))))
423 (when parent-mode
424 (insert (substitute-command-keys "\nParent mode: `"))
425 (let ((beg (point)))
426 (insert (format "%s" parent-mode))
427 (make-text-button beg (point)
428 'type 'help-function
429 'help-args (list parent-mode)))
430 (insert (substitute-command-keys "'.\n")))))
431
432 (defun help-fns--obsolete (function)
433 ;; Ignore lambda constructs, keyboard macros, etc.
434 (let* ((obsolete (and (symbolp function)
435 (get function 'byte-obsolete-info)))
436 (use (car obsolete)))
437 (when obsolete
438 (insert "\nThis "
439 (if (eq (car-safe (symbol-function function)) 'macro)
440 "macro"
441 "function")
442 " is obsolete")
443 (when (nth 2 obsolete)
444 (insert (format " since %s" (nth 2 obsolete))))
445 (insert (cond ((stringp use) (concat ";\n" use))
446 (use (format-message ";\nuse `%s' instead." use))
447 (t "."))
448 "\n"))))
449
450 ;; We could use `symbol-file' but this is a wee bit more efficient.
451 (defun help-fns--autoloaded-p (function file)
452 "Return non-nil if FUNCTION has previously been autoloaded.
453 FILE is the file where FUNCTION was probably defined."
454 (let* ((file (file-name-sans-extension (file-truename file)))
455 (load-hist load-history)
456 (target (cons t function))
457 found)
458 (while (and load-hist (not found))
459 (and (caar load-hist)
460 (equal (file-name-sans-extension (caar load-hist)) file)
461 (setq found (member target (cdar load-hist))))
462 (setq load-hist (cdr load-hist)))
463 found))
464
465 (defun help-fns--interactive-only (function)
466 "Insert some help blurb if FUNCTION should only be used interactively."
467 ;; Ignore lambda constructs, keyboard macros, etc.
468 (and (symbolp function)
469 (not (eq (car-safe (symbol-function function)) 'macro))
470 (let* ((interactive-only
471 (or (get function 'interactive-only)
472 (if (boundp 'byte-compile-interactive-only-functions)
473 (memq function
474 byte-compile-interactive-only-functions)))))
475 (when interactive-only
476 (insert "\nThis function is for interactive use only"
477 ;; Cf byte-compile-form.
478 (cond ((stringp interactive-only)
479 (format ";\nin Lisp code %s" interactive-only))
480 ((and (symbolp 'interactive-only)
481 (not (eq interactive-only t)))
482 (format-message ";\nin Lisp code use `%s' instead."
483 interactive-only))
484 (t "."))
485 "\n")))))
486
487 (defun help-fns-short-filename (filename)
488 (let* ((abbrev (abbreviate-file-name filename))
489 (short abbrev))
490 (dolist (dir load-path)
491 (let ((rel (file-relative-name filename dir)))
492 (if (< (length rel) (length short))
493 (setq short rel)))
494 (let ((rel (file-relative-name abbrev dir)))
495 (if (< (length rel) (length short))
496 (setq short rel))))
497 short))
498
499 ;;;###autoload
500 (defun describe-function-1 (function)
501 (let* ((advised (and (symbolp function)
502 (featurep 'nadvice)
503 (advice--p (advice--symbol-function function))))
504 ;; If the function is advised, use the symbol that has the
505 ;; real definition, if that symbol is already set up.
506 (real-function
507 (or (and advised
508 (advice--cd*r (advice--symbol-function function)))
509 function))
510 ;; Get the real definition.
511 (def (if (symbolp real-function)
512 (or (symbol-function real-function)
513 (signal 'void-function (list real-function)))
514 real-function))
515 (aliased (or (symbolp def)
516 ;; Advised & aliased function.
517 (and advised (symbolp real-function)
518 (not (eq 'autoload (car-safe def))))))
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 (if aliased 'defun
531 def)))
532 (pt1 (with-current-buffer (help-buffer) (point)))
533 (beg (if (and (or (byte-code-function-p def)
534 (keymapp def)
535 (memq (car-safe def) '(macro lambda closure)))
536 (stringp file-name)
537 (help-fns--autoloaded-p function file-name))
538 (if (commandp def)
539 "an interactive autoloaded "
540 "an autoloaded ")
541 (if (commandp def) "an interactive " "a "))))
542
543 ;; Print what kind of function-like object FUNCTION is.
544 (princ (cond ((or (stringp def) (vectorp def))
545 "a keyboard macro")
546 ((subrp def)
547 (if (eq 'unevalled (cdr (subr-arity def)))
548 (concat beg "special form")
549 (concat beg "built-in function")))
550 ;; Aliases are Lisp functions, so we need to check
551 ;; aliases before functions.
552 (aliased
553 (format-message "an alias for `%s'" real-def))
554 ((autoloadp def)
555 (format "%s autoloaded %s"
556 (if (commandp def) "an interactive" "an")
557 (if (eq (nth 4 def) 'keymap) "keymap"
558 (if (nth 4 def) "Lisp macro" "Lisp function"))))
559 ((or (eq (car-safe def) 'macro)
560 ;; For advised macros, def is a lambda
561 ;; expression or a byte-code-function-p, so we
562 ;; need to check macros before functions.
563 (macrop function))
564 (concat beg "Lisp macro"))
565 ((byte-code-function-p def)
566 (concat beg "compiled Lisp function"))
567 ((eq (car-safe def) 'lambda)
568 (concat beg "Lisp function"))
569 ((eq (car-safe def) 'closure)
570 (concat beg "Lisp closure"))
571 ((keymapp def)
572 (let ((is-full nil)
573 (elts (cdr-safe def)))
574 (while elts
575 (if (char-table-p (car-safe elts))
576 (setq is-full t
577 elts nil))
578 (setq elts (cdr-safe elts)))
579 (concat beg (if is-full "keymap" "sparse keymap"))))
580 (t "")))
581
582 (if (and aliased (not (fboundp real-def)))
583 (princ ",\nwhich is not defined. Please make a bug report.")
584 (with-current-buffer standard-output
585 (save-excursion
586 (save-match-data
587 (when (re-search-backward (substitute-command-keys
588 "alias for `\\([^`']+\\)'")
589 nil t)
590 (help-xref-button 1 'help-function real-def)))))
591
592 (when file-name
593 ;; We used to add .el to the file name,
594 ;; but that's completely wrong when the user used load-file.
595 (princ (format-message " in `%s'"
596 (if (eq file-name 'C-source)
597 "C source code"
598 (help-fns-short-filename file-name))))
599 ;; Make a hyperlink to the library.
600 (with-current-buffer standard-output
601 (save-excursion
602 (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")
603 nil t)
604 (help-xref-button 1 'help-function-def function file-name))))
605 (princ ".")
606 (with-current-buffer (help-buffer)
607 (fill-region-as-paragraph (save-excursion (goto-char pt1) (forward-line 0) (point))
608 (point)))
609 (terpri)(terpri)
610
611 (let ((doc-raw (documentation function t))
612 (key-bindings-buffer (current-buffer)))
613
614 ;; If the function is autoloaded, and its docstring has
615 ;; key substitution constructs, load the library.
616 (and (autoloadp real-def) doc-raw
617 help-enable-auto-load
618 (string-match "\\([^\\]=\\|[^=]\\|\\`\\)\\\\[[{<]" doc-raw)
619 (autoload-do-load real-def))
620
621 (help-fns--key-bindings function)
622 (with-current-buffer standard-output
623 (let ((doc (help-fns--signature function doc-raw sig-key
624 real-function key-bindings-buffer)))
625 (run-hook-with-args 'help-fns-describe-function-functions function)
626 (insert "\n"
627 (or doc "Not documented."))
628 ;; Avoid asking the user annoying questions if she decides
629 ;; to save the help buffer, when her locale's codeset
630 ;; isn't UTF-8.
631 (unless (memq text-quoting-style '(straight grave))
632 (set-buffer-file-coding-system 'utf-8))))))))
633
634 ;; Add defaults to `help-fns-describe-function-functions'.
635 (add-hook 'help-fns-describe-function-functions #'help-fns--obsolete)
636 (add-hook 'help-fns-describe-function-functions #'help-fns--interactive-only)
637 (add-hook 'help-fns-describe-function-functions #'help-fns--parent-mode)
638 (add-hook 'help-fns-describe-function-functions #'help-fns--compiler-macro)
639
640 \f
641 ;; Variables
642
643 ;;;###autoload
644 (defun variable-at-point (&optional any-symbol)
645 "Return the bound variable symbol found at or before point.
646 Return 0 if there is no such symbol.
647 If ANY-SYMBOL is non-nil, don't insist the symbol be bound."
648 (with-syntax-table emacs-lisp-mode-syntax-table
649 (or (condition-case ()
650 (save-excursion
651 (skip-chars-forward "'")
652 (or (not (zerop (skip-syntax-backward "_w")))
653 (eq (char-syntax (following-char)) ?w)
654 (eq (char-syntax (following-char)) ?_)
655 (forward-sexp -1))
656 (skip-chars-forward "'")
657 (let ((obj (read (current-buffer))))
658 (and (symbolp obj) (boundp obj) obj)))
659 (error nil))
660 (let* ((str (find-tag-default))
661 (sym (if str (intern-soft str))))
662 (if (and sym (or any-symbol (boundp sym)))
663 sym
664 (save-match-data
665 (when (and str (string-match "\\`\\W*\\(.*?\\)\\W*\\'" str))
666 (setq sym (intern-soft (match-string 1 str)))
667 (and (or any-symbol (boundp sym)) sym)))))
668 0)))
669
670 (defun describe-variable-custom-version-info (variable)
671 (let ((custom-version (get variable 'custom-version))
672 (cpv (get variable 'custom-package-version))
673 (output nil))
674 (if custom-version
675 (setq output
676 (format "This variable was introduced, or its default value was changed, in\nversion %s of Emacs.\n"
677 custom-version))
678 (when cpv
679 (let* ((package (car-safe cpv))
680 (version (if (listp (cdr-safe cpv))
681 (car (cdr-safe cpv))
682 (cdr-safe cpv)))
683 (pkg-versions (assq package customize-package-emacs-version-alist))
684 (emacsv (cdr (assoc version pkg-versions))))
685 (if (and package version)
686 (setq output
687 (format (concat "This variable was introduced, or its default value was changed, in\nversion %s of the %s package"
688 (if emacsv
689 (format " that is part of Emacs %s" emacsv))
690 ".\n")
691 version package))))))
692 output))
693
694 ;;;###autoload
695 (defun describe-variable (variable &optional buffer frame)
696 "Display the full documentation of VARIABLE (a symbol).
697 Returns the documentation as a string, also.
698 If VARIABLE has a buffer-local value in BUFFER or FRAME
699 \(default to the current buffer and current frame),
700 it is displayed along with the global value."
701 (interactive
702 (let ((v (variable-at-point))
703 (enable-recursive-minibuffers t)
704 val)
705 (setq val (completing-read (if (symbolp v)
706 (format
707 "Describe variable (default %s): " v)
708 "Describe variable: ")
709 obarray
710 (lambda (vv)
711 (or (get vv 'variable-documentation)
712 (and (boundp vv) (not (keywordp vv)))))
713 t nil nil
714 (if (symbolp v) (symbol-name v))))
715 (list (if (equal val "")
716 v (intern val)))))
717 (let (file-name)
718 (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
719 (unless (frame-live-p frame) (setq frame (selected-frame)))
720 (if (not (symbolp variable))
721 (message "You did not specify a variable")
722 (save-excursion
723 (let ((valvoid (not (with-current-buffer buffer (boundp variable))))
724 (permanent-local (get variable 'permanent-local))
725 val val-start-pos locus)
726 ;; Extract the value before setting up the output buffer,
727 ;; in case `buffer' *is* the output buffer.
728 (unless valvoid
729 (with-selected-frame frame
730 (with-current-buffer buffer
731 (setq val (symbol-value variable)
732 locus (variable-binding-locus variable)))))
733 (help-setup-xref (list #'describe-variable variable buffer)
734 (called-interactively-p 'interactive))
735 (with-help-window (help-buffer)
736 (with-current-buffer buffer
737 (prin1 variable)
738 (setq file-name (find-lisp-object-file-name variable 'defvar))
739
740 (if file-name
741 (progn
742 (princ (format-message
743 " is a variable defined in `%s'.\n"
744 (if (eq file-name 'C-source)
745 "C source code"
746 (file-name-nondirectory file-name))))
747 (with-current-buffer standard-output
748 (save-excursion
749 (re-search-backward (substitute-command-keys
750 "`\\([^`']+\\)'")
751 nil t)
752 (help-xref-button 1 'help-variable-def
753 variable file-name)))
754 (if valvoid
755 (princ "It is void as a variable.")
756 (princ "Its ")))
757 (if valvoid
758 (princ " is void as a variable.")
759 (princ (substitute-command-keys "'s ")))))
760 (unless valvoid
761 (with-current-buffer standard-output
762 (setq val-start-pos (point))
763 (princ "value is ")
764 (let ((from (point))
765 (line-beg (line-beginning-position))
766 (print-rep
767 (let ((rep
768 (let ((print-quoted t))
769 (prin1-to-string val))))
770 (if (and (symbolp val) (not (booleanp val)))
771 (format-message "`%s'" rep)
772 rep))))
773 (if (< (+ (length print-rep) (point) (- line-beg)) 68)
774 (insert print-rep)
775 (terpri)
776 (pp val)
777 (if (< (point) (+ 68 (line-beginning-position 0)))
778 (delete-region from (1+ from))
779 (delete-region (1- from) from)))
780 (let* ((sv (get variable 'standard-value))
781 (origval (and (consp sv)
782 (condition-case nil
783 (eval (car sv))
784 (error :help-eval-error)))))
785 (when (and (consp sv)
786 (not (equal origval val))
787 (not (equal origval :help-eval-error)))
788 (princ "\nOriginal value was \n")
789 (setq from (point))
790 (pp origval)
791 (if (< (point) (+ from 20))
792 (delete-region (1- from) from)))))))
793 (terpri)
794 (when locus
795 (cond
796 ((bufferp locus)
797 (princ (format "Local in buffer %s; "
798 (buffer-name buffer))))
799 ((framep locus)
800 (princ (format "It is a frame-local variable; ")))
801 ((terminal-live-p locus)
802 (princ (format "It is a terminal-local variable; ")))
803 (t
804 (princ (format "It is local to %S" locus))))
805 (if (not (default-boundp variable))
806 (princ "globally void")
807 (let ((global-val (default-value variable)))
808 (with-current-buffer standard-output
809 (princ "global value is ")
810 (if (eq val global-val)
811 (princ "the same.")
812 (terpri)
813 ;; Fixme: pp can take an age if you happen to
814 ;; ask for a very large expression. We should
815 ;; probably print it raw once and check it's a
816 ;; sensible size before prettyprinting. -- fx
817 (let ((from (point)))
818 (pp global-val)
819 ;; See previous comment for this function.
820 ;; (help-xref-on-pp from (point))
821 (if (< (point) (+ from 20))
822 (delete-region (1- from) from)))))))
823 (terpri))
824
825 ;; If the value is large, move it to the end.
826 (with-current-buffer standard-output
827 (when (> (count-lines (point-min) (point-max)) 10)
828 ;; Note that setting the syntax table like below
829 ;; makes forward-sexp move over a `'s' at the end
830 ;; of a symbol.
831 (set-syntax-table emacs-lisp-mode-syntax-table)
832 (goto-char val-start-pos)
833 ;; The line below previously read as
834 ;; (delete-region (point) (progn (end-of-line) (point)))
835 ;; which suppressed display of the buffer local value for
836 ;; large values.
837 (when (looking-at "value is") (replace-match ""))
838 (save-excursion
839 (insert "\n\nValue:")
840 (set (make-local-variable 'help-button-cache)
841 (point-marker)))
842 (insert "value is shown ")
843 (insert-button "below"
844 'action help-button-cache
845 'follow-link t
846 'help-echo "mouse-2, RET: show value")
847 (insert ".\n")))
848 (terpri)
849
850 (let* ((alias (condition-case nil
851 (indirect-variable variable)
852 (error variable)))
853 (obsolete (get variable 'byte-obsolete-variable))
854 (use (car obsolete))
855 (safe-var (get variable 'safe-local-variable))
856 (doc (or (documentation-property
857 variable 'variable-documentation)
858 (documentation-property
859 alias 'variable-documentation)))
860 (extra-line nil))
861
862 ;; Mention if it's a local variable.
863 (cond
864 ((and (local-variable-if-set-p variable)
865 (or (not (local-variable-p variable))
866 (with-temp-buffer
867 (local-variable-if-set-p variable))))
868 (setq extra-line t)
869 (princ " Automatically becomes ")
870 (if permanent-local
871 (princ "permanently "))
872 (princ "buffer-local when set.\n"))
873 ((not permanent-local))
874 ((bufferp locus)
875 (setq extra-line t)
876 (princ
877 (substitute-command-keys
878 " This variable's buffer-local value is permanent.\n")))
879 (t
880 (setq extra-line t)
881 (princ (substitute-command-keys
882 " This variable's value is permanent \
883 if it is given a local binding.\n"))))
884
885 ;; Mention if it's an alias.
886 (unless (eq alias variable)
887 (setq extra-line t)
888 (princ (format-message
889 " This variable is an alias for `%s'.\n"
890 alias)))
891
892 (when obsolete
893 (setq extra-line t)
894 (princ " This variable is obsolete")
895 (if (nth 2 obsolete)
896 (princ (format " since %s" (nth 2 obsolete))))
897 (princ (cond ((stringp use) (concat ";\n " use))
898 (use (format-message ";\n use `%s' instead."
899 (car obsolete)))
900 (t ".")))
901 (terpri))
902
903 (when (member (cons variable val)
904 (with-current-buffer buffer
905 file-local-variables-alist))
906 (setq extra-line t)
907 (if (member (cons variable val)
908 (with-current-buffer buffer
909 dir-local-variables-alist))
910 (let ((file (and (buffer-file-name buffer)
911 (not (file-remote-p
912 (buffer-file-name buffer)))
913 (dir-locals-find-file
914 (buffer-file-name buffer))))
915 (dir-file t))
916 (princ (substitute-command-keys
917 " This variable's value is directory-local"))
918 (if (null file)
919 (princ ".\n")
920 (princ ", set ")
921 (if (consp file) ; result from cache
922 ;; If the cache element has an mtime, we
923 ;; assume it came from a file.
924 (if (nth 2 file)
925 (setq file (expand-file-name
926 dir-locals-file (car file)))
927 ;; Otherwise, assume it was set directly.
928 (setq file (car file)
929 dir-file nil)))
930 (princ (substitute-command-keys
931 (if dir-file
932 "by the file\n `"
933 "for the directory\n `")))
934 (with-current-buffer standard-output
935 (insert-text-button
936 file 'type 'help-dir-local-var-def
937 'help-args (list variable file)))
938 (princ (substitute-command-keys "'.\n"))))
939 (princ (substitute-command-keys
940 " This variable's value is file-local.\n"))))
941
942 (when (memq variable ignored-local-variables)
943 (setq extra-line t)
944 (princ " This variable is ignored as a file-local \
945 variable.\n"))
946
947 ;; Can be both risky and safe, eg auto-fill-function.
948 (when (risky-local-variable-p variable)
949 (setq extra-line t)
950 (princ " This variable may be risky if used as a \
951 file-local variable.\n")
952 (when (assq variable safe-local-variable-values)
953 (princ (substitute-command-keys
954 " However, you have added it to \
955 `safe-local-variable-values'.\n"))))
956
957 (when safe-var
958 (setq extra-line t)
959 (princ " This variable is safe as a file local variable ")
960 (princ "if its value\n satisfies the predicate ")
961 (princ (if (byte-code-function-p safe-var)
962 "which is a byte-compiled expression.\n"
963 (format-message "`%s'.\n" safe-var))))
964
965 (if extra-line (terpri))
966 (princ "Documentation:\n")
967 (with-current-buffer standard-output
968 (insert (or doc "Not documented as a variable."))))
969
970 ;; Make a link to customize if this variable can be customized.
971 (when (custom-variable-p variable)
972 (let ((customize-label "customize"))
973 (terpri)
974 (terpri)
975 (princ (concat "You can " customize-label " this variable."))
976 (with-current-buffer standard-output
977 (save-excursion
978 (re-search-backward
979 (concat "\\(" customize-label "\\)") nil t)
980 (help-xref-button 1 'help-customize-variable variable))))
981 ;; Note variable's version or package version.
982 (let ((output (describe-variable-custom-version-info variable)))
983 (when output
984 (terpri)
985 (terpri)
986 (princ output))))
987
988 (with-current-buffer standard-output
989 ;; Return the text we displayed.
990 (buffer-string))))))))
991
992
993 (defvar help-xref-stack-item)
994
995 ;;;###autoload
996 (defun describe-symbol (symbol &optional buffer frame)
997 "Display the full documentation of SYMBOL.
998 Will show the info of SYMBOL as a function, variable, and/or face.
999 Optional arguments BUFFER and FRAME specify for which buffer and
1000 frame to show the information about SYMBOL; they default to the
1001 current buffer and the selected frame, respectively."
1002 (interactive
1003 (let* ((v-or-f (symbol-at-point))
1004 (found (cl-some (lambda (x) (funcall (nth 1 x) v-or-f))
1005 describe-symbol-backends))
1006 (v-or-f (if found v-or-f (function-called-at-point)))
1007 (found (or found v-or-f))
1008 (enable-recursive-minibuffers t)
1009 (val (completing-read (if found
1010 (format
1011 "Describe symbol (default %s): " v-or-f)
1012 "Describe symbol: ")
1013 obarray
1014 (lambda (vv)
1015 (cl-some (lambda (x) (funcall (nth 1 x) vv))
1016 describe-symbol-backends))
1017 t nil nil
1018 (if found (symbol-name v-or-f)))))
1019 (list (if (equal val "")
1020 v-or-f (intern val)))))
1021 (if (not (symbolp symbol))
1022 (user-error "You didn't specify a function or variable"))
1023 (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
1024 (unless (frame-live-p frame) (setq frame (selected-frame)))
1025 (with-current-buffer (help-buffer)
1026 ;; Push the previous item on the stack before clobbering the output buffer.
1027 (help-setup-xref nil nil)
1028 (let* ((docs
1029 (nreverse
1030 (delq nil
1031 (mapcar (pcase-lambda (`(,name ,testfn ,descfn))
1032 (when (funcall testfn symbol)
1033 ;; Don't record the current entry in the stack.
1034 (setq help-xref-stack-item nil)
1035 (cons name
1036 (funcall descfn symbol buffer frame))))
1037 describe-symbol-backends))))
1038 (single (null (cdr docs))))
1039 (while (cdr docs)
1040 (goto-char (point-min))
1041 (let ((inhibit-read-only t)
1042 (name (caar docs)) ;Name of doc currently at BOB.
1043 (doc (cdr (cadr docs)))) ;Doc to add at BOB.
1044 (when doc
1045 (insert doc)
1046 (delete-region (point)
1047 (progn (skip-chars-backward " \t\n") (point)))
1048 (insert "\n\n"
1049 (eval-when-compile
1050 (propertize "\n" 'face '(:height 0.1 :inverse-video t)))
1051 "\n")
1052 (when name
1053 (insert (symbol-name symbol)
1054 " is also a " name "." "\n\n"))))
1055 (setq docs (cdr docs)))
1056 (unless single
1057 ;; Don't record the `describe-variable' item in the stack.
1058 (setq help-xref-stack-item nil)
1059 (help-setup-xref (list #'describe-symbol symbol) nil))
1060 (goto-char (point-min)))))
1061
1062 ;;;###autoload
1063 (defun describe-syntax (&optional buffer)
1064 "Describe the syntax specifications in the syntax table of BUFFER.
1065 The descriptions are inserted in a help buffer, which is then displayed.
1066 BUFFER defaults to the current buffer."
1067 (interactive)
1068 (setq buffer (or buffer (current-buffer)))
1069 (help-setup-xref (list #'describe-syntax buffer)
1070 (called-interactively-p 'interactive))
1071 (with-help-window (help-buffer)
1072 (let ((table (with-current-buffer buffer (syntax-table))))
1073 (with-current-buffer standard-output
1074 (describe-vector table 'internal-describe-syntax-value)
1075 (while (setq table (char-table-parent table))
1076 (insert "\nThe parent syntax table is:")
1077 (describe-vector table 'internal-describe-syntax-value))))))
1078
1079 (defun help-describe-category-set (value)
1080 (insert (cond
1081 ((null value) "default")
1082 ((char-table-p value) "deeper char-table ...")
1083 (t (condition-case nil
1084 (category-set-mnemonics value)
1085 (error "invalid"))))))
1086
1087 ;;;###autoload
1088 (defun describe-categories (&optional buffer)
1089 "Describe the category specifications in the current category table.
1090 The descriptions are inserted in a buffer, which is then displayed.
1091 If BUFFER is non-nil, then describe BUFFER's category table instead.
1092 BUFFER should be a buffer or a buffer name."
1093 (interactive)
1094 (setq buffer (or buffer (current-buffer)))
1095 (help-setup-xref (list #'describe-categories buffer)
1096 (called-interactively-p 'interactive))
1097 (with-help-window (help-buffer)
1098 (let* ((table (with-current-buffer buffer (category-table)))
1099 (docs (char-table-extra-slot table 0)))
1100 (if (or (not (vectorp docs)) (/= (length docs) 95))
1101 (error "Invalid first extra slot in this category table\n"))
1102 (with-current-buffer standard-output
1103 (insert "Legend of category mnemonics (see the tail for the longer description)\n")
1104 (let ((pos (point)) (items 0) lines n)
1105 (dotimes (i 95)
1106 (if (aref docs i) (setq items (1+ items))))
1107 (setq lines (1+ (/ (1- items) 4)))
1108 (setq n 0)
1109 (dotimes (i 95)
1110 (let ((elt (aref docs i)))
1111 (when elt
1112 (string-match ".*" elt)
1113 (setq elt (match-string 0 elt))
1114 (if (>= (length elt) 17)
1115 (setq elt (concat (substring elt 0 14) "...")))
1116 (if (< (point) (point-max))
1117 (move-to-column (* 20 (/ n lines)) t))
1118 (insert (+ i ?\s) ?: elt)
1119 (if (< (point) (point-max))
1120 (forward-line 1)
1121 (insert "\n"))
1122 (setq n (1+ n))
1123 (if (= (% n lines) 0)
1124 (goto-char pos))))))
1125 (goto-char (point-max))
1126 (insert "\n"
1127 "character(s)\tcategory mnemonics\n"
1128 "------------\t------------------")
1129 (describe-vector table 'help-describe-category-set)
1130 (insert "Legend of category mnemonics:\n")
1131 (dotimes (i 95)
1132 (let ((elt (aref docs i)))
1133 (when elt
1134 (if (string-match "\n" elt)
1135 (setq elt (substring elt (match-end 0))))
1136 (insert (+ i ?\s) ": " elt "\n"))))
1137 (while (setq table (char-table-parent table))
1138 (insert "\nThe parent category table is:")
1139 (describe-vector table 'help-describe-category-set))))))
1140
1141 \f
1142 ;;; Replacements for old lib-src/ programs. Don't seem especially useful.
1143
1144 ;; Replaces lib-src/digest-doc.c.
1145 ;;;###autoload
1146 (defun doc-file-to-man (file)
1147 "Produce an nroff buffer containing the doc-strings from the DOC file."
1148 (interactive (list (read-file-name "Name of DOC file: " doc-directory
1149 internal-doc-file-name t)))
1150 (or (file-readable-p file)
1151 (error "Cannot read file `%s'" file))
1152 (pop-to-buffer (generate-new-buffer "*man-doc*"))
1153 (setq buffer-undo-list t)
1154 (insert ".TH \"Command Summary for GNU Emacs\"\n"
1155 ".AU Richard M. Stallman\n")
1156 (insert-file-contents file)
1157 (let (notfirst)
1158 (while (search-forward "\1f" nil 'move)
1159 (if (looking-at "S")
1160 (delete-region (1- (point)) (line-end-position))
1161 (delete-char -1)
1162 (if notfirst
1163 (insert "\n.DE\n")
1164 (setq notfirst t))
1165 (insert "\n.SH ")
1166 (insert (if (looking-at "F") "Function " "Variable "))
1167 (delete-char 1)
1168 (forward-line 1)
1169 (insert ".DS L\n"))))
1170 (insert "\n.DE\n")
1171 (setq buffer-undo-list nil)
1172 (nroff-mode))
1173
1174 ;; Replaces lib-src/sorted-doc.c.
1175 ;;;###autoload
1176 (defun doc-file-to-info (file)
1177 "Produce a texinfo buffer with sorted doc-strings from the DOC file."
1178 (interactive (list (read-file-name "Name of DOC file: " doc-directory
1179 internal-doc-file-name t)))
1180 (or (file-readable-p file)
1181 (error "Cannot read file `%s'" file))
1182 (let ((i 0) type name doc alist)
1183 (with-temp-buffer
1184 (insert-file-contents file)
1185 ;; The characters "@{}" need special treatment.
1186 (while (re-search-forward "[@{}]" nil t)
1187 (backward-char)
1188 (insert "@")
1189 (forward-char 1))
1190 (goto-char (point-min))
1191 (while (search-forward "\1f" nil t)
1192 (unless (looking-at "S")
1193 (setq type (char-after)
1194 name (buffer-substring (1+ (point)) (line-end-position))
1195 doc (buffer-substring (line-beginning-position 2)
1196 (if (search-forward "\1f" nil 'move)
1197 (1- (point))
1198 (point)))
1199 alist (cons (list name type doc) alist))
1200 (backward-char 1))))
1201 (pop-to-buffer (generate-new-buffer "*info-doc*"))
1202 (setq buffer-undo-list t)
1203 ;; Write the output header.
1204 (insert "\\input texinfo @c -*-texinfo-*-\n"
1205 "@setfilename emacsdoc.info\n"
1206 "@settitle Command Summary for GNU Emacs\n"
1207 "@finalout\n"
1208 "\n@node Top\n"
1209 "@unnumbered Command Summary for GNU Emacs\n\n"
1210 "@table @asis\n\n"
1211 "@iftex\n"
1212 "@global@let@ITEM@item\n"
1213 "@def@item{@filbreak@vskip5pt@ITEM}\n"
1214 "@font@tensy cmsy10 scaled @magstephalf\n"
1215 "@font@teni cmmi10 scaled @magstephalf\n"
1216 "@def\\{{@tensy@char110}}\n" ; this backslash goes with cmr10
1217 "@def|{{@tensy@char106}}\n"
1218 "@def@{{{@tensy@char102}}\n"
1219 "@def@}{{@tensy@char103}}\n"
1220 "@def<{{@teni@char62}}\n"
1221 "@def>{{@teni@char60}}\n"
1222 "@chardef@@64\n"
1223 "@catcode43=12\n"
1224 "@tableindent-0.2in\n"
1225 "@end iftex\n")
1226 ;; Sort the array by name; within each name, by type (functions first).
1227 (setq alist (sort alist (lambda (e1 e2)
1228 (if (string-equal (car e1) (car e2))
1229 (<= (cadr e1) (cadr e2))
1230 (string-lessp (car e1) (car e2))))))
1231 ;; Print each function.
1232 (dolist (e alist)
1233 (insert "\n@item "
1234 (if (char-equal (cadr e) ?\F) "Function" "Variable")
1235 " @code{" (car e) "}\n@display\n"
1236 (nth 2 e)
1237 "\n@end display\n")
1238 ;; Try to avoid a save size overflow in the TeX output routine.
1239 (if (zerop (setq i (% (1+ i) 100)))
1240 (insert "\n@end table\n@table @asis\n")))
1241 (insert "@end table\n"
1242 "@bye\n")
1243 (setq buffer-undo-list nil)
1244 (texinfo-mode)))
1245
1246 (provide 'help-fns)
1247
1248 ;;; help-fns.el ends here