From 13519aff231476ae073a74313ba037df1b05ce80 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 6 Sep 2017 19:26:28 +0200 Subject: Emacs: Extract first-frame-hook --- emacs/.emacs.d/main.el | 20 ++++++++++++-------- 1 file 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 -- cgit 1.4.1