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: Štěpán Němec
Subject: bug#17871: 24.4.50; (elisp) `Core Advising Primitives': interactive spec as function?
Date: Wed, 21 Aug 2019 00:44:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

On Wed, 21 Aug 2019 00:49:05 +0300
Juri Linkov wrote:

>> And although I have managed to clarify a few points myself thanks to
>> this conversation, my personal conundrum[2] remains unanswered: why does
>> a simple advice have no effect on the interactive spec of the function
>> being advised, and is that really a feature? But perhaps that's for
>> another thread.
>
> Recently I tried to use an advice to override the default call of
> `forward-word' in `org-metaright', but this is impossible to do
> because it called by `call-interactively'.  Maybe your case has the
> same problem?

Not really. The real-life example with commentary is in the cited
message (<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=17871#38>), but
a minimal example could be the following:

  (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.

-- 
Štěpán





reply via email to

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