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

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

Re: (call-interactively FN) leaks prefix arg into FN when called from wi


From: Stefan Monnier
Subject: Re: (call-interactively FN) leaks prefix arg into FN when called from within an interactive command
Date: Tue, 24 Apr 2018 09:21:59 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> |   (if (null arg) (call-interactively #'find-file)
> |     (let (current-prefix-arg)
> |       (call-interactively #'ffap))))
> `----

I'd use

    (let ((current-prefix-arg nil))
      (call-interactively (if arg #'ffap #'find-file)))

> So the prefix argument to gk-find-file leaks to ffap,

The (interactive "P") does not *consume* the value of
current-prefix-arg, indeed.  It just uses it to set the value of `arg`.

> Is this intentional, or a bug?

Neither.  It's a consecuence of the design.

> But is it really the _current_ command when it's invoked by
> call-interactively?

The "current command" is defined in terms of read-eval-loop, not in
terms of `call-interactively`.  For the same reason `call-interactively`
does not run pre-command-hook and post-command-hook.


        Stefan




reply via email to

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