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

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

[elpa] externals/transient 90a0562 2/5: transient-highlight-higher-level


From: Jonas Bernoulli
Subject: [elpa] externals/transient 90a0562 2/5: transient-highlight-higher-levels: New option
Date: Thu, 1 Jul 2021 11:13:40 -0400 (EDT)

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

    transient-highlight-higher-levels: New option
---
 lisp/transient.el | 43 ++++++++++++++++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index d610d4a..aa26c76 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -239,6 +239,20 @@ and `transient-nonstandard-key'."
   :group 'transient
   :type 'boolean)
 
+(defcustom transient-highlight-higher-levels nil
+  "Whether to highlight suffixes on higher levels.
+
+This is primarily intended for package authors.
+
+When non-nil then highlight the description of suffixes whose
+level is above 4, the default of `transient-default-level'.
+Assuming you have set that variable to 7, this highlights all
+suffixes that won't be available to users without them making
+the same customization."
+  :package-version '(transient . "0.3.6")
+  :group 'transient
+  :type 'boolean)
+
 (defcustom transient-substitute-key-function nil
   "Function used to modify key bindings.
 
@@ -310,7 +324,11 @@ text and might otherwise have to scroll in two dimensions."
   :group 'transient
   :type 'boolean)
 
-(defcustom transient-default-level 4
+(defconst transient--default-child-level 1)
+
+(defconst transient--default-prefix-level 4)
+
+(defcustom transient-default-level transient--default-prefix-level
   "Control what suffix levels are made available by default.
 
 Each suffix command is placed on a level and each prefix command
@@ -444,6 +462,11 @@ See info node `(transient)Enabling and Disabling 
Suffixes'."
 See info node `(transient)Enabling and Disabling Suffixes'."
   :group 'transient-faces)
 
+(defface transient-higher-level '((t :underline t))
+  "Face optionally used to highlight suffixes on higher levels.
+Also see option `transient-highlight-higher-levels'."
+  :group 'transient-faces)
+
 (defface transient-separator
   `((((class color) (background light))
      ,@(and (>= emacs-major-version 27) '(:extend t))
@@ -580,8 +603,6 @@ the prototype is stored in the clone's `prototype' slot.")
 
 ;;;; Suffix
 
-(defconst transient--default-child-level 1)
-
 (defclass transient-child ()
   ((level
     :initarg :level
@@ -3004,9 +3025,7 @@ Optional support for popup buttons is also implemented 
here."
                                          'transient-disabled-suffix))))
               (cl-call-next-method obj))))
     (when (oref obj inapt)
-      (set-text-properties 0 (length str)
-                           (list 'face 'transient-inapt-suffix)
-                           str))
+      (add-face-text-property 0 (length str) 'transient-inapt-suffix nil str))
     (if transient-enable-popup-navigation
         (make-text-button str nil
                           'type 'transient-button
@@ -3118,9 +3137,15 @@ 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))))
-    (if (transient--key-unreachable-p obj)
-        (propertize desc 'face 'transient-unreachable)
-      desc)))
+    (cond ((transient--key-unreachable-p obj)
+           (propertize desc 'face 'transient-unreachable))
+          ((and transient-highlight-higher-levels
+                (> (oref obj level) transient--default-prefix-level))
+           (add-face-text-property
+            0 (length desc) 'transient-higher-level nil desc)
+           desc)
+          (t
+           desc))))
 
 (cl-defgeneric transient-format-value (obj)
   "Format OBJ's value for display and return the result.")



reply via email to

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