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