bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#17871: 24.4.50; (elisp) `Core Advising Primitives': interactive spec


From: Stefan Monnier
Subject: bug#17871: 24.4.50; (elisp) `Core Advising Primitives': interactive spec as function?
Date: Wed, 21 Aug 2019 03:01:23 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>   (defvar __testvar nil)
>   
>   (defun __test-command ()
>     (interactive (ignore (message "__test-command (interactive): %s" 
> __testvar)))
>     (message "__test-command (body): %s" __testvar))
>   
>   (defun __test-advice (orig &rest args)
>     (let ((__testvar t))
>       (apply orig args)))
>   
>   (advice-add '__test-command :around #'__test-advice)
>
> Even with the advice, calling __test-command gives:
>
>   __test-command (interactive): nil
>   __test-command (body): t
>
> I'd expect the advice to have effect on the whole function, including
> the interactive form.

The interactive form is executed to build the args with which the
function will be called (hence your advice is only executed after the
interactive spec), so in order for your code to do what you want,
we'd have to always wrap the interactive spec identically to the body.

Maybe in this case it'd do what you want, but in many other cases
it wouldn't.


        Stefan






reply via email to

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