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
229
230
231
232
233
234
235
236
|
#+TITLE: General settings
#+AUTHOR: MichaĆ Sapka (https://michal.sapka.me)
#+DATE: 2024-02-08
#+STARTUP: showall indent logdone
#+HUGO_SECTION: emacs/config
#+EXPORT_FILE_NAME: configuration
#+HUGO_BASE_DIR: ~/ghq/vcs.sapka.me/michal-sapka-me/
#+HUGO_WEIGHT: 10
#+HUGO_CATEGORIES: emacs emacs-config
#+HUGO_MENU: :menu "emacs-config" :name "Genral settings"
#+HUGO_CUSTOM_FRONT_MATTER: :abstract "My emacs config - general config"
#+HUGO_CUSTOM_FRONT_MATTER: :menu-abstract "Just some basic stuff"
This file sets generic things around my Emacs config.
All other files rely on this.
* Lexical binding
#+BEGIN_SRC emacs-lisp
;;; -*- lexical-binding: t -*-
#+END_SRC
* Basic configuration
I want to use UTF-8 everywhere
#+BEGIN_SRC emacs-lisp
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-language-environment "UTF-8")
(setq require-final-newline t)
#+END_SRC
Emacs has this terrible habbit of wanting to write "yes" or "no" to confirm different things.
This changes it to simple "y" and "n"
#+begin_src emacs-lisp
(setopt use-short-answers t)
#+end_src
I will save a lot files in my temporary filder.
#+begin_src emacs-lisp
(defvar mms-tmp-dir "~/tmp")
(make-directory mms-tmp-dir t)
#+end_src
I don't want to pollute each and every one of my folders, so I'm keeping all backup files in one place.
On each of my systems I have a =~/tmp= folder just for custom temporary file.
#+begin_src emacs-lisp
(setq backup-directory-alist `((".*" . ,mms-tmp-dir)))
(setq auto-save-file-name-transforms `((".*" ,mms-tmp-dir t)))
#+end_src
Tramp can get /even slower/ with file locks, so I disable those
Or at least this is what I've been told.
#+begin_src emacs-lisp
(setq remote-file-name-inhibit-locks t)
#+end_src
Tabs, what are they good for?
Absolutelly nothing!
Let's use spaces everywhere
#+begin_src emacs-lisp
(setq-default indent-tabs-mode nil)
#+end_src
Stop Emacs from using =audible bell=
#+begin_src emacs-lisp
(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))))
#+end_src
* Package management
Recently, I have migrated to Elpaca.
A lot of emacsers tend to use Straight, but Elpaca seems more modern with asynchronous loading of packages.
This, of course, is a can of worms.
#+BEGIN_SRC emacs-lisp
(defvar elpaca-installer-version 0.7)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil :depth 1
:files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca--activate-package)))
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (< emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (apply #'call-process `("git" nil ,buffer t "clone"
,@(when-let ((depth (plist-get order :depth)))
(list (format "--depth=%d" depth) "--no-single-branch"))
,(plist-get order :repo) ,repo))))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(load "./elpaca-autoloads")))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
#+end_src
#+begin_src emacs-lisp
(elpaca elpaca-use-package
;; Enable :elpaca use-package keyword.
(elpaca-use-package-mode)
;; Assume :elpaca t unless otherwise specified.
(setq elpaca-use-package-by-default t))
#+end_src
We need to wait here for elpaca to actually load.
We will see this pattern again.
#+begin_src emacs-lisp
(elpaca-wait)
#+end_src
* Auto-complete in minibuffer
Having autocomplete in emacs is one of most important things.
I've used =ido= before, but now I'm trying =vertico=.
I don't want a big plugin here, like helm.
I left the optional params here from the tutorial in case I want to get /fancy/.
#+begin_src emacs-lisp
(use-package vertico
:init
(vertico-mode)
;; Different scroll margin
;; (setq vertico-scroll-margin 0)
;; Show more candidates
;; (setq vertico-count 20)
;; Grow and shrink the Vertico minibuffer
;; (setq vertico-resize t)
)
#+end_src
Marginalia adds extra information to the list
#+begin_src emacs-lisp
(use-package marginalia
:init
(marginalia-mode))
#+end_src
* Variables
I use two machines on different OSes (personal on FreeBSD and work on MacOS).
On a few occasions, I will use device to use correct behavior.
#+begin_src emacs-lisp
(setq mms-is-voyager (string= (system-name) "voyager"))
(setq mms-is-mac (string= (system-name) "RN90Y7RDHT"))
#+end_src
* Line numbering
Most of the time, I want my line numbers.
I use Evil after all.
But sometimes they are not needed.
#+begin_src emacs-lisp
(defun mms-hide-line-numbers()
(interactive)
(display-line-numbers-mode 0))
#+end_src
* Allow for diminished mode
Emacs is based od modes which may pollute the modeline.
Dimish will hide them from the modeline, even if they are enabled.
#+begin_src emacs-lisp
(use-package diminish
:ensure t)
#+end_src
* Transistent
#+begin_src emacs-lisp
(use-package transient
:ensure t)
#+end_src
* Secrets
#+begin_src emacs-lisp
(setq auth-sources '((:source "~/.authinfo.gpg")))
#+end_src
#+RESULTS:
| :source | ~/.authinfo.gpg |
* Tests
#+begin_src emacs-lisp
;; (use-package ready-player
;; :
;; ensure t)
#+end_src
|