("faces"): Move load before loading "loaddefs.el".
[bpt/emacs.git] / lisp / help.el
CommitLineData
1a06eabd
ER
1;;; help.el --- help commands for Emacs
2
754084bb
GM
3;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001
4;; Free Software Foundation, Inc.
3a801d0c 5
e5167999 6;; Maintainer: FSF
fd7fa35a 7;; Keywords: help, internal
e5167999 8
433ae6f6
RS
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
e5167999 13;; the Free Software Foundation; either version 2, or (at your option)
433ae6f6
RS
14;; any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
b578f267
EN
22;; along with GNU Emacs; see the file COPYING. If not, write to the
23;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24;; Boston, MA 02111-1307, USA.
433ae6f6 25
d9ecc911
ER
26;;; Commentary:
27
a1c9f209 28;; This code implements GNU Emacs' on-line help system, the one invoked by
95ac0a6f 29;; `M-x help-for-help'.
d9ecc911 30
e5167999
ER
31;;; Code:
32
8aa3a187
RS
33;; Get the macro make-help-screen when this is compiled,
34;; or run interpreted, but not when the compiled code is loaded.
b1fe9304 35(eval-when-compile (require 'help-macro))
4a8adb0b 36(eval-when-compile (require 'view))
41b8542b 37
433ae6f6
RS
38(defvar help-map (make-sparse-keymap)
39 "Keymap for characters following the Help key.")
40
afaa65e4
KH
41(defvar help-mode-map (make-sparse-keymap)
42 "Keymap for help mode.")
43
e17d2fd1 44(define-key global-map (char-to-string help-char) 'help-command)
0af3df1c
RS
45(define-key global-map [help] 'help-command)
46(define-key global-map [f1] 'help-command)
433ae6f6
RS
47(fset 'help-command help-map)
48
e17d2fd1 49(define-key help-map (char-to-string help-char) 'help-for-help)
0af3df1c
RS
50(define-key help-map [help] 'help-for-help)
51(define-key help-map [f1] 'help-for-help)
433ae6f6
RS
52(define-key help-map "?" 'help-for-help)
53
54(define-key help-map "\C-c" 'describe-copying)
55(define-key help-map "\C-d" 'describe-distribution)
56(define-key help-map "\C-w" 'describe-no-warranty)
76766f2d 57(define-key help-map "\C-p" 'describe-project)
122955bf 58(define-key help-map "a" 'apropos-command)
433ae6f6
RS
59
60(define-key help-map "b" 'describe-bindings)
61
62(define-key help-map "c" 'describe-key-briefly)
63(define-key help-map "k" 'describe-key)
64
65(define-key help-map "d" 'describe-function)
66(define-key help-map "f" 'describe-function)
67
7ee71cf1
RS
68(define-key help-map "F" 'view-emacs-FAQ)
69
433ae6f6 70(define-key help-map "i" 'info)
4b08b7ed 71(define-key help-map "4i" 'info-other-window)
e5d77022
JB
72(define-key help-map "\C-f" 'Info-goto-emacs-command-node)
73(define-key help-map "\C-k" 'Info-goto-emacs-key-command-node)
32884eab 74(define-key help-map "\C-i" 'info-lookup-symbol)
433ae6f6
RS
75
76(define-key help-map "l" 'view-lossage)
77
78(define-key help-map "m" 'describe-mode)
754084bb 79(define-key help-map "\C-m" 'view-order-manuals)
433ae6f6
RS
80
81(define-key help-map "\C-n" 'view-emacs-news)
82(define-key help-map "n" 'view-emacs-news)
83
06b98c51 84(define-key help-map "p" 'finder-by-keyword)
3e9c095d
RS
85(autoload 'finder-by-keyword "finder"
86 "Find packages matching a given keyword." t)
06b98c51 87
4cbff657
DL
88(define-key help-map "P" 'view-emacs-problems)
89
433ae6f6
RS
90(define-key help-map "s" 'describe-syntax)
91
92(define-key help-map "t" 'help-with-tutorial)
93
94(define-key help-map "w" 'where-is)
95
96(define-key help-map "v" 'describe-variable)
97
2fc9d9f4
RS
98(define-key help-map "q" 'help-quit)
99
400a1b1f
RS
100(define-key help-mode-map [mouse-2] 'help-follow-mouse)
101(define-key help-mode-map "\C-c\C-b" 'help-go-back)
102(define-key help-mode-map "\C-c\C-c" 'help-follow)
103(define-key help-mode-map "\t" 'help-next-ref)
104(define-key help-mode-map [backtab] 'help-previous-ref)
306a5e68 105(define-key help-mode-map [(shift tab)] 'help-previous-ref)
400a1b1f
RS
106;; Documentation only, since we use minor-mode-overriding-map-alist.
107(define-key help-mode-map "\r" 'help-follow)
108
400a1b1f
RS
109(defvar help-xref-stack nil
110 "A stack of ways by which to return to help buffers after following xrefs.
4c45295b 111Used by `help-follow' and `help-xref-go-back'.
376b2a24
DL
112An element looks like (POSITION FUNCTION ARGS...), where POSITION is
113`(POINT . BUFFER-NAME)'.
114To use the element, do (apply FUNCTION ARGS) then goto the point in
115the named buffer.")
400a1b1f
RS
116(put 'help-xref-stack 'permanent-local t)
117
118(defvar help-xref-stack-item nil
4c45295b
KH
119 "An item for `help-follow' in this buffer to push onto `help-xref-stack'.
120The format is (FUNCTION ARGS...).")
400a1b1f
RS
121(put 'help-xref-stack-item 'permanent-local t)
122
123(setq-default help-xref-stack nil help-xref-stack-item nil)
507fb916 124
73ea6d94
DL
125(defcustom help-mode-hook nil
126 "Hook run by `help-mode'."
127 :type 'hook
128 :group 'help)
129
afaa65e4 130(defun help-mode ()
400a1b1f 131 "Major mode for viewing help text and navigating references in it.
afaa65e4
KH
132Entry to this mode runs the normal hook `help-mode-hook'.
133Commands:
134\\{help-mode-map}"
135 (interactive)
136 (kill-all-local-variables)
137 (use-local-map help-mode-map)
138 (setq mode-name "Help")
139 (setq major-mode 'help-mode)
507fb916 140 (make-local-variable 'font-lock-defaults)
400a1b1f 141 (setq font-lock-defaults nil) ; font-lock would defeat xref
42499979 142 (view-mode)
f90b6922
RS
143 (make-local-variable 'view-no-disable-on-exit)
144 (setq view-no-disable-on-exit t)
afaa65e4
KH
145 (run-hooks 'help-mode-hook))
146
e48143f0
RS
147(defun help-mode-setup ()
148 (help-mode)
149 (setq buffer-read-only nil))
150
3d02beed 151(add-hook 'temp-buffer-setup-hook 'help-mode-setup)
e48143f0
RS
152
153(defun help-mode-finish ()
4e1ede6c 154 (when (eq major-mode 'help-mode)
400a1b1f
RS
155 ;; View mode's read-only status of existing *Help* buffer is lost
156 ;; by with-output-to-temp-buffer.
157 (toggle-read-only 1)
158 (help-make-xrefs (current-buffer)))
01364a75
RS
159 (setq view-return-to-alist
160 (list (cons (selected-window) help-return-method))))
21de5941 161
3d02beed 162(add-hook 'temp-buffer-show-hook 'help-mode-finish)
21de5941 163
2fc9d9f4 164(defun help-quit ()
3120a677 165 "Just exit from the Help command's command loop."
2fc9d9f4
RS
166 (interactive)
167 nil)
168
0634ea78
KH
169(defun help-with-tutorial (&optional arg)
170 "Select the Emacs learn-by-doing tutorial.
da412772 171If there is a tutorial version written in the language
71e9bd71 172of the selected language environment, that version is used.
da412772 173If there's no tutorial in that language, `TUTORIAL' is selected.
c822b44b 174With arg, you are asked to choose which language."
0634ea78 175 (interactive "P")
3060bf83
KH
176 (let ((lang (if arg
177 (read-language-name 'tutorial "Language: " "English")
178 (if (get-language-info current-language-environment 'tutorial)
179 current-language-environment
ad21fa07
RS
180 "English")))
181 file filename)
3060bf83 182 (setq filename (get-language-info lang 'tutorial))
7c9b148e 183 (setq file (expand-file-name (concat "~/" filename)))
433ae6f6
RS
184 (delete-other-windows)
185 (if (get-file-buffer file)
186 (switch-to-buffer (get-file-buffer file))
187 (switch-to-buffer (create-file-buffer file))
188 (setq buffer-file-name file)
189 (setq default-directory (expand-file-name "~/"))
79058860 190 (setq buffer-auto-save-file-name nil)
0634ea78 191 (insert-file-contents (expand-file-name filename data-directory))
433ae6f6
RS
192 (goto-char (point-min))
193 (search-forward "\n<<")
194 (beginning-of-line)
195 (delete-region (point) (progn (end-of-line) (point)))
857a1de6 196 (let ((n (- (window-height (selected-window))
433ae6f6 197 (count-lines (point-min) (point))
857a1de6 198 6)))
d0da2301 199 (if (< n 12)
857a1de6
KH
200 (newline n)
201 ;; Some people get confused by the large gap.
202 (newline (/ n 2))
203 (insert "[Middle of page left blank for didactic purposes. "
204 "Text continues below]")
205 (newline (- n (/ n 2)))))
433ae6f6
RS
206 (goto-char (point-min))
207 (set-buffer-modified-p nil))))
208
c085b77c
GM
209(defun string-key-binding (key)
210 "Value is the binding of KEY in a string.
211If KEY is an event on a string, and that string has a `local-map'
212or `keymap' property, return the binding of KEY in the string's keymap."
213 (let* ((defn nil)
214 (start (when (vectorp key)
215 (if (memq (aref key 0) '(mode-line header-line))
216 (event-start (aref key 1))
4b29c200
GM
217 (and (consp (aref key 0))
218 (event-start (aref key 0))))))
c085b77c
GM
219 (string-info (and (consp start) (nth 4 start))))
220 (when string-info
221 (let* ((string (car string-info))
222 (pos (cdr string-info))
223 (local-map (and (> pos 0)
224 (< pos (length string))
225 (or (get-text-property pos 'local-map string)
226 (get-text-property pos 'keymap string)))))
227 (setq defn (and local-map (lookup-key local-map key)))))
35831732
GM
228 defn))
229
e88a2c59
RS
230(defun describe-key-briefly (key &optional insert)
231 "Print the name of the function KEY invokes. KEY is a string.
232If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
233 (interactive "kDescribe key briefly: \nP")
fc558e4d
RS
234 (save-excursion
235 (let ((modifiers (event-modifiers (aref key 0)))
e88a2c59 236 (standard-output (if insert (current-buffer) t))
fc558e4d
RS
237 window position)
238 ;; For a mouse button event, go to the button it applies to
239 ;; to get the right key bindings. And go to the right place
240 ;; in case the keymap depends on where you clicked.
241 (if (or (memq 'click modifiers) (memq 'down modifiers)
242 (memq 'drag modifiers))
243 (setq window (posn-window (event-start (aref key 0)))
244 position (posn-point (event-start (aref key 0)))))
245 (if (windowp window)
246 (progn
247 (set-buffer (window-buffer window))
248 (goto-char position)))
249 ;; Ok, now look up the key and name the command.
c085b77c 250 (let ((defn (or (string-key-binding key)
35831732 251 (key-binding key)))
e88a2c59 252 (key-desc (key-description key)))
fc558e4d 253 (if (or (null defn) (integerp defn))
e88a2c59
RS
254 (princ (format "%s is undefined" key-desc))
255 (princ (format (if insert
0f2aa0e1 256 "`%s' (`%s')"
e88a2c59
RS
257 (if (windowp window)
258 "%s at that spot runs the command %s"
259 "%s runs the command %s"))
260 key-desc
261 (if (symbolp defn) defn (prin1-to-string defn)))))))))
433ae6f6 262
01364a75
RS
263(defvar help-return-method nil
264 "What to do to \"exit\" the help buffer.
265This is a list
266 (WINDOW . t) delete the selected window, go to WINDOW.
267 (WINDOW . quit-window) do quit-window, then select WINDOW.
268 (WINDOW BUF START POINT) display BUF at START, POINT, then select WINDOW.")
269
433ae6f6
RS
270(defun print-help-return-message (&optional function)
271 "Display or return message saying how to restore windows after help command.
272Computes a message and applies the optional argument FUNCTION to it.
273If FUNCTION is nil, applies `message' to it, thus printing it."
274 (and (not (get-buffer-window standard-output))
d536293f 275 (let ((first-message
a1c9f209 276 (cond ((special-display-p (buffer-name standard-output))
01364a75 277 (setq help-return-method (cons (selected-window) t))
d536293f
RS
278 ;; If the help output buffer is a special display buffer,
279 ;; don't say anything about how to get rid of it.
280 ;; First of all, the user will do that with the window
281 ;; manager, not with Emacs.
282 ;; Secondly, the buffer has not been displayed yet,
283 ;; so we don't know whether its frame will be selected.
d536293f 284 nil)
f3ad2fc8
GM
285 (display-buffer-reuse-frames
286 (setq help-return-method (cons (selected-window)
287 'quit-window))
288 nil)
d536293f 289 ((not (one-window-p t))
01364a75
RS
290 (setq help-return-method
291 (cons (selected-window) 'quit-window))
d536293f
RS
292 "Type \\[switch-to-buffer-other-window] RET to restore the other window.")
293 (pop-up-windows
01364a75 294 (setq help-return-method (cons (selected-window) t))
d536293f
RS
295 "Type \\[delete-other-windows] to remove help window.")
296 (t
01364a75
RS
297 (setq help-return-method
298 (list (selected-window) (window-buffer)
299 (window-start) (window-point)))
d536293f
RS
300 "Type \\[switch-to-buffer] RET to remove help window."))))
301 (funcall (or function 'message)
302 (concat
303 (if first-message
376b2a24
DL
304 (substitute-command-keys first-message))
305 (if first-message " ")
125a8d70
RS
306 ;; If the help buffer will go in a separate frame,
307 ;; it's no use mentioning a command to scroll, so don't.
a1c9f209 308 (if (special-display-p (buffer-name standard-output))
125a8d70 309 nil
a1c9f209 310 (if (same-window-p (buffer-name standard-output))
125a8d70
RS
311 ;; Say how to scroll this window.
312 (substitute-command-keys
313 "\\[scroll-up] to scroll the help.")
314 ;; Say how to scroll some other window.
6e7f5182 315 (substitute-command-keys
125a8d70 316 "\\[scroll-other-window] to scroll the help."))))))))
433ae6f6
RS
317
318(defun describe-key (key)
319 "Display documentation of the function invoked by KEY. KEY is a string."
320 (interactive "kDescribe key: ")
fc558e4d
RS
321 (save-excursion
322 (let ((modifiers (event-modifiers (aref key 0)))
323 window position)
324 ;; For a mouse button event, go to the button it applies to
325 ;; to get the right key bindings. And go to the right place
326 ;; in case the keymap depends on where you clicked.
327 (if (or (memq 'click modifiers) (memq 'down modifiers)
328 (memq 'drag modifiers))
329 (setq window (posn-window (event-start (aref key 0)))
330 position (posn-point (event-start (aref key 0)))))
331 (if (windowp window)
332 (progn
333 (set-buffer (window-buffer window))
334 (goto-char position)))
c085b77c 335 (let ((defn (or (string-key-binding key) (key-binding key))))
fc558e4d
RS
336 (if (or (null defn) (integerp defn))
337 (message "%s is undefined" (key-description key))
338 (with-output-to-temp-buffer "*Help*"
339 (princ (key-description key))
340 (if (windowp window)
341 (princ " at that spot"))
342 (princ " runs the command ")
343 (prin1 defn)
05f6170c 344 (princ "\n which is ")
0ab0e672 345 (describe-function-1 defn nil (interactive-p))
fc558e4d 346 (print-help-return-message)))))))
433ae6f6 347
ad023904
RS
348(defun describe-mode ()
349 "Display documentation of current major mode and minor modes.
40b3bdc1
RS
350The major mode description comes first, followed by the minor modes,
351each on a separate page.
352
433ae6f6 353For this to work correctly for a minor mode, the mode's indicator variable
61c6b658 354\(listed in `minor-mode-alist') must also be a function whose documentation
433ae6f6 355describes the minor mode."
7192540b 356 (interactive)
433ae6f6 357 (with-output-to-temp-buffer "*Help*"
40b3bdc1
RS
358 (when minor-mode-alist
359 (princ "The major mode is described first.
360For minor modes, see following pages.\n\n"))
361 (princ mode-name)
362 (princ " mode:\n")
363 (princ (documentation major-mode))
364 (help-setup-xref (list #'help-xref-mode (current-buffer)) (interactive-p))
365 (let ((minor-modes minor-mode-alist))
7192540b
RS
366 (while minor-modes
367 (let* ((minor-mode (car (car minor-modes)))
ddbe99e0 368 (indicator (car (cdr (car minor-modes)))))
7192540b
RS
369 ;; Document a minor mode if it is listed in minor-mode-alist,
370 ;; bound locally in this buffer, non-nil, and has a function
371 ;; definition.
4675e266
GM
372 (if (and (boundp minor-mode)
373 (symbol-value minor-mode)
7192540b
RS
374 (fboundp minor-mode))
375 (let ((pretty-minor-mode minor-mode))
376 (if (string-match "-mode$" (symbol-name minor-mode))
377 (setq pretty-minor-mode
378 (capitalize
379 (substring (symbol-name minor-mode)
380 0 (match-beginning 0)))))
e95419a6
RS
381 (while (and indicator (symbolp indicator)
382 (boundp indicator)
383 (not (eq indicator (symbol-value indicator))))
7192540b 384 (setq indicator (symbol-value indicator)))
40b3bdc1 385 (princ "\n\f\n")
2ef581f3
RS
386 (princ (format "%s minor mode (%s):\n"
387 pretty-minor-mode
388 (if indicator
389 (format "indicator%s" indicator)
390 "no indicator")))
40b3bdc1 391 (princ (documentation minor-mode)))))
7192540b 392 (setq minor-modes (cdr minor-modes))))
433ae6f6
RS
393 (print-help-return-message)))
394
395;; So keyboard macro definitions are documented correctly
396(fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
397
398(defun describe-distribution ()
399 "Display info on how to obtain the latest version of GNU Emacs."
400 (interactive)
401 (find-file-read-only
1e6dacf6 402 (expand-file-name "DISTRIB" data-directory)))
433ae6f6
RS
403
404(defun describe-copying ()
405 "Display info on how you may redistribute copies of GNU Emacs."
406 (interactive)
407 (find-file-read-only
1e6dacf6 408 (expand-file-name "COPYING" data-directory))
433ae6f6
RS
409 (goto-char (point-min)))
410
76766f2d
RS
411(defun describe-project ()
412 "Display info on the GNU project."
413 (interactive)
414 (find-file-read-only
869e248d 415 (expand-file-name "THE-GNU-PROJECT" data-directory))
76766f2d
RS
416 (goto-char (point-min)))
417
433ae6f6
RS
418(defun describe-no-warranty ()
419 "Display info on all the kinds of warranty Emacs does NOT have."
420 (interactive)
421 (describe-copying)
422 (let (case-fold-search)
423 (search-forward "NO WARRANTY")
424 (recenter 0)))
425
61c6b658 426(defun describe-prefix-bindings ()
c7cba9cb
RS
427 "Describe the bindings of the prefix used to reach this command.
428The prefix described consists of all but the last event
429of the key sequence that ran this command."
61c6b658 430 (interactive)
ccc06dcc
KH
431 (let* ((key (this-command-keys)))
432 (describe-bindings
433 (if (stringp key)
434 (substring key 0 (1- (length key)))
435 (let ((prefix (make-vector (1- (length key)) nil))
436 (i 0))
437 (while (< i (length prefix))
438 (aset prefix i (aref key i))
439 (setq i (1+ i)))
440 prefix)))))
c7cba9cb
RS
441;; Make C-h after a prefix, when not specifically bound,
442;; run describe-prefix-bindings.
61c6b658
RS
443(setq prefix-help-command 'describe-prefix-bindings)
444
382d018a
RS
445(defun view-emacs-news (&optional arg)
446 "Display info on recent changes to Emacs.
f0753a5f 447With numeric argument, display information on correspondingly older changes."
382d018a 448 (interactive "P")
f0753a5f
GM
449 (let* ((arg (if arg (prefix-numeric-value arg) 0))
450 (file (cond ((eq arg 0) "NEWS")
451 ((eq arg 1) "ONEWS")
452 (t
453 (nth (- arg 2)
454 (nreverse (directory-files data-directory
975f82c9 455 nil "^ONEWS\\.[0-9]+$"
f0753a5f
GM
456 nil)))))))
457 (if file
458 (find-file-read-only (expand-file-name file data-directory))
459 (error "No such old news"))))
433ae6f6 460
754084bb
GM
461(defun view-order-manuals ()
462 "Display the Emacs ORDERS file."
463 (interactive)
38790755
GM
464 (find-file-read-only (expand-file-name "ORDERS" data-directory))
465 (goto-address))
754084bb 466
7ee71cf1
RS
467(defun view-emacs-FAQ ()
468 "Display the Emacs Frequently Asked Questions (FAQ) file."
469 (interactive)
4a8adb0b 470;;; (find-file-read-only (expand-file-name "FAQ" data-directory))
279b772d 471 (info "(efaq)"))
7ee71cf1 472
4cbff657
DL
473(defun view-emacs-problems ()
474 "Display info on known problems with Emacs and possible workarounds."
475 (interactive)
476 (view-file (expand-file-name "PROBLEMS" data-directory)))
477
433ae6f6 478(defun view-lossage ()
50b57199
EZ
479 "Display last 100 input keystrokes.
480
481To record all your input on a file, use `open-dribble-file'."
433ae6f6
RS
482 (interactive)
483 (with-output-to-temp-buffer "*Help*"
298a7c8c
RS
484 (princ (mapconcat (function (lambda (key)
485 (if (or (integerp key)
486 (symbolp key)
487 (listp key))
488 (single-key-description key)
489 (prin1-to-string key nil))))
490 (recent-keys)
491 " "))
433ae6f6
RS
492 (save-excursion
493 (set-buffer standard-output)
494 (goto-char (point-min))
495 (while (progn (move-to-column 50) (not (eobp)))
496 (search-forward " " nil t)
613a39b9
RS
497 (insert "\n"))
498 (setq help-xref-stack nil
499 help-xref-stack-item nil))
433ae6f6
RS
500 (print-help-return-message)))
501
2fc9d9f4 502(defalias 'help 'help-for-help)
41b8542b 503(make-help-screen help-for-help
a30a106b 504 "a b c C f F C-f i I k C-k l L m n p s t v w C-c C-d C-n C-p C-w; ? for help:"
a82e9c01 505 "You have typed %THIS-KEY%, the help character. Type a Help option:
efcce2d2 506\(Use SPC or DEL to scroll through this text. Type \\<help-map>\\[help-quit] to exit the Help command.)
433ae6f6 507
21ee8c42
RM
508a command-apropos. Give a substring, and see a list of commands
509 (functions interactively callable) that contain
510 that substring. See also the apropos command.
af6a9de9
RS
511b describe-bindings. Display table of all key bindings.
512c describe-key-briefly. Type a command key sequence;
21ee8c42 513 it prints the function name that sequence runs.
a30a106b
RS
514C describe-coding-system. This describes either a specific coding system
515 (if you type its name) or the coding systems currently in use
516 (if you type just RET).
af6a9de9 517f describe-function. Type a function name and get documentation of it.
21ee8c42
RM
518C-f Info-goto-emacs-command-node. Type a function name;
519 it takes you to the Info node for that command.
af6a9de9 520i info. The info documentation reader.
a30a106b
RS
521I describe-input-method. Describe a specific input method (if you type
522 its name) or the current input method (if you type just RET).
90a56040
KH
523C-i info-lookup-symbol. Display the definition of a specific symbol
524 as found in the manual for the language this buffer is written in.
af6a9de9 525k describe-key. Type a command key sequence;
21ee8c42
RM
526 it displays the full documentation.
527C-k Info-goto-emacs-key-command-node. Type a command key sequence;
528 it takes you to the Info node for the command bound to that key.
90a56040 529l view-lossage. Show last 100 characters you typed.
5760471f 530L describe-language-environment. This describes either a
a30a106b
RS
531 specific language environment (if you type its name)
532 or the current language environment (if you type just RET).
ed13681f
KH
533m describe-mode. Print documentation of current minor modes,
534 and the current major mode, including their special commands.
90a56040 535n view-emacs-news. Display news of recent Emacs changes.
af6a9de9 536p finder-by-keyword. Find packages matching a given topic keyword.
e0c21266 537s describe-syntax. Display contents of syntax table, plus explanations.
af6a9de9
RS
538t help-with-tutorial. Select the Emacs learn-by-doing tutorial.
539v describe-variable. Type name of a variable;
21ee8c42 540 it displays the variable's documentation and value.
af6a9de9 541w where-is. Type command name; it prints which keystrokes
21ee8c42 542 invoke that command.
a30a106b
RS
543
544F Display the frequently asked questions file.
545h Display the HELLO file which illustrates various scripts.
546C-c Display Emacs copying permission (General Public License).
547C-d Display Emacs ordering information.
548C-n Display news of recent Emacs changes.
549C-p Display information about the GNU project.
550C-w Display information on absence of warranty for GNU Emacs."
41b8542b 551 help-map)
433ae6f6 552
433ae6f6 553(defun function-called-at-point ()
b2c85790
DL
554 "Return a function around point or else called by the list containing point.
555If that doesn't give a function, return nil."
9a200f68
DL
556 (with-syntax-table emacs-lisp-mode-syntax-table
557 (or (condition-case ()
558 (save-excursion
559 (or (not (zerop (skip-syntax-backward "_w")))
560 (eq (char-syntax (following-char)) ?w)
561 (eq (char-syntax (following-char)) ?_)
562 (forward-sexp -1))
563 (skip-chars-forward "'")
564 (let ((obj (read (current-buffer))))
565 (and (symbolp obj) (fboundp obj) obj)))
566 (error nil))
567 (condition-case ()
568 (save-excursion
569 (save-restriction
570 (narrow-to-region (max (point-min)
571 (- (point) 1000)) (point-max))
572 ;; Move up to surrounding paren, then after the open.
573 (backward-up-list 1)
574 (forward-char 1)
575 ;; If there is space here, this is probably something
576 ;; other than a real Lisp function call, so ignore it.
577 (if (looking-at "[ \t]")
578 (error "Probably not a Lisp function call"))
579 (let ((obj (read (current-buffer))))
580 (and (symbolp obj) (fboundp obj) obj))))
581 (error nil)))))
433ae6f6 582
0f619a41
KH
583(defvar symbol-file-load-history-loaded nil
584 "Non-nil means we have loaded the file `fns-VERSION.el' in `exec-directory'.
585That file records the part of `load-history' for preloaded files,
586which is cleared out before dumping to make Emacs smaller.")
587
50ca4be0
GM
588(defun load-symbol-file-load-history ()
589 "Load the file `fns-VERSION.el' in `exec-directory' if not already done.
590That file records the part of `load-history' for preloaded files,
591which is cleared out before dumping to make Emacs smaller."
0f619a41
KH
592 (unless symbol-file-load-history-loaded
593 (load (expand-file-name
594 ;; fns-XX.YY.ZZ.el does not work on DOS filesystem.
595 (if (eq system-type 'ms-dos)
596 "fns.el"
597 (format "fns-%s.el" emacs-version))
598 exec-directory)
599 ;; The file name fns-%s.el already has a .el extension.
600 nil nil t)
50ca4be0
GM
601 (setq symbol-file-load-history-loaded t)))
602
603(defun symbol-file (function)
604 "Return the input source from which FUNCTION was loaded.
605The value is normally a string that was passed to `load':
606either an absolute file name, or a library name
607\(with no directory name and no `.el' or `.elc' at the end).
608It can also be nil, if the definition is not associated with any file."
609 (load-symbol-file-load-history)
ca5ed196
RS
610 (let ((files load-history)
611 file functions)
612 (while files
613 (if (memq function (cdr (car files)))
614 (setq file (car (car files)) files nil))
615 (setq files (cdr files)))
616 file))
617
433ae6f6
RS
618(defun describe-function (function)
619 "Display the full documentation of FUNCTION (a symbol)."
620 (interactive
621 (let ((fn (function-called-at-point))
622 (enable-recursive-minibuffers t)
623 val)
624 (setq val (completing-read (if fn
625 (format "Describe function (default %s): " fn)
626 "Describe function: ")
1bacc93e 627 obarray 'fboundp t nil nil (symbol-name fn)))
433ae6f6
RS
628 (list (if (equal val "")
629 fn (intern val)))))
00d3de8e
RS
630 (if function
631 (with-output-to-temp-buffer "*Help*"
632 (prin1 function)
eea844b2
RS
633 ;; Use " is " instead of a colon so that
634 ;; it is easier to get out the function name using forward-sexp.
635 (princ " is ")
0ab0e672 636 (describe-function-1 function nil (interactive-p))
00d3de8e
RS
637 (print-help-return-message)
638 (save-excursion
639 (set-buffer standard-output)
00d3de8e
RS
640 ;; Return the text we displayed.
641 (buffer-string)))
642 (message "You didn't specify a function")))
643
0ab0e672 644(defun describe-function-1 (function parens interactive-p)
6016b6e4
RS
645 (let* ((def (if (symbolp function)
646 (symbol-function function)
647 function))
05f6170c
KH
648 file-name string need-close
649 (beg (if (commandp def) "an interactive " "a ")))
650 (setq string
651 (cond ((or (stringp def)
652 (vectorp def))
653 "a keyboard macro")
654 ((subrp def)
d16296bb
DL
655 (if (eq 'unevalled (cdr (subr-arity def)))
656 (concat beg "special form")
657 (concat beg "built-in function")))
05f6170c
KH
658 ((byte-code-function-p def)
659 (concat beg "compiled Lisp function"))
660 ((symbolp def)
3f8309db
RS
661 (while (symbolp (symbol-function def))
662 (setq def (symbol-function def)))
213f4eae 663 (format "an alias for `%s'" def))
05f6170c
KH
664 ((eq (car-safe def) 'lambda)
665 (concat beg "Lisp function"))
666 ((eq (car-safe def) 'macro)
667 "a Lisp macro")
668 ((eq (car-safe def) 'mocklisp)
669 "a mocklisp function")
670 ((eq (car-safe def) 'autoload)
671 (setq file-name (nth 1 def))
aed2b2cd 672 (format "%s autoloaded %s"
05f6170c 673 (if (commandp def) "an interactive" "an")
aed2b2cd
AS
674 (if (eq (nth 4 def) 'keymap) "keymap"
675 (if (nth 4 def) "Lisp macro" "Lisp function"))
05f6170c 676 ))
b89d72a1
RS
677 ;; perhaps use keymapp here instead
678 ((eq (car-safe def) 'keymap)
679 (let ((is-full nil)
680 (elts (cdr-safe def)))
681 (while elts
682 (if (char-table-p (car-safe elts))
683 (setq is-full t
684 elts nil))
685 (setq elts (cdr-safe elts)))
686 (if is-full
687 "a full keymap"
688 "a sparse keymap")))
05f6170c
KH
689 (t "")))
690 (when (and parens (not (equal string "")))
691 (setq need-close t)
692 (princ "("))
693 (princ string)
b2c85790
DL
694 (with-current-buffer "*Help*"
695 (save-excursion
696 (save-match-data
697 (if (re-search-backward "alias for `\\([^`']+\\)'" nil t)
d77dae5c
DL
698 (help-xref-button 1 #'describe-function def
699 "mouse-2, RET: describe this function")))))
05f6170c 700 (or file-name
0f619a41 701 (setq file-name (symbol-file function)))
05f6170c
KH
702 (if file-name
703 (progn
704 (princ " in `")
705 ;; We used to add .el to the file name,
706 ;; but that's completely wrong when the user used load-file.
707 (princ file-name)
2676e099
DL
708 (princ "'")
709 ;; Make a hyperlink to the library.
710 (with-current-buffer "*Help*"
711 (save-excursion
712 (re-search-backward "`\\([^`']+\\)'" nil t)
e5c60e46
SM
713 (help-xref-button
714 1
715 #'(lambda (fun file)
c1068847 716 (require 'find-func)
e5c60e46
SM
717 ;; Don't use find-function-noselect because it follows
718 ;; aliases (which fails for built-in functions).
c1068847 719 (let* ((location (find-function-search-for-symbol
e5c60e46 720 fun nil file)))
c1068847
GM
721 (pop-to-buffer (car location))
722 (goto-char (cdr location))))
e5c60e46 723 (list function file-name)
c1068847 724 "mouse-2, RET: find function's definition")))))
05f6170c
KH
725 (if need-close (princ ")"))
726 (princ ".")
727 (terpri)
3f8309db
RS
728 ;; Handle symbols aliased to other symbols.
729 (setq def (indirect-function def))
730 ;; If definition is a macro, find the function inside it.
731 (if (eq (car-safe def) 'macro)
732 (setq def (cdr def)))
733 (let ((arglist (cond ((byte-code-function-p def)
734 (car (append def nil)))
735 ((eq (car-safe def) 'lambda)
736 (nth 1 def))
f0d0fb19
DL
737 ((and (eq (car-safe def) 'autoload)
738 (not (eq (nth 4 def) 'keymap)))
739 (concat "[Arg list not available until "
740 "function definition is loaded.]"))
3f8309db 741 (t t))))
f0d0fb19
DL
742 (cond ((listp arglist)
743 (princ (cons (if (symbolp function) function "anonymous")
744 (mapcar (lambda (arg)
745 (if (memq arg '(&optional &rest))
746 arg
747 (intern (upcase (symbol-name arg)))))
748 arglist)))
749 (terpri))
750 ((stringp arglist)
751 (princ arglist)
752 (terpri))))
05f6170c
KH
753 (let ((doc (documentation function)))
754 (if doc
755 (progn (terpri)
756 (princ doc)
6ce5615d 757 (if (subrp def)
d16296bb
DL
758 (with-current-buffer standard-output
759 (beginning-of-line)
760 ;; Builtins get the calling sequence at the end of
761 ;; the doc string. Move it to the same place as
762 ;; for other functions.
9c50afce
DL
763
764 ;; In cases where `function' has been fset to a
765 ;; subr we can't search for function's name in
766 ;; the doc string. Kluge round that using the
767 ;; printed representation. The arg list then
768 ;; shows the wrong function name, but that
769 ;; might be a useful hint.
770 (let* ((rep (prin1-to-string def))
771 (name (progn
772 (string-match " \\([^ ]+\\)>$" rep)
773 (match-string 1 rep))))
0383ed60 774 (if (looking-at (format "(%s[ )]" (regexp-quote name)))
9c50afce
DL
775 (let ((start (point-marker)))
776 (goto-char (point-min))
777 (forward-paragraph)
778 (insert-buffer-substring (current-buffer) start)
779 (insert ?\n)
780 (delete-region (1- start) (point-max)))
781 (goto-char (point-min))
782 (forward-paragraph)
783 (insert
784 "[Missing arglist. Please make a bug report.]\n")))
d16296bb 785 (goto-char (point-max))))
f0d0fb19
DL
786 (help-setup-xref (list #'describe-function function)
787 interactive-p))
05f6170c
KH
788 (princ "not documented")))))
789
433ae6f6 790(defun variable-at-point ()
b2c85790
DL
791 "Return the bound variable symbol found around point.
792Return 0 if there is no such symbol."
433ae6f6 793 (condition-case ()
9a200f68
DL
794 (with-syntax-table emacs-lisp-mode-syntax-table
795 (save-excursion
796 (or (not (zerop (skip-syntax-backward "_w")))
797 (eq (char-syntax (following-char)) ?w)
798 (eq (char-syntax (following-char)) ?_)
799 (forward-sexp -1))
800 (skip-chars-forward "'")
801 (let ((obj (read (current-buffer))))
802 (or (and (symbolp obj) (boundp obj) obj)
803 0))))
00d3de8e 804 (error 0)))
433ae6f6 805
2e48ba18
GM
806(defun help-xref-on-pp (from to)
807 "Add xrefs for symbols in `pp's output between FROM and TO."
808 (let ((ost (syntax-table)))
809 (unwind-protect
810 (save-excursion
811 (save-restriction
812 (set-syntax-table emacs-lisp-mode-syntax-table)
813 (narrow-to-region from to)
814 (goto-char (point-min))
815 (while (not (eobp))
816 (cond
817 ((looking-at "\"") (forward-sexp 1))
818 ((looking-at "#<") (search-forward ">" nil 'move))
819 ((looking-at "\\(\\(\\sw\\|\\s_\\)+\\)")
4e1ede6c 820 (let* ((sym (intern-soft (match-string 1)))
2e48ba18 821 (fn (cond ((fboundp sym) #'describe-function)
820ad5e7
DL
822 ((or (memq sym '(t nil))
823 (keywordp sym))
824 nil)
825 ((and sym (boundp sym))
826 #'describe-variable))))
2e48ba18
GM
827 (when fn (help-xref-button 1 fn sym)))
828 (goto-char (match-end 1)))
829 (t (forward-char 1))))))
830 (set-syntax-table ost))))
831
4e1ede6c 832(defun describe-variable (variable &optional buffer)
433ae6f6 833 "Display the full documentation of VARIABLE (a symbol).
4e1ede6c
SM
834Returns the documentation as a string, also.
835If VARIABLE has a buffer-local value in BUFFER (default to the current buffer),
836it is displayed along with the global value."
837 (interactive
433ae6f6
RS
838 (let ((v (variable-at-point))
839 (enable-recursive-minibuffers t)
840 val)
00d3de8e 841 (setq val (completing-read (if (symbolp v)
820ad5e7
DL
842 (format
843 "Describe variable (default %s): " v)
433ae6f6 844 "Describe variable: ")
d5645846
KH
845 obarray 'boundp t nil nil
846 (if (symbolp v) (symbol-name v))))
433ae6f6
RS
847 (list (if (equal val "")
848 v (intern val)))))
4e1ede6c
SM
849 (unless (bufferp buffer) (setq buffer (current-buffer)))
850 (if (not (symbolp variable))
851 (message "You did not specify a variable")
852 (let (valvoid)
853 (with-current-buffer buffer
9a656d19
RS
854 (with-output-to-temp-buffer "*Help*"
855 (prin1 variable)
856 (if (not (boundp variable))
857 (progn
858 (princ " is void")
9a656d19 859 (setq valvoid t))
2e48ba18
GM
860 (let ((val (symbol-value variable)))
861 (with-current-buffer standard-output
862 (princ "'s value is ")
863 (terpri)
864 (let ((from (point)))
865 (pp val)
7727f3c0
RS
866 (help-xref-on-pp from (point))
867 (if (< (point) (+ from 20))
868 (save-excursion
869 (goto-char from)
870 (delete-char -1)))))))
2e48ba18 871 (terpri)
9a656d19
RS
872 (if (local-variable-p variable)
873 (progn
874 (princ (format "Local in buffer %s; " (buffer-name)))
875 (if (not (default-boundp variable))
876 (princ "globally void")
2e48ba18
GM
877 (let ((val (default-value variable)))
878 (with-current-buffer standard-output
879 (princ "global value is ")
880 (terpri)
9a200f68
DL
881 ;; Fixme: pp can take an age if you happen to
882 ;; ask for a very large expression. We should
883 ;; probably print it raw once and check it's a
884 ;; sensible size before prettyprinting. -- fx
2e48ba18
GM
885 (let ((from (point)))
886 (pp val)
7727f3c0
RS
887 (help-xref-on-pp from (point))
888 (if (< (point) (+ from 20))
889 (save-excursion
890 (goto-char from)
891 (delete-char -1)))))))
9a656d19
RS
892 (terpri)))
893 (terpri)
4e1ede6c 894 (with-current-buffer standard-output
9a656d19
RS
895 (if (> (count-lines (point-min) (point-max)) 10)
896 (progn
d365421f
GM
897 ;; Note that setting the syntax table like below
898 ;; makes forward-sexp move over a `'s' at the end
899 ;; of a symbol.
14cc00ad 900 (set-syntax-table emacs-lisp-mode-syntax-table)
9a656d19
RS
901 (goto-char (point-min))
902 (if valvoid
903 (forward-line 1)
904 (forward-sexp 1)
905 (delete-region (point) (progn (end-of-line) (point)))
d365421f 906 (insert " value is shown below.\n\n")
9a656d19
RS
907 (save-excursion
908 (insert "\n\nValue:"))))))
909 (princ "Documentation:")
910 (terpri)
911 (let ((doc (documentation-property variable 'variable-documentation)))
912 (princ (or doc "not documented as a variable.")))
4e1ede6c
SM
913 (help-setup-xref (list #'describe-variable variable (current-buffer))
914 (interactive-p))
915
7e824765 916 ;; Make a link to customize if this variable can be customized.
be66e132 917 ;; Note, it is not reliable to test only for a custom-type property
4f103eaa
RS
918 ;; because those are only present after the var's definition
919 ;; has been loaded.
96757035
DL
920 (if (or (get variable 'custom-type) ; after defcustom
921 (get variable 'custom-loads) ; from loaddefs.el
922 (get variable 'standard-value)) ; from cus-start.el
7e824765
RS
923 (let ((customize-label "customize"))
924 (terpri)
925 (terpri)
926 (princ (concat "You can " customize-label " this variable."))
927 (with-current-buffer "*Help*"
928 (save-excursion
4e1ede6c 929 (re-search-backward
7e824765 930 (concat "\\(" customize-label "\\)") nil t)
950cf06f
DL
931 (help-xref-button 1 (lambda (v)
932 (if help-xref-stack
933 (pop help-xref-stack))
934 (customize-variable v))
d77dae5c 935 variable
950cf06f 936 "mouse-2, RET: customize variable")))))
3476e159
DL
937 ;; Make a hyperlink to the library if appropriate. (Don't
938 ;; change the format of the buffer's initial line in case
939 ;; anything expects the current format.)
0f619a41 940 (let ((file-name (symbol-file variable)))
3476e159 941 (when file-name
5f373960 942 (princ "\n\nDefined in `")
3476e159 943 (princ file-name)
5f373960 944 (princ "'.")
3476e159
DL
945 (with-current-buffer "*Help*"
946 (save-excursion
5f373960 947 (re-search-backward "`\\([^`']+\\)'" nil t)
d77dae5c
DL
948 (help-xref-button
949 1 (lambda (arg)
950 (let ((location
951 (find-variable-noselect arg)))
952 (pop-to-buffer (car location))
953 (goto-char (cdr location))))
954 variable "mouse-2, RET: find variable's definition")))))
7e824765 955
9a656d19
RS
956 (print-help-return-message)
957 (save-excursion
958 (set-buffer standard-output)
9a656d19 959 ;; Return the text we displayed.
4e1ede6c 960 (buffer-string)))))))
433ae6f6 961
4c45295b 962(defun describe-bindings (&optional prefix buffer)
a8ad43aa
RS
963 "Show a list of all defined keys, and their definitions.
964We put that list in a buffer, and display the buffer.
965
966The optional argument PREFIX, if non-nil, should be a key sequence;
4c45295b
KH
967then we display only bindings that start with that prefix.
968The optional argument BUFFER specifies which buffer's bindings
969to display (default, the current buffer)."
a249d3a0 970 (interactive "P")
4c45295b
KH
971 (or buffer (setq buffer (current-buffer)))
972 (with-current-buffer buffer
973 (describe-bindings-internal nil prefix))
613a39b9 974 (with-current-buffer "*Help*"
4c45295b
KH
975 (help-setup-xref (list #'describe-bindings prefix buffer)
976 (interactive-p))))
a8ad43aa 977
e88a2c59 978(defun where-is (definition &optional insert)
b2c85790 979 "Print message listing key sequences that invoke the command DEFINITION.
e88a2c59
RS
980Argument is a command definition, usually a symbol with a function definition.
981If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
54c0b967
RS
982 (interactive
983 (let ((fn (function-called-at-point))
984 (enable-recursive-minibuffers t)
985 val)
986 (setq val (completing-read (if fn
987 (format "Where is command (default %s): " fn)
988 "Where is command: ")
d5f65532 989 obarray 'commandp t))
54c0b967 990 (list (if (equal val "")
e88a2c59
RS
991 fn (intern val))
992 current-prefix-arg)))
54c0b967 993 (let* ((keys (where-is-internal definition overriding-local-map nil nil))
e88a2c59
RS
994 (keys1 (mapconcat 'key-description keys ", "))
995 (standard-output (if insert (current-buffer) t)))
996 (if insert
997 (if (> (length keys1) 0)
998 (princ (format "%s (%s)" keys1 definition))
999 (princ (format "M-x %s RET" definition)))
1000 (if (> (length keys1) 0)
1001 (princ (format "%s is on %s" definition keys1))
1002 (princ (format "%s is not on any key" definition)))))
54c0b967
RS
1003 nil)
1004
a130d829 1005(defun locate-library (library &optional nosuffix path interactive-call)
2747503c 1006 "Show the precise file name of Emacs library LIBRARY.
433ae6f6
RS
1007This command searches the directories in `load-path' like `M-x load-library'
1008to find the file that `M-x load-library RET LIBRARY RET' would load.
1009Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
9dc176a0
RS
1010to the specified name LIBRARY.
1011
1012If the optional third arg PATH is specified, that list of directories
b2c85790
DL
1013is used instead of `load-path'.
1014
1015When called from a program, the file name is normaly returned as a
1016string. When run interactively, the argument INTERACTIVE-CALL is t,
1017and the file name is displayed in the echo area."
a130d829
RS
1018 (interactive (list (read-string "Locate library: ")
1019 nil nil
1020 t))
dd557bb8 1021 (let (result)
a130d829 1022 (catch 'answer
e3e36d74 1023 (mapc
a1c9f209 1024 (lambda (dir)
e3e36d74 1025 (mapc
a1c9f209
EN
1026 (lambda (suf)
1027 (let ((try (expand-file-name (concat library suf) dir)))
1028 (and (file-readable-p try)
1029 (null (file-directory-p try))
1030 (progn
1031 (setq result try)
1032 (throw 'answer try)))))
1033 (if nosuffix
1034 '("")
dd557bb8 1035 '(".elc" ".el" "")
f1c53471
EZ
1036 (let ((basic '(".elc" ".el" ""))
1037 (compressed '(".Z" ".gz" "")))
1038 ;; If autocompression mode is on,
1039 ;; consider all combinations of library suffixes
1040 ;; and compression suffixes.
1041 (if (rassq 'jka-compr-handler file-name-handler-alist)
1042 (apply 'nconc
1043 (mapcar (lambda (compelt)
1044 (mapcar (lambda (baselt)
1045 (concat baselt compelt))
1046 basic))
1047 compressed))
1048 basic)))))
a130d829
RS
1049 (or path load-path)))
1050 (and interactive-call
1051 (if result
1052 (message "Library is file %s" result)
1053 (message "No library %s in search path" library)))
1054 result))
1a06eabd 1055
400a1b1f
RS
1056\f
1057;;; Grokking cross-reference information in doc strings and
1058;;; hyperlinking it.
1059
1060;; This may have some scope for extension and the same or something
1061;; similar should be done for widget doc strings, which currently use
1062;; another mechanism.
1063
1064(defcustom help-highlight-p t
1065 "*If non-nil, `help-make-xrefs' highlight cross-references.
1066Under a window system it highlights them with face defined by
510df933 1067`help-highlight-face'."
400a1b1f
RS
1068 :group 'help
1069 :version "20.3"
1070 :type 'boolean)
1071
1072(defcustom help-highlight-face 'underline
1073 "Face used by `help-make-xrefs' to highlight cross-references.
1074Must be previously-defined."
1075 :group 'help
1076 :version "20.3"
7f082394 1077 :type 'face)
400a1b1f 1078
4607e12b 1079(defvar help-back-label (purecopy "[back]")
400a1b1f
RS
1080 "Label to use by `help-make-xrefs' for the go-back reference.")
1081
4607e12b
DL
1082(defconst help-xref-symbol-regexp
1083 (purecopy (concat "\\(\\<\\(\\(variable\\|option\\)\\|"
1084 "\\(function\\|command\\)\\|"
950cf06f 1085 "\\(face\\)\\|"
9bc4554a
RS
1086 "\\(symbol\\)\\|"
1087 "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)\\s-+\\)?"
4607e12b
DL
1088 ;; Note starting with word-syntax character:
1089 "`\\(\\sw\\(\\sw\\|\\s_\\)+\\)'"))
400a1b1f
RS
1090 "Regexp matching doc string references to symbols.
1091
1092The words preceding the quoted symbol can be used in doc strings to
1093distinguish references to variables, functions and symbols.")
1094
cba62b78 1095(defconst help-xref-mule-regexp nil
5b7a8c46 1096 "Regexp matching doc string references to MULE-related keywords.
cba62b78 1097
5b7a8c46
EZ
1098It is usually nil, and is temporarily bound to an appropriate regexp
1099when help commands related to multilingual environment (e.g.,
1100`describe-coding-system') are invoked.")
cba62b78
KH
1101
1102
4607e12b
DL
1103(defconst help-xref-info-regexp
1104 (purecopy "\\<[Ii]nfo[ \t\n]+node[ \t\n]+`\\([^']+\\)'")
400a1b1f
RS
1105 "Regexp matching doc string references to an Info node.")
1106
1107(defun help-setup-xref (item interactive-p)
1108 "Invoked from commands using the \"*Help*\" buffer to install some xref info.
1109
4c45295b 1110ITEM is a (FUNCTION . ARGS) pair appropriate for recreating the help
400a1b1f
RS
1111buffer after following a reference. INTERACTIVE-P is non-nil if the
1112calling command was invoked interactively. In this case the stack of
1113items for help buffer \"back\" buttons is cleared."
1114 (if interactive-p
1115 (setq help-xref-stack nil))
1116 (setq help-xref-stack-item item))
1117
376b2a24
DL
1118(defvar help-xref-following nil
1119 "Non-nil when following a help cross-reference.")
1120
400a1b1f
RS
1121(defun help-make-xrefs (&optional buffer)
1122 "Parse and hyperlink documentation cross-references in the given BUFFER.
1123
1124Find cross-reference information in a buffer and, if
1125`help-highlight-p' is non-nil, highlight it with face defined by
1126`help-highlight-face'; activate such cross references for selection
1127with `help-follow'. Cross-references have the canonical form `...'
1128and the type of reference may be disambiguated by the preceding
1129word(s) used in `help-xref-symbol-regexp'.
1130
cba62b78 1131If the variable `help-xref-mule-regexp' is non-nil, find also
5b7a8c46
EZ
1132cross-reference information related to multilingual environment
1133\(e.g., coding-systems). This variable is also used to disambiguate
1134the type of reference as the same way as `help-xref-symbol-regexp'.
cba62b78 1135
400a1b1f
RS
1136A special reference `back' is made to return back through a stack of
1137help buffers. Variable `help-back-label' specifies the text for
1138that."
1139 (interactive "b")
1140 (save-excursion
1141 (set-buffer (or buffer (current-buffer)))
1142 (goto-char (point-min))
1143 ;; Skip the header-type info, though it might be useful to parse
1144 ;; it at some stage (e.g. "function in `library'").
1145 (forward-paragraph)
1146 (let ((old-modified (buffer-modified-p)))
1147 (let ((stab (syntax-table))
1148 (case-fold-search t)
1149 (inhibit-read-only t))
1150 (set-syntax-table emacs-lisp-mode-syntax-table)
1151 ;; The following should probably be abstracted out.
1152 (unwind-protect
1153 (progn
f58790da
RS
1154 ;; Info references
1155 (save-excursion
1156 (while (re-search-forward help-xref-info-regexp nil t)
1157 (let ((data (match-string 1)))
1158 (save-match-data
1159 (unless (string-match "^([^)]+)" data)
1160 (setq data (concat "(emacs)" data))))
d77dae5c
DL
1161 (help-xref-button 1 #'info data
1162 "mouse-2, RET: read this Info node"))))
cba62b78
KH
1163 ;; Mule related keywords. Do this before trying
1164 ;; `help-xref-symbol-regexp' because some of Mule
1165 ;; keywords have variable or function definitions.
1166 (if help-xref-mule-regexp
1167 (save-excursion
1168 (while (re-search-forward help-xref-mule-regexp nil t)
96ede6b2 1169 (let* ((data (match-string 7))
cba62b78
KH
1170 (sym (intern-soft data)))
1171 (cond
1172 ((match-string 3) ; coding system
880c345e 1173 (and sym (coding-system-p sym)
cba62b78 1174 (help-xref-button
96ede6b2 1175 7 #'describe-coding-system sym
cba62b78
KH
1176 "mouse-2, RET: describe this coding system")))
1177 ((match-string 4) ; input method
1178 (and (assoc data input-method-alist)
1179 (help-xref-button
96ede6b2 1180 7 #'describe-input-method data
cba62b78 1181 "mouse-2, RET: describe this input method")))
96ede6b2
KH
1182 ((or (match-string 5) (match-string 6)) ; charset
1183 (and sym (charsetp sym)
1184 (help-xref-button
1185 7 #'describe-character-set sym
1186 "mouse-2, RET: describe this character set")))
1187 ((assoc data input-method-alist)
1188 (help-xref-button
1189 7 #'describe-input-method data
1190 "mouse-2, RET: describe this input method"))
880c345e 1191 ((and sym (coding-system-p sym))
cba62b78 1192 (help-xref-button
96ede6b2 1193 7 #'describe-coding-system sym
cba62b78 1194 "mouse-2, RET: describe this coding system"))
96ede6b2 1195 ((and sym (charsetp sym))
cba62b78 1196 (help-xref-button
96ede6b2
KH
1197 7 #'describe-character-set sym
1198 "mouse-2, RET: describe this character set")))))))
400a1b1f
RS
1199 ;; Quoted symbols
1200 (save-excursion
1201 (while (re-search-forward help-xref-symbol-regexp nil t)
9bc4554a 1202 (let* ((data (match-string 8))
400a1b1f
RS
1203 (sym (intern-soft data)))
1204 (if sym
1205 (cond
1206 ((match-string 3) ; `variable' &c
1207 (and (boundp sym) ; `variable' doesn't ensure
1208 ; it's actually bound
d77dae5c 1209 (help-xref-button
9bc4554a 1210 8 #'describe-variable sym
d77dae5c 1211 "mouse-2, RET: describe this variable")))
400a1b1f
RS
1212 ((match-string 4) ; `function' &c
1213 (and (fboundp sym) ; similarly
d77dae5c 1214 (help-xref-button
9bc4554a 1215 8 #'describe-function sym
d77dae5c 1216 "mouse-2, RET: describe this function")))
950cf06f
DL
1217 ((match-string 5) ; `face'
1218 (and (facep sym)
9bc4554a 1219 (help-xref-button 8 #'describe-face sym
950cf06f 1220 "mouse-2, RET: describe this face")))
9bc4554a
RS
1221 ((match-string 6)) ; nothing for `symbol'
1222 ((match-string 7)
1223 (help-xref-button
1224 8
1225 #'(lambda (arg)
1226 (let ((location
1227 (find-function-noselect arg)))
1228 (pop-to-buffer (car location))
1229 (goto-char (cdr location))))
1230 sym
1231 "mouse-2, RET: find function's definition"))
d77dae5c 1232 ((and (boundp sym) (fboundp sym))
400a1b1f
RS
1233 ;; We can't intuit whether to use the
1234 ;; variable or function doc -- supply both.
d77dae5c 1235 (help-xref-button
9bc4554a 1236 8 #'help-xref-interned sym
d77dae5c
DL
1237 "mouse-2, RET: describe this symbol"))
1238 ((boundp sym)
1239 (help-xref-button
9bc4554a 1240 8 #'describe-variable sym
d77dae5c
DL
1241 "mouse-2, RET: describe this variable"))
1242 ((fboundp sym)
1243 (help-xref-button
9bc4554a 1244 8 #'describe-function sym
950cf06f
DL
1245 "mouse-2, RET: describe this function"))
1246 ((facep sym)
1247 (help-xref-button
9bc4554a 1248 8 #'describe-face sym)))))))
400a1b1f 1249 ;; An obvious case of a key substitution:
4e1ede6c 1250 (save-excursion
b2c85790
DL
1251 (while (re-search-forward
1252 ;; Assume command name is only word characters
1253 ;; and dashes to get things like `use M-x foo.'.
1254 "\\<M-x\\s-+\\(\\sw\\(\\sw\\|-\\)+\\)" nil t)
400a1b1f
RS
1255 (let ((sym (intern-soft (match-string 1))))
1256 (if (fboundp sym)
d77dae5c
DL
1257 (help-xref-button
1258 1 #'describe-function sym
1259 "mouse-2, RET: describe this command")))))
ff3453e4
DL
1260 ;; Look for commands in whole keymap substitutions:
1261 (save-excursion
9b49f910
RS
1262 ;; Make sure to find the first keymap.
1263 (goto-char (point-min))
ff3453e4
DL
1264 ;; Find a header and the column at which the command
1265 ;; name will be found.
4e1ede6c 1266 (while (re-search-forward "^key +binding\n\\(-+ +\\)-+\n\n"
ff3453e4
DL
1267 nil t)
1268 (let ((col (- (match-end 1) (match-beginning 1))))
1269 (while
1270 ;; Ignore single blank lines in table, but not
1271 ;; double ones, which should terminate it.
95ac0a6f 1272 (and (not (looking-at "\n\\s-*\n"))
ff3453e4 1273 (progn
657cca97
AS
1274 (and (eolp) (forward-line))
1275 (end-of-line)
1276 (skip-chars-backward "^\t\n")
1277 (if (and (>= (current-column) col)
377d15d9 1278 (looking-at "\\(\\sw\\|-\\)+$"))
ff3453e4
DL
1279 (let ((sym (intern-soft (match-string 0))))
1280 (if (fboundp sym)
4e1ede6c 1281 (help-xref-button
d77dae5c
DL
1282 0 #'describe-function sym
1283 "mouse-2, RET: describe this function"))))
657cca97 1284 (zerop (forward-line)))))))))
400a1b1f 1285 (set-syntax-table stab))
a2e6f426
MB
1286 ;; Delete extraneous newlines at the end of the docstring
1287 (goto-char (point-max))
1288 (while (and (not (bobp)) (bolp))
1289 (delete-char -1))
400a1b1f 1290 ;; Make a back-reference in this buffer if appropriate.
376b2a24 1291 (when (and help-xref-following help-xref-stack)
400a1b1f
RS
1292 (save-excursion
1293 (insert "\n\n" help-back-label))
1294 ;; Just to provide the match data:
1295 (looking-at (concat "\n\n\\(" (regexp-quote help-back-label) "\\)"))
613a39b9 1296 (help-xref-button 1 #'help-xref-go-back (current-buffer))))
400a1b1f
RS
1297 ;; View mode steals RET from us.
1298 (set (make-local-variable 'minor-mode-overriding-map-alist)
1299 (list (cons 'view-mode
1300 (let ((map (make-sparse-keymap)))
ff3453e4 1301 (set-keymap-parent map view-mode-map)
400a1b1f
RS
1302 (define-key map "\r" 'help-follow)
1303 map))))
1304 (set-buffer-modified-p old-modified))))
1305
d77dae5c 1306(defun help-xref-button (match-number function data &optional help-echo)
400a1b1f
RS
1307 "Make a hyperlink for cross-reference text previously matched.
1308
1309MATCH-NUMBER is the subexpression of interest in the last matched
1310regexp. FUNCTION is a function to invoke when the button is
1311activated, applied to DATA. DATA may be a single value or a list.
d77dae5c
DL
1312See `help-make-xrefs'.
1313If optional arg HELP-ECHO is supplied, it is used as a help string."
5f373960
RS
1314 ;; Don't mung properties we've added specially in some instances.
1315 (unless (get-text-property (match-beginning match-number) 'help-xref)
1316 (add-text-properties (match-beginning match-number)
1317 (match-end match-number)
1318 (list 'mouse-face 'highlight
1319 'help-xref (cons function
1320 (if (listp data)
1321 data
1322 (list data)))))
d77dae5c
DL
1323 (if help-echo
1324 (put-text-property (match-beginning match-number)
1325 (match-end match-number)
1326 'help-echo help-echo))
5f373960
RS
1327 (if help-highlight-p
1328 (put-text-property (match-beginning match-number)
1329 (match-end match-number)
1330 'face help-highlight-face))))
400a1b1f 1331
96ede6b2 1332(defun help-insert-xref-button (string function data &optional help-echo)
bb934822 1333 "Insert STRING and make a hyperlink from cross-reference text on it.
96ede6b2
KH
1334
1335FUNCTION is a function to invoke when the button is activated, applied
bb934822 1336to DATA. DATA may be a single value or a list. See `help-make-xrefs'.
96ede6b2
KH
1337If optional arg HELP-ECHO is supplied, it is used as a help string."
1338 (let ((pos (point)))
1339 (insert string)
1340 (goto-char pos)
1341 (search-forward string)
1342 (help-xref-button 0 function data help-echo)))
1343
1344
400a1b1f
RS
1345\f
1346;; Additional functions for (re-)creating types of help buffers.
1347(defun help-xref-interned (symbol)
1348 "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL.
1349
1350Both variable and function documentation are extracted into a single
1351help buffer."
950cf06f
DL
1352 (let ((fdoc (when (fboundp symbol) (describe-function symbol)))
1353 (facedoc (when (facep symbol) (describe-face symbol))))
accd1266
SM
1354 (when (or (boundp symbol) (not fdoc))
1355 (describe-variable symbol)
1356 ;; We now have a help buffer on the variable. Insert the function
1357 ;; text before it.
950cf06f 1358 (when (or fdoc facedoc)
accd1266
SM
1359 (with-current-buffer "*Help*"
1360 (goto-char (point-min))
1361 (let ((inhibit-read-only t))
950cf06f
DL
1362 (when fdoc
1363 (insert fdoc "\n\n"))
1364 (when facedoc
1365 (insert (make-string 30 ?-) "\n\n" (symbol-name symbol)
1366 " is also a " "face." "\n\n" facedoc "\n\n"))
1367 (insert (make-string 30 ?-) "\n\n" (symbol-name symbol)
1368 " is also a " "variable." "\n\n"))
accd1266 1369 (help-setup-xref (list #'help-xref-interned symbol) nil))))))
400a1b1f
RS
1370
1371(defun help-xref-mode (buffer)
1372 "Do a `describe-mode' for the specified BUFFER."
1373 (save-excursion
1374 (set-buffer buffer)
1375 (describe-mode)))
1376\f
1377;;; Navigation/hyperlinking with xrefs
1378
1379(defun help-follow-mouse (click)
1380 "Follow the cross-reference that you click on."
1381 (interactive "e")
9b49f910
RS
1382 (let* ((start (event-start click))
1383 (window (car start))
1384 (pos (car (cdr start))))
1385 (with-current-buffer (window-buffer window)
400a1b1f
RS
1386 (help-follow pos))))
1387
613a39b9 1388(defun help-xref-go-back (buffer)
b2c85790 1389 "From BUFFER, go back to previous help buffer text using `help-xref-stack'."
4c45295b 1390 (let (item position method args)
613a39b9
RS
1391 (with-current-buffer buffer
1392 (when help-xref-stack
1393 (setq help-xref-stack (cdr help-xref-stack)) ; due to help-follow
376b2a24 1394 (setq item (pop help-xref-stack)
4c45295b
KH
1395 position (car item)
1396 method (cadr item)
376b2a24 1397 args (cddr item))))
4c45295b 1398 (apply method args)
376b2a24
DL
1399 ;; We assume that the buffer we just recreated has the saved name,
1400 ;; which might not always be true.
1401 (when (get-buffer (cdr position))
1402 (with-current-buffer (cdr position)
1403 (goto-char (car position))))))
400a1b1f
RS
1404
1405(defun help-go-back ()
b2c85790 1406 "Invoke the [back] button (if any) in the Help mode buffer."
400a1b1f
RS
1407 (interactive)
1408 (help-follow (1- (point-max))))
1409
400c12fd 1410(defun help-follow (&optional pos)
400a1b1f
RS
1411 "Follow cross-reference at POS, defaulting to point.
1412
1413For the cross-reference format, see `help-make-xrefs'."
1414 (interactive "d")
400c12fd
DL
1415 (unless pos
1416 (setq pos (point)))
accd1266
SM
1417 (let* ((help-data
1418 (or (and (not (= pos (point-max)))
1419 (get-text-property pos 'help-xref))
1420 (and (not (= pos (point-min)))
1421 (get-text-property (1- pos) 'help-xref))
1422 ;; check if the symbol under point is a function or variable
1423 (let ((sym
1424 (intern
1425 (save-excursion
1426 (goto-char pos) (skip-syntax-backward "w_")
1427 (buffer-substring (point)
1428 (progn (skip-syntax-forward "w_")
1429 (point)))))))
1430 (when (or (boundp sym) (fboundp sym))
1431 (list #'help-xref-interned sym)))))
400a1b1f
RS
1432 (method (car help-data))
1433 (args (cdr help-data)))
400a1b1f 1434 (when help-data
376b2a24
DL
1435 (setq help-xref-stack (cons (cons (cons pos (buffer-name))
1436 help-xref-stack-item)
accd1266
SM
1437 help-xref-stack))
1438 (setq help-xref-stack-item nil)
400a1b1f 1439 ;; There is a reference at point. Follow it.
376b2a24
DL
1440 (let ((help-xref-following t))
1441 (apply method args)))))
400a1b1f
RS
1442
1443;; For tabbing through buffer.
1444(defun help-next-ref ()
1445 "Find the next help cross-reference in the buffer."
1446 (interactive)
1447 (let (pos)
1448 (while (not pos)
1449 (if (get-text-property (point) 'help-xref) ; move off reference
ff3453e4
DL
1450 (goto-char (or (next-single-property-change (point) 'help-xref)
1451 (point))))
400a1b1f
RS
1452 (cond ((setq pos (next-single-property-change (point) 'help-xref))
1453 (if pos (goto-char pos)))
1454 ((bobp)
1455 (message "No cross references in the buffer.")
1456 (setq pos t))
1457 (t ; be circular
1458 (goto-char (point-min)))))))
1459
1460(defun help-previous-ref ()
1461 "Find the previous help cross-reference in the buffer."
1462 (interactive)
1463 (let (pos)
1464 (while (not pos)
1465 (if (get-text-property (point) 'help-xref) ; move off reference
1466 (goto-char (or (previous-single-property-change (point) 'help-xref)
1467 (point))))
1468 (cond ((setq pos (previous-single-property-change (point) 'help-xref))
1469 (if pos (goto-char pos)))
1470 ((bobp)
1471 (message "No cross references in the buffer.")
1472 (setq pos t))
1473 (t ; be circular
1474 (goto-char (point-max)))))))
1475
48ce3c22
RS
1476\f
1477;;; Automatic resizing of temporary buffers.
1478
4483ddc5 1479(defcustom temp-buffer-max-height (lambda (buffer) (/ (- (frame-height) 2) 2))
48ce3c22
RS
1480 "*Maximum height of a window displaying a temporary buffer.
1481This is the maximum height (in text lines) which `resize-temp-buffer-window'
1482will give to a window displaying a temporary buffer.
1483It can also be a function which will be called with the object corresponding
1484to the buffer to be displayed as argument and should return an integer
1485positive number."
1486 :type '(choice integer function)
1487 :group 'help
1488 :version "20.4")
1489
4e1ede6c
SM
1490(define-minor-mode temp-buffer-resize-mode
1491 "Toggle the mode which makes windows smaller for temporary buffers.
48ce3c22
RS
1492With prefix argument ARG, turn the resizing of windows displaying temporary
1493buffers on if ARG is positive or off otherwise.
4e1ede6c
SM
1494This makes the window the right height for its contents, but never
1495more than `temp-buffer-max-height' nor less than `window-min-height'.
1496This applies to `help', `apropos' and `completion' buffers, and some others."
1497 nil nil nil :global t :group 'help
1498 (if temp-buffer-resize-mode
57f43907 1499 ;; `help-make-xrefs' may add a `back' button and thus increase the
4e1ede6c
SM
1500 ;; text size, so `resize-temp-buffer-window' must be run *after* it.
1501 (add-hook 'temp-buffer-show-hook 'resize-temp-buffer-window 'append)
8304a3bb 1502 (remove-hook 'temp-buffer-show-hook 'resize-temp-buffer-window)))
48ce3c22
RS
1503
1504(defun resize-temp-buffer-window ()
1505 "Resize the current window to fit its contents.
4483ddc5 1506Will not make it higher than `temp-buffer-max-height' nor smaller than
b2c85790 1507`window-min-height'. Do nothing if it is the only window on its frame, if it
48ce3c22
RS
1508is not as wide as the frame or if some of the window's contents are scrolled
1509out of view."
1510 (unless (or (one-window-p 'nomini)
1511 (not (pos-visible-in-window-p (point-min)))
1512 (/= (frame-width) (window-width)))
d9c30bdf
MB
1513 (fit-window-to-buffer
1514 (selected-window)
1515 (if (functionp temp-buffer-max-height)
1516 (funcall temp-buffer-max-height (current-buffer))
1517 temp-buffer-max-height))))
48ce3c22 1518
f0d0fb19
DL
1519;; `help-manyarg-func-alist' is defined primitively (in doc.c).
1520;; New primitives with `MANY' or `UNEVALLED' arglists should be added
1521;; to this alist.
1522;; The parens and function name are redundant, but it's messy to add
1523;; them in `documentation'.
3b4429b4
DL
1524
1525;; This will find any missing items:
1526;; (let (l)
1527;; (mapatoms (lambda (x)
1528;; (if (and (fboundp x)
1529;; (subrp (symbol-function x))
1530;; (not (numberp (cdr (subr-arity (symbol-function x)))))
1531;; (not (assq x help-manyarg-func-alist)))
1532;; (push x l))))
1533;; l)
f0d0fb19
DL
1534(defconst help-manyarg-func-alist
1535 (purecopy
1536 '((list . "(list &rest OBJECTS)")
1537 (vector . "(vector &rest OBJECTS)")
1538 (make-byte-code . "(make-byte-code &rest ELEMENTS)")
1539 (call-process
1540 . "(call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)")
e3e36d74
DL
1541 (call-process-region
1542 . "(call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &rest ARGS)")
f0d0fb19
DL
1543 (string . "(string &rest CHARACTERS)")
1544 (+ . "(+ &rest NUMBERS-OR-MARKERS)")
1545 (- . "(- &optional NUMBER-OR-MARKER &rest MORE-NUMBERS-OR-MARKERS)")
1546 (* . "(* &rest NUMBERS-OR-MARKERS)")
1547 (/ . "(/ DIVIDEND DIVISOR &rest DIVISORS)")
1548 (max . "(max NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS)")
1549 (min . "(min NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS)")
1550 (logand . "(logand &rest INTS-OR-MARKERS)")
1551 (logior . "(logior &rest INTS-OR-MARKERS)")
1552 (logxor . "(logxor &rest INTS-OR-MARKERS)")
1553 (encode-time
1554 . "(encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE)")
1555 (insert . "(insert &rest ARGS)")
9a200f68 1556 (insert-and-inherit . "(insert-and-inherit &rest ARGS)")
f0d0fb19
DL
1557 (insert-before-markers . "(insert-before-markers &rest ARGS)")
1558 (message . "(message STRING &rest ARGUMENTS)")
1559 (message-box . "(message-box STRING &rest ARGUMENTS)")
1560 (message-or-box . "(message-or-box STRING &rest ARGUMENTS)")
1561 (propertize . "(propertize STRING &rest PROPERTIES)")
1562 (format . "(format STRING &rest OBJECTS)")
1563 (apply . "(apply FUNCTION &rest ARGUMENTS)")
1564 (run-hooks . "(run-hooks &rest HOOKS)")
2de47765
DL
1565 (run-hook-with-args . "(run-hook-with-args HOOK &rest ARGS)")
1566 (run-hook-with-args-until-failure
1567 . "(run-hook-with-args-until-failure HOOK &rest ARGS)")
1568 (run-hook-with-args-until-success
1569 . "(run-hook-with-args-until-success HOOK &rest ARGS)")
f0d0fb19
DL
1570 (funcall . "(funcall FUNCTION &rest ARGUMENTS)")
1571 (append . "(append &rest SEQUENCES)")
1572 (concat . "(concat &rest SEQUENCES)")
46c56972 1573 (vconcat . "(vconcat &rest SEQUENCES)")
f0d0fb19
DL
1574 (nconc . "(nconc &rest LISTS)")
1575 (widget-apply . "(widget-apply WIDGET PROPERTY &rest ARGS)")
1576 (make-hash-table . "(make-hash-table &rest KEYWORD-ARGS)")
1577 (insert-string . "(insert-string &rest ARGS)")
1578 (start-process . "(start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)")
1579 (setq-default . "(setq-default SYMBOL VALUE [SYMBOL VALUE...])")
1580 (save-excursion . "(save-excursion &rest BODY)")
1581 (save-current-buffer . "(save-current-buffer &rest BODY)")
1582 (save-restriction . "(save-restriction &rest BODY)")
1583 (or . "(or CONDITIONS ...)")
1584 (and . "(and CONDITIONS ...)")
1585 (if . "(if COND THEN ELSE...)")
1586 (cond . "(cond CLAUSES...)")
1587 (progn . "(progn BODY ...)")
1588 (prog1 . "(prog1 FIRST BODY...)")
1589 (prog2 . "(prog2 X Y BODY...)")
1590 (setq . "(setq SYM VAL SYM VAL ...)")
1591 (quote . "(quote ARG)")
1592 (function . "(function ARG)")
1593 (defun . "(defun NAME ARGLIST [DOCSTRING] BODY...)")
1594 (defmacro . "(defmacro NAME ARGLIST [DOCSTRING] BODY...)")
1595 (defvar . "(defvar SYMBOL [INITVALUE DOCSTRING])")
1596 (defconst . "(defconst SYMBOL INITVALUE [DOCSTRING])")
1597 (let* . "(let* VARLIST BODY...)")
1598 (let . "(let VARLIST BODY...)")
1599 (while . "(while TEST BODY...)")
1600 (catch . "(catch TAG BODY...)")
1601 (unwind-protect . "(unwind-protect BODYFORM UNWINDFORMS...)")
1602 (condition-case . "(condition-case VAR BODYFORM HANDLERS...)")
194959c7 1603 (track-mouse . "(track-mouse BODY ...)")
2de47765
DL
1604 (ml-if . "(ml-if COND THEN ELSE...)")
1605 (ml-provide-prefix-argument . "(ml-provide-prefix-argument ARG1 ARG2)")
3b4429b4 1606 (ml-prefix-argument-loop . "(ml-prefix-argument-loop ...)")
2de47765
DL
1607 (with-output-to-temp-buffer
1608 . "(with-output-to-temp-buffer BUFFNAME BODY ...)")
caf047ec
DL
1609 (save-window-excursion . "(save-window-excursion BODY ...)")
1610 (find-operation-coding-system
3b4429b4
DL
1611 . "(find-operation-coding-system OPERATION ARGUMENTS ...)")
1612 (insert-before-markers-and-inherit
1613 . "(insert-before-markers-and-inherit &rest ARGS)"))))
f0d0fb19 1614
5fbeea74
GM
1615;; Provide this for the sake of define-minor-mode which generates
1616;; defcustoms which require 'help'.
1617
1618(provide 'help)
1619
1a06eabd 1620;;; help.el ends here