dotfiles/dot_config/emacs/early-init.el.new

91 lines
3 KiB
Text

;;; early-init.el --- GNU Emacs Early Initialization File -*- lexical-binding: t; -*-
;; Copyright (c) 2023 Andrew Scott
;; Author: Andrew Scott <andy at andyscott dot me>
;; Keywords: convenience, tools
;; URL: https://codeberg.org/andyscott/dotfiles
;; This file is not part of GNU Emacs.
;;; Commentary:
;; My customizations for early Emacs initialization
;;; License:
;; MIT No Attribution
;; Permission is hereby granted, free of charge, to any person obtaining a copy of this
;; software and associated documentation files (the "Software"), to deal in the Software
;; without restriction, including without limitation the rights to use, copy, modify,
;; merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
;; permit persons to whom the Software is furnished to do so.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
;; INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
;; PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
;;; Code:
;; Disable package.el
(setq package-enable-at-startup nil)
;; Ensure other default libs are loaded
(setq inhibit-default-init nil)
;; Load newest byte code
(setq load-prefer-newer t)
;; Enable async native compilation and suppress warnings
(when (featurep 'native-compile)
(setq native-comp-deferred-compilation t
native-comp-async-report-warnings-errors nil))
;; Raise garbage collection threshold
(setq gc-cons-threshold 100000000
gc-cons-percentage 0.1)
;; Don't advertise instructions for frame exit
(setq server-client-instructions nil)
;; Don't implicitly resize the frame
(setq frame-inhibit-implied-resize t)
;; Disable startup screen
(setq inhibit-startup-screen t)
;; Visible bell only
(setq visible-bell t)
;; Fonts
(push '(font . "Hack-24") default-frame-alist)
(set-face-font 'default "Hack-24")
(set-face-font 'fixed-pitch "Hack-24")
(set-face-font 'variable-pitch "DejaVu Sans-24")
;; Disable some GUI options
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
;; Relocate emacs-user-directory to XDG_DATA_HOME
(setq user-emacs-directory
(expand-file-name "emacs/" (or (getenv "XDG_DATA_HOME") "~/.local/share/")))
;; Set cache directory
(setq xdg-cache-home (expand-file-name "emacs/" (or (getenv "XDG_CACHE_HOME") "~/.cache/")))
(unless (file-directory-p xdg-cache-home)
(make-directory xdg-cache-home))
;; Move eln-cache to XDG_CACHE_HOME
(when (fboundp 'startup-redirect-eln-cache)
(if (< emacs-major-version 29)
(push (expand-file-name "eln-cache/" xdg-cache-home) native-comp-eln-load-path)
(startup-redirect-eln-cache (expand-file-name "eln-cache/" xdg-cache-home))))
(provide 'early-init)
;;; early-init.el ends here