From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62563: [FR] Expose `interactive' arg handling as an Elisp function Date: Fri, 31 Mar 2023 15:27:47 +0800 Message-ID: Reply-To: Ruijie Yu Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11186"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.14; emacs 30.0.50 To: 62563@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 31 09:29:46 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pi9Ck-0002ma-By for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 31 Mar 2023 09:29:46 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pi9CW-0000Jv-KS; Fri, 31 Mar 2023 03:29:32 -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 1pi9C2-0000Go-52 for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2023 03:29:31 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pi9C1-0004q1-Sx for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2023 03:29:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pi9C1-0004N6-OD for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2023 03:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ruijie Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 31 Mar 2023 07:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62563 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Emacs Bug Tracker Original-Received: via spool by submit@debbugs.gnu.org id=B.168024768316734 (code B ref -1); Fri, 31 Mar 2023 07:29:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Mar 2023 07:28:03 +0000 Original-Received: from localhost ([127.0.0.1]:60227 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pi9B4-0004Lp-Va for submit@debbugs.gnu.org; Fri, 31 Mar 2023 03:28:03 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:43438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pi9B3-0004LX-Ep for submit@debbugs.gnu.org; Fri, 31 Mar 2023 03:28:01 -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 1pi9B3-0000Bq-3L for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2023 03:28:01 -0400 Original-Received: from netyu.xyz ([152.44.41.246] helo=mail.netyu.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pi9B0-0004ko-Rw for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2023 03:28:00 -0400 Original-Received: from fw.net.yu.netyu.xyz ( [27.18.235.88]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 844505ea (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 31 Mar 2023 07:27:55 +0000 (UTC) Received-SPF: pass client-ip=152.44.41.246; envelope-from=ruijie@netyu.xyz; helo=mail.netyu.xyz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:258976 Archived-At: Hello, I find myself sometimes needing to manually write code that do the same job as the string-form `interactive' would do, like "read for an existing file name" (the "f" form), etc. This happens because I want to do the following conversion.=20=20 --8<---------------cut here---------------start------------->8--- (defun foo (fname) (interactive "f") (ignore fname)) (defun foo (fname bar) (interactive (list (simulate-interactive-f) (get-bar))) (ignore fname bar)) --8<---------------cut here---------------end--------------->8--- In short, this is useful when I need to add an interactive argument that is not already covered by interactive codes, so I have to use the more verbose interactive list form. Currently, the code that handles interactive codes is written as part of `call-interactively'. This is in src/callint.c, DEFUN("call-interactively"). In fact, there is already _a way_ to do it (I consider it more like a workaround). However, I think my proposal might be more concise than the workaround for readers. And also more performant, since the workaround unnecessarily creates a lambda and then extracts its interactive form, only to make use of the result of its interactive code. --8<---------------cut here---------------start------------->8--- (call-interactively (lambda (f) (interactive "f") f)) --8<---------------cut here---------------end--------------->8--- If people are in favor of exposing the interactive codes, I imagine it can be defined as `interactive-handle-code (code &optional prompt)', and I would be able to do this: --8<---------------cut here---------------start------------->8--- (interactive-handle-code ?f) (interactive-handle-code ?M "Insert some random text: ") ;; etc --8<---------------cut here---------------end--------------->8--- Alternatively, if we believe that my c-i + =CE=BB workaround is sufficiently small, we could advise people in the same boat to follow suit? That implies modifying the `interactive' docstring and (info "(elisp) Interactive Codes"). --=20 Best, RY