diff options
| author | Tassilo Horn | 2013-12-07 18:05:38 +0100 |
|---|---|---|
| committer | Tassilo Horn | 2013-12-07 18:05:38 +0100 |
| commit | faec28d9083cea00c0913b48d42508062a2243eb (patch) | |
| tree | 5562c6bac8e5fa5cf2124e27df6399818a5ce137 | |
| parent | 1bb2debd5f1f02397458de593531f9712cfeb068 (diff) | |
| download | emacs-faec28d9083cea00c0913b48d42508062a2243eb.tar.gz emacs-faec28d9083cea00c0913b48d42508062a2243eb.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/help-fns.el | 49 |
2 files changed, 36 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5cac769f01b..d032e3c9243 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-12-07 Tassilo Horn <tsdh@gnu.org> | ||
| 2 | |||
| 3 | * help-fns.el (describe-function-1): Use new advice-* functions | ||
| 4 | rather than old ad-* functions. Fix function type description and | ||
| 5 | source links for advised functions and subrs. | ||
| 6 | |||
| 1 | 2013-12-07 Lars Magne Ingebrigtsen <larsi@gnus.org> | 7 | 2013-12-07 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 8 | ||
| 3 | * net/shr.el (shr-tag-img): Don't bug out on <img src=""> | 9 | * net/shr.el (shr-tag-img): Don't bug out on <img src=""> |
diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 52aa0517fa8..4a96b23a2cd 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el | |||
| @@ -382,8 +382,6 @@ suitable file is found, return nil." | |||
| 382 | (match-string 1 str)))) | 382 | (match-string 1 str)))) |
| 383 | (and src-file (file-readable-p src-file) src-file)))))) | 383 | (and src-file (file-readable-p src-file) src-file)))))) |
| 384 | 384 | ||
| 385 | (declare-function ad-get-advice-info "advice" (function)) | ||
| 386 | |||
| 387 | (defun help-fns--key-bindings (function) | 385 | (defun help-fns--key-bindings (function) |
| 388 | (when (commandp function) | 386 | (when (commandp function) |
| 389 | (let ((pt2 (with-current-buffer standard-output (point))) | 387 | (let ((pt2 (with-current-buffer standard-output (point))) |
| @@ -531,27 +529,34 @@ FILE is the file where FUNCTION was probably defined." | |||
| 531 | 529 | ||
| 532 | ;;;###autoload | 530 | ;;;###autoload |
| 533 | (defun describe-function-1 (function) | 531 | (defun describe-function-1 (function) |
| 534 | (let* ((advised (and (symbolp function) (featurep 'advice) | 532 | (let* ((advised (and (symbolp function) |
| 535 | (ad-get-advice-info function))) | 533 | (featurep 'nadvice) |
| 534 | (advice--p (advice--symbol-function function)))) | ||
| 536 | ;; If the function is advised, use the symbol that has the | 535 | ;; If the function is advised, use the symbol that has the |
| 537 | ;; real definition, if that symbol is already set up. | 536 | ;; real definition, if that symbol is already set up. |
| 538 | (real-function | 537 | (real-function |
| 539 | (or (and advised | 538 | (or (and advised |
| 540 | (let ((origname (cdr (assq 'origname advised)))) | 539 | (let* ((advised-fn (advice--cdr |
| 541 | (and (fboundp origname) origname))) | 540 | (advice--symbol-function function)))) |
| 541 | (while (advice--p advised-fn) | ||
| 542 | (setq advised-fn (advice--cdr advised-fn))) | ||
| 543 | advised-fn)) | ||
| 542 | function)) | 544 | function)) |
| 543 | ;; Get the real definition. | 545 | ;; Get the real definition. |
| 544 | (def (if (symbolp real-function) | 546 | (def (if (symbolp real-function) |
| 545 | (symbol-function real-function) | 547 | (symbol-function real-function) |
| 546 | function)) | 548 | real-function)) |
| 547 | (aliased (symbolp def)) | 549 | (aliased (or (symbolp def) |
| 548 | (real-def (if aliased | 550 | ;; Advised & aliased function. |
| 549 | (let ((f def)) | 551 | (and advised (symbolp real-function)))) |
| 550 | (while (and (fboundp f) | 552 | (real-def (cond |
| 551 | (symbolp (symbol-function f))) | 553 | (aliased (let ((f real-function)) |
| 552 | (setq f (symbol-function f))) | 554 | (while (and (fboundp f) |
| 553 | f) | 555 | (symbolp (symbol-function f))) |
| 554 | def)) | 556 | (setq f (symbol-function f))) |
| 557 | f)) | ||
| 558 | ((subrp def) (intern (subr-name def))) | ||
| 559 | (t def))) | ||
| 555 | (file-name (find-lisp-object-file-name function def)) | 560 | (file-name (find-lisp-object-file-name function def)) |
| 556 | (pt1 (with-current-buffer (help-buffer) (point))) | 561 | (pt1 (with-current-buffer (help-buffer) (point))) |
| 557 | (beg (if (and (or (byte-code-function-p def) | 562 | (beg (if (and (or (byte-code-function-p def) |
| @@ -571,14 +576,20 @@ FILE is the file where FUNCTION was probably defined." | |||
| 571 | (if (eq 'unevalled (cdr (subr-arity def))) | 576 | (if (eq 'unevalled (cdr (subr-arity def))) |
| 572 | (concat beg "special form") | 577 | (concat beg "special form") |
| 573 | (concat beg "built-in function"))) | 578 | (concat beg "built-in function"))) |
| 574 | ((byte-code-function-p def) | 579 | ;; Aliases are Lisp functions, so we need to check |
| 575 | (concat beg "compiled Lisp function")) | 580 | ;; aliases before functions. |
| 576 | (aliased | 581 | (aliased |
| 577 | (format "an alias for `%s'" real-def)) | 582 | (format "an alias for `%s'" real-def)) |
| 583 | ((or (eq (car-safe def) 'macro) | ||
| 584 | ;; For advised macros, def is a lambda | ||
| 585 | ;; expression or a byte-code-function-p, so we | ||
| 586 | ;; need to check macros before functions. | ||
| 587 | (macrop function)) | ||
| 588 | (concat beg "Lisp macro")) | ||
| 589 | ((byte-code-function-p def) | ||
| 590 | (concat beg "compiled Lisp function")) | ||
| 578 | ((eq (car-safe def) 'lambda) | 591 | ((eq (car-safe def) 'lambda) |
| 579 | (concat beg "Lisp function")) | 592 | (concat beg "Lisp function")) |
| 580 | ((eq (car-safe def) 'macro) | ||
| 581 | (concat beg "Lisp macro")) | ||
| 582 | ((eq (car-safe def) 'closure) | 593 | ((eq (car-safe def) 'closure) |
| 583 | (concat beg "Lisp closure")) | 594 | (concat beg "Lisp closure")) |
| 584 | ((autoloadp def) | 595 | ((autoloadp def) |