[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: describe-function and advised C functions
From: |
Tassilo Horn |
Subject: |
Re: describe-function and advised C functions |
Date: |
Wed, 04 Dec 2013 15:05:01 +0100 |
User-agent: |
Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) |
Hi again,
my previous patch had an unreachable code path & one always-nil test I
forgot to delete. Here's a better patch. The C-h f output is the same
as in my last mail.
BTW, why are the advice annotations in the *Help* buffer fontified for
`load', `append', and `concat-seqs', but not for `scheme-mode' and
`quack-mode'.
Bye,
Tassilo
--8<---------------cut here---------------start------------->8---
=== modified file 'lisp/help-fns.el'
--- lisp/help-fns.el 2013-06-15 01:12:05 +0000
+++ lisp/help-fns.el 2013-12-04 13:59:39 +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,39 @@
;;;###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* ((f function)
+ (advised-fn (advice--cdr (advice--symbol-function
f))))
+ (while (advice--p advised-fn)
+ (setq f advised-fn)
+ (setq advised-fn (advice--cdr (if (symbolp f)
+
(advice--symbol-function f)
+ f))))
+ 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
+ (and (symbolp function)
+ (symbolp real-function)
+ (not (eq function 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)
@@ -567,14 +577,14 @@
;; Print what kind of function-like object FUNCTION is.
(princ (cond ((or (stringp def) (vectorp def))
"a keyboard macro")
+ (aliased
+ (format "an alias for `%s'" real-def))
((subrp def)
(if (eq 'unevalled (cdr (subr-arity def)))
(concat beg "special form")
(concat beg "built-in function")))
((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)
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo