diff --git a/modules/feature/popup/+hacks.el b/modules/feature/popup/+hacks.el index a34324e15..74bebc3d4 100644 --- a/modules/feature/popup/+hacks.el +++ b/modules/feature/popup/+hacks.el @@ -82,9 +82,11 @@ ;; `org' (after! org - (set! :popup "^ ?\\*Org \\(todo\\|Links\\)" '((slot . -1) (size . shrink-window-if-larger-than-buffer))) + (set! :popup "^\\*Org \\(?:Links\\|Export Dispatcher\\|Select\\)" + '((slot . -1) (size . +popup-shrink-to-fit)) + '((select))) (set! :popup "^\\*Org Agenda" '((slot . -1) (size . 20))) - (set! :popup "^\\*Org Src" '((size . 0.3)) '((quit) (select . t))) + (set! :popup "^\\*Org Src" '((size . 0.3)) '((quit) (select . t))) ;; Org has a scorched-earth window management system I'm not fond of. i.e. it ;; kills all windows and monopolizes the frame. No thanks. We can do better diff --git a/modules/feature/popup/autoload.el b/modules/feature/popup/autoload.el index 2aece169c..b68dc94fd 100644 --- a/modules/feature/popup/autoload.el +++ b/modules/feature/popup/autoload.el @@ -144,6 +144,16 @@ with ARGS to get its return value." "Returns a list of all popup windows." (cl-remove-if-not #'+popup-p (window-list))) +;;;###autoload +(defun +popup-shrink-to-fit (&optional window) + "Shrinks WINDOW to fit the buffer contents, if the buffer isn't empty. + +Uses `shrink-window-if-larger-than-buffer'." + (unless window + (setq window (selected-window))) + (unless (= (- (point-max) (point-min)) 0) + (shrink-window-if-larger-than-buffer window))) + ;; ;; Minor mode diff --git a/modules/feature/popup/config.el b/modules/feature/popup/config.el index a270e01bb..34c157f0d 100644 --- a/modules/feature/popup/config.el +++ b/modules/feature/popup/config.el @@ -137,7 +137,7 @@ ALIST supports one custom parameter: `size', which will resolve to ;; (eval-when-compile - (set! :popup "^ \\*" '((slot . -1))) + (set! :popup "^ \\*" '((slot . -1) (size . +popup-shrink-to-fit))) (set! :popup "^\\*" nil '((select . t))) (set! :popup "^\\*Completions" '((slot . -1)) '((transient . 0))) (set! :popup "^\\*Compilation" nil '((transient . 0) (quit . t)))