[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient 3d395d643b 6/6: Add support for :inapt* predi
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient 3d395d643b 6/6: Add support for :inapt* predicates for groups |
Date: |
Thu, 16 May 2024 07:49:35 -0400 (EDT) |
branch: externals/transient
commit 3d395d643b1476b07c6c3d7217f5b2ad2c0b425e
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Add support for :inapt* predicates for groups
---
lisp/transient.el | 71 ++++++++++++++++++++++++++++++++-----------------------
1 file changed, 41 insertions(+), 30 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index 993ba13625..555df62657 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -724,24 +724,12 @@ the prototype is stored in the clone's `prototype' slot.")
(if-not-derived
:initarg :if-not-derived
:initform nil
- :documentation "Enable if major-mode does not derive from value."))
- "Abstract superclass for group and suffix classes.
-
-It is undefined what happens if more than one `if*' predicate
-slot is non-nil."
- :abstract t)
-
-(defclass transient-suffix (transient-child)
- ((definition :allocation :class :initform nil)
- (key :initarg :key)
- (command :initarg :command)
- (transient :initarg :transient)
- (format :initarg :format :initform " %k %d")
- (description :initarg :description :initform nil)
- (face :initarg :face :initform nil)
- (show-help :initarg :show-help :initform nil)
- (inapt-face :initarg :inapt-face :initform 'transient-inapt-suffix)
- (inapt :initform nil)
+ :documentation "Enable if major-mode does not derive from value.")
+ (inapt
+ :initform nil)
+ (inapt-face
+ :initarg :inapt-face
+ :initform 'transient-inapt-suffix)
(inapt-if
:initarg :inapt-if
:initform nil
@@ -774,6 +762,21 @@ slot is non-nil."
:initarg :inapt-if-not-derived
:initform nil
:documentation "Inapt if major-mode does not derive from value."))
+ "Abstract superclass for group and suffix classes.
+
+It is undefined what happens if more than one `if*' predicate
+slot is non-nil."
+ :abstract t)
+
+(defclass transient-suffix (transient-child)
+ ((definition :allocation :class :initform nil)
+ (key :initarg :key)
+ (command :initarg :command)
+ (transient :initarg :transient)
+ (format :initarg :format :initform " %k %d")
+ (description :initarg :description :initform nil)
+ (face :initarg :face :initform nil)
+ (show-help :initarg :show-help :initform nil))
"Superclass for suffix command.")
(defclass transient-information (transient-suffix)
@@ -2071,7 +2074,7 @@ value. Otherwise return CHILDREN as is."
(defun transient--init-suffixes (name)
(let ((levels (alist-get name transient-levels)))
- (cl-mapcan (lambda (c) (transient--init-child levels c))
+ (cl-mapcan (lambda (c) (transient--init-child levels c nil))
(append (get name 'transient--layout)
(and (not transient--editp)
(get 'transient-common-commands
@@ -2089,24 +2092,29 @@ value. Otherwise return CHILDREN as is."
(list def)))))
(cl-mapcan #'s layout)))
-(defun transient--init-child (levels spec)
+(defun transient--init-child (levels spec parent)
(cl-etypecase spec
- (vector (transient--init-group levels spec))
- (list (transient--init-suffix levels spec))
+ (vector (transient--init-group levels spec parent))
+ (list (transient--init-suffix levels spec parent))
(string (list spec))))
-(defun transient--init-group (levels spec)
+(defun transient--init-group (levels spec parent)
(pcase-let ((`(,level ,class ,args ,children) (append spec nil)))
(and-let* (((transient--use-level-p level))
(obj (apply class :level level args))
((transient--use-suffix-p obj))
- (suffixes (cl-mapcan (lambda (c) (transient--init-child levels
c))
- (transient-setup-children obj children))))
+ ((prog1 t
+ (when (or (and parent (oref parent inapt))
+ (transient--inapt-suffix-p obj))
+ (oset obj inapt t))))
+ (suffixes (cl-mapcan
+ (lambda (c) (transient--init-child levels c obj))
+ (transient-setup-children obj children))))
(progn ; work around debbugs#31840
(oset obj suffixes suffixes)
(list obj)))))
-(defun transient--init-suffix (levels spec)
+(defun transient--init-suffix (levels spec parent)
(pcase-let* ((`(,level ,class ,args) spec)
(cmd (plist-get args :command))
(key (transient--kbd (plist-get args :key)))
@@ -2139,7 +2147,8 @@ value. Otherwise return CHILDREN as is."
(unless (cl-typep obj 'transient-information)
(transient--init-suffix-key obj))
(when (transient--use-suffix-p obj)
- (if (transient--inapt-suffix-p obj)
+ (if (or (and parent (oref parent inapt))
+ (transient--inapt-suffix-p obj))
(oset obj inapt t)
(transient-init-scope obj)
(transient-init-value obj))
@@ -3945,9 +3954,11 @@ and its value is returned to the caller."
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)))
- (if (text-property-not-all 0 (length desc) 'face nil desc)
- desc
- (propertize desc 'face 'transient-heading))))
+ (cond ((oref obj inapt)
+ (propertize desc 'face 'transient-inapt-suffix))
+ ((text-property-not-all 0 (length desc) 'face nil desc)
+ desc)
+ ((propertize desc 'face 'transient-heading)))))
(cl-defmethod transient-format-description :around ((obj transient-suffix))
"Format the description by calling the next method. If the result
- [elpa] externals/transient updated (2dd0102ec3 -> 3d395d643b), Jonas Bernoulli, 2024/05/16
- [elpa] externals/transient dc967e07fe 5/6: transient--debug: Cosmetics, Jonas Bernoulli, 2024/05/16
- [elpa] externals/transient 753de9088e 1/6: transient--insert-groups: Use while-let, Jonas Bernoulli, 2024/05/16
- [elpa] externals/transient 9c3986d6d6 2/6: Use more function quotes, Jonas Bernoulli, 2024/05/16
- [elpa] externals/transient e2bfe89e8f 4/6: transient--debug: Use new help-fns-function-name if available, Jonas Bernoulli, 2024/05/16
- [elpa] externals/transient 3d395d643b 6/6: Add support for :inapt* predicates for groups,
Jonas Bernoulli <=
- [elpa] externals/transient f3e1e70428 3/6: Use lexical binding with eval, Jonas Bernoulli, 2024/05/16