From f575c7afe3735b944d22d5a4c076b8b1b3d85352 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 --- docs/transient.org | 6 ++++++ lisp/transient.el | 22 ++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/transient.org b/docs/transient.org index 1985871..95cfe7f 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. @@ -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 diff --git a/lisp/transient.el b/lisp/transient.el index 08c3bfc..bd6d4f4 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) (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 () + (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)