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: Lars Ingebrigtsen
Subject: bug#17871: 24.4.50; (elisp) `Core Advising Primitives': interactive spec as function?
Date: Sun, 04 Aug 2019 14:06:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> Dunno if that would be good.  Although we can with nadvice use
> the same syntax for defining pieces of advice as for defining functions,
> advices have a different meaning (semantic).  The interactive
> specs of advices are not exactly interactive specs in the common sense -
> although they look similar, they are related, but different features.

Yes, I think the description of this wrinkle of the interactive spec in
advised functions belongs in this section of the manual and not in the
normal `interactive' doc string.

> I think a short example would be good.  Also, the term "function" is a
> bit unclear here, maybe we should add "a lambda expression or fbound
> symbol" or so, to make clear that we don't mean a sexp that returns a
> function.

I've now added the "a lambda ..." etc to the manual, but while trying to
find an example to use here, I came up short.

But the manual says

To interpret the spec received as argument, use
@code{advice-eval-interactive-spec}.

so I went looking for that function, and what I found was slightly
puzzling:

(defun advice-eval-interactive-spec (spec)
  "Evaluate the interactive spec SPEC."
  (cond
   ((stringp spec)
    ;; There's no direct access to the C code (in call-interactively) that
    ;; processes those specs, but that shouldn't stop us, should it?
    ;; FIXME: Despite appearances, this is not faithful: SPEC and
    ;; (advice-eval-interactive-spec SPEC) will behave subtly differently w.r.t
    ;; command-history (and maybe a few other details).
    (call-interactively `(lambda (&rest args) (interactive ,spec) args)))
   ;; ((functionp spec) (funcall spec))
   (t (eval spec))))

The functionp case is commented out?  This was apparently done in
1668ea9062e (in 2012!) by Stefan while rewriting this stuff.

If nobody has missed this since 2012...  perhaps it should just be
removed?  

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

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