From e561ea58f4c2170dc86c62ae78836832c0faff7e Mon Sep 17 00:00:00 2001 From: Daniel Radetsky Date: Mon, 28 Oct 2024 16:30:51 -0700 Subject: [PATCH] feat(lib): factor out window handler into variable --- lisp/lib/config.el | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lisp/lib/config.el b/lisp/lib/config.el index 6ed2828265f..0ad26693f22 100644 --- a/lisp/lib/config.el +++ b/lisp/lib/config.el @@ -70,17 +70,23 @@ And jumps to your `doom!' block." ("DEBUG" (if doom-debug-mode (number-to-string doom-log-level) ""))) (with-current-buffer (compile (format ,command (expand-file-name doom-bin doom-bin-dir)) t) - (let ((w (get-buffer-window (current-buffer)))) - (select-window w) - (add-hook - 'compilation-finish-functions - (lambda (_buf status) - (if (equal status "finished\n") - (progn - (delete-window w) - ,on-success) - ,on-failure)) - nil 'local)))))) + (add-hook + 'compilation-finish-functions + (lambda (_buf status) + (if (equal status "finished\n") + ,on-success + ,on-failure)) + nil 'local) + (add-hook 'compilation-finish-functions ,#'doom-handle-compile-buffer-fn nil 'local))))) + +(defun doom--handle-compile-buffer-default (_buf status) + (when (equal status "finished\n") + (let ((w (get-buffer-window _buf))) + (select-window w) + (delete-window w)))) + +(defvar doom-handle-compile-buffer-fn doom--handle-compile-buffer-default + "Function run by doom to clean up the compile buffer/window") (defvar doom-reload-command (format "%s sync -B -e"