Merge from emacs--devo--0
[bpt/emacs.git] / lisp / help-fns.el
index 25e8ca7..f62fadc 100644 (file)
@@ -239,7 +239,7 @@ face (according to `face-differs-from-default-p')."
                                   ".elc"))
                                 load-path))
         (str (if (and elc-file (file-readable-p elc-file))
-                 (with-temp-buffer 
+                 (with-temp-buffer
                    (insert-file-contents-literally elc-file nil 0 256)
                    (buffer-string))))
         (src-file (and str
@@ -251,8 +251,18 @@ face (according to `face-differs-from-default-p')."
 
 ;;;###autoload
 (defun describe-function-1 (function)
-  (let* ((def (if (symbolp function)
-                 (symbol-function function)
+  (let* ((advised (and (featurep 'advice) (ad-get-advice-info function)))
+        ;; If the function is advised, use the symbol that has the
+        ;; real definition, if that symbol is already set up.
+        (real-function
+         (or (and advised
+                  (cdr (assq 'origname advised))
+                  (fboundp (cdr (assq 'origname advised)))
+                  (cdr (assq 'origname advised)))
+             function))
+        ;; Get the real definition.
+        (def (if (symbolp real-function)
+                 (symbol-function real-function)
                function))
         file-name string
         (beg (if (commandp def) "an interactive " "a ")))
@@ -334,7 +344,7 @@ face (according to `face-differs-from-default-p')."
       (with-current-buffer standard-output
         (save-excursion
          (re-search-backward "`\\([^`']+\\)'" nil t)
-         (help-xref-button 1 'help-function-def function file-name))))
+         (help-xref-button 1 'help-function-def real-function file-name))))
     (princ ".")
     (terpri)
     (when (commandp function)
@@ -383,8 +393,9 @@ face (according to `face-differs-from-default-p')."
                         ((listp arglist)
                          (format "%S" (help-make-usage function arglist)))
                         ((stringp arglist) arglist)
-                        ;; Maybe the arglist is in the docstring of the alias.
-                        ((let ((fun function))
+                        ;; Maybe the arglist is in the docstring of a symbol
+                       ;; this one is aliased to.
+                        ((let ((fun real-function))
                            (while (and (symbolp fun)
                                        (setq fun (symbol-function fun))
                                        (not (setq usage (help-split-fundoc
@@ -565,7 +576,8 @@ it is displayed along with the global value."
                      ;; See previous comment for this function.
                      ;; (help-xref-on-pp from (point))
                      (if (< (point) (+ from 20))
-                         (delete-region (1- from) from)))))))
+                         (delete-region (1- from) from))))))
+              (terpri))
 
            ;; If the value is large, move it to the end.
            (with-current-buffer standard-output
@@ -617,7 +629,7 @@ it is displayed along with the global value."
                 (setq extra-line t)
                 (princ "  This variable is obsolete")
                 (if (cdr obsolete) (princ (format " since %s" (cdr obsolete))))
-                (princ ";") (terpri)
+                (princ ";\n  ")
                 (princ (if (stringp (car obsolete)) (car obsolete)
                          (format "use `%s' instead." (car obsolete))))
                 (terpri))