From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Sean Whitton <spwhitton@spwhitton.name>
Cc: emacs-devel@gnu.org
Subject: Re: master a30781399b3: * subr-x (eval-command-interactive-spec): New function.
Date: Wed, 14 Jun 2023 16:52:37 -0400 [thread overview]
Message-ID: <jwvilbp4vmk.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87fs6u5p1r.fsf@melete.silentflame.com> (Sean Whitton's message of "Wed, 14 Jun 2023 11:14:08 +0100")
>> AFAICT the functionality of `advice-eval-interactive-spec` is not used
>> often at all, so having a specialized version for the specific case when
>> it's applied to (cadr (interactive-form command)) seems hard to justify.
>>
>> Can you point to (potential) users?
>
> Here is something I have:
>
> (defun spw/run-or-restore-gud (arg)
> (interactive "P")
> (if (or arg (not (and (bound-and-true-p gud-comint-buffer)
> (get-buffer-process gud-comint-buffer))))
> ;; Start a new debugging session even if one already exists.
> ;; Killing `gud-comint-buffer' is the documented way to quit an
> ;; existing session.
> (let* ((cmd (cl-case major-mode
> (c-mode 'gdb) (cperl-mode 'perldb) (python-mode 'pdb)
> (t (intern (completing-read "GUD command: "
> '(gdb perldb pdb) nil t)))))
> (args (eval-command-interactive-spec cmd)))
> (when (buffer-live-p gud-comint-buffer)
> (when-let ((proc (get-buffer-process gud-comint-buffer)))
> (set-process-query-on-exit-flag proc nil))
> (kill-buffer gud-comint-buffer))
> (gdb-wait-for-pending (lambda () (apply cmd args))))
> ;; Restore the session.
> (cl-case (buffer-local-value 'gud-minor-mode gud-comint-buffer)
> (gdbmi (gdb-restore-windows)
> ;; Try to ensure prompt is at the bottom of its window.
> (recenter (window-body-height)))
> (t (pop-to-buffer gud-comint-buffer)))))
>
> I initially tried implementing this using :around advice, but found that
> worked less well in some respect that I can now not remember.
> But I definitely tried it :)
OK, so that's one example. Any other? Because, to me, a single
use-case doesn't seem to justify the definition of a one-liner helper
function.
[ Especially since that helper function is still not a faithful
simulation of what happens in a "normal" execution of the command
and fixing that wrinkle will likely require changing the API :-( ]
Stefan
next prev parent reply other threads:[~2023-06-14 20:52 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
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 [this message]
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=jwvilbp4vmk.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).