-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
228 lines (183 loc) · 7.9 KB
/
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
;;; init.el --- BB's config -*- lexical-binding: t -*-
;; Copyright (c) 2023 Bruno Boal <egomet@bboal.com>
;; Author: Bruno Boal <egomet@bboal.com>
;; URL: https://git.sr.ht/~bboal/emacs-config
;; Package-Requires: ((emacs "30.0"))
;; This file is NOT part of GNU Emacs.
;; This file is free software: you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by the
;; Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;;
;; This file is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this file. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Still a sapling dreaming of becoming a tree
;;; Code:
(defgroup personal-config ()
"User setup/configuration preferences."
:group 'emacs)
;;;;;; https://www.gnu.org/software/emacs/manual/html_node/efaq/Not-writing-files-to-the-current-directory.html
(setq create-lockfiles nil
make-backup-files nil
backup-inhibited t
auto-save-list-file-prefix (expand-file-name ".cache/auto-save-list/saves-"
user-emacs-directory)
auto-save-file-name-transforms
`(("\\`/.*/\\([^/]+\\)\\'"
,(expand-file-name "\\1"(locate-user-emacs-file ".tmp/")) t)))
;;; Welcome message
(setq-default
initial-scratch-message
(let ((emacs-version (replace-regexp-in-string "\s\(.*\)\n" "" (emacs-version))))
(format ";; %s, initialization in %s\n\n"
emacs-version (emacs-init-time "%.3fs"))))
(defun bb-maybe-check-parens ()
"If derived-mode is Lisp data, check for parenthesis correcteness."
(if (derived-mode-p 'lisp-data-mode) (check-parens)))
(setq bidi-inhibit-bpa t
scroll-conservatively 101
scroll-preserve-screen-position t
x-stretch-cursor t
ring-bell-function 'ignore
use-short-answers t
suggest-key-bindings nil
confirm-kill-processes nil
read-process-output-max (* 1024 1024)
save-interprogram-paste-before-kill t
kill-read-only-ok t
revert-without-query '(".*")
help-window-select t
help-window-keep-selected t
kill-whole-line t
mouse-yank-at-point t
custom-safe-themes t
delete-window-choose-selected 'mru
;; window-restore-killed-buffer-windows 'delete
switch-to-prev-buffer-skip 'this
enable-recursive-minibuffers t
write-file-functions '(bb-maybe-check-parens)
show-paren-delay 0
blink-matching-paren nil
delete-pair-blink-delay 0
show-paren-context-when-offscreen 'overlay
show-paren-when-point-in-periphery t
split-height-threshold 20
auto-save-no-message t
uniquify-buffer-name-style 'forward
uniquify-ignore-buffers-re "^\\*"
window-combination-resize t
;; window-combination-limit 'display-buffer
describe-bindings-outline-rules nil
read-file-name-completion-ignore-case t
read-buffer-completion-ignore-case t
frame-title-format '(multiple-frames
"%b" ("" "Emacs - %b ")))
(setq-default fill-column 80
tab-width 4
scroll-margin 3
indent-tabs-mode nil
comment-fill-column fill-column
emacs-lisp-docstring-fill-column fill-column
sentence-end-double-space nil
eval-expression-print-length nil
;; case-fold-search nil
tab-always-indent 'complete
tab-first-completion 'word-or-paren-or-punct
kill-do-not-save-duplicates t
write-contents-functions '(bb-maybe-check-parens)
cursor-in-non-selected-windows nil
bidi-paragraph-direction 'left-to-right
large-file-warning-threshold (* 30 1024 1024)
project-vc-extra-root-markers
'( ".dir-locals.el" "package.json" "Makefile" "Gemfile"
"*.gemspec" "requirements.txt" "cargo.toml"
"Dockerfile" "CMakeLists.txt" "autogen.sh" "main.*"))
;; No cursor blinking
(blink-cursor-mode -1)
;; Depth indication of recursive minibuffers
(minibuffer-depth-indicate-mode t)
;; Select text is replaced with input
(delete-selection-mode t)
;; Automatically loads the files if they change in another process
(global-auto-revert-mode t)
;; File name shadow mode
(file-name-shadow-mode t)
;; Remember last position on file
(with-eval-after-load 'saveplace
(setopt save-place-file (expand-file-name "var/places" user-emacs-directory)))
(save-place-mode t)
;;; No warnings and restrictions
(defvar restricted-functions
'(erase-buffer narrow-to-region narrow-to-page dired-find-alternate-file
upcase-region downcase-region list-timers)
"List of restricted functions by default that we want to always enable.")
(mapc (lambda (restricted)
(put restricted 'disabled nil))
restricted-functions)
;; Allow the following local variables in files
(setq safe-local-variable-values
'((eval add-to-list 'whitespace-style 'indentation::tab)
(eval delete 'indentation whitespace-style)
(display-line-numbers . visual)
(eval visual-line-mode t)
(eval visual-line-mode nil)
(eval indent-tabs-mode t)
(eval indent-tabs-mode nil)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Custom functions/libraries/modules ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Adding "bb-" dirs to load-path
(mapc (lambda (dir)
(cl-pushnew dir load-path))
(directory-files user-emacs-directory :fullpath "bb-"))
;; Initialization
(require 'package-init nil t)
(require 'project)
(with-eval-after-load 'project
(setq project-list-file (expand-file-name "var/projects" user-emacs-directory))
(setcdr project-vc-backend-markers-alist nil))
(require 'setup-langs nil t)
(require 'server)
(with-eval-after-load 'server
(setq server-client-instructions nil)
;; access from emacsclient
(add-hook 'after-init-hook
(lambda () (unless (server-running-p) (server-start)))))
;; Loads all "bb-" elisp files from "bb-" dirs
(declare-function bb-require-lisp-files-in-dir-matching "package-init.el")
(bb-require-lisp-files-in-dir-matching user-emacs-directory "bb-")
;; Try to keep important buffers alive when on cleaning spree
(defvar extra-life-buffers '("*scratch*" "*Messages*" "*notmuch-saved-search")
"List of buffers that try to survive an unintentional kill.")
(defun not-extra-life-buffer-p ()
"Return nil when `current-buffer' is in the `extra-life-buffers' list.
This function is meant to be added to `kill-buffer-query-functions' in order to
avoid killing the elements of the aforementioned list unintentionally."
(not (string-match-p (regexp-opt extra-life-buffers)
(buffer-name (current-buffer)))))
(cl-pushnew #'not-extra-life-buffer-p kill-buffer-query-functions)
;;;;;;;;;;;
;; Hooks ;;
;;;;;;;;;;;
(add-hook 'before-save-hook #'delete-trailing-whitespace)
(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
(add-hook 'org-babel-post-tangle-hook
#'executable-make-buffer-file-executable-if-script-p)
(add-hook 'emacs-lisp-mode-hook
(lambda() (setq sentence-end-double-space t) (eldoc-mode 1)))
(add-hook 'activate-mark-hook (lambda() (setq cursor-type 'bar)))
(add-hook 'deactivate-mark-hook (lambda() (setq cursor-type t)))
(defvar modes-with-autofill '( text-mode-hook message-mode-hook adoc-mode-hook
markdown-mode-hook emacs-lisp-mode-hook
lisp-interaction-mode-hook org-mode-hook)
"Modes that benefit from auto-fill mode.")
(mapc (lambda (mode) (add-hook mode #'turn-on-auto-fill)) modes-with-autofill)
(provide 'init)
;;; init.el ends here