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

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

[elpa] externals/transient a99dcda957 09/23: transient--key-face: Take k


From: Jonas Bernoulli
Subject: [elpa] externals/transient a99dcda957 09/23: transient--key-face: Take key into account
Date: Sun, 22 Dec 2024 08:44:39 -0500 (EST)

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

    transient--key-face: Take key into account
    
    [1: fe71a7e7] only did so when determining the transient behavior.
    This commit takes care of also properly visualizing that behavior.
    
    - Take an additional KEY argument and pass it along to
      `transient--get-pre-command'.  The previous commit [2: db9603be]
      added that argument to that function.
    
    - No longer prefer the command's `transient-face' symbol property,
      which we did since the very first implementation of this feature,
      added in [3: 248862c5].  Overriding the automatically determined
      face is counterproductive as it would counter binding-specific
      changes to the transient behavior and inapt predicate.  We don't
      actually do this for any commands, so in practice this did not
      matter.
    
    - No longer define an around method, the primary method handles it
      all.  It already did that before this commit.
    
    1: 2024-12-15 fe71a7e7d63c1685d22b59e792c6b67cefebf2af
       Account for duplicated commands with different transient behavior
    
    2: 2024-12-16 db9603bef9afc23b7c6df2483cf2295cd3ff34ab
       transient--get-pre-command: Change argument order
    
    3: 2020-06-21 248862c58e3bc0c13c6e3315adc2f3bb43c3c476
       Add experimental support for semantic coloring
---
 lisp/transient.el | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index 0cc84a131b..fd877558af 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -4009,7 +4009,8 @@ have a history of their own.")
             (propertize "\n" 'face face 'line-height t))))
 
 (defun transient--prefix-color ()
-  (or (face-foreground (transient--key-face nil 'non-suffix) nil t) "#gray60"))
+  (or (face-foreground (transient--key-face nil nil 'non-suffix) nil t)
+      "#gray60"))
 
 (defmacro transient-with-shadowed-buffer (&rest body)
   "While in the transient buffer, temporarily make the shadowed buffer 
current."
@@ -4161,13 +4162,6 @@ as a button."
 (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))
-  "Add `transient-inapt-suffix' face if suffix is inapt."
-  (let ((str (cl-call-next-method)))
-    (if (oref obj inapt)
-        (transient--add-face str 'transient-inapt-suffix)
-      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) ""))
@@ -4200,16 +4194,16 @@ as a button."
                 (setq suf (string-replace " " "" suf)))
               (concat (propertize pre 'face 'transient-unreachable-key)
                       (and (string-prefix-p (concat pre " ") key) " ")
-                      (propertize suf 'face (transient--key-face cmd))
+                      (propertize suf 'face (transient--key-face cmd key))
                       (save-excursion
                         (and (string-match " +\\'" key)
                              (propertize (match-string 0 key)
                                          'face 'fixed-pitch))))))
            ((transient--lookup-key transient-sticky-map (kbd key))
-            (propertize key 'face (transient--key-face cmd)))
+            (propertize key 'face (transient--key-face cmd key)))
            (t
             (propertize key 'face 'transient-unreachable-key))))
-      (propertize key 'face (transient--key-face cmd)))))
+      (propertize key 'face (transient--key-face cmd key)))))
 
 (cl-defmethod transient-format-key :around ((obj transient-argument))
   "Handle `transient-highlight-mismatched-keys'."
@@ -4358,13 +4352,12 @@ apply the face `transient-unreachable' to the complete 
string."
     (add-face-text-property (or beg 0) (or end (length str)) face append str)
     str))
 
-(defun transient--key-face (&optional cmd enforce-type)
+(defun transient--key-face (cmd key &optional enforce-type)
   (or (and transient-semantic-coloring
            (not transient--helpp)
            (not transient--editp)
-           (or (and cmd (get cmd 'transient-face))
-               (get (transient--get-pre-command cmd nil enforce-type)
-                    'transient-face)))
+           (get (transient--get-pre-command cmd key enforce-type)
+                'transient-face))
       (if cmd 'transient-key 'transient-key-noop)))
 
 (defun transient--key-unreachable-p (obj)



reply via email to

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