From 12868aaaef4a0a6bd5cd5dad4f462da7e1cac32a Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Sat, 14 Feb 2026 18:27:32 -0500 Subject: [PATCH] tweak: add more robust popup rules --- config.org | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/config.org b/config.org index 871339e..ea3dd9a 100644 --- a/config.org +++ b/config.org @@ -866,11 +866,27 @@ Doom also includes its own default popup rules. Most of these are inoffensive, b "Remove the popup rule with the predicate PREDICATE and replace it with this one. See `set-popup-rule!' for the arguments this function should take." + (declare (indent defun)) (setq +popup--display-buffer-alist (assoc-delete-all predicate +popup--display-buffer-alist)) (apply #'set-popup-rule! predicate args)) #+end_src +Sometimes I want to set the size of a popup window, but allow the window to shrink if it is too big for its contents. The sizing function Doom provides for this purpose, ~+popup-shrink-to-fit~, does not allow the user to specify an initial size, it only does the shrinking. + +#+begin_src emacs-lisp +(defun ~/popup--shrink-to-fit (height &optional window) + (let* ((new-height + (if (integerp height) height + (round (* (window-total-height (frame-root-window window)) + height))))) + (fit-window-to-buffer window new-height) + (+popup-shrink-to-fit window))) + +(defun ~/popup-shrink-to-fit (height) + (apply-partially #'~/popup--shrink-to-fit height)) +#+end_src + * Doom Modules One of Doom Emacs's most useful features is its modular configuration system, allowing configuration code to be sectioned into modules that can be enabled or customized individually. Doom provides a full suite of prewritten modules to enable. @@ -2777,7 +2793,8 @@ I use the standard Unix-style password management system, [[https://www.password ;; Move to right side (after! pass - (replace-popup-rule! "^\\*Password-Store" :side 'right :size 0.25 :quit nil)) + (replace-popup-rule! "^\\*Password-Store" + :side 'right :size 0.25 :quit nil)) #+end_src *** Tweaks @@ -2818,7 +2835,7 @@ When visiting a password file, the file's buffer replaces the pass buffer, which ;; The popup rule indirectly triggered by above (set-popup-rule! '(derived-mode . pass-view-mode) - :side 'bottom :size 8 :quit t :modeline t) + :side 'bottom :size 8 :quit t :ttl t :modeline t) #+end_src Asking for confirmation on ~pass-quit~ is ridiculous, seeing as it doesn't actually do anything sensitive or permanent. The other instances of confirmation are comparatively much more important, so I won't touch those. @@ -4406,7 +4423,8 @@ Doom by default sets Eglot's help window (used for documentation and the like) w #+begin_src emacs-lisp (after! eglot - (replace-popup-rule! "^\\*eglot-help" :size 0.4 :quit t :select t)) + (replace-popup-rule! "^\\*eglot-help" + :size (~/popup-shrink-to-fit 0.4) :quit t :select nil)) #+end_src *** Server Booster