From c53f63b96edfae1b064c44c225b12872891a62e1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 28 Aug 2024 17:46:45 -0400 Subject: [PATCH] fix: trigger doom-first-{file,buffer}-hook at startup Should fix issues where modes/hooks weren't triggered for files/directories opened early (e.g. from the command-line or programmatically from the user's config). --- lisp/doom-start.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lisp/doom-start.el b/lisp/doom-start.el index c38a7ebfb..35a4f2e9e 100644 --- a/lisp/doom-start.el +++ b/lisp/doom-start.el @@ -322,6 +322,15 @@ If RETURN-P, return the message as a string instead of displaying it." (doom-run-hook-on 'doom-first-buffer-hook '(find-file-hook doom-switch-buffer-hook)) (doom-run-hook-on 'doom-first-file-hook '(find-file-hook dired-initial-position-hook)) (doom-run-hook-on 'doom-first-input-hook '(pre-command-hook)) + +;; If the user's already opened something (e.g. with command-line arguments), +;; then we should assume nothing about the user's intentions and simply treat +;; this session as fully initialized. +(add-hook! 'doom-after-init-hook :depth 100 + (defun doom-run-first-hooks-if-files-open-h () + (when file-name-history + (doom-run-hooks 'doom-first-file-hook 'doom-first-buffer-hook)))) + ;; PERF: Activate these later, otherwise they'll fire for every buffer created ;; between now and the end of startup. (add-hook! 'after-init-hook