emacs-devel
[Top][All Lists]
Advanced

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

Re: 29.0.60; keymap-local-set and keymap-global-set became less strict


From: Daniel Mendler
Subject: Re: 29.0.60; keymap-local-set and keymap-global-set became less strict
Date: Wed, 1 Feb 2023 23:56:12 +0100

On 2/1/23 23:42, Stefan Monnier wrote:
>>>> I think call-interactively-p would be better for this use case, but
>>>> that's my opinion versus yours.
>>> Have you ever looked at the implementation of `called-interactively-p`?
>> I guess there is no doubt that we all agree that the implementation is
>> not great.
> 
> The problem is that it's not the fault of the implementation.
> The idea of having it as a function is fundamentally flawed, which is
> why the function can be nothing but a mess.

Yes, I agree.

>> But I would not consider it prohibitively bad, such that it
>> should never ever be used in new code.  If that is the case why is the
>> function not officially deprecated?
> 
> `called-interactive-p` is in the same category as `advice-add`.
> It's great that we have it, but you should only use it when there's no
> other way.

I would go so far to say that `advice-add' is technically much saner
than `called-interactively-p`. I wouldn't want to miss `advice-add'!

>> To be clear, I was aware of the recommendation to avoid
>> `called-interactively-p' and iirc I have not used it in any of my
>> packages.  It is a kludge to use it, but using "hidden arguments" and
>> "advertised calling convention" seems as much a kludge in my eyes.
> 
> Maybe they're kludges, but at least they have a well defined meaning.
> `called-interactively-p` is in a completely different category of kludges.

Well, this is where I disagree. It is a *technically* kludge, but it
will only occur within the innards of the function, and it won't be
exposed on the level of the function calling convention. The advised
function calling convention is a kludge which is exposed to the caller
of the function - hidden or not.

>> The problem with the hidden INTERACTIVE (or ALLOW-VECTOR) argument is
>> that it is still somewhat exposed to non-interactive callers. For
> 
> Emacs is not in the business of imposing The Right Way, instead we
> prefer to encourage it while still allowing people to shoot themselves
> in the foot in all kinds of fun ways.

Tell that to Eli, who seems to be in the business of preaching The Right
Way and also following it. At least that's better than preaching water
and drinking wine.

But that's beside the point - keymap.el is a newly introduced library
with a newly designed API. I would expect that such a library can be
implemented according to the best practices without any kludges -
without `call-interactively-p' and without advertised calling
conventions. That this does not seem to be possible, leaves me
unsatisfied. Well, it would actually be possible, we just have to do it
differently - either allowing vectors as arguments or by using a
different interactive form calling `keymap--read-key`. But these better
solutions were rejected for other reasons.

Daniel



reply via email to

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