-
Notifications
You must be signed in to change notification settings - Fork 0
/
early-init.el
164 lines (147 loc) · 6.29 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
;;; early-init.el -*- lexical-binding: t; -*-
(defvar my/saved-file-name-handler-alist file-name-handler-alist)
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.6
file-name-handler-alist nil
load-prefer-newer noninteractive
garbage-collection-messages nil)
(add-hook 'emacs-startup-hook ; hook run after loading init files
#'(lambda ()
(setq gc-cons-threshold (* 16 1024 1024)
gc-cons-percentage 0.1
file-name-handler-alist my/saved-file-name-handler-alist)))
;; src: skangas
(when (>= emacs-major-version 27)
(defun gc-on-last-frame-out-of-focus ()
"GC if all frames are inactive."
(if (seq-every-p #'null (mapcar #'frame-focus-state (frame-list)))
(garbage-collect)))
(add-function :after after-focus-change-function
#'gc-on-last-frame-out-of-focus))
(setq-default default-frame-alist
'((menu-bar-lines . 0)
(tool-bar-lines . 0)
(vertical-scroll-bars)
(fullscreen . maximized))
fringe-indicator-alist
(assq-delete-all 'truncation fringe-indicator-alist)
cursor-in-non-selected-windows nil
bidi-display-reordering 'left-to-right
bidi-inhibit-bpa t
bidi-paragraph-direction 'left-to-right)
;; Android
(defconst is-android (eq system-type 'android))
(defconst is-mac (eq system-type 'darwin))
(when is-android
(let ((termuxpath "/data/data/com.termux/files/usr/"))
(setenv "PATH" (concat (getenv "PATH") ":" termuxpath "bin"))
(push (concat termuxpath "bin") exec-path))
(set-face-attribute 'default nil :height 170)
(unless (file-directory-p "~/fonts")
(copy-directory "~/.emacs.d/fonts/" "~/fonts")))
(if is-mac
(push '(font . "VictorMono Nerd Font Mono-16:weight=semi-bold") default-frame-alist)
(push '(font . "VictorMono Nerd Font Mono-13:weight=semi-bold") default-frame-alist))
(if is-android
(set-face-attribute
'variable-pitch nil :family "iA Writer Duo S" :weight 'regular :height 170)
(set-face-attribute
'variable-pitch nil :family "iA Writer Duospace" :weight 'regular :height (if is-mac
170
130)))
;; doom
(setq-default inhibit-redisplay t
inhibit-message t)
;(advice-add #'tool-bar-setup :override #'ignore)
(add-hook 'after-init-hook
(lambda nil
(setq-default inhibit-redisplay nil
inhibit-message nil)
(redraw-frame))
; (advice-remove #'tool-bar-setup #'ignore))
:depth -105)
;;
(fset 'display-startup-echo-area-message 'ignore)
(setf (cdr (assq 'continuation fringe-indicator-alist))
'(nil nil))
(when t
(defvar package-quickstart)
(setq package-quickstart t))
(setq package-enable-at-startup nil
inhibit-startup-screen t
redisplay-skip-fontification-on-input t
window-combination-resize t
frame-inhibit-implied-resize t
frame-resize-pixelwise t
initial-major-mode 'fundamental-mode
initial-scratch-message nil)
(defun ar/show-welcome-buffer () ;; xendoium (centering issues...)
"Show *Welcome* buffer."
(with-current-buffer (get-buffer-create "*Welcome*")
(setq truncate-lines t)
(let* ((buffer-read-only)
(image-path (fancy-splash-image-file))
(image (create-image image-path))
(size (image-size image))
(height (cdr size))
(width (and image (car size)))
(top-margin (floor (/ (- (window-height) height) 2)))
(left-margin (floor (/ (- (max (window-width) 195) width) 2)))
(prompt-title (format "%d packages loaded in %s"
(length package-activated-list)
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time))))))
(erase-buffer)
(setq mode-line-format nil)
(goto-char (point-min))
(insert (make-string top-margin ?\n ))
(insert (make-string left-margin ?\ ))
(insert-image image)
(insert "\n\n\n")
(insert (make-string (floor (/ (- (max (window-width) 195)
(string-width prompt-title))
2))
?\ ))
(insert prompt-title))
(setq-local cursor-type nil)
(read-only-mode +1)
(switch-to-buffer (current-buffer))
(local-set-key (kbd "q") 'kill-current-buffer)
(local-set-key (kbd "RET") 'kill-current-buffer)))
(add-hook 'window-setup-hook
(lambda ()
(if (file-exists-p (locate-user-emacs-file ".emacs.desktop"))
(message (format "%d packages loaded in %s"
(length package-activated-list)
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))))
(when (display-graphic-p)
(ar/show-welcome-buffer)))))
(when is-mac
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(let ((home (getenv "HOME")))
(setenv "PATH" (concat (getenv "PATH")
":" home "/.nix-profile/bin:/usr/bin"))
(setq exec-path (append `(,(concat home "/.nix-profile/bin")
"/nix/var/nix/profiles/default/bin")
exec-path))))
(if is-mac
(setq mac-option-modifier 'meta)
(setq command-line-ns-option-alist nil))
(unless (eq system-type 'gnu/linux)
(setq command-line-x-option-alist nil))
;; native-comp
(if (and (featurep 'native-compile)
(fboundp 'native-comp-available-p)
(native-comp-available-p))
;; Activate `native-compile'
(setq native-comp-jit-compilation t
native-comp-enable-subr-trampolines t
native-comp-async-report-warnings-errors nil
package-native-compile t)
;; Deactivate the `native-compile' feature if it is not available
(setq features (delq 'native-compile features)))
(provide 'early-init)
;;; early-init.el ends here