From c05d1ba2c8e28f2f55f9e11bcf8e42b1ed43e539 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 6 Apr 2021 17:59:45 -0500 Subject: 7 --- early-init.el | 75 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 41 deletions(-) (limited to 'early-init.el') diff --git a/early-init.el b/early-init.el index fac0705..b8f652e 100644 --- a/early-init.el +++ b/early-init.el @@ -24,37 +24,21 @@ load-path) (require 'acdw) -;;; Refresh Emacs easily -(defun refresh-emacs () - "Reload Emacs's configuration files." - (interactive) - (dolist (file (list (locate-user-emacs-file "early-init.el") - (locate-user-emacs-file "init.el" ".emacs"))) - (when (file-exists-p file) - (load-file file)))) - + ;;; Speed up init ;; see doom-emacs, et al. -(defvar orig-file-name-handler-alist file-name-handler-alist - "The original value of `file-name-handler-alist' will be restored - after init.") - -(setq file-name-handler-alist nil) -(setq gc-cons-threshold (* 800 1024 1024) - gc-cons-percentage 0.6) - -(add-hook 'after-init-hook - (defun hook--post-init-reset () - "Reset `gc-cons-threshold', `gc-cons-percentage', and - `file-name-handler-alist' to their defaults after init." - (acdw/gc-enable) - (dolist (handler file-name-handler-alist) - (add-to-list 'orig-file-name-handler-alist handler)) - (setq file-name-handler-alist orig-file-name-handler-alist))) +(setq orig-file-name-handler-alist file-name-handler-alist + file-name-handler-alist nil) +(acdw/gc-disable) +(hook-defun post-init-reset after-init-hook + (acdw/gc-enable) + (dolist (handler file-name-handler-alist) + (add-to-list 'orig-file-name-handler-alist handler)) + (setq file-name-handler-alist orig-file-name-handler-alist)) + ;;; Frame settings - (setq default-frame-alist ; Remove most UI `((tool-bar-lines . 0) ; No tool bar (menu-bar-lines . 0) ; No menu bar @@ -73,8 +57,7 @@ frame-resize-pixelwise t ; Resize by pixels, not chars ) -(defun hook--disable-ui-modes () - "Disable frame UI using modes, for toggling later." +(hook-defun disable-ui-modes after-init-hook (dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR) '((tool-bar-mode . tool-bar-lines) (menu-bar-mode . menu-bar-lines) @@ -86,8 +69,25 @@ (= 0 setting)) (funcall (car mode) -1))))) -(add-hook 'after-init-hook #'hook--disable-ui-modes) - +(add-function :after after-focus-change-function + (defun hook--setup-fonts () + (dolist (face '(default fixed-pitch)) + ;; `default' and `fixed-pitch' should be the same. + (set-face-attribute face nil + :font (pcase acdw/system + (:home "DejaVu Sans Mono-10") + (:work "Consolas-10") + (:other "monospace-10")))) + ;; `variable-pitch' is, of course, different. + (set-face-attribute 'variable-pitch nil + :font (pcase acdw/system + (:home "DejaVu Sans") + (:work "Calibri-11") + (:other "sans-serif"))) + (remove-function after-focus-change-function + 'hook--setup-fonts))) + + ;;; Bootstrap package manager (`straight.el') ;; 1. Update `exec-path'. @@ -108,7 +108,7 @@ package-quickstart nil straight-host-usernames '((github . "duckwork") (gitlab . "acdw")) - straight-base-dir acdw/dir) + straight-base-dir (acdw/dir)) ;; 3. Bootstrap `straight'. (defvar bootstrap-version) @@ -126,9 +126,10 @@ (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) - + ;;; Message startup time for profiling - +;; This just redefines the Emacs function +;; `display-startup-echo-area-message', so no hooks needed. (defun display-startup-echo-area-message () "Show Emacs's startup time in the message buffer. For profiling." (message "Emacs ready in %s with %d garbage collections." @@ -136,11 +137,3 @@ (float-time (time-subtract after-init-time before-init-time))) gcs-done)) - -;;; Install `no-littering', pointing both directories at `acdw/dir'. This will -;;; take care of the packages I don't care about configuring. - -(straight-use-package 'no-littering) -(setq no-littering-etc-directory acdw/dir - no-littering-var-directory acdw/dir) -(require 'no-littering) -- cgit 1.4.1-21-gabe81