From c651e9cf85ebceb8bf2ce4addde1a796a7fbf5dc Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Thu, 12 Dec 2024 10:30:06 +0100 Subject: [PATCH] transient--display-action: Pre-calculate frame dimensions When displaying the transient menu in a dedicated frame, calculate the approximate dimensions beforehand to avoid potentially massive flickering due to resizing and to improve placement. --- lisp/transient.el | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lisp/transient.el b/lisp/transient.el index 383ab11..ee69ec4 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -3948,13 +3948,23 @@ have a history of their own.") (transient--fit-window-to-buffer transient--window))))) (defun transient--display-action () - (cond ((oref transient--prefix display-action)) - ((memq 'display-buffer-full-frame - (ensure-list (car transient-display-buffer-action))) - (user-error "%s disallowed in %s" - 'display-buffer-full-frame - 'transient-display-buffer-action)) - (transient-display-buffer-action))) + (let ((action + (cond ((oref transient--prefix display-action)) + ((memq 'display-buffer-full-frame + (ensure-list (car transient-display-buffer-action))) + (user-error "%s disallowed in %s" + 'display-buffer-full-frame + 'transient-display-buffer-action)) + (transient-display-buffer-action)))) + (when (assq 'pop-up-frame-parameters (cdr action)) + (setq action (copy-tree action)) + (pcase-let ((`(,height ,width) + (buffer-line-statistics transient--buffer)) + (params (assq 'pop-up-frame-parameters (cdr action)))) + (setf (alist-get 'height params) height) + (setf (alist-get 'width params) + (max width (or transient-minimal-frame-width 0))))) + action)) (defun transient--fit-window-to-buffer (window) (set-window-parameter window 'window-preserved-size nil)