[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master a30781399b3: * subr-x (eval-command-interactive-spec): New fu
From: |
Sean Whitton |
Subject: |
Re: master a30781399b3: * subr-x (eval-command-interactive-spec): New function. |
Date: |
Wed, 14 Jun 2023 11:14:08 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hello,
On Fri 09 Jun 2023 at 10:39AM -04, Stefan Monnier wrote:
> 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 :)
--
Sean Whitton
- Re: master a30781399b3: * subr-x (eval-command-interactive-spec): New function., (continued)
Re: master a30781399b3: * subr-x (eval-command-interactive-spec): New function., Stefan Monnier, 2023/06/05