summary refs log tree commit diff stats
path: root/emacs
diff options
context:
space:
mode:
authorAlan Pearce2017-09-06 19:26:28 +0200
committerAlan Pearce2017-09-06 19:26:28 +0200
commit13519aff231476ae073a74313ba037df1b05ce80 (patch)
tree941c919866917f028a748664bf5c43f4f8fb8651 /emacs
parent11209f698ab6bc154de5abf8fd14bf2f9ad28610 (diff)
downloadnixfiles-13519aff231476ae073a74313ba037df1b05ce80.tar.lz
nixfiles-13519aff231476ae073a74313ba037df1b05ce80.tar.zst
nixfiles-13519aff231476ae073a74313ba037df1b05ce80.zip
Emacs: Extract first-frame-hook
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/main.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/emacs/.emacs.d/main.el b/emacs/.emacs.d/main.el
index 2f7bf539..2e8a393a 100644
--- a/emacs/.emacs.d/main.el
+++ b/emacs/.emacs.d/main.el
@@ -224,9 +224,9 @@
       (ap/set-fonts "PT Mono" 14 "Noto Sans" 14 nil))
      ((and (eq window-system 'x)
            (eq system-type 'gnu/linux/windows))
-      (ap/set-fonts "Noto Mono" 12 "Sans" 12 nil))))
+      (ap/set-fonts "Noto Mono" 12 "Sans" 12 nil)))))
 
-  (ap/set-fonts-according-to-system))
+(add-hook 'first-frame-hook #'ap/set-fonts-according-to-system)
 ;; #+END_SRC
 
 ;; Reduce font decoration.  I’m trying to see whether this helps me focus
@@ -1566,16 +1566,20 @@ With prefix TO-CURRENT-BUFFER, insert command output into buffer."
       (add-to-list 'load-suffixes ".el.gpg")
       (load-gpg (expand-file-name (system-name) user-emacs-directory)))))
 
-(defun first-frame-hook (frame)
+(defvar first-frame-hook nil
+  "Hook for running code after first-frame is opened.")
+
+(defun first-frame-hook-handler (frame)
   "Hook run only after first frame is created."
-  (remove-hook 'after-make-frame-functions #'first-frame-hook)
-  (run-at-time nil nil #'load-private-data)
-  (run-at-time nil nil #'ap/set-fonts-according-to-system))
+  (remove-hook 'after-make-frame-functions #'first-frame-hook-handler)
+  (run-at-time nil nil (lambda () (run-hooks 'first-frame-hook))))
 
 (if (or (daemonp)
         (not (eq 1 (length (frame-list)))))
-    (add-hook 'after-make-frame-functions #'first-frame-hook)
-  (add-hook 'after-init-hook #'load-private-data))
+    (add-hook 'after-make-frame-functions #'first-frame-hook-handler)
+  (run-at-time nil nil (lambda () (run-hooks 'first-frame-hook))))
+
+(add-hook 'first-frame-hook #'load-private-data)
 ;; #+END_SRC
 
 ;; ** Minibuffer