aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Bernoulli2024-06-24 13:38:35 +0200
committerJonas Bernoulli2024-06-24 13:38:35 +0200
commit4fcc38966bf58cc9977fc9fea0f7cec7eea30f6b (patch)
tree8fa7feb752d7e3aaaa0ad6bc3a7d3792ba41f83b
parentb7d5ca3a8fbb315c982966d9860c2284a82fa3ab (diff)
downloademacs-4fcc38966bf58cc9977fc9fea0f7cec7eea30f6b.tar.gz
emacs-4fcc38966bf58cc9977fc9fea0f7cec7eea30f6b.zip
Update to Transient v0.7.2-1-gf273c0c8
This fixes two bugs, one of them restoring compatibility with the version that ships with Emacs 29, making emoji-insert usable again. The other changes are of cosmetic nature. The only exception is a new command, whose creation lead to the discovery of one of the bugs, and remains unused until a package author actually binds it in a prefix. I.e., unless someone actually uses this, the risk of a regression is close to zero, and even if it is used, it can only affect the prefix that binds it.
-rw-r--r--doc/misc/transient.texi4
-rw-r--r--lisp/transient.el62
2 files changed, 56 insertions, 10 deletions
diff --git a/doc/misc/transient.texi b/doc/misc/transient.texi
index 7e8ffcf91bf..407b55ee017 100644
--- a/doc/misc/transient.texi
+++ b/doc/misc/transient.texi
@@ -31,7 +31,7 @@ General Public License for more details.
31@finalout 31@finalout
32@titlepage 32@titlepage
33@title Transient User and Developer Manual 33@title Transient User and Developer Manual
34@subtitle for version 0.7.0 34@subtitle for version 0.7.2
35@author Jonas Bernoulli 35@author Jonas Bernoulli
36@page 36@page
37@vskip 0pt plus 1filll 37@vskip 0pt plus 1filll
@@ -53,7 +53,7 @@ resource to get over that hurdle is Psionic K's interactive tutorial,
53available at @uref{https://github.com/positron-solutions/transient-showcase}. 53available at @uref{https://github.com/positron-solutions/transient-showcase}.
54 54
55@noindent 55@noindent
56This manual is for Transient version 0.7.0. 56This manual is for Transient version 0.7.2.
57 57
58@insertcopying 58@insertcopying
59@end ifnottex 59@end ifnottex
diff --git a/lisp/transient.el b/lisp/transient.el
index 34458bec688..805b0acd6f3 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -5,7 +5,7 @@
5;; Author: Jonas Bernoulli <jonas@bernoul.li> 5;; Author: Jonas Bernoulli <jonas@bernoul.li>
6;; URL: https://github.com/magit/transient 6;; URL: https://github.com/magit/transient
7;; Keywords: extensions 7;; Keywords: extensions
8;; Version: 0.7.0 8;; Version: 0.7.2
9 9
10;; SPDX-License-Identifier: GPL-3.0-or-later 10;; SPDX-License-Identifier: GPL-3.0-or-later
11 11
@@ -835,6 +835,11 @@ Technically a suffix object with no associated command.")
835All remaining arguments are treated as files. 835All remaining arguments are treated as files.
836They become the value of this argument.") 836They become the value of this argument.")
837 837
838(defclass transient-value-preset (transient-suffix)
839 ((transient :initform t)
840 (set :initarg := :initform nil))
841 "Class used by the `transient-preset' suffix command.")
842
838;;;; Group 843;;;; Group
839 844
840(defclass transient-group (transient-child) 845(defclass transient-group (transient-child)
@@ -1075,7 +1080,10 @@ commands are aliases for."
1075 (and val (not (eq val 'transient--default-infix-command)) val))) 1080 (and val (not (eq val 'transient--default-infix-command)) val)))
1076 1081
1077(eval-and-compile ;transient--expand-define-args 1082(eval-and-compile ;transient--expand-define-args
1078 (defun transient--expand-define-args (args arglist form &optional nobody) 1083 (defun transient--expand-define-args (args &optional arglist form nobody)
1084 ;; ARGLIST and FORM are only optional for backward compatibility.
1085 ;; This is necessary because "emoji.el" from Emacs 29 calls this
1086 ;; function directly, with just one argument.
1079 (unless (listp arglist) 1087 (unless (listp arglist)
1080 (error "Mandatory ARGLIST is missing")) 1088 (error "Mandatory ARGLIST is missing"))
1081 (let (class keys suffixes docstr declare (interactive-only t)) 1089 (let (class keys suffixes docstr declare (interactive-only t))
@@ -2020,7 +2028,7 @@ transient. In that case NAME is mandatory, LAYOUT and EDIT must
2020be nil and PARAMS may be (but usually is not) used to set, e.g., 2028be nil and PARAMS may be (but usually is not) used to set, e.g.,
2021the \"scope\" of the transient (see `transient-define-prefix'). 2029the \"scope\" of the transient (see `transient-define-prefix').
2022 2030
2023This function is also called internally in which case LAYOUT and 2031This function is also called internally, in which case LAYOUT and
2024EDIT may be non-nil." 2032EDIT may be non-nil."
2025 (transient--debug 'setup) 2033 (transient--debug 'setup)
2026 (transient--with-emergency-exit :setup 2034 (transient--with-emergency-exit :setup
@@ -2275,6 +2283,12 @@ value. Otherwise return CHILDREN as is."
2275 (transient--pop-keymap 'transient--predicate-map) 2283 (transient--pop-keymap 'transient--predicate-map)
2276 (transient--pop-keymap 'transient--transient-map) 2284 (transient--pop-keymap 'transient--transient-map)
2277 (transient--pop-keymap 'transient--redisplay-map) 2285 (transient--pop-keymap 'transient--redisplay-map)
2286 (if (eq transient--refreshp 'updated-value)
2287 ;; Preserve the prefix value this once, because the
2288 ;; invoked suffix indicates that it has updated that.
2289 (setq transient--refreshp (oref transient--prefix refresh-suffixes))
2290 ;; Otherwise update the prefix value from suffix values.
2291 (oset transient--prefix value (transient-get-value)))
2278 (transient--init-objects) 2292 (transient--init-objects)
2279 (transient--init-keymaps) 2293 (transient--init-keymaps)
2280 (transient--push-keymap 'transient--transient-map) 2294 (transient--push-keymap 'transient--transient-map)
@@ -3081,6 +3095,12 @@ transient is active."
3081 (oset obj value (nth pos hst)) 3095 (oset obj value (nth pos hst))
3082 (mapc #'transient-init-value transient--suffixes)))) 3096 (mapc #'transient-init-value transient--suffixes))))
3083 3097
3098(transient-define-suffix transient-preset ()
3099 "Put this preset into action."
3100 :class transient-value-preset
3101 (interactive)
3102 (transient-prefix-set (oref (transient-suffix-object) set)))
3103
3084;;;; Auxiliary 3104;;;; Auxiliary
3085 3105
3086(defun transient-toggle-common () 3106(defun transient-toggle-common ()
@@ -3258,7 +3278,7 @@ it\", in which case it is pointless to preserve history.)"
3258 (reader (oref obj reader)) 3278 (reader (oref obj reader))
3259 (choices (if (functionp choices) (funcall choices) choices)) 3279 (choices (if (functionp choices) (funcall choices) choices))
3260 (prompt (transient-prompt obj)) 3280 (prompt (transient-prompt obj))
3261 (value (if multi-value (mapconcat #'identity value ",") value)) 3281 (value (if multi-value (string-join value ",") value))
3262 (history-key (or (oref obj history-key) 3282 (history-key (or (oref obj history-key)
3263 (oref obj command))) 3283 (oref obj command)))
3264 (transient--history (alist-get history-key transient-history)) 3284 (transient--history (alist-get history-key transient-history))
@@ -3405,10 +3425,10 @@ prompt."
3405;;;; Set 3425;;;; Set
3406 3426
3407(cl-defgeneric transient-infix-set (obj value) 3427(cl-defgeneric transient-infix-set (obj value)
3408 "Set the value of infix object OBJ to value.") 3428 "Set the value of infix object OBJ to VALUE.")
3409 3429
3410(cl-defmethod transient-infix-set ((obj transient-infix) value) 3430(cl-defmethod transient-infix-set ((obj transient-infix) value)
3411 "Set the value of infix object OBJ to value." 3431 "Set the value of infix object OBJ to VALUE."
3412 (oset obj value value)) 3432 (oset obj value value))
3413 3433
3414(cl-defmethod transient-infix-set :after ((obj transient-argument) value) 3434(cl-defmethod transient-infix-set :after ((obj transient-argument) value)
@@ -3438,8 +3458,16 @@ prompt."
3438 (member arg incomp))))) 3458 (member arg incomp)))))
3439 (transient-infix-set obj nil))))) 3459 (transient-infix-set obj nil)))))
3440 3460
3461(defun transient-prefix-set (value)
3462 "Set the value of the active transient prefix to VALUE.
3463Intended for use by transient suffix commands."
3464 (oset transient--prefix value value)
3465 (setq transient--refreshp 'updated-value))
3466
3441(cl-defgeneric transient-set-value (obj) 3467(cl-defgeneric transient-set-value (obj)
3442 "Set the value of the transient prefix OBJ.") 3468 "Persist the value of the transient prefix OBJ.
3469Only intended for use by `transient-set'.
3470Also see `transient-prefix-set'.")
3443 3471
3444(cl-defmethod transient-set-value ((obj transient-prefix)) 3472(cl-defmethod transient-set-value ((obj transient-prefix))
3445 (oset (oref obj prototype) value (transient-get-value)) 3473 (oset (oref obj prototype) value (transient-get-value))
@@ -3495,7 +3523,7 @@ the set, saved or default value for PREFIX."
3495 (and (or (not (slot-exists-p obj 'unsavable)) 3523 (and (or (not (slot-exists-p obj 'unsavable))
3496 (not (oref obj unsavable))) 3524 (not (oref obj unsavable)))
3497 (transient--get-wrapped-value obj))) 3525 (transient--get-wrapped-value obj)))
3498 transient-current-suffixes))) 3526 (or transient--suffixes transient-current-suffixes))))
3499 3527
3500(defun transient--get-wrapped-value (obj) 3528(defun transient--get-wrapped-value (obj)
3501 (and-let* ((value (transient-infix-value obj))) 3529 (and-let* ((value (transient-infix-value obj)))
@@ -3954,6 +3982,24 @@ called inside the correct buffer (see `transient--insert-group')
3954and its value is returned to the caller." 3982and its value is returned to the caller."
3955 (transient--get-description obj)) 3983 (transient--get-description obj))
3956 3984
3985(cl-defmethod transient-format-description ((obj transient-value-preset))
3986 (pcase-let* (((eieio description key set) obj)
3987 ((eieio value) transient--prefix)
3988 (active (seq-set-equal-p set value)))
3989 (format
3990 "%s %s"
3991 (propertize (or description (format "Preset %s" key))
3992 'face (and active 'transient-argument))
3993 (format (propertize "(%s)" 'face 'transient-delimiter)
3994 (mapconcat (lambda (arg)
3995 (propertize
3996 arg 'face (cond (active 'transient-argument)
3997 ((member arg value)
3998 '((:weight demibold)
3999 transient-inactive-argument))
4000 ('transient-inactive-argument))))
4001 set " ")))))
4002
3957(cl-defmethod transient-format-description ((obj transient-group)) 4003(cl-defmethod transient-format-description ((obj transient-group))
3958 "Format the description by calling the next method. If the result 4004 "Format the description by calling the next method. If the result
3959doesn't use the `face' property at all, then apply the face 4005doesn't use the `face' property at all, then apply the face