-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathearly-init.el
132 lines (101 loc) · 4.41 KB
/
early-init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
;;; early-init.el -*- lexical-binding: t; -*-
;;; SYSTEM
;; Store current OS
(defvar aj8/my-os
(cond
((string-match "Microsoft" (shell-command-to-string "cat /proc/version")) 'wsl)
((eq system-type 'darwin) 'macos)
((eq system-type 'gnu/linux) 'linux)
(t 'unknown)))
;; Store current Linux OS
(defvar aj8/my-linux-os
(cond
((string-match "fedora" (shell-command-to-string "cat /etc/os-release")) 'fedora)
((string-match "ubuntu" (shell-command-to-string "cat /etc/os-release")) 'ubuntu)
(t 'unknown)))
;; Store current terminal emulator
(defvar aj8/my-terminal-emulator
(cond
((getenv "KONSOLE_DBUS_SESSION") 'konsole)
((getenv "GNOME_TERMINAL_SCREEN") 'gnome-terminal)
((getenv "WT_PROFILE_ID") 'windows-terminal)
((getenv "TERM_PROGRAM")
(cond
((string-equal (getenv "TERM_PROGRAM") "Apple_Terminal") 'apple-terminal)
((string-equal (getenv "TERM_PROGRAM") "iTerm.app") 'iterm2)))
(t 'unknown)))
;;; STARTUP
;; Reduce garbage collection during startup
;; (and reset default values after)
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.5)
(add-hook 'after-init-hook (lambda () (setq gc-cons-threshold 800000
gc-cons-percentage 0.1)))
;;; GUI
;; Remove unneeded UI elements
;; (push '(tool-bar-lines . 0) default-frame-alist) ; disable tool bar
;; (push '(menu-bar-lines . 0) default-frame-alist) ; disable menu bar
;; (push '(vertical-scroll-bars . nil) default-frame-alist) ; disable scroll bar
;; Disable menu bar
(menu-bar-mode -1)
;; Disable toolbar (graphical Emacs)
(tool-bar-mode -1)
;; Disable scroll bar
;; (with-eval-after-load "scroll-bar" ; avoid error on some systems
(scroll-bar-mode -1)
;; Disable welcome buffer
;; (setq inhibit-startup-screen t)
;; Display *Messages* buffer at startup
;; (setq initial-buffer-choice (lambda () (get-buffer "*Messages*")))
;; Loads a nice blue theme, avoids the white screen flash on startup
;; (load-theme 'deeper-blue t)
;; Set initial major mode to fundamental-mode
;; (makes the initial buffer load faster)
;; (customize-set-variable 'initial-major-mode 'fundamental-mode)
;;; PACKAGES
;; Add path to local files
;; (add-to-list 'load-path "~/local/share/emacs/site-lisp/")
(add-to-list 'load-path "~/.emacs.d/lisp/")
;; Prevent stale elisp bytecode from shadowing more up-to-date source files
(setq load-prefer-newer t)
;; Initialize package sources
(require 'package)
;; Add package-archives
;; Emacs 28.x has GNU `and' non-GNU ELPA as default
(add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Set package-archives priorities
(customize-set-variable 'package-archive-priorities
'(("melpa" . 4) ; prefer Melpa packages
("stable" . 3) ; otherwise, prefer "releases" from Melpa
("nongnu" . 2) ; otherwise, prefer non-GNU packages
("gnu" . 1))) ; lastly, use GNU
;; Refresh packages database (in background)
;; (unless package-archive-contents
;; (package-refresh-contents t))
;; Refresh packages database (on first install)
(defun my/package-install-refresh-contents (&rest args)
"Refresh package database on first install."
(package-refresh-contents)
(advice-remove 'package-install #'my/package-install-refresh-contents))
(advice-add 'package-install :before #'my/package-install-refresh-contents)
;; Native compilation
(when (featurep 'native-compile)
;; Silence compiler warnings
;; (setq native-comp-async-report-warnings-errors nil)
;; Set directory to store native compilation cache
(when (fboundp 'startup-redirect-eln-cache)
(if (version< emacs-version "29")
(add-to-list 'native-comp-eln-load-path
(convert-standard-filename
(expand-file-name "var/eln-cache/" user-emacs-directory)))
(startup-redirect-eln-cache
(convert-standard-filename
(expand-file-name "var/eln-cache/" user-emacs-directory)))))
(add-to-list 'native-comp-eln-load-path
(expand-file-name "eln-cache/" user-emacs-directory)))
;;; CUSTOMIZATION
;; Use custom-file.el for custom-* code
(setq custom-file (expand-file-name "custom-file.el" user-emacs-directory))
(if (file-exists-p custom-file)
(load-file custom-file))