2023-08-10 00:59:36 -04:00
|
|
|
;;; 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:
|
|
|
|
|
2024-08-20 17:33:23 -04:00
|
|
|
;; Disable `package.el'
|
|
|
|
(setq package-enable-at-startup nil)
|
|
|
|
|
|
|
|
;; Ensure other defaults are loaded
|
|
|
|
(setq inhibit-default-init nil)
|
|
|
|
|
|
|
|
;; Avoid `garbage-collect' during init
|
|
|
|
(setq gc-cons-percentage 1
|
|
|
|
gc-cons-threshold most-positive-fixnum)
|
|
|
|
|
|
|
|
;; Skip regexp checking by `find-file-name-handler' during init
|
|
|
|
(defvar default-file-name-handler-alist file-name-handler-alist)
|
|
|
|
(setq file-name-handler-alist nil)
|
|
|
|
|
|
|
|
;; Restore `garbage-collect' and `file-name-handler-alist' settings
|
2024-08-26 16:40:15 -04:00
|
|
|
(add-hook 'elpaca-after-init-hook
|
2024-09-05 11:39:59 -04:00
|
|
|
(lambda ()
|
|
|
|
(setq file-name-handler-alist default-file-name-handler-alist
|
|
|
|
gc-cons-percentage 0.1
|
|
|
|
gc-cons-threshold (* 1024 1024 8))))
|
2024-08-20 17:33:23 -04:00
|
|
|
|
|
|
|
;; Relocate `emacs-user-directory' to XDG_DATA_HOME
|
2023-11-26 23:54:45 -05:00
|
|
|
(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))
|
|
|
|
|
2024-10-06 00:51:46 -04:00
|
|
|
;; Move eln-cache to XDG_CACHE_HOME
|
2023-11-26 23:54:45 -05:00
|
|
|
(when (fboundp 'startup-redirect-eln-cache)
|
2024-05-18 13:02:27 -04:00
|
|
|
(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))))
|
2023-11-26 23:54:45 -05:00
|
|
|
|
2023-08-10 00:59:36 -04:00
|
|
|
;; Load newest byte code
|
|
|
|
(setq load-prefer-newer t)
|
|
|
|
|
|
|
|
;; Enable async native compilation and suppress warnings
|
|
|
|
(when (featurep 'native-compile)
|
2024-10-06 00:51:46 -04:00
|
|
|
(setq native-comp-jit-compilation t
|
2023-08-10 00:59:36 -04:00
|
|
|
native-comp-async-report-warnings-errors nil))
|
|
|
|
|
|
|
|
;; Don't advertise instructions for frame exit
|
|
|
|
(setq server-client-instructions nil)
|
|
|
|
|
|
|
|
;; Don't implicitly resize the frame
|
|
|
|
(setq frame-inhibit-implied-resize t)
|
|
|
|
|
2024-08-20 17:33:23 -04:00
|
|
|
;; Allow frames to increase/decrease by one pixel
|
|
|
|
(setq frame-resize-pixelwise t)
|
|
|
|
|
2023-08-10 00:59:36 -04:00
|
|
|
;; Disable startup screen
|
|
|
|
(setq inhibit-startup-screen t)
|
|
|
|
|
2024-09-05 11:39:59 -04:00
|
|
|
;; Start in `fundamental-mode' to prevent loading of non-essential packages
|
2024-08-20 17:33:23 -04:00
|
|
|
(setq initial-major-mode 'fundamental-mode)
|
|
|
|
|
2024-09-05 11:39:59 -04:00
|
|
|
;; Visible bell in mode-line only
|
|
|
|
(setq ring-bell-function
|
|
|
|
(lambda ()
|
|
|
|
(let ((orig_fg (face-foreground 'mode-line)))
|
|
|
|
(set-face-foreground 'mode-line "#F2804F")
|
|
|
|
(run-with-idle-timer 0.1 nil
|
|
|
|
(lambda (fg) (set-face-foreground 'mode-line fg))
|
|
|
|
orig_fg))))
|
2023-08-10 00:59:36 -04:00
|
|
|
|
|
|
|
;; Fonts
|
2024-11-28 12:41:56 -05:00
|
|
|
;; (set-face-font 'default "Hack-14")
|
|
|
|
;; (set-face-font 'fixed-pitch "Hack-14")
|
|
|
|
;; (set-face-font 'variable-pitch "DejaVu Sans-14")
|
|
|
|
|
|
|
|
;; Some UI options
|
|
|
|
(let ((options '((font . "Hack-14")
|
|
|
|
(undecorated . t)
|
2024-09-05 11:39:59 -04:00
|
|
|
(menu-bar-lines . 0)
|
|
|
|
(tool-bar-lines . 0)
|
|
|
|
(vertical-scroll-bars)
|
|
|
|
(background-color . "#282828")
|
|
|
|
(foreground-color . "#c6c6c6"))))
|
|
|
|
(dolist (option options)
|
|
|
|
(push option default-frame-alist)))
|
2023-08-10 00:59:36 -04:00
|
|
|
|
2024-05-18 13:02:27 -04:00
|
|
|
;; Make lsp-mode use plists
|
|
|
|
(setenv "LSP_USE_PLISTS" "true")
|
|
|
|
|
2023-08-10 00:59:36 -04:00
|
|
|
(provide 'early-init)
|
|
|
|
;;; early-init.el ends here
|