From ba26ce39fe699db3f83c70d14df3ad9c7c5816d9 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 21 Jul 2019 19:34:53 +0200 Subject: [PATCH] tools/magit: lazily compile emacsql Prevents the emacsql binary from being built just because you tried literally anything remotely to do with magit. --- modules/tools/magit/config.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index e2e36bac3..45f38b1d5 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -68,7 +68,23 @@ It is passed a user and repository name.") ;; All forge list modes are derived from `forge-topic-list-mode' (map! :map forge-topic-list-mode-map :n "q" #'kill-current-buffer) (set-popup-rule! "^\\*?[0-9]+:\\(?:new-\\|[0-9]+$\\)" :size 0.45 :modeline t :ttl 0 :quit nil) - (set-popup-rule! "^\\*\\(?:[^/]+/[^ ]+ #[0-9]+\\*$\\|Issues\\|Pull-Requests\\|forge\\)" :ignore t)) + (set-popup-rule! "^\\*\\(?:[^/]+/[^ ]+ #[0-9]+\\*$\\|Issues\\|Pull-Requests\\|forge\\)" :ignore t) + + (def-advice! +magit--forge-get-repository-lazily-a (&rest _) + "Make `forge-get-repository' return nil if the binary isn't built yet. +This prevents emacsql getting compiled, which appears to come out of the blue +and blocks Emacs for a short while." + :before-while #'forge-get-repository + (file-executable-p emacsql-sqlite-executable)) + + (def-advice! +magit--forge-build-binary-lazily-a (&rest _) + "Make `forge-dispatch' only build emacsql if necessary. +Annoyingly, the binary gets built as soon as Forge is loaded. Since we've +disabled that in `+magit--forge-get-repository-lazily-a', we must manually +ensure it is built when we actually use Forge." + :before #'forge-dispatch + (unless (file-executable-p emacsql-sqlite-executable) + (emacsql-sqlite-compile 2)))) (def-package! magit-todos