emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/transient 71399d21c5 30/41: transient-format: No longer


From: Jonas Bernoulli
Subject: [elpa] externals/transient 71399d21c5 30/41: transient-format: No longer apply face for inapt bindings here
Date: Sun, 12 Nov 2023 20:04:09 -0500 (EST)

branch: externals/transient
commit 71399d21c52048cc809dd848a71dbe3887b93acf
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    transient-format: No longer apply face for inapt bindings here
    
    Apply a face individually for the key and the description.  For the
    key, always use `transient-inapt-suffix'.  For the description honor
    the new `inapt-face' slot.
    
    Some suffixes are inapt because they represent the current state and
    invoking them therefore wouldn't makes sense.  In that case we likely
    want to highlight them, instead of dimming them.
---
 lisp/transient.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index d4af5c94f9..d642ba5d11 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -716,6 +716,7 @@ slot is non-nil."
    (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)
    (inapt-if
     :initarg :inapt-if
@@ -3617,8 +3618,6 @@ Optional support for popup buttons is also implemented 
here."
                                            'transient-enabled-suffix
                                          'transient-disabled-suffix))))
               (cl-call-next-method obj))))
-    (when (oref obj inapt)
-      (add-face-text-property 0 (length str) 'transient-inapt-suffix nil str))
     (if transient-enable-popup-navigation
         (make-text-button str nil
                           'type 'transient
@@ -3646,6 +3645,12 @@ Optional support for popup buttons is also implemented 
here."
 (cl-defgeneric transient-format-key (obj)
   "Format OBJ's `key' for display and return the result.")
 
+(cl-defmethod transient-format-key :around ((obj transient-suffix))
+  (let ((str (cl-call-next-method)))
+    (when (oref obj inapt)
+      (add-face-text-property 0 (length str) 'transient-inapt-suffix nil str))
+    str))
+
 (cl-defmethod transient-format-key ((obj transient-suffix))
   "Format OBJ's `key' for display and return the result."
   (let ((key (if (slot-boundp obj 'key) (oref obj key) ""))
@@ -3744,7 +3749,11 @@ If the OBJ's `key' is currently unreachable, then apply 
the face
                        (funcall (oref transient--prefix suffix-description)
                                 obj))
                   (propertize "(BUG: no description)" 'face 'error))))
-    (cond ((and (slot-boundp obj 'key)
+    (cond ((oref obj inapt)
+           (when-let ((face (oref obj inapt-face)))
+             (add-face-text-property 0 (length desc) face nil desc))
+           desc)
+          ((and (slot-boundp obj 'key)
                 (transient--key-unreachable-p obj))
            (propertize desc 'face 'transient-unreachable))
           ((if transient--all-levels-p



reply via email to

[Prev in Thread] Current Thread [Next in Thread]