1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

nadvice.el: Use OClosures

* lisp/emacs-lisp/nadvice.el (advice): New OClosure type.
(advice--how-alist): Make it hold prototype OClosures rather
than bytecode strings.
(advice--bytecodes): Delete var.
(advice--where): Make it an obsolete alias of new `advice--how`.
(oclosure-interactive-form, cl-print-object) <advice>: New methods.
(advice--make-1): Delete function.
(advice--make): Use `advice-copy` and `advice-cons`.
(advice--tweak): Use `advice-cons`.
(add-function, advice-add): Rename `where` arg to `how`.

* lisp/emacs-lisp/cl-print.el (cl-print-object) <:extra "nadvice">:
Remove now-redundant ad-hoc method.

* test/lisp/emacs-lisp/nadvice-tests.el (advice-test-print): New test.
This commit is contained in:
Stefan Monnier 2022-04-26 16:39:41 -04:00
parent bc9be5449e
commit f30625943e
3 changed files with 64 additions and 74 deletions

View file

@ -221,27 +221,6 @@ into a button whose action shows the function's disassembly.")
'byte-code-function object)))))
(princ ")" stream))
;; This belongs in nadvice.el, of course, but some load-ordering issues make it
;; complicated: cl-generic uses macros from cl-macs and cl-macs uses advice-add
;; from nadvice, so nadvice needs to be loaded before cl-generic and hence
;; can't use cl-defmethod.
(cl-defmethod cl-print-object :extra "nadvice"
((object compiled-function) stream)
(if (not (advice--p object))
(cl-call-next-method)
(princ "#f(advice-wrapper " stream)
(when (fboundp 'advice--how)
(princ (advice--how object) stream)
(princ " " stream))
(cl-print-object (advice--cdr object) stream)
(princ " " stream)
(cl-print-object (advice--car object) stream)
(let ((props (advice--props object)))
(when props
(princ " " stream)
(cl-print-object props stream)))
(princ ")" stream)))
;; This belongs in oclosure.el, of course, but some load-ordering issues make it
;; complicated.
(cl-defmethod cl-print-object ((object accessor) stream)