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