Rewrite early-init.el
This commit is contained in:
parent
e423eeca3e
commit
8df085bb42
|
@ -24,23 +24,24 @@
|
||||||
load-path)
|
load-path)
|
||||||
(require 'acdw)
|
(require 'acdw)
|
||||||
|
|
||||||
|
|
||||||
;;; Speed up init
|
;;; Speed up init
|
||||||
;; see doom-emacs, et al.
|
;; see doom-emacs, et al.
|
||||||
|
|
||||||
(setq load-prefer-newer noninteractive
|
(setq acdw/orig-file-name-handler-alist file-name-handler-alist
|
||||||
orig-file-name-handler-alist file-name-handler-alist
|
|
||||||
file-name-handler-alist nil
|
file-name-handler-alist nil
|
||||||
inhibit-x-resources t)
|
gc-cons-percentage 0.8
|
||||||
(acdw/gc-disable)
|
gc-cons-threshold most-positive-fixnum
|
||||||
|
load-prefer-newer noninteractive)
|
||||||
|
|
||||||
(add-hook 'after-init-hook
|
(add-hook 'after-init-hook
|
||||||
(defun after-init@reset ()
|
(defun after-init@reset ()
|
||||||
(acdw/gc-enable)
|
"Reset `file-name-handler-alist' and garbage collection."
|
||||||
|
(setq gc-cons-percentage 0.1
|
||||||
|
gc-cons-threshold (* 800 1024 1024))
|
||||||
(dolist (handler file-name-handler-alist)
|
(dolist (handler file-name-handler-alist)
|
||||||
(add-to-list 'orig-file-name-handler-alist handler))
|
(add-to-list 'acdw/orig-file-name-handler-alist handler))
|
||||||
(setq file-name-handler-alist orig-file-name-handler-alist)))
|
(setq file-name-handler-alist acdw/orig-file-name-handler-alist)))
|
||||||
|
|
||||||
;;; Frame settings
|
;;; Frame settings
|
||||||
(setq default-frame-alist ; Remove most UI
|
(setq default-frame-alist ; Remove most UI
|
||||||
`((tool-bar-lines . 0) ; No tool bar
|
`((tool-bar-lines . 0) ; No tool bar
|
||||||
|
@ -63,53 +64,65 @@
|
||||||
|
|
||||||
(add-hook 'after-init-hook
|
(add-hook 'after-init-hook
|
||||||
(defun after-init@disable-ui-modes ()
|
(defun after-init@disable-ui-modes ()
|
||||||
|
"Disable UI modes after init.
|
||||||
|
I already disable them from the `default-frame-alist' for speed
|
||||||
|
and anti-flickering reasons, but this function allows running,
|
||||||
|
say, `tool-bar-mode' once to toggle the tool bar back on."
|
||||||
(dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR)
|
(dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR)
|
||||||
'((tool-bar-mode . tool-bar-lines)
|
'((tool-bar-mode . tool-bar-lines)
|
||||||
(menu-bar-mode . menu-bar-lines)
|
(menu-bar-mode . menu-bar-lines)
|
||||||
(scroll-bar-mode . vertical-scroll-bars)
|
(scroll-bar-mode . vertical-scroll-bars)
|
||||||
(horizontal-scroll-bar-mode . horizontal-scroll-bars)
|
(horizontal-scroll-bar-mode . horizontal-scroll-bars)))
|
||||||
))
|
|
||||||
(let ((setting (alist-get (cdr mode) default-frame-alist)))
|
(let ((setting (alist-get (cdr mode) default-frame-alist)))
|
||||||
(when (or (not setting)
|
(when (or (not setting)
|
||||||
(= 0 setting))
|
(zerop setting))
|
||||||
(funcall (car mode) -1))))))
|
(funcall (car mode) -1))))))
|
||||||
|
|
||||||
(add-hook 'after-make-frame-functions
|
(add-hook 'after-make-frame-functions
|
||||||
(defun acdw/frame-setup (&rest args)
|
(defun after-make-frame@setup (&rest args)
|
||||||
(ignore args)
|
(ignore args)
|
||||||
;; fonts
|
(let ((monospace-faces '((:font "DejaVu Sans Mono" :height 100)
|
||||||
(require 'acdw-fonts)
|
(:font "Consolas" :height 100)
|
||||||
(setq acdw-fonts/monospace (acdw/system
|
(:font "monospace" :height 100))))
|
||||||
(:home "DejaVu Sans Mono")
|
(acdw/set-first-face-attribute 'default monospace-faces)
|
||||||
(:work "Consolas")
|
(acdw/set-first-face-attribute 'fixed-pitch monospace-faces)
|
||||||
(_ "monospace"))
|
(acdw/set-first-face-attribute 'variable-pitch
|
||||||
acdw-fonts/monospace-size (acdw/system
|
'((:font "Inter" :height 12)
|
||||||
(:work 12)
|
(:font "sans-serif"
|
||||||
(_ 10))
|
:height 10))))
|
||||||
acdw-fonts/variable (acdw/system
|
(acdw/set-emoji-fonts "Segoe UI Emoji"
|
||||||
(:home "Inter")
|
"Noto Color Emoji"
|
||||||
(:work "Inter")
|
"Apple Color Emoji"
|
||||||
(_ "sans-serif"))
|
"Symbola")
|
||||||
acdw-fonts/variable-size (acdw/system
|
(acdw/set-fringes '((left-curly-arrow [#b01100000
|
||||||
(:work 14)
|
#b00110000
|
||||||
(_ 12)))
|
#b00011000
|
||||||
(acdw-fonts/set)
|
#b00001100]
|
||||||
(acdw-fonts/setup-emoji-fonts "Segoe UI Emoji"
|
4 8 center)
|
||||||
"Noto Color Emoji"
|
(right-curly-arrow [#b00000011
|
||||||
"Apple Color Emoji"
|
#b00000110
|
||||||
"Symbola")
|
#b00001100
|
||||||
;; fringes
|
#b00011000]
|
||||||
(acdw/setup-fringes)))
|
4 8 center)
|
||||||
|
(left-arrow [#b01100000
|
||||||
|
#b01010000]
|
||||||
|
2 8 (top t))
|
||||||
|
(right-arrow [#b00000011
|
||||||
|
#b00000101]
|
||||||
|
2 8 (top t))))
|
||||||
|
(setq indicate-empty-lines nil
|
||||||
|
indicate-buffer-boundaries '((top . right)
|
||||||
|
(bottom . right)))
|
||||||
|
(custom-set-faces '(fringe ((t (:foreground "dim gray")))))))
|
||||||
|
|
||||||
;; I have this here because ... the first frame doesn't ? run ? the hook ???
|
;; I have this here because ... the first frame doesn't ? run ? the hook ???
|
||||||
(add-function :after after-focus-change-function
|
(add-function :after after-focus-change-function
|
||||||
(defun acdw/first-frame-setup (&rest args)
|
(defun after-focus-change@first-frame-setup (&rest args)
|
||||||
(ignore args)
|
(ignore args)
|
||||||
(acdw/frame-setup)
|
(after-make-frame@setup)
|
||||||
(remove-function after-focus-change-function
|
(remove-function after-focus-change-function
|
||||||
#'acdw/first-frame-setup)))
|
#'after-focus-change@first-frame-setup)))
|
||||||
|
|
||||||
|
|
||||||
;;; Bootstrap package manager (`straight.el')
|
;;; Bootstrap package manager (`straight.el')
|
||||||
|
|
||||||
;; 1. Update `exec-path'.
|
;; 1. Update `exec-path'.
|
||||||
|
@ -161,7 +174,6 @@
|
||||||
;; By the way, the alias is `straight-package-neutering-mode'.
|
;; By the way, the alias is `straight-package-neutering-mode'.
|
||||||
(defalias 'straight-ಠ_ಠ-mode nil)
|
(defalias 'straight-ಠ_ಠ-mode nil)
|
||||||
|
|
||||||
|
|
||||||
;;; Message startup time for profiling
|
;;; Message startup time for profiling
|
||||||
;; This just redefines the Emacs function
|
;; This just redefines the Emacs function
|
||||||
;; `display-startup-echo-area-message', so no hooks needed.
|
;; `display-startup-echo-area-message', so no hooks needed.
|
||||||
|
@ -172,3 +184,5 @@
|
||||||
(float-time (time-subtract after-init-time
|
(float-time (time-subtract after-init-time
|
||||||
before-init-time)))
|
before-init-time)))
|
||||||
gcs-done))
|
gcs-done))
|
||||||
|
|
||||||
|
;;; early-init.el ends here
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
;;; acdw-frame.el -*- lexical-binding: t; coding: utf-8-unix -*-
|
||||||
|
|
||||||
|
;;; Fonts
|
||||||
|
|
||||||
|
(defun acdw/set-first-face-attribute (face font-list)
|
||||||
|
"Set FACE to the first font found in FONT-LIST.
|
||||||
|
FONT-LIST is a list of `font-spec' plists to be passed to
|
||||||
|
`set-face-attribute'."
|
||||||
|
(cond
|
||||||
|
((or (null window-system)
|
||||||
|
(null font-list))
|
||||||
|
nil)
|
||||||
|
((x-list-fonts (or (plist-get (car font-list) :font)
|
||||||
|
(plist-get (car font-list) :family)))
|
||||||
|
(apply #'set-face-attribute face nil (car font-list)))
|
||||||
|
(t (acdw/set-first-face-attribute face (cdr font-list)))))
|
||||||
|
|
||||||
|
(defun acdw/set-emoji-fonts (&rest emoji-fonts)
|
||||||
|
"Add all installed EMOJI-FONTS to the symbol fontset."
|
||||||
|
(let ((ffl (font-family-list)))
|
||||||
|
(dolist (font emoji-fonts)
|
||||||
|
(when (member font ffl)
|
||||||
|
(set-fontset-font t 'symbol
|
||||||
|
(font-spec :family font) nil 'append)))))
|
||||||
|
|
||||||
|
;;; Fringes
|
||||||
|
|
||||||
|
(defun acdw/set-fringes (bitmap-list)
|
||||||
|
"Apply multiple fringes at once.
|
||||||
|
BITMAP-LIST is a list of arglists passed directly to
|
||||||
|
`define-fringe-bitmap', which see."
|
||||||
|
(dolist (bitmap bitmap-list)
|
||||||
|
(apply #'define-fringe-bitmap bitmap))
|
||||||
|
(redraw-frame))
|
||||||
|
|
||||||
|
(provide 'acdw-frame)
|
Loading…
Reference in New Issue