1 ;;; help.el --- help commands for XEmacs.
3 ;; Copyright (C) 1985, 1986, 1992-4, 1997 Free Software Foundation, Inc.
6 ;; Keywords: help, internal, dumped
8 ;; This file is part of XEmacs.
10 ;; XEmacs is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; XEmacs is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with XEmacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;; Synched up with: FSF 19.30.
29 ;; This file is dumped with XEmacs.
31 ;; This code implements XEmacs's on-line help system, the one invoked by
32 ;;`M-x help-for-help'.
34 ;; 06/11/1997 -- Converted to use char-after instead of broken
35 ;; following-char. -slb
39 ;; Get the macro make-help-screen when this is compiled,
40 ;; or run interpreted, but not when the compiled code is loaded.
41 (eval-when-compile (require 'help-macro))
44 "Support for on-line help systems."
47 (defgroup help-appearance nil
48 "Appearance of help buffers."
51 (defvar help-map (let ((map (make-sparse-keymap)))
52 (set-keymap-name map 'help-map)
54 map (purecopy (gettext "(Type ? for further options)")))
56 "Keymap for characters following the Help key.")
58 ;; global-map definitions moved to keydefs.el
59 (fset 'help-command help-map)
61 (define-key help-map (vector help-char) 'help-for-help)
62 (define-key help-map "?" 'help-for-help)
63 (define-key help-map 'help 'help-for-help)
64 (define-key help-map '(f1) 'help-for-help)
66 (define-key help-map "\C-l" 'describe-copying) ; on \C-c in FSFmacs
67 (define-key help-map "\C-d" 'describe-distribution)
68 (define-key help-map "\C-w" 'describe-no-warranty)
69 (define-key help-map "a" 'hyper-apropos) ; 'command-apropos in FSFmacs
70 (define-key help-map "A" 'command-apropos)
72 (define-key help-map "b" 'describe-bindings)
73 (define-key help-map "B" 'describe-beta)
74 (define-key help-map "\C-p" 'describe-pointer)
76 (define-key help-map "C" 'customize)
77 (define-key help-map "c" 'describe-key-briefly)
78 (define-key help-map "k" 'describe-key)
80 (define-key help-map "d" 'describe-function)
81 (define-key help-map "e" 'describe-last-error)
82 (define-key help-map "f" 'describe-function)
84 (define-key help-map "F" 'xemacs-local-faq)
86 (define-key help-map "i" 'info)
87 (define-key help-map '(control i) 'Info-query)
88 ;; FSFmacs has Info-goto-emacs-command-node on C-f, no binding
90 (define-key help-map '(control c) 'Info-goto-emacs-command-node)
91 (define-key help-map '(control k) 'Info-goto-emacs-key-command-node)
92 (define-key help-map '(control f) 'Info-elisp-ref)
94 (define-key help-map "l" 'view-lossage)
96 (define-key help-map "m" 'describe-mode)
98 (define-key help-map "\C-n" 'view-emacs-news)
99 (define-key help-map "n" 'view-emacs-news)
101 (define-key help-map "p" 'finder-by-keyword)
103 ;; Do this right with an autoload cookie in finder.el.
104 ;;(autoload 'finder-by-keyword "finder"
105 ;; "Find packages matching a given keyword." t)
107 (define-key help-map "s" 'describe-syntax)
109 (define-key help-map "t" 'help-with-tutorial)
111 (define-key help-map "w" 'where-is)
113 (define-key help-map "v" 'describe-variable)
115 (if (fboundp 'view-last-error)
116 (define-key help-map "e" 'view-last-error))
119 (define-key help-map "q" 'help-quit)
121 ;#### This stuff was an attempt to have font locking and hyperlinks in the
122 ;help buffer, but it doesn't really work. Some of this stuff comes from
123 ;FSF Emacs; but the FSF Emacs implementation is rather broken, as usual.
124 ;What needs to happen is this:
126 ; -- we probably need a "hyperlink mode" from which help-mode is derived.
127 ; -- this means we probably need multiple inheritance of modes!
128 ; Thankfully this is not hard to implement; we already have the
129 ; ability for a keymap to have multiple parents. However, we'd
130 ; have to define any multiply-inherited-from modes using a standard
131 ; `define-mode' construction instead of manually doing it, because
132 ; we don't want each guy calling `kill-all-local-variables' and
133 ; messing up the previous one.
134 ; -- we need to scan the buffer ourselves (not from font-lock, because
135 ; the user might not have font-lock enabled) and highlight only
136 ; those words that are *documented* functions and variables (and
137 ; probably excluding words without dashes in them unless enclosed
138 ; in quotes, so that common words like "list" and "point" don't
140 ; -- we should *not* use font-lock keywords like below. Instead we
141 ; should add the font-lock stuff ourselves during the scanning phase,
142 ; if font-lock is enabled in this buffer.
144 ;(defun help-follow-reference (event extent user-data)
145 ; (let ((symbol (intern-soft (extent-string extent))))
146 ; (cond ((and symbol (fboundp symbol))
147 ; (describe-function symbol))
148 ; ((and symbol (boundp symbol))
149 ; (describe-variable symbol))
152 ;(defvar help-font-lock-keywords
153 ; (let ((name-char "[-+a-zA-Z0-9_*]") (sym-char "[-+a-zA-Z0-9_:*]"))
156 ; ;; The symbol itself.
157 ; (list (concat "\\`\\(" name-char "+\\)\\(:\\)?")
158 ; '(1 (if (match-beginning 2)
159 ; 'font-lock-function-name-face
160 ; 'font-lock-variable-name-face)
163 ; ;; Words inside `' which tend to be symbol names.
164 ; (list (concat "`\\(" sym-char sym-char "+\\)'")
166 ; 'font-lock-reference-face
167 ; (add-list-mode-item (match-beginning 1)
170 ; 'help-follow-reference))
173 ; ;; CLisp `:' keywords as references.
174 ; (list (concat "\\<:" sym-char "+\\>") 0 'font-lock-reference-face t)))
175 ; "Default expressions to highlight in Help mode.")
177 ;(put 'help-mode 'font-lock-defaults '(help-font-lock-keywords))
179 (define-derived-mode help-mode view-major-mode "Help"
180 "Major mode for viewing help text.
181 Entry to this mode runs the normal hook `help-mode-hook'.
186 (define-key help-mode-map "q" 'help-mode-quit)
187 (define-key help-mode-map "Q" 'help-mode-bury)
188 (define-key help-mode-map "f" 'find-function-at-point)
189 (define-key help-mode-map "d" 'describe-function-at-point)
190 (define-key help-mode-map "v" 'describe-variable-at-point)
191 (define-key help-mode-map "i" 'Info-elisp-ref)
192 (define-key help-mode-map "c" 'customize-variable)
193 (define-key help-mode-map [tab] 'help-next-symbol)
194 (define-key help-mode-map [(shift tab)] 'help-prev-symbol)
195 (define-key help-mode-map "n" 'help-next-section)
196 (define-key help-mode-map "p" 'help-prev-section)
198 (defun describe-function-at-point ()
199 "Describe directly the function at point in the other window."
201 (let ((symb (function-at-point)))
203 (describe-function symb))))
205 (defun describe-variable-at-point ()
206 "Describe directly the variable at point in the other window."
208 (let ((symb (variable-at-point)))
210 (describe-variable symb))))
212 (defun help-next-symbol ()
213 "Move point to the next quoted symbol."
215 (search-forward "`" nil t))
217 (defun help-prev-symbol ()
218 "Move point to the previous quoted symbol."
220 (search-backward "'" nil t))
222 (defun help-next-section ()
223 "Move point to the next quoted symbol."
225 (search-forward-regexp "^\\w+:" nil t))
227 (defun help-prev-section ()
228 "Move point to the previous quoted symbol."
230 (search-backward-regexp "^\\w+:" nil t))
232 (defun help-mode-bury ()
233 "Bury the help buffer, possibly restoring the previous window configuration."
237 (defun help-mode-quit (&optional bury)
238 "Exit from help mode, possibly restoring the previous window configuration.
239 If the optional argument BURY is non-nil, the help buffer is buried,
240 otherwise it is killed."
242 (let ((buf (current-buffer)))
243 (cond ((frame-property (selected-frame) 'help-window-config)
244 (set-window-configuration
245 (frame-property (selected-frame) 'help-window-config))
246 (set-frame-property (selected-frame) 'help-window-config nil))
247 ((not (one-window-p))
257 ;; This is a grody hack of the same genotype as `advertised-undo'; if the
258 ;; bindings of Backspace and C-h are the same, we want the menubar to claim
259 ;; that `info' in invoked with `C-h i', not `BS i'.
261 (defun deprecated-help-command ()
263 (if (eq 'help-command (key-binding "\C-h"))
264 (setq unread-command-event (character-to-event ?\C-h))
267 ;;(define-key global-map 'backspace 'deprecated-help-command)
269 ;; This function has been moved to help-nomule.el and mule-help.el.
270 ;; TUTORIAL arg is XEmacs addition
271 ;(defun help-with-tutorial (&optional tutorial)
272 ; "Select the XEmacs learn-by-doing tutorial.
273 ;Optional arg TUTORIAL specifies the tutorial file; default is \"TUTORIAL\"."
275 ; (if (null tutorial)
276 ; (setq tutorial "TUTORIAL"))
277 ; (let ((file (expand-file-name (concat "~/" tutorial))))
278 ; (delete-other-windows)
279 ; (if (get-file-buffer file)
280 ; (switch-to-buffer (get-file-buffer file))
281 ; (switch-to-buffer (create-file-buffer file))
282 ; (setq buffer-file-name file)
283 ; (setq default-directory (expand-file-name "~/"))
284 ; (setq buffer-auto-save-file-name nil)
285 ; (insert-file-contents (expand-file-name tutorial data-directory))
286 ; (goto-char (point-min))
287 ; (search-forward "\n<<")
288 ; (delete-region (point-at-bol) (point-at-eol))
289 ; (let ((n (- (window-height (selected-window))
290 ; (count-lines (point-min) (point))
294 ; ;; Some people get confused by the large gap.
296 ; (insert "[Middle of page left blank for didactic purposes. "
297 ; "Text continues below]")
298 ; (newline (- n (/ n 2)))))
299 ; (goto-char (point-min))
300 ; (set-buffer-modified-p nil))))
302 ;; used by describe-key, describe-key-briefly, insert-key-binding, etc.
304 (defun key-or-menu-binding (key &optional menu-flag)
305 "Return the command invoked by KEY.
306 Like `key-binding', but handles menu events and toolbar presses correctly.
307 KEY is any value returned by `next-command-event'.
308 MENU-FLAG is a symbol that should be set to T if KEY is a menu event,
311 (and menu-flag (set menu-flag nil))
312 ;; If the key typed was really a menu selection, grab the form out
313 ;; of the event object and intuit the function that would be called,
314 ;; and describe that instead.
315 (if (and (vectorp key) (= 1 (length key))
316 (or (misc-user-event-p (aref key 0))
317 (eq (car-safe (aref key 0)) 'menu-selection)))
318 (let ((event (aref key 0)))
319 (setq defn (if (eventp event)
320 (list (event-function event) (event-object event))
322 (and menu-flag (set menu-flag t))
323 (when (eq (car defn) 'eval)
324 (setq defn (car (cdr defn))))
325 (when (eq (car-safe defn) 'call-interactively)
326 (setq defn (car (cdr defn))))
327 (when (and (consp defn) (null (cdr defn)))
328 (setq defn (car defn))))
330 (setq defn (key-binding key)))
331 ;; kludge: if a toolbar button was pressed on, try to find the
332 ;; binding of the toolbar button.
333 (if (and (eq defn 'press-toolbar-button)
335 (button-press-event-p (aref key (1- (length key)))))
336 ;; wait for the button release. We're on shaky ground here ...
337 (let ((event (next-command-event))
339 (if (and (button-release-event-p event)
340 (event-over-toolbar-p event)
341 (eq 'release-and-activate-toolbar-button
342 (key-binding (vector event)))
343 (setq button (event-toolbar-button event)))
344 (toolbar-button-callback button)
345 ;; if anything went wrong, try returning the binding of
346 ;; the button-up event, of the original binding
347 (or (key-or-menu-binding (vector event))
353 (defun describe-key-briefly (key &optional insert)
354 "Print the name of the function KEY invokes. KEY is a string.
355 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
356 (interactive "kDescribe key briefly: \nP")
357 (let ((standard-output (if insert (current-buffer) t))
359 (setq defn (key-or-menu-binding key 'menup))
360 (if (or (null defn) (integerp defn))
361 (princ (format "%s is undefined" (key-description key)))
362 ;; If it's a keyboard macro which trivially invokes another command,
363 ;; document that instead.
364 (if (or (stringp defn) (vectorp defn))
365 (setq defn (or (key-binding defn)
367 (let ((last-event (and (vectorp key)
368 (aref key (1- (length key))))))
369 (princ (format (cond (insert
371 ((or (button-press-event-p last-event)
372 (button-release-event-p last-event))
373 (gettext "%s at that spot runs the command %s"))
375 (gettext "%s runs the command %s")))
376 ;; This used to say 'This menu item' but it
377 ;; could also be a scrollbar event. We can't
378 ;; distinguish at the moment.
380 (if insert "item" "This item")
381 (key-description key))
382 (if (symbolp defn) defn (prin1-to-string defn))))))))
384 ;; #### this is a horrible piece of shit function that should
385 ;; not exist. In FSF 19.30 this function has gotten three times
386 ;; as long and has tons and tons of dumb shit checking
387 ;; special-display-buffer-names and such crap. I absolutely
388 ;; refuse to insert that Ebolification here. I wanted to delete
389 ;; this function entirely but Mly bitched.
391 ;; If your user-land code calls this function, rewrite it to
392 ;; call with-displaying-help-buffer.
394 (defun print-help-return-message (&optional function)
395 "Display or return message saying how to restore windows after help command.
396 Computes a message and applies the optional argument FUNCTION to it.
397 If FUNCTION is nil, applies `message' to it, thus printing it."
398 (and (not (get-buffer-window standard-output))
400 (or function 'message)
402 (substitute-command-keys
405 (gettext "Type \\[delete-other-windows] to remove help window.")
406 (gettext "Type \\[switch-to-buffer] RET to remove help window."))
407 (gettext "Type \\[switch-to-buffer-other-window] RET to restore the other window.")))
408 (substitute-command-keys
409 (gettext " \\[scroll-other-window] to scroll the help."))))))
411 (defcustom help-selects-help-window t
412 "*If nil, use the \"old Emacs\" behavior for Help buffers.
413 This just displays the buffer in another window, rather than selecting
416 :group 'help-appearance)
418 (defcustom help-max-help-buffers 10
419 "*Maximum help buffers to allow before they start getting killed.
420 If this is a positive integer, before a help buffer is displayed
421 by `with-displaying-help-buffer', any excess help buffers which
422 are not being displayed are first killed. Otherwise, if it is
423 zero or nil, only one help buffer, \"*Help*\" is ever used."
424 :type '(choice integer (const :tag "None" nil))
425 :group 'help-appearance)
427 (defvar help-buffer-list nil
428 "List of help buffers used by `help-register-and-maybe-prune-excess'")
430 (defun help-register-and-maybe-prune-excess (newbuf)
431 "Register use of a help buffer and possibly kill any excess ones."
432 ;; remove new buffer from list
433 (setq help-buffer-list (remove newbuf help-buffer-list))
434 ;; maybe kill excess help buffers
435 (if (and (integerp help-max-help-buffers)
436 (> (length help-buffer-list) help-max-help-buffers))
437 (let ((keep-list nil)
438 (num-kill (- (length help-buffer-list)
439 help-max-help-buffers)))
440 (while help-buffer-list
441 (let ((buf (car help-buffer-list)))
442 (if (and (or (equal buf newbuf) (get-buffer buf))
443 (string-match "^*Help" buf)
444 (save-excursion (set-buffer buf)
445 (eq major-mode 'help-mode)))
446 (if (and (>= num-kill (length help-buffer-list))
447 (not (get-buffer-window buf t t)))
449 (setq keep-list (cons buf keep-list)))))
450 (setq help-buffer-list (cdr help-buffer-list)))
451 (setq help-buffer-list (nreverse keep-list))))
453 (setq help-buffer-list (cons newbuf help-buffer-list)))
455 (defvar help-buffer-prefix-string "Help"
456 "Initial string to use in constructing help buffer names.
457 You should never set this directory, only let-bind it.")
459 (defun help-buffer-name (name)
460 "Return a name for a Help buffer using string NAME for context."
461 (if (and (integerp help-max-help-buffers)
462 (> help-max-help-buffers 0)
464 (format "*%s: %s*" help-buffer-prefix-string name)
465 (format "*%s*" help-buffer-prefix-string)))
467 ;; Use this function for displaying help when C-h something is pressed
468 ;; or in similar situations. Do *not* use it when you are displaying
469 ;; a help message and then prompting for input in the minibuffer --
470 ;; this macro usually selects the help buffer, which is not what you
471 ;; want in those situations.
473 ;; #### Should really be a macro to eliminate the requirement of
474 ;; caller to code a lambda form in THUNK -- mrb
476 ;; #### BEFORE you rush to make this a macro, think about backward
477 ;; compatibility. The right way would be to create a macro with
478 ;; another name (which is a shame, because w-d-h-b is a perfect name
479 ;; for a macro) that uses with-displaying-help-buffer internally.
481 (defun with-displaying-help-buffer (thunk &optional name)
482 "Form which makes a help buffer with given NAME and evaluates BODY there.
483 The actual name of the buffer is generated by the function `help-buffer-name'."
484 (let* ((winconfig (current-window-configuration))
485 (was-one-window (one-window-p))
486 (buffer-name (help-buffer-name name))
488 (not (and (windows-of-buffer buffer-name) ;shortcut
489 (memq (selected-frame)
490 (mapcar 'window-frame
491 (windows-of-buffer buffer-name)))))))
492 (help-register-and-maybe-prune-excess buffer-name)
493 (prog1 (with-output-to-temp-buffer buffer-name
494 (prog1 (funcall thunk)
496 (set-buffer standard-output)
498 (let ((helpwin (get-buffer-window buffer-name)))
500 (with-current-buffer (window-buffer helpwin)
501 ;; If the *Help* buffer is already displayed on this
502 ;; frame, don't override the previous configuration
503 (when help-not-visible
504 (set-frame-property (selected-frame)
505 'help-window-config winconfig)))
506 (when help-selects-help-window
507 (select-window helpwin))
508 (cond ((eq helpwin (selected-window))
509 (display-message 'command
510 (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help.")))
512 (display-message 'command
513 (substitute-command-keys "Type \\[delete-other-windows] to remove help window, \\[scroll-other-window] to scroll the help.")))
515 (display-message 'command
516 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help.")))))))))
518 (defun describe-key (key)
519 "Display documentation of the function invoked by KEY.
520 KEY is a string, or vector of events.
521 When called interactively, KEY may also be a menu selection."
522 (interactive "kDescribe key: ")
523 (let ((defn (key-or-menu-binding key))
524 (key-string (key-description key)))
525 (if (or (null defn) (integerp defn))
526 (message "%s is undefined" key-string)
527 (with-displaying-help-buffer
532 (princ (format "`%s'" defn))
535 (cond ((or (stringp defn) (vectorp defn))
536 (let ((cmd (key-binding defn)))
538 (princ "a keyboard macro")
540 (princ "a keyboard macro which runs the command ")
543 (if (documentation cmd) (princ (documentation cmd)))))))
544 ((and (consp defn) (not (eq 'lambda (car-safe defn))))
545 (let ((describe-function-show-arglist nil))
546 (describe-function-1 (car defn))))
548 (describe-function-1 defn))
549 ((documentation defn)
550 (princ (documentation defn)))
552 (princ "not documented"))))
553 (format "key `%s'" key-string)))))
555 (defun describe-mode ()
556 "Display documentation of current major mode and minor modes.
557 For this to work correctly for a minor mode, the mode's indicator variable
558 \(listed in `minor-mode-alist') must also be a function whose documentation
559 describes the minor mode."
561 (with-displaying-help-buffer
563 ;; XEmacs change: print the major-mode documentation before
567 (princ (documentation major-mode))
568 (princ "\n\n----\n\n")
569 (let ((minor-modes minor-mode-alist))
571 (let* ((minor-mode (car (car minor-modes)))
572 (indicator (car (cdr (car minor-modes)))))
573 ;; Document a minor mode if it is listed in minor-mode-alist,
574 ;; bound locally in this buffer, non-nil, and has a function
576 (if (and (boundp minor-mode)
577 (symbol-value minor-mode)
578 (fboundp minor-mode))
579 (let ((pretty-minor-mode minor-mode))
580 (if (string-match "-mode\\'" (symbol-name minor-mode))
581 (setq pretty-minor-mode
583 (substring (symbol-name minor-mode)
584 0 (match-beginning 0)))))
585 (while (and (consp indicator) (extentp (car indicator)))
586 (setq indicator (cdr indicator)))
587 (while (and indicator (symbolp indicator))
588 (setq indicator (symbol-value indicator)))
589 (princ (format "%s minor mode (indicator%s):\n"
590 pretty-minor-mode indicator))
591 (princ (documentation minor-mode))
592 (princ "\n\n----\n\n"))))
593 (setq minor-modes (cdr minor-modes)))))
594 (format "%s mode" mode-name)))
596 ;; So keyboard macro definitions are documented correctly
597 (fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
599 (defun describe-distribution ()
600 "Display info on how to obtain the latest version of XEmacs."
603 (locate-data-file "DISTRIB")))
605 (defun describe-beta ()
606 "Display info on how to deal with Beta versions of XEmacs."
609 (locate-data-file "BETA"))
610 (goto-char (point-min)))
612 (defun describe-copying ()
613 "Display info on how you may redistribute copies of XEmacs."
616 (locate-data-file "COPYING"))
617 (goto-char (point-min)))
619 (defun describe-pointer ()
620 "Show a list of all defined mouse buttons, and their definitions."
622 (describe-bindings nil t))
624 (defun describe-project ()
625 "Display info on the GNU project."
628 (locate-data-file "GNU"))
629 (goto-char (point-min)))
631 (defun describe-no-warranty ()
632 "Display info on all the kinds of warranty XEmacs does NOT have."
635 (let (case-fold-search)
636 (search-forward "NO WARRANTY")
639 (defun describe-bindings (&optional prefix mouse-only-p)
640 "Show a list of all defined keys, and their definitions.
641 The list is put in a buffer, which is displayed.
642 If the optional argument PREFIX is supplied, only commands which
643 start with that sequence of keys are described.
644 If the second argument (prefix arg, interactively) is non-null
645 then only the mouse bindings are displayed."
646 (interactive (list nil current-prefix-arg))
647 (with-displaying-help-buffer
649 (describe-bindings-1 prefix mouse-only-p))
650 (format "bindings for %s" major-mode)))
652 (defun describe-bindings-1 (&optional prefix mouse-only-p)
653 (let ((heading (if mouse-only-p
654 (gettext "button binding\n------ -------\n")
655 (gettext "key binding\n--- -------\n")))
656 (buffer (current-buffer))
657 (minor minor-mode-map-alist)
658 (local (current-local-map))
660 (set-buffer standard-output)
662 (let ((sym (car (car minor)))
663 (map (cdr (car minor))))
664 (if (symbol-value-in-buffer sym buffer nil)
666 (insert (format "Minor Mode Bindings for `%s':\n"
669 (describe-bindings-internal map nil shadow prefix mouse-only-p)
671 (setq shadow (cons map shadow))))
672 (setq minor (cdr minor))))
675 (insert "Local Bindings:\n" heading)
676 (describe-bindings-internal local nil shadow prefix mouse-only-p)
678 (setq shadow (cons local shadow))))
679 (insert "Global Bindings:\n" heading)
680 (describe-bindings-internal (current-global-map)
681 nil shadow prefix mouse-only-p)
682 (when (and prefix function-key-map (not mouse-only-p))
683 (insert "\nFunction key map translations:\n" heading)
684 (describe-bindings-internal function-key-map nil nil
685 prefix mouse-only-p))
689 (defun describe-prefix-bindings ()
690 "Describe the bindings of the prefix used to reach this command.
691 The prefix described consists of all but the last event
692 of the key sequence that ran this command."
694 (let* ((key (this-command-keys))
695 (prefix (make-vector (1- (length key)) nil))
698 (while (< i (length prefix))
699 (aset prefix i (aref key i))
701 (with-displaying-help-buffer
703 (princ "Key bindings starting with ")
704 (princ (key-description prefix))
706 (describe-bindings-1 prefix nil))
707 (format "%s prefix" (key-description prefix)))))
709 ;; Make C-h after a prefix, when not specifically bound,
710 ;; run describe-prefix-bindings.
711 (setq prefix-help-command 'describe-prefix-bindings)
713 (defun describe-installation ()
714 "Display a buffer showing information about this XEmacs was compiled."
716 (if (and (boundp 'Installation-string)
717 (stringp Installation-string))
718 (with-displaying-help-buffer
720 (princ Installation-string))
722 (error "No Installation information available.")))
724 (defun view-emacs-news ()
725 "Display info on recent changes to XEmacs."
727 (find-file (locate-data-file "NEWS")))
729 (defun xemacs-www-page ()
730 "Go to the XEmacs World Wide Web page."
732 (if (boundp 'browse-url-browser-function)
733 (funcall browse-url-browser-function "http://www.xemacs.org/")
734 (error "xemacs-www-page requires browse-url")))
736 (defun xemacs-www-faq ()
737 "View the latest and greatest XEmacs FAQ using the World Wide Web."
739 (if (boundp 'browse-url-browser-function)
740 (funcall browse-url-browser-function
741 "http://www.xemacs.org/faq/index.html")
742 (error "xemacs-www-faq requires browse-url")))
744 (defun xemacs-local-faq ()
745 "View the local copy of the XEmacs FAQ.
746 If you have access to the World Wide Web, you should use `xemacs-www-faq'
747 instead, to ensure that you get the most up-to-date information."
749 (save-window-excursion
751 (Info-find-node "xemacs-faq" "Top"))
752 (switch-to-buffer "*info*"))
754 (defcustom view-lossage-key-count 100
755 "*Number of keys `view-lossage' shows.
756 The maximum number of available keys is governed by `recent-keys-ring-size'."
760 (defcustom view-lossage-message-count 100
761 "*Number of minibuffer messages `view-lossage' shows."
765 (defun print-recent-messages (n)
766 "Print N most recent messages to standard-output, most recent first.
767 If N is nil, all messages will be printed."
769 (let ((buffer (get-buffer-create " *Message-Log*"))
771 (goto-char (point-max buffer) buffer)
772 (set-buffer standard-output)
773 (while (and (not (bobp buffer))
774 (or (null n) (>= (decf n) 0)))
775 (setq oldpoint (point buffer))
776 (setq extent (extent-at oldpoint buffer
777 'message-multiline nil 'before))
778 ;; If the message was multiline, move all the way to the
781 (goto-char (extent-start-position extent) buffer)
782 (forward-line -1 buffer))
783 (insert-buffer-substring buffer (point buffer) oldpoint)))))
785 (defun view-lossage ()
786 "Display recent input keystrokes and recent minibuffer messages.
787 The number of keys shown is controlled by `view-lossage-key-count'.
788 The number of messages shown is controlled by `view-lossage-message-count'."
790 (with-displaying-help-buffer
792 (princ (key-description (recent-keys view-lossage-key-count)))
794 (set-buffer standard-output)
795 (goto-char (point-min))
796 (insert "Recent keystrokes:\n\n")
797 (while (progn (move-to-column 50) (not (eobp)))
798 (search-forward " " nil t)
800 ;; XEmacs addition: copy the messages from " *Message-Log*",
801 ;; reversing their order and handling multiline messages
803 (princ "\n\n\nRecent minibuffer messages (most recent first):\n\n")
804 (print-recent-messages view-lossage-message-count))
807 (define-function 'help 'help-for-help)
809 (make-help-screen help-for-help
810 "A B C F I K L M N P S T V W C-c C-d C-f C-i C-k C-n C-w; ? for more help:"
812 \(Use SPC or DEL to scroll through this text. Type \\<help-map>\\[help-quit] to exit the Help command.)
814 \\[hyper-apropos] Type a substring; it shows a hypertext list of
815 functions and variables that contain that substring.
816 See also the `apropos' command.
817 \\[command-apropos] Type a substring; it shows a list of commands
818 (interactively callable functions) that contain that substring.
819 \\[describe-bindings] Table of all key bindings.
820 \\[describe-key-briefly] Type a command key sequence;
821 it displays the function name that sequence runs.
822 \\[customize] Customize Emacs options.
823 \\[Info-goto-emacs-command-node] Type a function name; it displays the Info node for that command.
824 \\[describe-function] Type a function name; it shows its documentation.
825 \\[Info-elisp-ref] Type a function name; it jumps to the full documentation
826 in the XEmacs Lisp Programmer's Manual.
827 \\[xemacs-local-faq] Local copy of the XEmacs FAQ.
828 \\[info] Info documentation reader.
829 \\[Info-query] Type an Info file name; it displays it in Info reader.
830 \\[describe-key] Type a command key sequence;
831 it displays the documentation for the command bound to that key.
832 \\[Info-goto-emacs-key-command-node] Type a command key sequence;
833 it displays the Info node for the command bound to that key.
834 \\[view-lossage] Recent input keystrokes and minibuffer messages.
835 \\[describe-mode] Documentation of current major and minor modes.
836 \\[view-emacs-news] News of recent XEmacs changes.
837 \\[finder-by-keyword] Type a topic keyword; it finds matching packages.
838 \\[describe-pointer] Table of all mouse-button bindings.
839 \\[describe-syntax] Contents of syntax table with explanations.
840 \\[help-with-tutorial] XEmacs learn-by-doing tutorial.
841 \\[describe-variable] Type a variable name; it displays its documentation and value.
842 \\[where-is] Type a command name; it displays which keystrokes invoke that command.
843 \\[describe-distribution] XEmacs ordering information.
844 \\[describe-no-warranty] Information on absence of warranty for XEmacs.
845 \\[describe-copying] XEmacs copying permission (General Public License)."
848 (defmacro with-syntax-table (syntab &rest body)
849 "Evaluate BODY with the syntax-table SYNTAB"
850 `(let ((stab (syntax-table)))
853 (set-syntax-table (copy-syntax-table ,syntab))
855 (set-syntax-table stab))))
856 (put 'with-syntax-table 'lisp-indent-function 1)
857 (put 'with-syntax-table 'edebug-form-spec '(form body))
859 (defun function-called-at-point ()
860 "Return the function which is called by the list containing point.
861 If that gives no function, return the function whose name is around point.
862 If that doesn't give a function, return nil."
866 (narrow-to-region (max (point-min) (- (point) 1000))
871 (setq obj (read (current-buffer)))
872 (and (symbolp obj) (fboundp obj) obj)))))
874 (with-syntax-table emacs-lisp-mode-syntax-table
876 (or (not (zerop (skip-syntax-backward "_w")))
877 (eq (char-syntax (char-after (point))) ?w)
878 (eq (char-syntax (char-after (point))) ?_)
880 (skip-chars-forward "`'")
881 (let ((obj (read (current-buffer))))
882 (and (symbolp obj) (fboundp obj) obj)))))))
884 (defun function-at-point ()
885 "Return the function whose name is around point.
886 If that gives no function, return the function which is called by the
887 list containing point. If that doesn't give a function, return nil."
889 (with-syntax-table emacs-lisp-mode-syntax-table
891 (or (not (zerop (skip-syntax-backward "_w")))
892 (eq (char-syntax (char-after (point))) ?w)
893 (eq (char-syntax (char-after (point))) ?_)
895 (skip-chars-forward "`'")
896 (let ((obj (read (current-buffer))))
897 (and (symbolp obj) (fboundp obj) obj)))))
901 (narrow-to-region (max (point-min) (- (point) 1000))
906 (setq obj (read (current-buffer)))
907 (and (symbolp obj) (fboundp obj) obj)))))))
909 ;; Default to nil for the non-hackers? Not until we find a way to
910 ;; distinguish hackers from non-hackers automatically!
911 (defcustom describe-function-show-arglist t
912 "*If non-nil, describe-function will show its arglist,
913 unless the function is autoloaded."
915 :group 'help-appearance)
917 (defun describe-symbol-find-file (symbol)
918 (loop for (file . load-data) in load-history
919 do (when (memq symbol load-data)
922 (define-obsolete-function-alias
923 'describe-function-find-file
924 'describe-symbol-find-file)
926 (defun describe-function (function)
927 "Display the full documentation of FUNCTION (a symbol).
928 When run interactively, it defaults to any function found by
929 `function-at-point'."
931 (let* ((fn (function-at-point))
932 (val (let ((enable-recursive-minibuffers t))
935 (format (gettext "Describe function (default %s): ")
937 (gettext "Describe function: "))
938 obarray 'fboundp t nil 'function-history))))
939 (list (if (equal val "") fn (intern val)))))
940 (with-displaying-help-buffer
942 (describe-function-1 function)
943 ;; Return the text we displayed.
944 (buffer-string nil nil standard-output))
945 (format "function `%s'" function)))
947 (defun function-obsolete-p (function)
948 "Return non-nil if FUNCTION is obsolete."
949 (not (null (get function 'byte-obsolete-info))))
951 (defun function-obsoleteness-doc (function)
952 "If FUNCTION is obsolete, return a string describing this."
953 (let ((obsolete (get function 'byte-obsolete-info)))
955 (format "Obsolete; %s"
956 (if (stringp (car obsolete))
958 (format "use `%s' instead." (car obsolete)))))))
960 (defun function-compatible-p (function)
961 "Return non-nil if FUNCTION is present for Emacs compatibility."
962 (not (null (get function 'byte-compatible-info))))
964 (defun function-compatibility-doc (function)
965 "If FUNCTION is Emacs compatible, return a string describing this."
966 (let ((compatible (get function 'byte-compatible-info)))
968 (format "Emacs Compatible; %s"
969 (if (stringp (car compatible))
971 (format "use `%s' instead." (car compatible)))))))
973 ;Here are all the possibilities below spelled out, for the benefit
974 ;of the I18N3 snarfer.
976 ;(gettext "a built-in function")
977 ;(gettext "an interactive built-in function")
978 ;(gettext "a built-in macro")
979 ;(gettext "an interactive built-in macro")
980 ;(gettext "a compiled Lisp function")
981 ;(gettext "an interactive compiled Lisp function")
982 ;(gettext "a compiled Lisp macro")
983 ;(gettext "an interactive compiled Lisp macro")
984 ;(gettext "a Lisp function")
985 ;(gettext "an interactive Lisp function")
986 ;(gettext "a Lisp macro")
987 ;(gettext "an interactive Lisp macro")
988 ;(gettext "a mocklisp function")
989 ;(gettext "an interactive mocklisp function")
990 ;(gettext "a mocklisp macro")
991 ;(gettext "an interactive mocklisp macro")
992 ;(gettext "an autoloaded Lisp function")
993 ;(gettext "an interactive autoloaded Lisp function")
994 ;(gettext "an autoloaded Lisp macro")
995 ;(gettext "an interactive autoloaded Lisp macro")
997 ;; taken out of `describe-function-1'
998 (defun function-arglist (function)
999 "Return a string giving the argument list of FUNCTION.
1002 (function-arglist 'function-arglist)
1003 => (function-arglist FUNCTION)
1005 This function is used by `describe-function-1' to list function
1006 arguments in the standard Lisp style."
1007 (let* ((fndef (indirect-function function))
1009 (cond ((compiled-function-p fndef)
1010 (compiled-function-arglist fndef))
1011 ((eq (car-safe fndef) 'lambda)
1014 (let* ((doc (documentation function))
1015 (args (and (string-match
1016 "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'"
1018 (match-string 1 doc))))
1019 ;; If there are no arguments documented for the
1020 ;; subr, rather don't print anything.
1021 (cond ((null args) t)
1022 ((equal args "") nil)
1025 (cond ((listp arglist)
1027 (cons function (mapcar (lambda (arg)
1028 (if (memq arg '(&optional &rest))
1030 (intern (upcase (symbol-name arg)))))
1034 (format "(%s %s)" function arglist)))))
1036 (defun function-documentation (function &optional strip-arglist)
1037 "Return a string giving the documentation for FUNCTION, if any.
1038 If the optional argument STRIP-ARGLIST is non-nil, remove the arglist
1039 part of the documentation of internal subroutines."
1040 (let ((doc (condition-case nil
1041 (or (documentation function)
1042 (gettext "not documented"))
1043 (void-function ""))))
1044 (if (and strip-arglist
1045 (string-match "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'" doc))
1046 (setq doc (substring doc 0 (match-beginning 0))))
1049 (defun describe-function-1 (function &optional nodoc)
1050 "This function does the work for `describe-function'."
1051 (princ (format "`%s' is " function))
1052 (let* ((def function)
1053 aliases file-name autoload-file kbd-macro-p fndef macrop)
1054 (while (and (symbolp def) (fboundp def))
1055 (when (not (eq def function))
1058 ;; I18N3 Need gettext due to concat
1061 "\n which is an alias for `%s', "
1063 (format "an alias for `%s', " (symbol-name def)))))
1064 (setq def (symbol-function def)))
1065 (if (and (fboundp 'compiled-function-annotation)
1066 (compiled-function-p def))
1067 (setq file-name (compiled-function-annotation def)))
1068 (if (eq 'macro (car-safe def))
1069 (setq fndef (cdr def)
1070 file-name (and (compiled-function-p (cdr def))
1071 (fboundp 'compiled-function-annotation)
1072 (compiled-function-annotation (cdr def)))
1075 (if aliases (princ aliases))
1076 (let ((int #'(lambda (string an-p macro-p)
1079 (cond ((commandp def)
1084 (if macro-p " macro" " function")))
1086 (cond ((or (stringp def) (vectorp def))
1087 (princ "a keyboard macro.")
1088 (setq kbd-macro-p t))
1090 (funcall int "built-in" nil macrop))
1091 ((compiled-function-p fndef)
1092 (funcall int "compiled Lisp" nil macrop))
1093 ((eq (car-safe fndef) 'lambda)
1094 (funcall int "Lisp" nil macrop))
1095 ((eq (car-safe fndef) 'mocklisp)
1096 (funcall int "mocklisp" nil macrop))
1097 ((eq (car-safe def) 'autoload)
1098 (setq autoload-file (elt def 1))
1099 (funcall int "autoloaded Lisp" t (elt def 4)))
1100 ((and (symbolp def) (not (fboundp def)))
1101 (princ "a symbol with a void (unbound) function definition."))
1106 (princ (format " -- autoloads from \"%s\"\n" autoload-file)))
1108 (setq file-name (describe-symbol-find-file function)))
1110 (princ (format " -- loaded from \"%s\"\n" file-name)))
1112 (if describe-function-show-arglist
1113 (let ((arglist (function-arglist function)))
1119 (princ "These characters are executed:\n\n\t")
1120 (princ (key-description def))
1121 (cond ((setq def (key-binding def))
1122 (princ (format "\n\nwhich executes the command `%s'.\n\n"
1124 (describe-function-1 def))))
1127 ;; tell the user about obsoleteness.
1128 ;; If the function is obsolete and is aliased, don't
1129 ;; even bother to report the documentation, as a further
1130 ;; encouragement to use the new function.
1131 (let ((obsolete (function-obsoleteness-doc function))
1132 (compatible (function-compatibility-doc function)))
1141 (unless (and obsolete aliases)
1142 (let ((doc (function-documentation function t)))
1143 (princ "Documentation:\n")
1145 (unless (or (equal doc "")
1146 (eq ?\n (aref doc (1- (length doc)))))
1150 ;;; [Obnoxious, whining people who complain very LOUDLY on Usenet
1151 ;;; are binding this to keys.]
1152 (defun describe-function-arglist (function)
1153 (interactive (list (or (function-at-point)
1154 (error "no function call at point"))))
1156 (message (function-arglist function)))
1159 (defun variable-at-point ()
1161 (with-syntax-table emacs-lisp-mode-syntax-table
1163 (or (not (zerop (skip-syntax-backward "_w")))
1164 (eq (char-syntax (char-after (point))) ?w)
1165 (eq (char-syntax (char-after (point))) ?_)
1167 (skip-chars-forward "'")
1168 (let ((obj (read (current-buffer))))
1169 (and (symbolp obj) (boundp obj) obj))))))
1171 (defun variable-obsolete-p (variable)
1172 "Return non-nil if VARIABLE is obsolete."
1173 (not (null (get variable 'byte-obsolete-variable))))
1175 (defun variable-obsoleteness-doc (variable)
1176 "If VARIABLE is obsolete, return a string describing this."
1177 (let ((obsolete (get variable 'byte-obsolete-variable)))
1179 (format "Obsolete; %s"
1180 (if (stringp obsolete)
1182 (format "use `%s' instead." obsolete))))))
1184 (defun variable-compatible-p (variable)
1185 "Return non-nil if VARIABLE is Emacs compatible."
1186 (not (null (get variable 'byte-compatible-variable))))
1188 (defun variable-compatibility-doc (variable)
1189 "If VARIABLE is Emacs compatible, return a string describing this."
1190 (let ((compatible (get variable 'byte-compatible-variable)))
1192 (format "Emacs Compatible; %s"
1193 (if (stringp compatible)
1195 (format "use `%s' instead." compatible))))))
1197 (defun built-in-variable-doc (variable)
1198 "Return a string describing whether VARIABLE is built-in."
1199 (let ((type (built-in-variable-type variable)))
1201 (integer "a built-in integer variable")
1202 (const-integer "a built-in constant integer variable")
1203 (boolean "a built-in boolean variable")
1204 (const-boolean "a built-in constant boolean variable")
1205 (object "a simple built-in variable")
1206 (const-object "a simple built-in constant variable")
1207 (const-specifier "a built-in constant specifier variable")
1208 (current-buffer "a built-in buffer-local variable")
1209 (const-current-buffer "a built-in constant buffer-local variable")
1210 (default-buffer "a built-in default buffer-local variable")
1211 (selected-console "a built-in console-local variable")
1212 (const-selected-console "a built-in constant console-local variable")
1213 (default-console "a built-in default console-local variable")
1215 (if type "an unknown type of built-in variable?"
1216 "a variable declared in Lisp")))))
1218 (defun describe-variable (variable)
1219 "Display the full documentation of VARIABLE (a symbol)."
1221 (let* ((v (variable-at-point))
1222 (val (let ((enable-recursive-minibuffers t))
1225 (format "Describe variable (default %s): " v)
1226 (gettext "Describe variable: "))
1227 obarray 'boundp t nil 'variable-history))))
1228 (list (if (equal val "") v (intern val)))))
1229 (with-displaying-help-buffer
1231 (let ((origvar variable)
1233 (let ((print-escape-newlines t))
1234 (princ (format "`%s' is " (symbol-name variable)))
1235 (while (variable-alias variable)
1236 (let ((newvar (variable-alias variable)))
1238 ;; I18N3 Need gettext due to concat
1241 (format "\n which is an alias for `%s',"
1242 (symbol-name newvar))))
1244 (format "an alias for `%s',"
1245 (symbol-name newvar))))
1246 (setq variable newvar)))
1248 (princ (format "%s" aliases)))
1249 (princ (built-in-variable-doc variable))
1251 (let ((file-name (describe-symbol-find-file variable)))
1253 (princ (format " -- loaded from \"%s\"\n" file-name))))
1255 (if (not (boundp variable))
1257 (prin1 (symbol-value variable))
1260 (cond ((local-variable-p variable (current-buffer))
1261 (let* ((void (cons nil nil))
1262 (def (condition-case nil
1263 (default-value variable)
1265 (princ "This value is specific to the current buffer.\n")
1266 (if (local-variable-p variable nil)
1267 (princ "(Its value is local to each buffer.)\n"))
1269 (if (if (eq def void)
1271 (not (eq (symbol-value variable) def)))
1272 ;; #### I18N3 doesn't localize properly!
1273 (progn (princ "Default-value: ")
1279 ((local-variable-p variable (current-buffer) t)
1280 (princ "Setting it would make its value buffer-local.\n\n"))))
1281 (princ "Documentation:")
1283 (let ((doc (documentation-property variable 'variable-documentation))
1284 (obsolete (variable-obsoleteness-doc origvar))
1285 (compatible (variable-compatibility-doc origvar)))
1294 ;; don't bother to print anything if variable is obsolete and aliased.
1295 (when (or (not obsolete) (not aliases))
1297 ;; note: documentation-property calls substitute-command-keys.
1299 (princ "not documented as a variable."))))
1301 (format "variable `%s'" variable)))
1303 (defun sorted-key-descriptions (keys &optional separator)
1304 "Sort and separate the key descriptions for KEYS.
1305 The sorting is done by length (shortest bindings first), and the bindings
1306 are separated with SEPARATOR (\", \" by default)."
1307 (mapconcat 'key-description
1308 (sort keys #'(lambda (x y)
1309 (< (length x) (length y))))
1310 (or separator ", ")))
1312 (defun where-is (definition &optional insert)
1313 "Print message listing key sequences that invoke specified command.
1314 Argument is a command definition, usually a symbol with a function definition.
1315 When run interactively, it defaults to any function found by
1316 `function-at-point'.
1317 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
1319 (let ((fn (function-at-point))
1320 (enable-recursive-minibuffers t)
1322 (setq val (read-command
1323 (if fn (format "Where is command (default %s): " fn)
1324 "Where is command: ")))
1325 (list (if (equal (symbol-name val) "")
1327 current-prefix-arg)))
1328 (let ((keys (where-is-internal definition)))
1331 (princ (format "%s (%s)" (sorted-key-descriptions keys)
1332 definition) (current-buffer))
1333 (message "%s is on %s" definition (sorted-key-descriptions keys)))
1335 (princ (format (if (commandp definition) "M-x %s RET"
1336 "M-: (%s ...)") definition) (current-buffer))
1337 (message "%s is not on any keys" definition))))
1340 ;; `locate-library' moved to "packages.el"
1343 ;; Functions ported from C into Lisp in XEmacs
1345 (defun describe-syntax ()
1346 "Describe the syntax specifications in the syntax table.
1347 The descriptions are inserted in a buffer, which is then displayed."
1349 (with-displaying-help-buffer
1351 ;; defined in syntax.el
1352 (describe-syntax-table (syntax-table) standard-output))
1353 (format "syntax-table for %s" major-mode)))
1355 (defun list-processes ()
1356 "Display a list of all processes.
1357 \(Any processes listed as Exited or Signaled are actually eliminated
1358 after the listing is made.)"
1360 (with-output-to-temp-buffer "*Process List*"
1361 (set-buffer standard-output)
1362 (buffer-disable-undo standard-output)
1363 (make-local-variable 'truncate-lines)
1364 (setq truncate-lines t)
1365 ;; 00000000001111111111222222222233333333334444444444
1366 ;; 01234567890123456789012345678901234567890123456789
1367 ;; rewritten for I18N3. This one should stay rewritten
1368 ;; so that the dashes will line up properly.
1369 (princ "Proc Status Buffer Tty Command\n---- ------ ------ --- -------\n")
1370 (let ((tail (process-list)))
1372 (let* ((p (car tail))
1373 (pid (process-id p))
1374 (s (process-status p)))
1375 (setq tail (cdr tail))
1376 (princ (format "%-13s" (process-name p)))
1378 (if (and (eq s 'exit) (/= (process-exit-status p) 0))
1379 (princ (format " %d" (process-exit-status p))))
1380 (if (memq s '(signal exit closed))
1381 ;; Do delete-exited-processes' work
1383 (indent-to 22 1) ;####
1384 (let ((b (process-buffer p)))
1387 ((not (buffer-name b))
1390 (princ (buffer-name b)))))
1391 (indent-to 37 1) ;####
1392 (let ((tn (process-tty-name p)))
1396 (princ (format "%s" tn)))))
1397 (indent-to 49 1) ;####
1398 (if (not (integerp pid))
1400 (princ "network stream connection ")
1404 (let ((cmd (process-command p)))
1407 (setq cmd (cdr cmd))
1408 (if cmd (princ " ")))))
1411 ;; Stop gap for 21.0 untill we do help-char etc properly.
1412 (defun help-keymap-with-help-key (keymap form)
1413 "Return a copy of KEYMAP with an help-key binding according to help-char
1414 invoking FORM like help-form. An existing binding is not overridden.
1415 If FORM is nil then no binding is made."
1416 (let ((map (copy-keymap keymap))
1417 (key (if (characterp help-char)
1418 (vector (character-to-event help-char))
1420 (when (and form key (not (lookup-key map key)))
1422 `(lambda () (interactive) (help-print-help-form ,form))))
1425 (defun help-print-help-form (form)
1426 (let ((string (eval form)))
1427 (if (stringp string)
1428 (with-displaying-help-buffer
1432 ;;; help.el ends here