dotfiles.nix/home/programs/emacs/early-init.el

74 lines
2.1 KiB
EmacsLisp

;;; early-init.el -- willemm's Emacs configuration (early-init).
;;
;;; Commentary:
;;
;; The early-init part of my Emacs configuration.
;; Originally generated by home-manager.
;;
;;; Code:
(defun hm/reduce-gc ()
"Reduce the frequency of garbage collection."
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.6))
(defun hm/restore-gc ()
"Restore the frequency of garbage collection."
(setq gc-cons-threshold 16777216
gc-cons-percentage 0.1))
;; Make GC more rare during init, while minibuffer is active, and
;; when shutting down. In the latter two cases we try doing the
;; reduction early in the hook.
(hm/reduce-gc)
(add-hook 'minibuffer-setup-hook #'hm/reduce-gc -50)
(add-hook 'kill-emacs-hook #'hm/reduce-gc -50)
;; But make it more regular after startup and after closing minibuffer.
(add-hook 'emacs-startup-hook #'hm/restore-gc)
(add-hook 'minibuffer-exit-hook #'hm/restore-gc)
;; Avoid unnecessary regexp matching while loading .el files.
(defvar hm/file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(defun hm/restore-file-name-handler-alist ()
"Restore the `file-name-handler-alist` variable."
(setq file-name-handler-alist hm/file-name-handler-alist)
(makunbound 'hm/file-name-handler-alist))
(add-hook 'emacs-startup-hook #'hm/restore-file-name-handler-alist)
;; Avoid expensive frame resizing. Inspired by Doom Emacs.
(setq frame-inhibit-implied-resize t)
;; Disable Toolbar
(tool-bar-mode -1)
;; Disable scrollbar
(scroll-bar-mode -1)
;; Disable menubar
(menu-bar-mode -1)
(setq debug-on-error t)
;; Use UTF-8
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;; Minimize native-comp warnings
(defvar native-comp-async-report-warnings-errors nil)
(defvar warning-minimum-level 'error)
;; Disable startup message.
(setq inhibit-startup-screen t
inhibit-startup-echo-area-message (user-login-name))
;; Empty initial scratch buffer.
(setq initial-major-mode 'emacs-lisp-mode
initial-scratch-message nil)
(provide 'early-init)
;;; early-init.el ends here