From 66e2ed1a6d850d25f9b943959ddc05b53343a196 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 18 Nov 2024 09:40:41 +0800 Subject: [PATCH] fix: transient frame size is incorrect See https://github.com/yanghaoxie/transient-posframe/pull/7. --- lisp/init-vcs.el | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lisp/init-vcs.el b/lisp/init-vcs.el index 3f75b2942..84dedfec4 100644 --- a/lisp/init-vcs.el +++ b/lisp/init-vcs.el @@ -62,6 +62,7 @@ (when (childframe-completion-workable-p) (use-package transient-posframe :diminish + :after posframe transient :defines posframe-border-width :custom-face (transient-posframe ((t (:inherit tooltip)))) @@ -69,8 +70,8 @@ :hook (after-init . transient-posframe-mode) :init (setq transient-posframe-border-width posframe-border-width - transient-posframe-min-height nil transient-posframe-min-width 80 + transient-posframe-min-height nil transient-posframe-poshandler 'posframe-poshandler-frame-center transient-posframe-parameters '((left-fringe . 8) (right-fringe . 8))) @@ -82,12 +83,12 @@ (when (posframe-workable-p) (let* ((posframe (posframe-show buffer - :height (with-current-buffer buffer (1- (count-screen-lines (point-min) (point-max)))) :font transient-posframe-font :position (point) :poshandler transient-posframe-poshandler :background-color (face-attribute 'transient-posframe :background nil t) :foreground-color (face-attribute 'transient-posframe :foreground nil t) + :initialize #'transient-posframe--initialize :min-width transient-posframe-min-width :min-height transient-posframe-min-height :internal-border-width transient-posframe-border-width @@ -96,6 +97,20 @@ (frame-selected-window posframe)))) (advice-add #'transient-posframe--show-buffer :override #'my-transient-posframe--show-buffer) + (setq transient-mode-line-format nil) ; without line + + (defun transient-posframe--initialize () + "Initialize transient posframe." + (setq window-resize-pixelwise t) + (setq window-size-fixed nil)) + + (defun transient-posframe--resize (window) + "Resize transient posframe." + (fit-frame-to-buffer-1 (window-frame window) + nil transient-posframe-min-height + nil transient-posframe-min-width)) + (advice-add 'transient--fit-window-to-buffer :override #'transient-posframe--resize) + (defun my-transient-posframe--hide () "Hide transient posframe." (posframe-hide transient--buffer-name))