From 94935628f81a625eb6abeb41986988b5307731c1 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Wed, 27 Nov 2024 09:22:59 -0800 Subject: [PATCH] transient-prefix: Add display-action slot This change lets each transient-prefix display according to its own display-buffer-action. Resolves this discussion: https://github.com/magit/transient/discussions/303 --- lisp/transient.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/transient.el b/lisp/transient.el index 911a34d..08c3bfc 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -681,6 +681,7 @@ If `transient-save-history' is nil, then do nothing." (transient-suffix :initarg :transient-suffix :initform nil) (transient-non-suffix :initarg :transient-non-suffix :initform nil) (transient-switch-frame :initarg :transient-switch-frame) + (display-action :initarg :display-action :initform nil) (refresh-suffixes :initarg :refresh-suffixes :initform nil) (environment :initarg :environment :initform nil) (incompatible :initarg :incompatible :initform nil) @@ -3856,12 +3857,9 @@ have a history of their own.") (when-let ((line (transient--separator-line))) (insert line))) (unless (window-live-p transient--window) - (when (eq (car transient-display-buffer-action) - 'display-buffer-full-frame) - (user-error "Invalid value for `transient-display-buffer-action'")) (setq transient--window (display-buffer transient--buffer - transient-display-buffer-action))) + (transient--display-action)))) (when (window-live-p transient--window) (with-selected-window transient--window (set-window-parameter nil 'prev--no-other-window @@ -3872,6 +3870,13 @@ have a history of their own.") (transient--goto-button focus)) (transient--fit-window-to-buffer transient--window))))) +(defun transient--display-action () + (let ((action (or (oref transient--prefix display-action) + transient-display-buffer-action))) + (when (eq (car action) 'display-buffer-full-frame) + (user-error "Invalid value for `transient-display-buffer-action'")) + action)) + (defun transient--fit-window-to-buffer (window) (let ((window-resize-pixelwise t) (window-size-fixed nil))