Skip to content

Commit

Permalink
transient-prefix: Add mode-line-format slot
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmturner committed Dec 1, 2024
1 parent c719afb commit f575c7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
6 changes: 6 additions & 0 deletions docs/transient.org
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -1917,6 +1920,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.

- ~incompatible~ A list of lists. Each sub-list specifies a set of
mutually exclusive arguments. Enabling one of these arguments
causes the others to be disabled. An argument may appear in
Expand Down
22 changes: 14 additions & 8 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ If `transient-save-history' is nil, then do nothing."
(transient-non-suffix :initarg :transient-non-suffix :initform nil)
(transient-switch-frame :initarg :transient-switch-frame)
(display-action :initarg :display-action :initform nil)
(mode-line-format :initarg :mode-line-format)
(refresh-suffixes :initarg :refresh-suffixes :initform nil)
(environment :initarg :environment :initform nil)
(incompatible :initarg :incompatible :initform nil)
Expand Down Expand Up @@ -3839,10 +3840,10 @@ 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
Expand Down Expand Up @@ -3886,11 +3887,16 @@ have a history of their own.")
(fit-window-to-buffer window nil (window-height window))
(fit-window-to-buffer window nil 1))))

(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)
Expand Down

0 comments on commit f575c7a

Please sign in to comment.