]> code.delx.au - gnu-emacs/blobdiff - lisp/help.el
Update PostScript version.
[gnu-emacs] / lisp / help.el
index c067214f9927b7383fddf7b52b56e41fdc990985..70951e021b90e3baf1478601f10ef99bf817d80b 100644 (file)
 
 (define-key help-map "\C-c" 'describe-copying)
 (define-key help-map "\C-d" 'describe-distribution)
-(define-key help-map "\C-w" 'describe-no-warranty)
+(define-key help-map "\C-e" 'view-emacs-problems)
+(define-key help-map "\C-f" 'view-emacs-FAQ)
+(define-key help-map "\C-m" 'view-order-manuals)
+(define-key help-map "\C-n" 'view-emacs-news)
 (define-key help-map "\C-p" 'describe-project)
+(define-key help-map "\C-w" 'describe-no-warranty)
+
+;; This does not fit the pattern, but it is natural given the C-\ command.
+(define-key help-map "\C-\\" 'describe-input-method)
+
+(define-key help-map "C" 'describe-coding-system)
+(define-key help-map "F" 'Info-goto-emacs-command-node)
+(define-key help-map "I" 'describe-input-method)
+(define-key help-map "K" 'Info-goto-emacs-key-command-node)
+(define-key help-map "L" 'describe-language-environment)
+(define-key help-map "S" 'info-lookup-symbol)
+
 (define-key help-map "a" 'apropos-command)
 
 (define-key help-map "b" 'describe-bindings)
 
 (define-key help-map "c" 'describe-key-briefly)
-(define-key help-map "k" 'describe-key)
 
-(define-key help-map "d" 'describe-function)
+(define-key help-map "e" 'view-echo-area-messages)
+
 (define-key help-map "f" 'describe-function)
 
-(define-key help-map "F" 'view-emacs-FAQ)
+(define-key help-map "h" 'view-hello-file)
 
 (define-key help-map "i" 'info)
 (define-key help-map "4i" 'info-other-window)
-(define-key help-map "\C-f" 'Info-goto-emacs-command-node)
-(define-key help-map "\C-k" 'Info-goto-emacs-key-command-node)
-(define-key help-map "\C-i" 'info-lookup-symbol)
+
+(define-key help-map "k" 'describe-key)
 
 (define-key help-map "l" 'view-lossage)
 
 (define-key help-map "m" 'describe-mode)
-(define-key help-map "\C-m" 'view-order-manuals)
 
-(define-key help-map "\C-n" 'view-emacs-news)
 (define-key help-map "n" 'view-emacs-news)
 
 (define-key help-map "p" 'finder-by-keyword)
 (autoload 'finder-by-keyword "finder"
   "Find packages matching a given keyword." t)
 
-(define-key help-map "P" 'view-emacs-problems)
-
 (define-key help-map "s" 'describe-syntax)
 
 (define-key help-map "t" 'help-with-tutorial)
@@ -163,7 +173,7 @@ If FUNCTION is nil, applies `message' to it, thus printing it."
 
 (defalias 'help 'help-for-help)
 (make-help-screen help-for-help
-  "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:"
+  "a b c C e f F C-f i I k C-k l L m p s t v w C-c C-d C-n C-p C-w or ? :"
   "You have typed %THIS-KEY%, the help character.  Type a Help option:
 \(Use SPC or DEL to scroll through this text.  Type \\<help-map>\\[help-quit] to exit the Help command.)
 
@@ -176,17 +186,17 @@ c  describe-key-briefly.  Type a command key sequence;
 C  describe-coding-system.  This describes either a specific coding system
         (if you type its name) or the coding systems currently in use
        (if you type just RET).
+e  view-echo-area-messages.  Show the `*Messages*' buffer.
 f  describe-function.  Type a function name and get documentation of it.
-C-f Info-goto-emacs-command-node.  Type a function name;
+ Info-goto-emacs-command-node.  Type a function name;
        it takes you to the Info node for that command.
+h  Display the HELLO file which illustrates various scripts.
 i  info. The  info  documentation reader.
 I  describe-input-method.  Describe a specific input method (if you type
        its name) or the current input method (if you type just RET).
-C-i  info-lookup-symbol.  Display the definition of a specific symbol
-        as found in the manual for the language this buffer is written in.
 k  describe-key.  Type a command key sequence;
        it displays the full documentation.
-C-k Info-goto-emacs-key-command-node.  Type a command key sequence;
+K Info-goto-emacs-key-command-node.  Type a command key sequence;
        it takes you to the Info node for the command bound to that key.
 l  view-lossage.  Show last 100 characters you typed.
 L  describe-language-environment.  This describes either a
@@ -194,19 +204,21 @@ L  describe-language-environment.  This describes either a
        or the current language environment (if you type just RET).
 m  describe-mode.  Print documentation of current minor modes,
        and the current major mode, including their special commands.
-n  view-emacs-news.  Display news of recent Emacs changes.
 p  finder-by-keyword. Find packages matching a given topic keyword.
 s  describe-syntax.  Display contents of syntax table, plus explanations.
+S  info-lookup-symbol.  Display the definition of a specific symbol
+        as found in the manual for the language this buffer is written in.
 t  help-with-tutorial.  Select the Emacs learn-by-doing tutorial.
 v  describe-variable.  Type name of a variable;
        it displays the variable's documentation and value.
 w  where-is.  Type command name; it prints which keystrokes
        invoke that command.
 
-F  Display the frequently asked questions file.
-h  Display the HELLO file which illustrates various scripts.
-C-c Display Emacs copying permission (General Public License).
+C-c Display Emacs copying permission (GNU General Public License).
 C-d Display Emacs ordering information.
+C-e Display info about Emacs problems.
+C-f Display the Emacs FAQ.
+C-m Display how to order printed Emacs manuals.
 C-n Display news of recent Emacs changes.
 C-p Display information about the GNU project.
 C-w Display information on absence of warranty for GNU Emacs."
@@ -250,21 +262,18 @@ If that doesn't give a function, return nil."
 (defun describe-distribution ()
   "Display info on how to obtain the latest version of GNU Emacs."
   (interactive)
-  (find-file-read-only
-   (expand-file-name "DISTRIB" data-directory)))
+  (view-file (expand-file-name "DISTRIB" data-directory)))
 
 (defun describe-copying ()
   "Display info on how you may redistribute copies of GNU Emacs."
   (interactive)
-  (find-file-read-only
-   (expand-file-name "COPYING" data-directory))
+  (view-file (expand-file-name "COPYING" data-directory))
   (goto-char (point-min)))
 
 (defun describe-project ()
   "Display info on the GNU project."
   (interactive)
-  (find-file-read-only
-   (expand-file-name "THE-GNU-PROJECT" data-directory))
+  (view-file (expand-file-name "THE-GNU-PROJECT" data-directory))
   (goto-char (point-min)))
 
 (defun describe-no-warranty ()
@@ -307,13 +316,20 @@ With numeric argument, display information on correspondingly older changes."
                                                      nil "^ONEWS\\.[0-9]+$"
                                                      nil)))))))
     (if file
-       (find-file-read-only (expand-file-name file data-directory))
+       (view-file (expand-file-name file data-directory))
       (error "No such old news"))))
 
+(defun view-echo-area-messages ()
+  "View the log of recent echo-area messages: the `*Messages*' buffer.
+The number of messages retained in that buffer
+is specified by the variable `message-log-max'."
+  (interactive)
+  (switch-to-buffer (get-buffer-create "*Messages*")))
+
 (defun view-order-manuals ()
   "Display the Emacs ORDERS file."
   (interactive)
-  (find-file-read-only (expand-file-name "ORDERS" data-directory))
+  (view-file (expand-file-name "ORDERS" data-directory))
   (goto-address))
 
 (defun view-emacs-FAQ ()
@@ -332,7 +348,8 @@ With numeric argument, display information on correspondingly older changes."
 
 To record all your input on a file, use `open-dribble-file'."
   (interactive)
-  (with-output-to-temp-buffer "*Help*"
+  (help-setup-xref (list #'view-lossage) (interactive-p))
+  (with-output-to-temp-buffer (help-buffer)
     (princ (mapconcat (function (lambda (key)
                                  (if (or (integerp key)
                                          (symbolp key)
@@ -345,8 +362,7 @@ To record all your input on a file, use `open-dribble-file'."
       (goto-char (point-min))
       (while (progn (move-to-column 50) (not (eobp)))
        (search-forward " " nil t)
-       (insert "\n"))
-      (help-setup-xref nil t))
+       (insert "\n")))
     (print-help-return-message)))
 
 \f
@@ -360,13 +376,11 @@ The optional argument PREFIX, if non-nil, should be a key sequence;
 then we display only bindings that start with that prefix.
 The optional argument BUFFER specifies which buffer's bindings
 to display (default, the current buffer)."
-  (interactive "P")
+  (interactive)
   (or buffer (setq buffer (current-buffer)))
+  (help-setup-xref (list #'describe-bindings prefix buffer) (interactive-p))
   (with-current-buffer buffer
-    (describe-bindings-internal nil prefix))
-  (with-current-buffer "*Help*"
-    (help-setup-xref (list #'describe-bindings prefix buffer)
-                    (interactive-p))))
+    (describe-bindings-internal nil prefix)))
 
 ;; This function used to be in keymap.c.
 (defun describe-bindings-internal (&optional menus prefix)
@@ -398,15 +412,22 @@ If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
      (list (if (equal val "")
               fn (intern val))
           current-prefix-arg)))
-  (let* ((keys (where-is-internal definition overriding-local-map nil nil))
+  (let* ((binding (and (symbolp definition) (commandp definition)
+                      (key-binding definition nil t)))
+        (remap (and (symbolp binding) (commandp binding) binding))
+        (keys (where-is-internal definition overriding-local-map nil nil remap))
         (keys1 (mapconcat 'key-description keys ", "))
         (standard-output (if insert (current-buffer) t)))
     (if insert
        (if (> (length keys1) 0)
-           (princ (format "%s (%s)" keys1 definition))
+           (if remap
+               (princ (format "%s (%s) (remapped from %s)" keys1 remap definition))
+             (princ (format "%s (%s)" keys1 definition)))
          (princ (format "M-x %s RET" definition)))
       (if (> (length keys1) 0)
-         (princ (format "%s is on %s" definition keys1))
+         (if remap
+             (princ (format "%s is remapped to %s which is on %s" definition remap keys1))
+           (princ (format "%s is on %s" definition keys1)))
        (princ (format "%s is not on any key" definition)))))
   nil)
 
@@ -466,7 +487,9 @@ If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
 
 
 (defun describe-key (key)
-  "Display documentation of the function invoked by KEY.  KEY is a string."
+  "Display documentation of the function invoked by KEY.
+KEY should be a key sequence--when calling from a program,
+pass a string or a vector."
   (interactive "kDescribe key: ")
   (save-excursion
     (let ((modifiers (event-modifiers (aref key 0)))
@@ -484,18 +507,18 @@ If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
       (let ((defn (or (string-key-binding key) (key-binding key))))
        (if (or (null defn) (integerp defn))
            (message "%s is undefined" (key-description key))
-         (with-output-to-temp-buffer "*Help*"
+         (help-setup-xref (list #'describe-function defn) (interactive-p))
+         (with-output-to-temp-buffer (help-buffer)
            (princ (key-description key))
            (if (windowp window)
                (princ " at that spot"))
            (princ " runs the command ")
            (prin1 defn)
            (princ "\n   which is ")
-           (describe-function-1 defn nil (interactive-p))
+           (describe-function-1 defn)
            (print-help-return-message)))))))
 
 \f
-;;;###autoload
 (defun describe-mode (&optional buffer)
   "Display documentation of current major mode and minor modes.
 The major mode description comes first, followed by the minor modes,
@@ -504,45 +527,49 @@ For this to work correctly for a minor mode, the mode's indicator variable
 \(listed in `minor-mode-alist') must also be a function whose documentation
 describes the minor mode."
   (interactive)
-  (when buffer (set-buffer buffer))
-  (with-output-to-temp-buffer "*Help*"
-    (when minor-mode-alist
-      (princ "The major mode is described first.
+  (help-setup-xref (list #'describe-mode (or buffer (current-buffer)))
+                  (interactive-p))
+  ;; For the sake of help-do-xref and help-xref-go-back,
+  ;; don't switch buffers before calling `help-buffer'.
+  (with-output-to-temp-buffer (help-buffer)
+    (save-excursion
+      (when buffer (set-buffer buffer))
+      (when minor-mode-alist
+       (princ "The major mode is described first.
 For minor modes, see following pages.\n\n"))
-    (princ mode-name)
-    (princ " mode:\n")
-    (princ (documentation major-mode))
-    (help-setup-xref (list #'describe-mode (current-buffer)) (interactive-p))
-    (let ((minor-modes minor-mode-alist))
-      (while minor-modes
-       (let* ((minor-mode (car (car minor-modes)))
-              (indicator (car (cdr (car minor-modes)))))
-         ;; Document a minor mode if it is listed in minor-mode-alist,
-         ;; bound locally in this buffer, non-nil, and has a function
-         ;; definition.
-         (if (and (boundp minor-mode)
-                  (symbol-value minor-mode)
-                  (fboundp minor-mode))
-             (let ((pretty-minor-mode minor-mode))
-               (if (string-match "\\(-minor\\)?-mode\\'"
-                                 (symbol-name minor-mode))
-                   (setq pretty-minor-mode
-                         (capitalize
-                          (substring (symbol-name minor-mode)
-                                     0 (match-beginning 0)))))
-               (while (and indicator (symbolp indicator)
-                           (boundp indicator)
-                           (not (eq indicator (symbol-value indicator))))
-                 (setq indicator (symbol-value indicator)))
-               (princ "\n\f\n")
-               (princ (format "%s minor mode (%s):\n"
-                              pretty-minor-mode
-                              (if indicator
-                                  (format "indicator%s" indicator)
-                                "no indicator")))
-               (princ (documentation minor-mode)))))
-       (setq minor-modes (cdr minor-modes))))
-    (print-help-return-message)))
+      (princ mode-name)
+      (princ " mode:\n")
+      (princ (documentation major-mode))
+      (let ((minor-modes minor-mode-alist))
+       (while minor-modes
+         (let* ((minor-mode (car (car minor-modes)))
+                (indicator (car (cdr (car minor-modes)))))
+           ;; Document a minor mode if it is listed in minor-mode-alist,
+           ;; bound locally in this buffer, non-nil, and has a function
+           ;; definition.
+           (if (and (boundp minor-mode)
+                    (symbol-value minor-mode)
+                    (fboundp minor-mode))
+               (let ((pretty-minor-mode minor-mode))
+                 (if (string-match "\\(-minor\\)?-mode\\'"
+                                   (symbol-name minor-mode))
+                     (setq pretty-minor-mode
+                           (capitalize
+                            (substring (symbol-name minor-mode)
+                                       0 (match-beginning 0)))))
+                 (while (and indicator (symbolp indicator)
+                             (boundp indicator)
+                             (not (eq indicator (symbol-value indicator))))
+                   (setq indicator (symbol-value indicator)))
+                 (princ "\n\f\n")
+                 (princ (format "%s minor mode (%s):\n"
+                                pretty-minor-mode
+                                (if indicator
+                                    (format "indicator%s" indicator)
+                                  "no indicator")))
+                 (princ (documentation minor-mode)))))
+         (setq minor-modes (cdr minor-modes))))
+      (print-help-return-message))))
 
 \f
 ;;; Automatic resizing of temporary buffers.