[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59820: [PATCH] * nadvice/nadvice.el: support non-symbol (closure/lam
From: |
Stefan Kangas |
Subject: |
bug#59820: [PATCH] * nadvice/nadvice.el: support non-symbol (closure/lambda) advices (old Emacs) |
Date: |
Mon, 12 Dec 2022 17:04:01 -0800 |
daanturo <daanturo@gmail.com> writes:
> This patch provides the ELPA version (for Emacs < 24.4) of nadvice.el's
> advice-add the ability to handle anonymous advices.
>
> I have tested with a simple example:
>
> ```emacs-lisp
>
> (let* ((sym (make-symbol "nadvice λ")))
> (defalias sym (lambda (&rest args) '(1)))
> (advice-add sym :around (lambda (func &rest args)
> (append (apply func args) '(2))))
> (vector
> ;; advised returned value
> (funcall sym)
> (progn
> (advice-remove sym (lambda (func &rest args)
> (append (apply func args) '(2))))
> ;; unadvised returned value
> (funcall sym))))
>
> ;; => [(1 2) (1)]
>
> ```
Stefan, any comments here?