From f852dad9e33105136674cb6c89876d3eb7cb6911 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 30 Nov 2024 00:04:23 -0800 Subject: [PATCH] transient-prefix: Add mode-line-format slot :initform is set to 'undefined so that passing :mode-line-format nil to transient-define-prefix overrides transient-mode-line-format. --- lisp/transient.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lisp/transient.el b/lisp/transient.el index 08c3bfc..25710bb 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -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) @@ -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 @@ -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)