-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
core-display-init.el
46 lines (42 loc) · 1.84 KB
/
core-display-init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
;;; core-display-init.el --- Spacemacs Core File
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defvar spacemacs--after-display-system-init-list '()
"List of functions to be run after the display system is initialized.")
(defadvice server-create-window-system-frame
(after spacemacs-init-display activate)
"After Emacs server creates a frame, run functions queued in
`SPACEMACS--AFTER-DISPLAY-SYSTEM-INIT-LIST' to do any setup that needs to have
the display system initialized."
(progn
(dolist (fn (reverse spacemacs--after-display-system-init-list))
(funcall fn))
(ad-disable-advice 'server-create-window-system-frame
'after
'spacemacs-init-display)
(ad-activate 'server-create-window-system-frame)))
(defmacro spacemacs|do-after-display-system-init (&rest body)
"If the display-system is initialized, run `BODY', otherwise,
add it to a queue of actions to perform after the first graphical frame is
created."
`(let ((init (cond ((boundp 'ns-initialized) ns-initialized)
;; w32-initialized gets set too early, so
;; if we're on Windows, check the list of fonts
;; instead (this is nil until the graphics system
;; is initialized)
((boundp 'w32-initialized) (font-family-list))
((boundp 'x-initialized) x-initialized)
;; fallback to normal loading behavior only if in a GUI
(t (display-graphic-p)))))
(if init
(progn
,@body)
(push (lambda () ,@body) spacemacs--after-display-system-init-list))))
(provide 'core-display-init)