branch: externals/transient
commit 4e05e53cc988fe399dd7a6c87bf1d2abe28bbbe8
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
transient--get-description: New function
As a result, `transient-format-description(transient-group)' no longer
has to call the next method.
As a result of that in turn, `transient--get-face' no longer gets called
for objects that lack the `face' slot. Remove the `slot-exists-p' check
and restrict to `transient-suffix', which all have that slot. Restrict
type of `transient--get-face' as well.
We do all this, so that we can, in a later commit, add a `face' slot to
`transient-group', but use it for a different purpose.
---
lisp/transient.el | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index 2185cc899c..8d48386de4 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -3937,16 +3937,11 @@ as a button."
(cl-defgeneric transient-format-description (obj)
"Format OBJ's `description' for display and return the result.")
-(cl-defmethod transient-format-description ((obj transient-child))
+(cl-defmethod transient-format-description ((obj transient-suffix))
"The `description' slot may be a function, in which case that is
called inside the correct buffer (see `transient--insert-group')
and its value is returned to the caller."
- (and-let* ((desc (oref obj description))
- (desc (if (functionp desc)
- (if (= (car (transient--func-arity desc)) 1)
- (funcall desc obj)
- (funcall desc))
- desc)))
+ (and-let* ((desc (transient--get-description obj)))
(if-let* ((face (transient--get-face obj 'face)))
(transient--add-face desc face t)
desc)))
@@ -3955,7 +3950,7 @@ and its value is returned to the caller."
"Format the description by calling the next method. If the result
doesn't use the `face' property at all, then apply the face
`transient-heading' to the complete string."
- (and-let* ((desc (cl-call-next-method obj)))
+ (and-let* ((desc (transient--get-description obj)))
(cond ((oref obj inapt)
(propertize desc 'face 'transient-inapt-suffix))
((text-property-not-all 0 (length desc) 'face nil desc)
@@ -4033,9 +4028,16 @@ If the OBJ's `key' is currently unreachable, then apply
the face
choices
(propertize "|" 'face 'transient-delimiter))))))
-(defun transient--get-face (obj slot)
- (and-let* (((slot-exists-p obj slot))
- ((slot-boundp obj slot))
+(cl-defmethod transient--get-description ((obj transient-child))
+ (and-let* ((desc (oref obj description)))
+ (if (functionp desc)
+ (if (= (car (transient--func-arity desc)) 1)
+ (funcall desc obj)
+ (funcall desc))
+ desc)))
+
+(cl-defmethod transient--get-face ((obj transient-suffix) slot)
+ (and-let* (((slot-boundp obj slot))
(face (slot-value obj slot)))
(if (and (not (facep face))
(functionp face))