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
|
#+TITLE: Miran Bastaja's Emacs Configuration
#+PROPERTY: header-args :tangle init.el
#+TOC: headlines 2
* Preface
** Inspiration
The current structure of this config was pretty much entirely copied from
[[https://rossabaker.com/configs/emacs/][Ross A. Baker's configuration]]. Many other resources such as stack overflow,
and other peoples configs were used. Here's some of the more notable ones:
- [[https://sanemacs.com/][sanemacs]]
- [https://idiomdrottning.org/bad-emacs-defaults]
** TODO Licensing
* Startup
** Early Init
From preliterate items.
#+begin_src emacs-lisp :tangle early-init.el
;; All our packages come from Nix
(setq package-enable-at-startup nil
package-archives nil)
(provide 'early-init)
;;; early-init.el ends here
#+end_src
** Packages
*** Ensuring packages
Most of this config is broken down into [[https://github.com/jwiegley/use-package][~use-package~]] stanzas. All
dependencies are managed by [[https://nixos.org/][Nix]]. Any package with a true ~:ensure~
keyword is found by [[https://github.com/nix-community/emacs-overlay#extra-library-functionality][~emacsWithPackagesFromUsePackage~]] to generate
the set of Emacs packages to install with Nix.
In the brutish non-Nix world, ~:ensure~ triggers Emacs' own package
manager with willy nilly downloads. To prevent this, we tell
~use-package~ to assume the package is there and merely look for its
autoloads.
#+begin_src emacs-lisp
(defun ross/use-package-ensure-already-installed
(name _ensure state &optional _context)
"Value for `use-package-ensure-function` that assumes the package
is already installed. This is true in our Nix environment."
(let ((autoloads-file-name (format "%s-autoloads" name)))
(with-demoted-errors "Error loading autoloads: %s"
(load autoloads-file-name t t))))
(setq use-package-ensure-function #'ross/use-package-ensure-already-installed)
#+end_src
*** Hook naming
~use-package~ also by default appends ~"-hook"~ to all its hooks.
This impairs ripgreppability. Let's be explicit:
#+begin_src emacs-lisp
(setq use-package-hook-name-suffix nil)
#+end_src
*** Load it
~use-package~ doesn't use itself. (Well, I think it could, but this
is the recommended approach...)
#+begin_src emacs-lisp
(eval-when-compile
(require 'use-package))
#+end_src
** Helpers
*** General
[[https://github.com/noctuid/general.el][General]] is known for keybindings, particularly among [[https://github.com/emacs-evil/evil][the evil]]. A
lesser known feature is [[https://github.com/noctuid/general.el#settings][~general-setq~]], which understands the ~:set~
hooks of custom variables. [[https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21695][#21695]] raged on for a half decade without
a consensus, and I find this solution as tidy as any,
#+begin_src emacs-lisp
(use-package general :ensure)
#+end_src
* Personalization
#+begin_src emacs-lisp
(general-setq user-full-name "Miran Bastaja"
user-mail-address "miran.bastaja04@gmail.com")
#+end_src
* Display
** Scrolling
Emacs' default scrolling behavior feels a bit janky in the 2020s.
- ~scroll-conservatively~ has a magic number of ~100~. Greater than
this scrolls just enough to get the point back on screen without
recentering.
- ~scroll-margin~ specifies how many lines of context to keep above
and below the point.
#+begin_src emacs-lisp
(use-package emacs
:custom
(frame-inhibit-implied-resize t)
(scroll-conservatively 101)
(scroll-margin 2)
(scroll-preserve-screen-position t))
#+end_src
* Customization
** Theme
I use [[https://github.com/doomemacs/themes][Doom emacs' theme pack]] to source my themes.
#+begin_src emacs-lisp
(use-package doom-themes
:ensure t
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-one t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
#+end_src
* Languages
** Emacs Lisp
I use local variables in this config to keep the code from indenting
two spaces. Without this, we get prompted the first time we read
this file:
#+begin_src emacs-lisp
(dolist (pair '((org-src-preserve-indentation . t) (org-src-tab-acts-natively . t)))
(add-to-list 'safe-local-variable-values pair))
#+end_src
** Org
#+begin_src emacs-lisp
#+end_src
|