emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115408: Fix describe-function with advised function


From: Tassilo Horn
Subject: [Emacs-diffs] trunk r115408: Fix describe-function with advised functions.
Date: Sat, 07 Dec 2013 17:06:00 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115408
revision-id: address@hidden
parent: address@hidden
committer: Tassilo Horn <address@hidden>
branch nick: trunk
timestamp: Sat 2013-12-07 18:05:38 +0100
message:
  Fix describe-function with advised functions.
  
  * lisp/help-fns.el (describe-function-1): Use new advice-* functions
  rather than old ad-* functions.  Fix function type description and
  source links for advised functions and subrs.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/help-fns.el               helpfns.el-20091113204419-o5vbwnq5f7feedwu-2354
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-12-07 01:44:15 +0000
+++ b/lisp/ChangeLog    2013-12-07 17:05:38 +0000
@@ -1,3 +1,9 @@
+2013-12-07  Tassilo Horn  <address@hidden>
+
+       * help-fns.el (describe-function-1): Use new advice-* functions
+       rather than old ad-* functions.  Fix function type description and
+       source links for advised functions and subrs.
+
 2013-12-07  Lars Magne Ingebrigtsen  <address@hidden>
 
        * net/shr.el (shr-tag-img): Don't bug out on <img src="">

=== modified file 'lisp/help-fns.el'
--- a/lisp/help-fns.el  2013-06-15 01:12:05 +0000
+++ b/lisp/help-fns.el  2013-12-07 17:05:38 +0000
@@ -382,8 +382,6 @@
                            (match-string 1 str))))
        (and src-file (file-readable-p src-file) src-file))))))
 
-(declare-function ad-get-advice-info "advice" (function))
-
 (defun help-fns--key-bindings (function)
   (when (commandp function)
     (let ((pt2 (with-current-buffer standard-output (point)))
@@ -531,27 +529,34 @@
 
 ;;;###autoload
 (defun describe-function-1 (function)
-  (let* ((advised (and (symbolp function) (featurep 'advice)
-                      (ad-get-advice-info function)))
+  (let* ((advised (and (symbolp function)
+                      (featurep 'nadvice)
+                      (advice--p (advice--symbol-function 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
-                  (let ((origname (cdr (assq 'origname advised))))
-                    (and (fboundp origname) origname)))
+                  (let* ((advised-fn (advice--cdr
+                                      (advice--symbol-function function))))
+                    (while (advice--p advised-fn)
+                      (setq advised-fn (advice--cdr advised-fn)))
+                    advised-fn))
              function))
         ;; Get the real definition.
         (def (if (symbolp real-function)
                  (symbol-function real-function)
-               function))
-        (aliased (symbolp def))
-        (real-def (if aliased
-                      (let ((f def))
-                        (while (and (fboundp f)
-                                    (symbolp (symbol-function f)))
-                          (setq f (symbol-function f)))
-                        f)
-                    def))
+               real-function))
+        (aliased (or (symbolp def)
+                     ;; Advised & aliased function.
+                     (and advised (symbolp real-function))))
+        (real-def (cond
+                   (aliased (let ((f real-function))
+                              (while (and (fboundp f)
+                                          (symbolp (symbol-function f)))
+                                (setq f (symbol-function f)))
+                              f))
+                   ((subrp def) (intern (subr-name def)))
+                   (t def)))
         (file-name (find-lisp-object-file-name function def))
          (pt1 (with-current-buffer (help-buffer) (point)))
         (beg (if (and (or (byte-code-function-p def)
@@ -571,14 +576,20 @@
                  (if (eq 'unevalled (cdr (subr-arity def)))
                      (concat beg "special form")
                    (concat beg "built-in function")))
+                ;; Aliases are Lisp functions, so we need to check
+                ;; aliases before functions.
+                (aliased
+                 (format "an alias for `%s'" real-def))
+                ((or (eq (car-safe def) 'macro)
+                     ;; For advised macros, def is a lambda
+                     ;; expression or a byte-code-function-p, so we
+                     ;; need to check macros before functions.
+                     (macrop function))
+                 (concat beg "Lisp macro"))
                 ((byte-code-function-p def)
                  (concat beg "compiled Lisp function"))
-                (aliased
-                 (format "an alias for `%s'" real-def))
                 ((eq (car-safe def) 'lambda)
                  (concat beg "Lisp function"))
-                ((eq (car-safe def) 'macro)
-                 (concat beg "Lisp macro"))
                 ((eq (car-safe def) 'closure)
                  (concat beg "Lisp closure"))
                 ((autoloadp def)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]