summaryrefslogtreecommitdiff
path: root/.config/emacs/early-init.el
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-09-08 12:06:50 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-09-08 12:07:32 +0200
commit98cbdb2271e93cf7b45bf5a89106f4353ca9bdfc (patch)
tree339b83b31351e515cedcd834c29b0ba8d5e2d049 /.config/emacs/early-init.el
parenta793342e47d2e282fe3ae4f554f7c6cefadfcffe (diff)
emacs: Add the new configuration
Diffstat (limited to '.config/emacs/early-init.el')
-rw-r--r--.config/emacs/early-init.el64
1 files changed, 64 insertions, 0 deletions
diff --git a/.config/emacs/early-init.el b/.config/emacs/early-init.el
new file mode 100644
index 0000000..b74ba18
--- /dev/null
+++ b/.config/emacs/early-init.el
@@ -0,0 +1,64 @@
+;; -*- lexical-binding: t; -*-
+
+(defconst 1-KiB 1024
+ "The number of bytes in 1 kibibyte")
+
+(defconst 1-MiB (* 1-KiB 1024)
+ "The number of bytes in 1 mebibyte.")
+
+(defconst 1-GiB (* 1-MiB 1024)
+ "The number of bytes in 1 gibibyte.")
+
+(defconst x-cache-directory
+ (expand-file-name
+ "emacs"
+ (or (getenv "XDG_CACHE_HOME")
+ (expand-file-name ".cache" (getenv "HOME"))))
+ "The XDG-conformant cache directory that Emacs should use.")
+
+(defconst x-config-directory
+ (expand-file-name
+ "emacs"
+ (or (getenv "XDG_CONFIG_HOME")
+ (expand-file-name ".config" (getenv "HOME"))))
+ "The XDG-conformant config directory that Emacs should use.")
+
+(defconst x-data-directory
+ (expand-file-name
+ "emacs"
+ (or (getenv "XDG_DATA_HOME")
+ (expand-file-name ".local/share" (getenv "HOME"))))
+ "The XDG-conformant data directory that Emacs should use.")
+
+;; Create standard Emacs directories
+(dolist (dir (list x-cache-directory
+ x-config-directory
+ x-data-directory))
+ (make-directory dir 'parents))
+
+(setq user-emacs-directory x-cache-directory
+ auto-save-list-file-prefix (expand-file-name
+ "auto-save-list/"
+ x-cache-directory)
+ backup-directory-alist `(("." . ,(expand-file-name
+ "backups"
+ x-cache-directory))))
+
+(when (featurep 'native-compile)
+ (startup-redirect-eln-cache
+ (expand-file-name (expand-file-name "eln/" x-cache-directory))))
+
+;; Don’t call the garbage collector during initialization
+(setq gc-cons-threshold most-positive-fixnum)
+(add-hook 'after-init-hook
+ (lambda () (setq gc-cons-threshold (* 512 1-MiB))))
+
+(setq read-process-output-max
+ (let ((pipe-size-file "/proc/sys/fs/pipe-max-size"))
+ (if (file-exists-p pipe-size-file)
+ (with-temp-buffer
+ (insert-file-contents pipe-size-file)
+ (number-at-point))
+ 1-MiB)))
+
+(setq package-enable-at-startup nil)