From: Sean Whitton <spwhitton@spwhitton.name>
To: emacs-devel@gnu.org
Subject: Re: Adding eval-command-interactive-spec
Date: Sun, 15 Jan 2023 11:00:29 -0700 [thread overview]
Message-ID: <87edrvk79e.fsf@melete.silentflame.com> (raw)
In-Reply-To: <Y7PAAq14YXevh0jh@athena.silentflame.com> (Sean Whitton's message of "Tue, 3 Jan 2023 05:41:22 +0000")
[-- Attachment #1: Type: text/plain, Size: 895 bytes --]
Hello,
On Tue 03 Jan 2023 at 05:41AM GMT, Sean Whitton wrote:
> I think that it would be useful to have this:
>
> (defun eval-command-interactive-spec (command)
> (advice-eval-interactive-spec
> (cadr (or (and (symbolp command) (get command 'interactive-form))
> (interactive-form command)))))
>
> but I'm not sure where it should go -- nadvice.el? subr.el? subr-x.el?
I realised after reading the commentary in subr-x that that's exactly
where it should go -- it is a complement to the C API for interactive
calls. So, here's my patch to add eval-command-interactive-spec.
Seperately, how about renaming advice-eval-interactive-spec to
eval-interactive-spec, and obsoleting, but not removing, the old name?
I guess that we'd also want to move it to subr.el; this is no promotion,
so far as I can tell, because nadvice.el is preloaded.
--
Sean Whitton
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-subr-x-eval-command-interactive-spec-New-function.patch --]
[-- Type: text/x-patch, Size: 1522 bytes --]
From 204582a0d8a85f5e411b76609440424353eeb744 Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhitton@spwhitton.name>
Date: Sun, 15 Jan 2023 10:57:30 -0700
Subject: [PATCH] * subr-x (eval-command-interactive-spec): New function.
---
etc/NEWS | 5 +++++
lisp/emacs-lisp/subr-x.el | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index a2924201267..d2e6b18cadd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -184,6 +184,11 @@ compared reliably at all.
This warning can be suppressed using 'with-suppressed-warnings' with
the warning name 'suspicious'.
+---
+** New function 'eval-command-interactive-spec' in the subr-x library.
+This function evaluates a command's interactive form and returns the
+resultant list.
+
\f
* Changes in Emacs 30.1 on Non-Free Operating Systems
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 8cdbdf1ef6a..0c52e5c25e9 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -488,6 +488,13 @@ emacs-etc--hide-local-variables
(progn (forward-line -1) (point))
(point-max)))))
+(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)))))
+
(provide 'subr-x)
;;; subr-x.el ends here
--
2.30.2
prev parent reply other threads:[~2023-01-15 18:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 5:41 Adding eval-command-interactive-spec Sean Whitton
2023-01-15 18:00 ` Sean Whitton [this message]
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=87edrvk79e.fsf@melete.silentflame.com \
--to=spwhitton@spwhitton.name \
--cc=emacs-devel@gnu.org \
/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).