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

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

[elpa] externals/transient 23cb5b109d 22/25: transient-prefix: Add mode-


From: Jonas Bernoulli
Subject: [elpa] externals/transient 23cb5b109d 22/25: transient-prefix: Add mode-line-format slot
Date: Tue, 3 Dec 2024 14:35:03 -0500 (EST)

branch: externals/transient
commit 23cb5b109dcb42550d573d7502bf9e8a5b7db325
Author: Joseph Turner <joseph@breatheoutbreathe.in>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    transient-prefix: Add mode-line-format slot
---
 CHANGELOG           |  4 ++++
 docs/transient.org  |  6 ++++++
 docs/transient.texi |  7 +++++++
 lisp/transient.el   | 20 ++++++++++++--------
 4 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index af6b1773d5..fe9853cb56 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,10 @@
 - ~transient-setup-buffer-hook~ is now run later to allow overriding
   more default settings.
 
+- The new prefix slots ~display-action~ and ~mode-line-format~, can be
+  used to override ~transient-display-buffer-action~ and
+  ~transient-mode-line-format~ for individual prefix menus.  #332
+
 Bug fixes:
 
 - Fixes some menu navigation edge-cases.
diff --git a/docs/transient.org b/docs/transient.org
index 9a9eaaa651..a66fb72db5 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -563,6 +563,9 @@ Also see [[* Common Suffix Commands]].
   ~transient-key-exit~ (if allowed and they exit the transient) is
   used to draw the line.
 
+  This user option may be overridden if ~:mode-line-format~ is passed
+  when creating a new prefix with ~transient-define-prefix~.
+
   Otherwise this can be any mode-line format.  See [[info:elisp#Mode
   Line Format]], for details.
 
@@ -1957,6 +1960,9 @@ functions use ~describe-function~.
 - ~display-action~ determines how this prefix is displayed, overriding
   ~transient-display-buffer-action~.  It should have the same type.
 
+- ~mode-line-format~ is this prefix's mode line format, overriding
+  ~transient-mode-line-format~.  It should have the same type.
+
 - ~scope~ For some transients it might be necessary to have a sort of
   secondary value, called a “scope”.  See ~transient-define-prefix~.
 
diff --git a/docs/transient.texi b/docs/transient.texi
index 74af03a8e7..b1ad8c85ac 100644
--- a/docs/transient.texi
+++ b/docs/transient.texi
@@ -722,6 +722,9 @@ color of @code{transient-key-noop} (if non-suffixes are 
disallowed),
 @code{transient-key-exit} (if allowed and they exit the transient) is
 used to draw the line.
 
+This user option may be overridden if @code{:mode-line-format} is passed
+when creating a new prefix with @code{transient-define-prefix}.
+
 Otherwise this can be any mode-line format.  See @ref{Mode Line 
Format,,,elisp,}, for details.
 @end defopt
 
@@ -2221,6 +2224,10 @@ for example, @code{--option=one}.
 @code{display-action} determines how this prefix is displayed, overriding
 @code{transient-display-buffer-action}.  It should have the same type.
 
+@item
+@code{mode-line-format} is this prefix's mode line format, overriding
+@code{transient-mode-line-format}.  It should have the same type.
+
 @item
 @code{scope} For some transients it might be necessary to have a sort of
 secondary value, called a ``scope''.  See @code{transient-define-prefix}.
diff --git a/lisp/transient.el b/lisp/transient.el
index b2103843c8..9d6699d6f5 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -724,6 +724,7 @@ If `transient-save-history' is nil, then do nothing."
    (incompatible         :initarg :incompatible         :initform nil)
    (suffix-description   :initarg :suffix-description)
    (display-action       :initarg :display-action       :initform nil)
+   (mode-line-format     :initarg :mode-line-format)
    (variable-pitch       :initarg :variable-pitch       :initform nil)
    (column-widths        :initarg :column-widths        :initform nil)
    (unwind-suffix        :documentation "Internal use." :initform nil))
@@ -3896,10 +3897,8 @@ have a history of their own.")
         (setq tab-line-format nil))
       (setq header-line-format nil)
       (setq mode-line-format
-            (if (or (natnump transient-mode-line-format)
-                    (eq transient-mode-line-format 'line))
-                nil
-              transient-mode-line-format))
+            (let ((format (transient--mode-line-format)))
+              (if (or (natnump format) (eq format 'line)) nil format)))
       (setq mode-line-buffer-identification
             (symbol-name (oref transient--prefix command)))
       (if transient-enable-popup-navigation
@@ -3947,11 +3946,16 @@ have a history of their own.")
                               (window-body-width window t)
                               (window-body-height window t))))
 
+(defun transient--mode-line-format ()
+  (if (slot-boundp transient--prefix 'mode-line-format)
+      (oref transient--prefix mode-line-format)
+    transient-mode-line-format))
+
 (defun transient--separator-line ()
-  (and-let* ((height (cond ((not window-system) nil)
-                           ((natnump transient-mode-line-format)
-                            transient-mode-line-format)
-                           ((eq transient-mode-line-format 'line) 1)))
+  (and-let* ((format (transient--mode-line-format))
+             (height (cond ((not window-system) nil)
+                           ((natnump format) format)
+                           ((eq format 'line) 1)))
              (face `(,@(and (>= emacs-major-version 27) '(:extend t))
                      :background
                      ,(or (face-foreground (transient--key-face nil 
'non-suffix)



reply via email to

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