emacs: improve init-related messages
[~bandali/configs] / .emacs.d / init.el
index bfc9d28..6068a1c 100644 (file)
 
 (defvar b/before-user-init-time (current-time)
   "Value of `current-time' when Emacs begins loading `user-init-file'.")
-(message "Loading Emacs...done (%.3fs)"
-         (float-time (time-subtract b/before-user-init-time
-                                    before-init-time)))
+(defvar b/emacs-initialized nil
+  "Whether Emacs has been initialized.")
+
+(when (not (bound-and-true-p b/emacs-initialized))
+  (message "Loading Emacs...done (%.3fs)"
+           (float-time (time-subtract b/before-user-init-time
+                                      before-init-time))))
 
 ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage'
 ;; during startup to reduce garbage collection frequency.  clearing
 
 ;; set them back to their defaults once we're done initializing
 (defun b/post-init ()
-  (setq gc-cons-threshold b/gc-cons-threshold
-        gc-cons-percentage b/gc-cons-percentage
+  "My post-initialize function, run after loading `user-init-file'."
+  (setq b/emacs-initialized     t
+        gc-cons-threshold       b/gc-cons-threshold
+        gc-cons-percentage      b/gc-cons-percentage
         file-name-handler-alist b/file-name-handler-alist))
 (add-hook 'after-init-hook #'b/post-init)
 
                (expand-file-name "~/.emacs.d/straight/build/")))
 
 (defun b/reload-init ()
-  "Reload init.el."
+  "Reload `user-init-file'."
   (interactive)
-  (setq b/file-name-handler-alist file-name-handler-alist)
+  (setq b/before-user-init-time   (current-time)
+        b/file-name-handler-alist file-name-handler-alist)
   (load user-init-file nil 'nomessage)
   (b/post-init))