]> code.delx.au - gnu-emacs/blobdiff - lisp/help.el
(disassemble-1): Move the call to
[gnu-emacs] / lisp / help.el
index 8d9f94f425406547af7cc0907afb078de19561b5..45d84b88970083295a09ddbc5e632e181c72429b 100644 (file)
@@ -66,6 +66,7 @@
 (define-key help-map "F" 'view-emacs-FAQ)
 
 (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)
@@ -214,14 +215,6 @@ With arg, you are asked to choose which language."
   "Print the name of the function KEY invokes.  KEY is a string.
 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
   (interactive "kDescribe key briefly: \nP")
-  ;; If this key seq ends with a down event, discard the
-  ;; following click or drag event.  Otherwise that would
-  ;; erase the message.
-  (let ((type (aref key (1- (length key)))))
-    (if (listp type) (setq type (car type)))
-    (and (symbolp type)
-        (memq 'down (event-modifiers type))
-        (read-event)))
   (save-excursion
     (let ((modifiers (event-modifiers (aref key 0)))
          (standard-output (if insert (current-buffer) t))
@@ -305,14 +298,6 @@ If FUNCTION is nil, applies `message' to it, thus printing it."
 (defun describe-key (key)
   "Display documentation of the function invoked by KEY.  KEY is a string."
   (interactive "kDescribe key: ")
-  ;; If this key seq ends with a down event, discard the
-  ;; following click or drag event.  Otherwise that would
-  ;; erase the message.
-  (let ((type (aref key (1- (length key)))))
-    (if (listp type) (setq type (car type)))
-    (and (symbolp type)
-        (memq 'down (event-modifiers type))
-        (read-event)))
   (save-excursion
     (let ((modifiers (event-modifiers (aref key 0)))
          window position)
@@ -600,6 +585,8 @@ C-w Display information on absence of warranty for GNU Emacs."
                ((byte-code-function-p def)
                 (concat beg "compiled Lisp function"))
                ((symbolp def)
+                (while (symbolp (symbol-function def))
+                  (setq def (symbol-function def)))
                 (format "alias for `%s'" def))
                ((eq (car-safe def) 'lambda)
                 (concat beg "Lisp function"))
@@ -634,20 +621,22 @@ C-w Display information on absence of warranty for GNU Emacs."
              (help-xref-button 1 #'(lambda (arg)
                                      (let ((location
                                             (find-function-noselect arg)))
-                                       (display-buffer (nth 0 location))
-                                       (goto-char (nth 1 location))))
+                                       (pop-to-buffer (car location))
+                                       (goto-char (cdr location))))
                                function)))))
     (if need-close (princ ")"))
     (princ ".")
     (terpri)
-    (let* ((inner-function (if (and (listp def) 'macro)
-                              (cdr def)
-                            def))
-          (arglist (cond ((byte-code-function-p inner-function)
-                          (car (append inner-function nil)))
-                         ((eq (car-safe inner-function) 'lambda)
-                          (nth 1 inner-function))
-                         (t t))))
+    ;; Handle symbols aliased to other symbols.
+    (setq def (indirect-function def))
+    ;; If definition is a macro, find the function inside it.
+    (if (eq (car-safe def) 'macro)
+       (setq def (cdr def)))
+    (let ((arglist (cond ((byte-code-function-p def)
+                         (car (append def nil)))
+                        ((eq (car-safe def) 'lambda)
+                         (nth 1 def))
+                        (t t))))
       (if (listp arglist)
          (progn
            (princ (cons function
@@ -738,8 +727,10 @@ Returns the documentation as a string, also."
           (help-setup-xref (list #'describe-variable variable) (interactive-p))
 
          ;; Make a link to customize if this variable can be customized.
-         (if (or (get variable 'custom-type)
-                 (user-variable-p variable))
+         ;; Note, it is not reliable to test for a custom-type property
+         ;; because those are only present after the var's definition
+         ;; has been loaded.
+         (if (user-variable-p variable)
              (let ((customize-label "customize"))
                (terpri)
                (terpri)
@@ -968,6 +959,8 @@ that."
                         (help-xref-button 1 #'describe-function sym)))))
               ;; Look for commands in whole keymap substitutions:
               (save-excursion
+               ;; Make sure to find the first keymap.
+               (goto-char (point-min))
                 ;; Find a header and the column at which the command
                 ;; name will be found.
                 (while (re-search-forward "^key +binding\n\\(-+ +\\)-+\n\n" 
@@ -1052,11 +1045,10 @@ help buffer."
 (defun help-follow-mouse (click)
   "Follow the cross-reference that you click on."
   (interactive "e")
-  (save-excursion
-    (let* ((start (event-start click))
-          (window (car start))
-          (pos (car (cdr start))))
-      (set-buffer (window-buffer window))
+  (let* ((start (event-start click))
+        (window (car start))
+        (pos (car (cdr start))))
+    (with-current-buffer (window-buffer window)
       (help-follow pos))))
 
 (defun help-xref-go-back (buffer)