From c41f3250f41bfc1934469822eff340c4ac0073a5 Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Tue, 1 Jul 2025 18:23:32 +0200 Subject: [PATCH] Update to Transient v0.9.3-8-gecd64f17 (cherry picked from commit d8cdbc9f615cc5b5daa075fb5c9832fe61ffce26) --- doc/misc/transient.texi | 12 ++++++++-- lisp/transient.el | 53 ++++++++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/doc/misc/transient.texi b/doc/misc/transient.texi index 3bb8beddcd3..fe7f81c7930 100644 --- a/doc/misc/transient.texi +++ b/doc/misc/transient.texi @@ -31,7 +31,7 @@ General Public License for more details. @finalout @titlepage @title Transient User and Developer Manual -@subtitle for version 0.9.1 +@subtitle for version 0.9.3 @author Jonas Bernoulli @page @vskip 0pt plus 1filll @@ -53,7 +53,7 @@ resource to get over that hurdle is Psionic K's interactive tutorial, available at @uref{https://github.com/positron-solutions/transient-showcase}. @noindent -This manual is for Transient version 0.9.1. +This manual is for Transient version 0.9.3. @insertcopying @end ifnottex @@ -3033,6 +3033,14 @@ the transient menu, you will be able to yank it in another buffer. #'transient--do-stay) @end lisp +Copying the region while not seeing the region is a bit fiddly, so a +dedicated command, @code{transient-copy-menu-text}, was added. You have to +add a binding for this command in @code{transient-map}. + +@lisp +(keymap-set transient-map "C-c C-w" #'transient-copy-menu-text) +@end lisp + @anchor{How can I autoload prefix and suffix commands?} @appendixsec How can I autoload prefix and suffix commands? diff --git a/lisp/transient.el b/lisp/transient.el index 7df961eca64..25f0018af54 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -5,7 +5,7 @@ ;; Author: Jonas Bernoulli ;; URL: https://github.com/magit/transient ;; Keywords: extensions -;; Version: 0.9.1 +;; Version: 0.9.3 ;; SPDX-License-Identifier: GPL-3.0-or-later @@ -33,7 +33,7 @@ ;;; Code: ;;;; Frontmatter -(defconst transient-version "v0.9.1-7-gd7d2c1c2-builtin") +(defconst transient-version "v0.9.3-8-g6fd0239e-builtin") (require 'cl-lib) (require 'eieio) @@ -2461,16 +2461,16 @@ value. Otherwise return CHILDREN as is.") (alist-get cmd levels) (plist-get args :level) (and proto (oref proto level)) - transient--default-child-level))) + transient--default-child-level)) + (args (plist-put (copy-sequence args) :level level))) (when (transient--use-level-p level) (let ((obj (if (child-of-class-p class 'transient-information) - (apply class :parent parent :level level args) + (apply class :parent parent args) (unless (and cmd (symbolp cmd)) (error "BUG: Non-symbolic suffix command: %s" cmd)) (if proto - (apply #'clone proto :parent parent :level level args) - (apply class :command cmd :parent parent :level level - args))))) + (apply #'clone proto :parent parent args) + (apply class :command cmd :parent parent args))))) (cond ((not cmd)) ((commandp cmd)) ((or (cl-typep obj 'transient-switch) @@ -2597,7 +2597,7 @@ value. Otherwise return CHILDREN as is.") (add-hook 'pre-command-hook #'transient--pre-command 99) (add-hook 'post-command-hook #'transient--post-command) (advice-add 'recursive-edit :around #'transient--recursive-edit) - (set-default-toplevel-value 'inhibit-quit t) + (transient--quit-kludge 'enable) (when transient--exitp ;; This prefix command was invoked as the suffix of another. ;; Prevent `transient--post-command' from removing the hooks @@ -2708,10 +2708,8 @@ value. Otherwise return CHILDREN as is.") (defun transient--resume-override (&optional _ignore) (transient--debug 'resume-override) - (cond ((and transient--showp (not (window-live-p transient--window))) - (transient--show)) - ((window-live-p transient--window) - (transient--fit-window-to-buffer transient--window))) + (when (window-live-p transient--window) + (transient--fit-window-to-buffer transient--window)) (transient--push-keymap 'transient--transient-map) (transient--push-keymap 'transient--redisplay-map) (add-hook 'pre-command-hook #'transient--pre-command) @@ -2891,8 +2889,7 @@ value. Otherwise return CHILDREN as is.") (setq transient--current-suffix nil)) (cond (resume (transient--stack-pop)) ((not replace) - (setq quit-flag nil) - (set-default-toplevel-value 'inhibit-quit nil) + (transient--quit-kludge 'disable) (run-hooks 'transient-post-exit-hook))))) (defun transient--stack-push () @@ -2975,13 +2972,35 @@ When no transient is active (i.e., when `transient--prefix' is nil) then only reset `inhibit-quit'. Optional ID is a keyword identifying the exit." (transient--debug 'emergency-exit id) - (set-default-toplevel-value 'inhibit-quit nil) + (transient--quit-kludge 'disable) (when transient--prefix (setq transient--stack nil) (setq transient--exitp t) (transient--pre-exit) (transient--post-exit this-command))) +(defun transient--quit-kludge (action) + (static-if (boundp 'redisplay-can-quit) ;Emacs 31 + action + (pcase-exhaustive action + ('enable + (add-function + :around command-error-function + (let (unreadp) + (lambda (orig data context fn) + (cond ((not (eq (car data) 'quit)) + (funcall orig data context fn) + (setq unreadp nil)) + (unreadp + (remove-function command-error-function "inhibit-quit") + (funcall orig data context fn)) + (t + (push ?\C-g unread-command-events) + (setq unreadp t))))) + '((name . "inhibit-quit")))) + ('disable + (remove-function command-error-function "inhibit-quit"))))) + ;;;; Pre-Commands (defun transient--call-pre-command () @@ -4997,7 +5016,9 @@ See `forward-button' for information about N." (when (re-search-forward (concat "^" (regexp-quote command)) nil t) (goto-char (match-beginning 0)))) (command - (cl-flet ((found () (eq (button-get (button-at (point)) 'command) command))) + (cl-flet ((found () + (and-let* ((button (button-at (point)))) + (eq (button-get button 'command) command)))) (while (and (ignore-errors (forward-button 1)) (not (found)))) (unless (found) -- 2.39.5