Re: Advicing the `interactive' form of a command
Stefan Monnier <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
> the interactive form is probably never evaluated as such, but it may
> likewise get dissected, and maybe the whole thing could be replaced by
> something like
>
> (advice-add 'foo :interactive
> (lambda (ispec)
> ...
> (advice-eval-interactive-spec ispec)
> ...)))
Yes, that's actually the ideal form, tho I'd even tweak it to:
(advice-add 'foo :interactive
(lambda (ispec-fun)
...
(funcall ispec-fun)
...)))
The `:interactive-only` thingy I just added goes a tiny step in the
direction you suggest by announcing that the whole
(lambda (&rest _)
(interactive ...)
nil)
wrapper is "thrown away". I did that instead of what you suggest for
two reasons:
- I was looking for a way to document the current functionality rather
than improve it (it just so happened that adding
a `:interactive-form` seemed to make it easier to document it).
- I think adding your `:interactive` would require a bit more work
(and encourage further changes, maybe).
So, I'd encourage you to take a stab at it.
> So (advice-eval-interactive-spec ispec) is essentially an (eval ispec)
> [or (apply ispec), in the spirit of what :around does to the body of a
> function].
Very much so, yes.
> But advice-eval-interactive-spec is maybe less important to advertise
> this entire feature than (interactive (lambda (ispec) ...))
> or :interactive. (While trying to solve my problem, at some point
> I was looking for something like :interactive because this appeared to
> me like a natural strategy to address my problem.)
Indeed, that's why I felt adding `:interactive-only` was a good way to
"advertise" the functionality.
=== Stefan