Skip to content

Commit

Permalink
transient-prefix: Add mode-line-format slot
Browse files Browse the repository at this point in the history
:initform is set to 'undefined so that passing :mode-line-format nil
to transient-define-prefix overrides transient-mode-line-format.
  • Loading branch information
josephmturner committed Nov 30, 2024
1 parent 9493562 commit f852dad
Showing 1 changed file with 14 additions and 8 deletions.
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 :initform 'undefined)
(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 ()
(let ((format (oref transient--prefix mode-line-format))
(default (oref-default transient--prefix mode-line-format)))
(if (eq format default) transient-mode-line-format 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 f852dad

Please sign in to comment.