unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Sean Whitton <spwhitton@spwhitton.name>
Subject: Re: master a30781399b3: * subr-x (eval-command-interactive-spec): New function.
Date: Mon, 05 Jun 2023 12:14:24 -0400	[thread overview]
Message-ID: <jwvlegx9axk.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20230605073635.19060C00613@vcs2.savannah.gnu.org> (Sean Whitton's message of "Mon,  5 Jun 2023 03:36:34 -0400 (EDT)")

>     * subr-x (eval-command-interactive-spec): New function.
[...]
> +;; FIXME: How about renaming this to just `eval-interactive-spec'?
> +;; It's not specific to the advice system.

Agreed.

> +(defun eval-command-interactive-spec (command)
> +  "Evaluate COMMAND's interactive form and return resultant list.
> +If COMMAND has no interactive form, return nil."
> +  (advice-eval-interactive-spec
> +   (cadr (or (and (symbolp command) (get command 'interactive-form))
> +             (interactive-form command)))))

Why the `get` business?  If we want that, it should be in
`interactive-form`, no (and AFAICT it is there, BTW)?
And why is that preferable over `(advice-)eval-interactive-spec`?

BTW, the reason I have not defined `eval-interactive-spec` (yet?)
is because it only provides an *approximation* of what
`call-interactively` would do.

The fundamental problem in `advice-eval-interactive-spec` is that

    (defun my-foo (..)
      (interactive (advice-eval-interactive-spec 'SPEC))
      ...)

will not behave 100% the same as

    (defun my-foo (..)
      (interactive SPEC)
      ...)

for example when SPEC contains "r", because of the `visargs/varies`
business in `call-interactively`.  The difference is that with "r", the
`command-history` will contain entries like

    (my-foo ... (point) (mark) ...)

whereas with `advice-eval-interactive-spec` they'll look like:

    (my-foo ... 457 562 ...)

I'm not completely sure how we should go about faithfully exporting
`callint.c` to ELisp in such a way that it can be (re)used in
interactive forms without losing such details.

One way would be to make `eval-interactive-spec` return a pair of
arglists: a list of values (to pass to `funcall-interactively`), and
a list of expressions (to store in `command-history`).  And then allow
interactive forms to return such pairs of arglists.

Another is to make it only return a list of expressions (and use
`mapcar #'eval` when we need to get the list of values from it), and
similarly let interactive forms return lists of expressions.  But since
currently interactive forms return lists of values, we'd need to somehow
add a marker to the returned lists to distinguish if we're returning
a list of values or a list of expressions.


        Stefan




  parent reply	other threads:[~2023-06-05 16:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <168595059426.2523.2109338263713299231@vcs2.savannah.gnu.org>
     [not found] ` <20230605073635.19060C00613@vcs2.savannah.gnu.org>
2023-06-05 10:24   ` master a30781399b3: * subr-x (eval-command-interactive-spec): New function Philip Kaludercic
2023-06-06 11:10     ` Sean Whitton
2023-06-06 11:25     ` Mattias Engdegård
2023-06-05 16:14   ` Stefan Monnier [this message]
2023-06-06 11:18     ` Sean Whitton
2023-06-09 14:39       ` Stefan Monnier
2023-06-14 10:14         ` Sean Whitton
2023-06-14 20:52           ` Stefan Monnier
2023-06-16  7:12             ` Sean Whitton
2023-06-05 11:40 Eli Zaretskii
2023-06-06 11:10 ` Sean Whitton
2023-06-06 11:59   ` Eli Zaretskii
2023-06-14 10:18     ` Sean Whitton
2023-06-14 11:35       ` 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=jwvlegx9axk.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=spwhitton@spwhitton.name \
    /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).