Skip to content

Commit f575c7a

Browse files
committed
transient-prefix: Add mode-line-format slot
1 parent c719afb commit f575c7a

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

docs/transient.org

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ Also see [[* Common Suffix Commands]].
563563
~transient-key-exit~ (if allowed and they exit the transient) is
564564
used to draw the line.
565565

566+
This user option may be overridden if ~:mode-line-format~ is passed
567+
when creating a new prefix with ~transient-define-prefix~.
568+
566569
Otherwise this can be any mode-line format. See [[info:elisp#Mode
567570
Line Format]], for details.
568571

@@ -1917,6 +1920,9 @@ functions use ~describe-function~.
19171920
- ~display-action~ determines how this prefix is displayed, overriding
19181921
~transient-display-buffer-action~. It should have the same type.
19191922

1923+
- ~mode-line-format~ is this prefix's mode line format, overriding
1924+
~transient-mode-line-format~. It should have the same type.
1925+
19201926
- ~incompatible~ A list of lists. Each sub-list specifies a set of
19211927
mutually exclusive arguments. Enabling one of these arguments
19221928
causes the others to be disabled. An argument may appear in

lisp/transient.el

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ If `transient-save-history' is nil, then do nothing."
682682
(transient-non-suffix :initarg :transient-non-suffix :initform nil)
683683
(transient-switch-frame :initarg :transient-switch-frame)
684684
(display-action :initarg :display-action :initform nil)
685+
(mode-line-format :initarg :mode-line-format)
685686
(refresh-suffixes :initarg :refresh-suffixes :initform nil)
686687
(environment :initarg :environment :initform nil)
687688
(incompatible :initarg :incompatible :initform nil)
@@ -3839,10 +3840,10 @@ have a history of their own.")
38393840
(setq tab-line-format nil))
38403841
(setq header-line-format nil)
38413842
(setq mode-line-format
3842-
(if (or (natnump transient-mode-line-format)
3843-
(eq transient-mode-line-format 'line))
3844-
nil
3845-
transient-mode-line-format))
3843+
(let ((format (transient--mode-line-format)))
3844+
(if (or (natnump format) (eq format 'line))
3845+
nil
3846+
format)))
38463847
(setq mode-line-buffer-identification
38473848
(symbol-name (oref transient--prefix command)))
38483849
(if transient-enable-popup-navigation
@@ -3886,11 +3887,16 @@ have a history of their own.")
38863887
(fit-window-to-buffer window nil (window-height window))
38873888
(fit-window-to-buffer window nil 1))))
38883889

3890+
(defun transient--mode-line-format ()
3891+
(if (slot-boundp transient--prefix mode-line-format)
3892+
(oref transient--prefix mode-line-format)
3893+
transient-mode-line-format))
3894+
38893895
(defun transient--separator-line ()
3890-
(and-let* ((height (cond ((not window-system) nil)
3891-
((natnump transient-mode-line-format)
3892-
transient-mode-line-format)
3893-
((eq transient-mode-line-format 'line) 1)))
3896+
(and-let* ((format (transient--mode-line-format))
3897+
(height (cond ((not window-system) nil)
3898+
((natnump format) format)
3899+
((eq format 'line) 1)))
38943900
(face `(,@(and (>= emacs-major-version 27) '(:extend t))
38953901
:background
38963902
,(or (face-foreground (transient--key-face nil 'non-suffix)

0 commit comments

Comments
 (0)