unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Mendler <mail@daniel-mendler.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>,
	rpluim@gmail.com, larsi@gnus.org, emacs-devel@gnu.org
Subject: Re: 29.0.60; keymap-local-set and keymap-global-set became less strict
Date: Wed, 1 Feb 2023 21:22:21 +0100	[thread overview]
Message-ID: <e67a532b-91f4-cd79-0d1d-3828904afc1c@daniel-mendler.de> (raw)
In-Reply-To: <jwvlelhxlml.fsf-monnier+emacs@gnu.org>

On 2/1/23 19:54, 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. 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?

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. Is it
commonly agreed upon that advertised calling conventions are the lesser
evil? I've usually understood advertised calling convention as a means
for deprecation - did I misunderstand that? I wonder if
`called-interactively-p' would lead to actual problems in this
particular use case?

The problem with the hidden INTERACTIVE (or ALLOW-VECTOR) argument is
that it is still somewhat exposed to non-interactive callers. For
example, in the context of the Compat library, should this argument be
made available, since non-interactive callers may want to use it? What
if callers start to use it if they want to pass vector arguments?

An example where INTERACTIVE arguments seems more justified to me are
the `completion-at-point-functions' provided by my Cape package. The
Capf `cape-line', which also happens to be a command, completes full
lines in a buffer. If called interactively or with a non-nil interactive
argument, it will use `completion-in-region'. The nice property is that
the equivalence `(call-interactively #'cape-line) == (cape-line t)` holds.

To come back to `keymap-local-set' - the good thing is that we can avoid
both kludges, advertised calling conventions and `call-interactively-p'.
All we have to do is move the key reading entirely to the interactive
form, which also seems to be semantically most correct. If I would rate
the possible solutions:

1. Just allow vector arguments for all the functions. Simplest solution,
least amount of code.

2. Use `(interactive (list (keymap--read-key) ...))`. Unfortunately this
solution lead to technical difficulties in the `keymap--read-key' function.

3. Use the `call-interactively-p' kludge.

4. Use the hidden INTERACTIVE argument kludge.

Unfortunately none of the solutions 1 to 3 seems to be good enough.

Daniel



  reply	other threads:[~2023-02-01 20:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5876987d-2479-f512-5767-218c8c16a909@daniel-mendler.de>
     [not found] ` <875ycngyji.fsf@gnus.org>
2023-01-31  9:05   ` 29.0.60; keymap-local-set and keymap-global-set became less strict Robert Pluim
2023-01-31 10:08     ` Stephen Berman
2023-01-31 14:27       ` [External] : " Drew Adams
2023-01-31 14:30     ` Stefan Monnier
2023-01-31 15:02       ` Robert Pluim
2023-01-31 15:06     ` Eli Zaretskii
2023-01-31 15:48       ` Robert Pluim
2023-01-31 16:37         ` Eli Zaretskii
2023-01-31 16:48           ` Robert Pluim
2023-01-31 18:43             ` Eli Zaretskii
2023-02-01 12:52               ` Robert Pluim
2023-02-01 13:06                 ` Eli Zaretskii
2023-02-01 13:13                   ` Daniel Mendler
2023-02-01 13:44                     ` Robert Pluim
2023-02-01 14:11                       ` Daniel Mendler
2023-02-01 13:50                     ` Eli Zaretskii
2023-02-01 13:57                       ` Daniel Mendler
2023-02-01 17:30                         ` Eli Zaretskii
2023-02-01 18:20                           ` Daniel Mendler
2023-02-01 18:54                             ` Stefan Monnier
2023-02-01 20:22                               ` Daniel Mendler [this message]
2023-02-01 22:42                                 ` Stefan Monnier
2023-02-01 22:56                                   ` Daniel Mendler
2023-02-02  6:58                                     ` Eli Zaretskii
2023-02-02  9:29                                       ` Daniel Mendler
2023-02-02  9:40                                       ` Robert Pluim
2023-02-02 10:17                                         ` Eli Zaretskii
2023-02-03  9:17                                           ` Robert Pluim
2023-02-03  9:56                                   ` Richard Stallman
2023-02-04  9:55                                     ` Daniel Mendler
2023-02-03  9:56                           ` Richard Stallman
2023-02-03 12:11                             ` Eli Zaretskii
2023-02-05  4:27                               ` Richard Stallman
2023-02-05  7:11                                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e67a532b-91f4-cd79-0d1d-3828904afc1c@daniel-mendler.de \
    --to=mail@daniel-mendler.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rpluim@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).