From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master a30781399b3: * subr-x (eval-command-interactive-spec): New function. Date: Mon, 05 Jun 2023 12:14:24 -0400 Message-ID: References: <168595059426.2523.2109338263713299231@vcs2.savannah.gnu.org> <20230605073635.19060C00613@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12000"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Sean Whitton To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jun 05 18:15:29 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6Crh-0002wm-4Z for ged-emacs-devel@m.gmane-mx.org; Mon, 05 Jun 2023 18:15:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6Cql-0006LL-K4; Mon, 05 Jun 2023 12:14:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6Cqj-0006LD-Os for emacs-devel@gnu.org; Mon, 05 Jun 2023 12:14:29 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6Cqi-000709-3O for emacs-devel@gnu.org; Mon, 05 Jun 2023 12:14:29 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B1E2A4426F2; Mon, 5 Jun 2023 12:14:26 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4B5774405F4; Mon, 5 Jun 2023 12:14:25 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1685981665; bh=MP1/l13zVYdsxUtqzF6C43uPo6AqH21rqAvxfbTnXF4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=eJ9zH7KAnolpoby2zZ4rcIUw0Qkmc+o+aMbVRB+I045PRgiW2/udy3PBuW8k87nrF lREV+c5KaMNbqeoE/pDmZ6tdRszlblotWOA3KisMcew1ZmJYUsIklS/9yxqInovZfn AStqVQJfljgjdPqHIcvWYMSTyE0j7asyEHQCx3PjtdrCvzQ8qMO2DlokcDp2+DvKxG fmJl2hcLzPAeTw9ivz/aWEQ9cEphHp+MXJvEY9tyxLHgl9797bNwYQpWohsWCDlyxH 0spUpTRBOAfhg3EQ926wgYZup9cj4Jb3plJlvD0zyYmq1MPly/L9o1NAB1ysLuqzGY OPas+930UkRNQ== Original-Received: from alfajor (unknown [45.44.229.252]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 301261202BC; Mon, 5 Jun 2023 12:14:25 -0400 (EDT) In-Reply-To: <20230605073635.19060C00613@vcs2.savannah.gnu.org> (Sean Whitton's message of "Mon, 5 Jun 2023 03:36:34 -0400 (EDT)") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306653 Archived-At: > * 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