Commit | Line | Data |
---|---|---|
33b1a7ea | 1 | ;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*- |
41d290a2 | 2 | |
4c05c418 | 3 | ;; Copyright (C) 2018-2020 Amin Bandali <bandali@gnu.org> |
41d290a2 AB |
4 | |
5 | ;; This program is free software: you can redistribute it and/or modify | |
6 | ;; it under the terms of the GNU General Public License as published by | |
7 | ;; the Free Software Foundation, either version 3 of the License, or | |
8 | ;; (at your option) any later version. | |
9 | ||
10 | ;; This program is distributed in the hope that it will be useful, | |
11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | ;; GNU General Public License for more details. | |
14 | ||
15 | ;; You should have received a copy of the GNU General Public License | |
16 | ;; along with this program. If not, see <https://www.gnu.org/licenses/>. | |
17 | ||
18 | ;;; Commentary: | |
19 | ||
33b1a7ea | 20 | ;; GNU Emacs configuration of Amin Bandali, computer scientist, |
92ad9675 | 21 | ;; Free Software activist, and GNU maintainer & webmaster. Packages |
f7910e3d | 22 | ;; are installed through using Borg for a fully reproducible setup. |
b57457b2 AB |
23 | |
24 | ;; Over the years, I've taken inspiration from configurations of many | |
25 | ;; great people. Some that I can remember off the top of my head are: | |
26 | ;; | |
27 | ;; - https://github.com/dieggsy/dotfiles | |
28 | ;; - https://github.com/dakra/dmacs | |
29 | ;; - http://pages.sachachua.com/.emacs.d/Sacha.html | |
30 | ;; - https://github.com/dakrone/eos | |
31 | ;; - http://doc.rix.si/cce/cce.html | |
32 | ;; - https://github.com/jwiegley/dot-emacs | |
33 | ;; - https://github.com/wasamasa/dotemacs | |
34 | ;; - https://github.com/hlissner/doom-emacs | |
41d290a2 | 35 | |
49e9503b AB |
36 | ;;; Code: |
37 | ||
b57457b2 AB |
38 | ;;; Emacs initialization |
39 | ||
dca50cf5 | 40 | (defvar b/before-user-init-time (current-time) |
41d290a2 | 41 | "Value of `current-time' when Emacs begins loading `user-init-file'.") |
83364e5b AB |
42 | (defvar b/emacs-initialized nil |
43 | "Whether Emacs has been initialized.") | |
8b1a2f32 AB |
44 | (defvar b/exwm-p (string= (system-name) "chaman") |
45 | "Whether or not we will be using `exwm'.") | |
83364e5b AB |
46 | |
47 | (when (not (bound-and-true-p b/emacs-initialized)) | |
48 | (message "Loading Emacs...done (%.3fs)" | |
49 | (float-time (time-subtract b/before-user-init-time | |
50 | before-init-time)))) | |
41d290a2 | 51 | |
b57457b2 AB |
52 | ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage' |
53 | ;; during startup to reduce garbage collection frequency. clearing | |
54 | ;; `file-name-handler-alist' seems to help reduce startup time too. | |
dca50cf5 AB |
55 | (defvar b/gc-cons-threshold gc-cons-threshold) |
56 | (defvar b/gc-cons-percentage gc-cons-percentage) | |
57 | (defvar b/file-name-handler-alist file-name-handler-alist) | |
bc58e70a | 58 | (setq gc-cons-threshold (* 30 1024 1024) ; 30 MiB |
41d290a2 AB |
59 | gc-cons-percentage 0.6 |
60 | file-name-handler-alist nil | |
61 | ;; sidesteps a bug when profiling with esup | |
62 | esup-child-profile-require-level 0) | |
63 | ||
b57457b2 | 64 | ;; set them back to their defaults once we're done initializing |
dca50cf5 | 65 | (defun b/post-init () |
83364e5b AB |
66 | "My post-initialize function, run after loading `user-init-file'." |
67 | (setq b/emacs-initialized t | |
68 | gc-cons-threshold b/gc-cons-threshold | |
69 | gc-cons-percentage b/gc-cons-percentage | |
e8a3b8f7 | 70 | file-name-handler-alist b/file-name-handler-alist) |
8b1a2f32 AB |
71 | (when b/exwm-p |
72 | (with-eval-after-load 'exwm-workspace | |
73 | (setq-default | |
74 | mode-line-format | |
75 | (append | |
76 | mode-line-format | |
77 | '((:eval | |
78 | (format | |
79 | "[%s]" (number-to-string | |
80 | exwm-workspace-current-index))))))))) | |
dca50cf5 | 81 | (add-hook 'after-init-hook #'b/post-init) |
41d290a2 | 82 | |
b57457b2 | 83 | ;; increase number of lines kept in *Messages* log |
41d290a2 AB |
84 | (setq message-log-max 20000) |
85 | ||
b57457b2 AB |
86 | ;; optionally, uncomment to supress some byte-compiler warnings |
87 | ;; (see C-h v byte-compile-warnings RET for more info) | |
41d290a2 AB |
88 | ;; (setq byte-compile-warnings |
89 | ;; '(not free-vars unresolved noruntime lexical make-local)) | |
90 | ||
b57457b2 AB |
91 | \f |
92 | ;;; whoami | |
93 | ||
41d290a2 | 94 | (setq user-full-name "Amin Bandali" |
33b1a7ea | 95 | user-mail-address "bandali@gnu.org") |
41d290a2 | 96 | |
b57457b2 AB |
97 | \f |
98 | ;;; comment macro | |
99 | ||
100 | ;; useful for commenting out multiple sexps at a time | |
101 | (defmacro comment (&rest _) | |
102 | "Comment out one or more s-expressions." | |
103 | (declare (indent defun)) | |
104 | nil) | |
105 | ||
106 | \f | |
33273849 AB |
107 | ;;; Package management |
108 | ||
032726b6 AB |
109 | (progn ; `borg' |
110 | (add-to-list 'load-path | |
111 | (expand-file-name "lib/borg" user-emacs-directory)) | |
112 | (require 'borg) | |
113 | (borg-initialize) | |
114 | (setq borg-rewrite-urls-alist | |
115 | '(("git@github.com:" . "https://github.com/") | |
116 | ("git@gitlab.com:" . "https://gitlab.com/")))) | |
33273849 AB |
117 | |
118 | ;; use-package | |
41d290a2 AB |
119 | (if nil ; set to t when need to debug init |
120 | (progn | |
121 | (setq use-package-verbose t | |
122 | use-package-expand-minimally nil | |
123 | use-package-compute-statistics t | |
124 | debug-on-error t) | |
125 | (require 'use-package)) | |
126 | (setq use-package-verbose nil | |
127 | use-package-expand-minimally t)) | |
128 | ||
129 | (setq use-package-always-defer t) | |
130 | (require 'bind-key) | |
131 | ||
b57457b2 AB |
132 | \f |
133 | ;;; Initial setup | |
134 | ||
135 | ;; keep ~/.emacs.d clean | |
1060413b AB |
136 | (use-package no-littering |
137 | :demand | |
138 | :config | |
139 | (defalias 'b/etc 'no-littering-expand-etc-file-name) | |
140 | (defalias 'b/var 'no-littering-expand-var-file-name)) | |
41d290a2 | 141 | |
032726b6 AB |
142 | (use-package auto-compile |
143 | :demand | |
144 | :config | |
145 | (auto-compile-on-load-mode) | |
146 | (auto-compile-on-save-mode) | |
147 | (setq auto-compile-display-buffer nil) | |
148 | (setq auto-compile-mode-line-counter t) | |
149 | (setq auto-compile-source-recreate-deletes-dest t) | |
150 | (setq auto-compile-toggle-deletes-nonlib-dest t) | |
151 | (setq auto-compile-update-autoloads t)) | |
152 | ||
b57457b2 | 153 | ;; separate custom file (don't want it mixing with init.el) |
47904cb7 | 154 | (use-package custom |
60ff805e | 155 | :no-require |
41d290a2 | 156 | :config |
dca50cf5 | 157 | (setq custom-file (b/etc "custom.el")) |
41d290a2 AB |
158 | (when (file-exists-p custom-file) |
159 | (load custom-file)) | |
b57457b2 | 160 | ;; while at it, treat themes as safe |
60ff805e AB |
161 | (setf custom-safe-themes t) |
162 | ;; only one custom theme at a time | |
163 | (comment | |
164 | (defadvice load-theme (before clear-previous-themes activate) | |
165 | "Clear existing theme settings instead of layering them" | |
166 | (mapc #'disable-theme custom-enabled-themes)))) | |
41d290a2 | 167 | |
b57457b2 | 168 | ;; load the secrets file if it exists, otherwise show a warning |
dca50cf5 AB |
169 | (comment |
170 | (with-demoted-errors | |
171 | (load (b/etc "secrets")))) | |
41d290a2 | 172 | |
b57457b2 AB |
173 | ;; start up emacs server. see |
174 | ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server | |
47904cb7 | 175 | (use-package server |
f7910e3d | 176 | :defer 0.5 |
2087ae39 AB |
177 | :config |
178 | (declare-function server-edit "server") | |
179 | (bind-key "C-c F D" 'server-edit) | |
180 | (declare-function server-running-p "server") | |
181 | (or (server-running-p) (server-mode))) | |
41d290a2 | 182 | |
60ff805e AB |
183 | \f |
184 | ;;; Useful utilities | |
185 | ||
60ff805e AB |
186 | (defmacro b/setq-every (value &rest vars) |
187 | "Set all the variables from VARS to value VALUE." | |
188 | (declare (indent defun) (debug t)) | |
189 | `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars))) | |
190 | ||
191 | (defun b/start-process (program &rest args) | |
192 | "Same as `start-process', but doesn't bother about name and buffer." | |
193 | (let ((process-name (concat program "_process")) | |
194 | (buffer-name (generate-new-buffer-name | |
195 | (concat program "_output")))) | |
196 | (apply #'start-process | |
197 | process-name buffer-name program args))) | |
198 | ||
199 | (defun b/dired-start-process (program &optional args) | |
200 | "Open current file with a PROGRAM." | |
201 | ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can | |
202 | ;; be nil, so remove it). | |
2087ae39 | 203 | (declare-function dired-get-file-for-visit "dired") |
60ff805e AB |
204 | (apply #'b/start-process |
205 | program | |
206 | (remove nil (list args (dired-get-file-for-visit))))) | |
207 | ||
208 | (defun b/add-elisp-section () | |
209 | (interactive) | |
210 | (insert "\n") | |
97141042 | 211 | (forward-line -1) |
60ff805e AB |
212 | (insert "\n\f\n;;; ")) |
213 | ||
a1e77a3d AB |
214 | ;; (defvar b/fill-column 47 |
215 | ;; "My custom `fill-column'.") | |
3214b7ca AB |
216 | |
217 | (defconst b/asterism "* * *") | |
218 | ||
bc2f85e1 | 219 | (defun b/insert-asterism () |
3214b7ca | 220 | "Insert a centred asterism." |
bc2f85e1 | 221 | (interactive) |
3214b7ca AB |
222 | (insert |
223 | (concat | |
224 | "\n\n" | |
a1e77a3d | 225 | (make-string (floor (/ (- fill-column (length b/asterism)) 2)) |
3214b7ca AB |
226 | ?\s) |
227 | b/asterism | |
228 | "\n\n"))) | |
bc2f85e1 | 229 | |
60ff805e AB |
230 | (defun b/no-mouse-autoselect-window () |
231 | "Conveniently disable `focus-follows-mouse'. | |
232 | For disabling the behaviour for certain buffers and/or modes." | |
233 | (make-local-variable 'mouse-autoselect-window) | |
234 | (setq mouse-autoselect-window nil)) | |
235 | ||
a5cc22f4 AB |
236 | (defun b/kill-current-buffer () |
237 | "Kill the current buffer." | |
238 | ;; also see https://redd.it/64xb3q | |
239 | (interactive) | |
240 | (kill-buffer (current-buffer))) | |
241 | ||
c64e010d AB |
242 | (defun b/move-indentation-or-beginning-of-line (arg) |
243 | "Move to the indentation or to the beginning of line." | |
244 | (interactive "^p") | |
245 | ;; (if (bolp) | |
246 | ;; (back-to-indentation) | |
247 | ;; (move-beginning-of-line arg)) | |
248 | (if (= (point) | |
249 | (progn (back-to-indentation) | |
250 | (point))) | |
251 | (move-beginning-of-line arg))) | |
252 | ||
e5c2d147 AB |
253 | (defun b/join-line-top () |
254 | "Like `join-line', but join next line to the current line." | |
255 | (interactive) | |
256 | (join-line 1)) | |
257 | ||
ad1f9d99 AB |
258 | (defun b/duplicate-line-or-region (&optional n) |
259 | "Duplicate the current line, or region (if active). | |
260 | Make N (default: 1) copies of the current line or region." | |
261 | (interactive "*p") | |
262 | (let ((u-r-p (use-region-p)) ; if region is active | |
263 | (n1 (or n 1))) | |
264 | (save-excursion | |
265 | (let ((text | |
266 | (if u-r-p | |
267 | (buffer-substring (region-beginning) (region-end)) | |
268 | (prog1 (thing-at-point 'line) | |
269 | (end-of-line) | |
270 | (if (eobp) | |
271 | (newline) | |
272 | (forward-line 1)))))) | |
273 | (dotimes (_ (abs n1)) | |
274 | (insert text)))) | |
275 | (let* ((beg (if u-r-p | |
276 | (region-beginning) | |
277 | (line-beginning-position))) | |
278 | (end (if u-r-p | |
279 | (region-end) | |
280 | (line-end-position))))))) | |
281 | ||
60ff805e AB |
282 | \f |
283 | ;;; Defaults | |
284 | ||
285 | ;;;; C-level customizations | |
286 | ||
287 | (setq | |
288 | ;; minibuffer | |
289 | enable-recursive-minibuffers t | |
290 | resize-mini-windows t | |
291 | ;; more useful frame titles | |
292 | frame-title-format '("" invocation-name " - " | |
293 | (:eval | |
294 | (if (buffer-file-name) | |
295 | (abbreviate-file-name (buffer-file-name)) | |
296 | "%b"))) | |
297 | ;; i don't feel like jumping out of my chair every now and again; so | |
298 | ;; don't BEEP! at me, emacs | |
299 | ring-bell-function 'ignore | |
300 | ;; better scrolling | |
301 | ;; scroll-margin 1 | |
302 | ;; scroll-conservatively 10000 | |
303 | scroll-step 1 | |
bdd3a0bb | 304 | scroll-conservatively 101 |
60ff805e AB |
305 | scroll-preserve-screen-position 1 |
306 | ;; focus follows mouse | |
39cc9c96 | 307 | mouse-autoselect-window t) |
60ff805e AB |
308 | |
309 | (setq-default | |
310 | ;; always use space for indentation | |
311 | indent-tabs-mode nil | |
312 | tab-width 4 | |
313 | ;; cursor shape | |
567440fa | 314 | cursor-type t) |
60ff805e | 315 | |
b57457b2 AB |
316 | ;; unicode support |
317 | (comment | |
318 | (dolist (ft (fontset-list)) | |
319 | (set-fontset-font | |
320 | ft | |
321 | 'unicode | |
322 | (font-spec :name "Source Code Pro" :size 14)) | |
323 | (set-fontset-font | |
324 | ft | |
325 | 'unicode | |
326 | (font-spec :name "DejaVu Sans Mono") | |
327 | nil | |
328 | 'append) | |
329 | ;; (set-fontset-font | |
330 | ;; ft | |
331 | ;; 'unicode | |
332 | ;; (font-spec | |
333 | ;; :name "Symbola monospacified for DejaVu Sans Mono") | |
334 | ;; nil | |
335 | ;; 'append) | |
336 | ;; (set-fontset-font | |
337 | ;; ft | |
338 | ;; #x2115 ; ℕ | |
339 | ;; (font-spec :name "DejaVu Sans Mono") | |
340 | ;; nil | |
341 | ;; 'append) | |
342 | (set-fontset-font | |
343 | ft | |
344 | (cons ?Α ?ω) | |
345 | (font-spec :name "DejaVu Sans Mono" :size 14) | |
346 | nil | |
347 | 'prepend))) | |
348 | ||
60ff805e | 349 | ;;;; Elisp-level customizations |
41d290a2 | 350 | |
47904cb7 | 351 | (use-package startup |
60ff805e AB |
352 | :no-require |
353 | :demand | |
41d290a2 | 354 | :config |
60ff805e AB |
355 | ;; don't need to see the startup echo area message |
356 | (advice-add #'display-startup-echo-area-message :override #'ignore) | |
357 | :custom | |
358 | ;; i want *scratch* as my startup buffer | |
359 | (initial-buffer-choice t) | |
360 | ;; i don't need the default hint | |
361 | (initial-scratch-message nil) | |
362 | ;; use customizable text-mode as major mode for *scratch* | |
2568a634 | 363 | ;; (initial-major-mode 'text-mode) |
60ff805e AB |
364 | ;; inhibit buffer list when more than 2 files are loaded |
365 | (inhibit-startup-buffer-menu t) | |
366 | ;; don't need to see the startup screen or echo area message | |
367 | (inhibit-startup-screen t) | |
368 | (inhibit-startup-echo-area-message user-login-name)) | |
41d290a2 | 369 | |
47904cb7 | 370 | (use-package files |
60ff805e AB |
371 | :no-require |
372 | :demand | |
9fc30d4c | 373 | :custom |
60ff805e AB |
374 | ;; backups (C-h v make-backup-files RET) |
375 | (backup-by-copying t) | |
376 | (version-control t) | |
377 | (delete-old-versions t) | |
41d290a2 | 378 | |
60ff805e AB |
379 | ;; auto-save |
380 | (auto-save-file-name-transforms | |
381 | `((".*" ,(b/var "auto-save/") t))) | |
41d290a2 | 382 | |
60ff805e AB |
383 | ;; insert newline at the end of files |
384 | (require-final-newline t) | |
b57457b2 | 385 | |
60ff805e AB |
386 | ;; open read-only file buffers in view-mode |
387 | ;; (enables niceties like `q' for quit) | |
388 | (view-read-only t)) | |
41d290a2 | 389 | |
60ff805e AB |
390 | ;; disable disabled commands |
391 | (setq disabled-command-function nil) | |
41d290a2 | 392 | |
60ff805e AB |
393 | ;; lazy-person-friendly yes/no prompts |
394 | (defalias 'yes-or-no-p #'y-or-n-p) | |
b57457b2 | 395 | |
60ff805e | 396 | ;; enable automatic reloading of changed buffers and files |
47904cb7 | 397 | (use-package autorevert |
60ff805e AB |
398 | :demand |
399 | :config | |
400 | (global-auto-revert-mode 1) | |
401 | :custom | |
402 | (auto-revert-verbose nil) | |
403 | (global-auto-revert-non-file-buffers nil)) | |
b57457b2 AB |
404 | |
405 | ;; time and battery in mode-line | |
47904cb7 | 406 | (use-package time |
e4902e0b | 407 | :demand |
64938292 AB |
408 | :config |
409 | (display-time-mode) | |
410 | :custom | |
411 | (display-time-default-load-average nil) | |
f7910e3d | 412 | (display-time-format " %a %b %-e %-l:%M%P") |
ad61316b AB |
413 | (display-time-mail-icon '(image :type xpm :file "gnus/gnus-pointer.xpm" :ascent center)) |
414 | (display-time-use-mail-icon t)) | |
64938292 | 415 | |
47904cb7 | 416 | (use-package battery |
e4902e0b | 417 | :demand |
64938292 AB |
418 | :config |
419 | (display-battery-mode) | |
420 | :custom | |
f7910e3d | 421 | (battery-mode-line-format "%p%% %t")) |
b57457b2 | 422 | |
47904cb7 | 423 | (use-package fringe |
60ff805e AB |
424 | :demand |
425 | :config | |
426 | ;; smaller fringe | |
427 | ;; (fringe-mode '(3 . 1)) | |
428 | (fringe-mode nil)) | |
41d290a2 | 429 | |
47904cb7 | 430 | (use-package winner |
60ff805e AB |
431 | :demand |
432 | :config | |
433 | ;; enable winner-mode (C-h f winner-mode RET) | |
434 | (winner-mode 1)) | |
41d290a2 | 435 | |
47904cb7 | 436 | (use-package compile |
60ff805e AB |
437 | :config |
438 | ;; don't display *compilation* buffer on success. based on | |
439 | ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf' | |
440 | ;; instead of the now obsolete `flet'. | |
dca50cf5 | 441 | (defun b/compilation-finish-function (buffer outstr) |
41d290a2 AB |
442 | (unless (string-match "finished" outstr) |
443 | (switch-to-buffer-other-window buffer)) | |
444 | t) | |
445 | ||
dca50cf5 | 446 | (setq compilation-finish-functions #'b/compilation-finish-function) |
41d290a2 AB |
447 | |
448 | (require 'cl-macs) | |
449 | ||
450 | (defadvice compilation-start | |
451 | (around inhibit-display | |
452 | (command &optional mode name-function highlight-regexp)) | |
453 | (if (not (string-match "^\\(find\\|grep\\)" command)) | |
454 | (cl-letf (((symbol-function 'display-buffer) #'ignore)) | |
455 | (save-window-excursion ad-do-it)) | |
456 | ad-do-it)) | |
457 | (ad-activate 'compilation-start)) | |
458 | ||
47904cb7 | 459 | (use-package isearch |
60ff805e AB |
460 | :custom |
461 | ;; allow scrolling in Isearch | |
462 | (isearch-allow-scroll t) | |
463 | ;; search for non-ASCII characters: i’d like non-ASCII characters such | |
464 | ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII | |
465 | ;; counterpart. shoutout to | |
466 | ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html | |
467 | (search-default-mode #'char-fold-to-regexp)) | |
468 | ||
469 | ;; uncomment to extend the above behaviour to query-replace | |
470 | (comment | |
47904cb7 | 471 | (use-package replace |
60ff805e AB |
472 | :custom |
473 | (replace-char-fold t))) | |
b9901074 | 474 | |
47904cb7 | 475 | (use-package vc |
b1a5d811 AB |
476 | :bind ("C-x v C-=" . vc-ediff)) |
477 | ||
47904cb7 | 478 | (use-package vc-git |
e59c8878 AB |
479 | :after vc |
480 | :custom | |
481 | (vc-git-print-log-follow t)) | |
482 | ||
47904cb7 | 483 | (use-package ediff |
b1a5d811 AB |
484 | :config (add-hook 'ediff-after-quit-hook-internal 'winner-undo) |
485 | :custom ((ediff-window-setup-function 'ediff-setup-windows-plain) | |
486 | (ediff-split-window-function 'split-window-horizontally))) | |
487 | ||
47904cb7 | 488 | (use-package face-remap |
60ff805e AB |
489 | :custom |
490 | ;; gentler font resizing | |
491 | (text-scale-mode-step 1.05)) | |
492 | ||
47904cb7 | 493 | (use-package mwheel |
60ff805e AB |
494 | :defer 0.4 |
495 | :config | |
496 | (setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time | |
497 | mouse-wheel-progressive-speed nil ; don't accelerate scrolling | |
498 | mouse-wheel-follow-mouse t)) ; scroll window under mouse | |
499 | ||
47904cb7 | 500 | (use-package pixel-scroll |
60ff805e AB |
501 | :defer 0.4 |
502 | :config (pixel-scroll-mode 1)) | |
503 | ||
47904cb7 | 504 | (use-package epg-config |
a89c8bd8 AB |
505 | :config |
506 | ;; ask for GPG passphrase in minibuffer | |
507 | ;; this will fail if gpg>=2.1 is not available | |
97141042 | 508 | (setq epg-pinentry-mode 'loopback) |
60ff805e | 509 | :custom |
47904cb7 | 510 | (epg-gpg-program (executable-find "gpg"))) |
1d405cde | 511 | |
47904cb7 AB |
512 | (use-package epg |
513 | :after epg-config) | |
514 | ||
a89c8bd8 | 515 | (use-package pinentry |
8b1a2f32 | 516 | :disabled |
a89c8bd8 AB |
517 | :demand |
518 | :after (epa epg server) | |
519 | :config | |
520 | ;; workaround for systemd-based distros: | |
521 | ;; (setq pinentry--socket-dir server-socket-dir) | |
522 | (pinentry-start)) | |
523 | ||
47904cb7 | 524 | (use-package auth-source |
b98dbb3d AB |
525 | :custom |
526 | (auth-sources '("~/.authinfo.gpg")) | |
527 | (authinfo-hidden (regexp-opt '("password" "client-secret" "token")))) | |
528 | ||
b57457b2 AB |
529 | \f |
530 | ;;; General bindings | |
531 | ||
41d290a2 | 532 | (bind-keys |
c64e010d | 533 | ("C-a" . b/move-indentation-or-beginning-of-line) |
41d290a2 | 534 | ("C-c a i" . ielm) |
ad1f9d99 | 535 | ("C-c d" . b/duplicate-line-or-region) |
41d290a2 AB |
536 | |
537 | ("C-c e b" . eval-buffer) | |
2a816b71 | 538 | ("C-c e e" . eval-last-sexp) |
12ff40a3 | 539 | ("C-c e p" . pp-macroexpand-last-sexp) |
41d290a2 AB |
540 | ("C-c e r" . eval-region) |
541 | ||
542 | ("C-c e i" . emacs-init-time) | |
543 | ("C-c e u" . emacs-uptime) | |
dca50cf5 | 544 | ("C-c e v" . emacs-version) |
41d290a2 | 545 | |
567440fa AB |
546 | ("C-c f ." . find-file) |
547 | ("C-c f d" . find-name-dired) | |
548 | ("C-c f l" . find-library) | |
549 | ||
41d290a2 AB |
550 | ("C-c F m" . make-frame-command) |
551 | ("C-c F d" . delete-frame) | |
41d290a2 | 552 | |
41d290a2 AB |
553 | ("C-S-h C" . describe-char) |
554 | ("C-S-h F" . describe-face) | |
555 | ||
e5c2d147 AB |
556 | ("C-S-j" . b/join-line-top) |
557 | ||
567440fa AB |
558 | ("C-c x" . execute-extended-command) |
559 | ||
a5cc22f4 | 560 | ("C-x k" . b/kill-current-buffer) |
41d290a2 | 561 | ("C-x K" . kill-buffer) |
2a816b71 AB |
562 | ("C-x s" . save-buffer) |
563 | ("C-x S" . save-some-buffers) | |
41d290a2 | 564 | |
b57457b2 | 565 | :map emacs-lisp-mode-map |
dca50cf5 | 566 | ("<C-return>" . b/add-elisp-section)) |
41d290a2 AB |
567 | |
568 | (when (display-graphic-p) | |
569 | (unbind-key "C-z" global-map)) | |
570 | ||
500004f4 AB |
571 | (bind-keys |
572 | ;; for back and forward mouse keys | |
0365678c | 573 | ("<XF86Back>" . previous-buffer) |
500004f4 | 574 | ("<mouse-8>" . previous-buffer) |
4bdfe6ab | 575 | ;; ("<drag-mouse-8>" . previous-buffer) |
0365678c | 576 | ("<XF86Forward>" . next-buffer) |
500004f4 | 577 | ("<mouse-9>" . next-buffer) |
4bdfe6ab AB |
578 | ;; ("<drag-mouse-9>" . next-buffer) |
579 | ;; ("<drag-mouse-2>" . kill-this-buffer) | |
580 | ;; ("<drag-mouse-3>" . switch-to-buffer) | |
581 | ) | |
500004f4 | 582 | |
b57457b2 AB |
583 | \f |
584 | ;;; Essential packages | |
585 | ||
f7910e3d AB |
586 | (add-to-list |
587 | 'load-path | |
588 | (expand-file-name | |
589 | (convert-standard-filename "lisp") user-emacs-directory)) | |
590 | ||
8b1a2f32 AB |
591 | (when b/exwm-p |
592 | (require 'bandali-exwm)) | |
33273849 | 593 | |
f7910e3d | 594 | (require 'bandali-org) |
41d290a2 | 595 | |
b57457b2 | 596 | ;; *the* right way to do git |
41d290a2 | 597 | (use-package magit |
2a816b71 AB |
598 | :bind (("C-x g" . magit-status) |
599 | ("C-c g g" . magit-status) | |
ef6c487c AB |
600 | ("C-c g b" . magit-blame-addition) |
601 | ("C-c g l" . magit-log-buffer-file)) | |
41d290a2 | 602 | :config |
2087ae39 AB |
603 | (declare-function magit-add-section-hook "magit-section" |
604 | (hook function &optional at append local)) | |
41d290a2 AB |
605 | (magit-add-section-hook 'magit-status-sections-hook |
606 | 'magit-insert-modules | |
607 | 'magit-insert-stashes | |
608 | 'append) | |
3b3615f5 AB |
609 | ;; (magit-add-section-hook 'magit-status-sections-hook |
610 | ;; 'magit-insert-ignored-files | |
611 | ;; 'magit-insert-untracked-files | |
612 | ;; 'append) | |
8a2e0eef | 613 | (setq magit-repository-directories '(("~/.emacs.d/" . 0) |
81ea6e55 | 614 | ("~/src/git/" . 2))) |
41d290a2 AB |
615 | (nconc magit-section-initial-visibility-alist |
616 | '(([unpulled status] . show) | |
617 | ([unpushed status] . show))) | |
2087ae39 | 618 | (declare-function magit-display-buffer-fullframe-status-v1 "magit-mode" (buffer)) |
3fffeb0a AB |
619 | :custom |
620 | (magit-diff-refine-hunk t) | |
621 | (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1) | |
6ca3a7b1 | 622 | ;; (magit-completing-read-function 'magit-ido-completing-read) |
41d290a2 AB |
623 | :custom-face (magit-diff-file-heading ((t (:weight normal))))) |
624 | ||
b57457b2 | 625 | ;; recently opened files |
47904cb7 | 626 | (use-package recentf |
41d290a2 | 627 | :defer 0.2 |
dca50cf5 | 628 | ;; :config |
9424b3d6 | 629 | ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:") |
6eb104ff AB |
630 | :config |
631 | (recentf-mode) | |
dca50cf5 | 632 | :custom |
1060413b | 633 | (recentf-max-saved-items 2000)) |
41d290a2 | 634 | |
679463c6 | 635 | ;; needed for history for counsel |
6eb104ff AB |
636 | (use-package amx |
637 | :defer 0.3 | |
638 | :config | |
639 | (amx-mode)) | |
640 | ||
679463c6 AB |
641 | ;; (require 'bandali-ido) |
642 | (require 'bandali-ivy) | |
41d290a2 | 643 | |
679463c6 | 644 | (require 'bandali-eshell) |
41d290a2 | 645 | |
679463c6 | 646 | (require 'bandali-ibuffer) |
41d290a2 | 647 | |
47904cb7 | 648 | (use-package outline |
2e81c51a | 649 | :disabled |
41d290a2 AB |
650 | :hook (prog-mode . outline-minor-mode) |
651 | :bind | |
652 | (:map | |
653 | outline-minor-mode-map | |
654 | ("<s-tab>" . outline-toggle-children) | |
655 | ("M-p" . outline-previous-visible-heading) | |
656 | ("M-n" . outline-next-visible-heading) | |
dca50cf5 | 657 | :prefix-map b/outline-prefix-map |
ed8c4fa9 | 658 | :prefix "s-O" |
41d290a2 AB |
659 | ("TAB" . outline-toggle-children) |
660 | ("a" . outline-hide-body) | |
661 | ("H" . outline-hide-body) | |
662 | ("S" . outline-show-all) | |
663 | ("h" . outline-hide-subtree) | |
664 | ("s" . outline-show-subtree))) | |
665 | ||
47904cb7 | 666 | (use-package ls-lisp |
41d290a2 AB |
667 | :custom (ls-lisp-dirs-first t)) |
668 | ||
679463c6 | 669 | (require 'bandali-dired) |
41d290a2 | 670 | |
47904cb7 | 671 | (use-package help |
41d290a2 AB |
672 | :config |
673 | (temp-buffer-resize-mode) | |
674 | (setq help-window-select t)) | |
675 | ||
47904cb7 | 676 | (use-package tramp |
41d290a2 AB |
677 | :config |
678 | (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:")) | |
679 | (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)) | |
680 | (add-to-list 'tramp-default-proxies-alist | |
681 | (list (regexp-quote (system-name)) nil nil))) | |
682 | ||
47904cb7 | 683 | (use-package doc-view |
41d290a2 AB |
684 | :bind (:map doc-view-mode-map |
685 | ("M-RET" . image-previous-line))) | |
686 | ||
e2178fd3 | 687 | ;; Email (with Gnus, message, and EBDB) |
2087ae39 | 688 | (require 'bandali-gnus) |
2087ae39 AB |
689 | (use-package sendmail |
690 | :config | |
691 | (setq sendmail-program (executable-find "msmtp") | |
692 | ;; message-sendmail-extra-arguments '("-v" "-d") | |
693 | mail-specify-envelope-from t | |
694 | mail-envelope-from 'header)) | |
2087ae39 | 695 | (require 'bandali-message) |
e2178fd3 | 696 | (require 'bandali-ebdb) |
2087ae39 | 697 | |
39c1c073 AB |
698 | ;; IRC (with ERC and ZNC) |
699 | (require 'bandali-erc) | |
700 | ||
2331b5a0 AB |
701 | (use-package scpaste |
702 | :config | |
703 | (setq scpaste-http-destination "https://p.bndl.org" | |
704 | scpaste-scp-destination "p:~")) | |
705 | ||
b57457b2 AB |
706 | \f |
707 | ;;; Editing | |
5750405c | 708 | |
b57457b2 | 709 | ;; highlight uncommitted changes in the left fringe |
41d290a2 | 710 | (use-package diff-hl |
df1c9bc8 | 711 | :defer 0.6 |
41d290a2 AB |
712 | :config |
713 | (setq diff-hl-draw-borders nil) | |
714 | (global-diff-hl-mode) | |
5750405c AB |
715 | :hook |
716 | ((magit-pre-refresh . diff-hl-magit-pre-refresh) | |
717 | (magit-post-refresh . diff-hl-magit-post-refresh))) | |
41d290a2 | 718 | |
b57457b2 | 719 | ;; display Lisp objects at point in the echo area |
47904cb7 | 720 | (use-package eldoc |
41d290a2 AB |
721 | :when (version< "25" emacs-version) |
722 | :config (global-eldoc-mode)) | |
723 | ||
b57457b2 | 724 | ;; highlight matching parens |
47904cb7 | 725 | (use-package paren |
41d290a2 AB |
726 | :demand |
727 | :config (show-paren-mode)) | |
728 | ||
47904cb7 | 729 | (use-package elec-pair |
40eddfea AB |
730 | :demand |
731 | :config (electric-pair-mode)) | |
732 | ||
47904cb7 | 733 | (use-package simple |
60ff805e AB |
734 | :config (column-number-mode) |
735 | :custom | |
736 | ;; Save what I copy into clipboard from other applications into Emacs' | |
737 | ;; kill-ring, which would allow me to still be able to easily access | |
738 | ;; it in case I kill (cut or copy) something else inside Emacs before | |
739 | ;; yanking (pasting) what I'd originally intended to. | |
740 | (save-interprogram-paste-before-kill t)) | |
41d290a2 | 741 | |
b57457b2 | 742 | ;; save minibuffer history |
47904cb7 | 743 | (use-package savehist |
1060413b | 744 | :demand |
dca50cf5 AB |
745 | :config |
746 | (savehist-mode) | |
1060413b | 747 | (add-to-list 'savehist-additional-variables 'kill-ring)) |
41d290a2 | 748 | |
b57457b2 | 749 | ;; automatically save place in files |
47904cb7 | 750 | (use-package saveplace |
41d290a2 | 751 | :when (version< "25" emacs-version) |
1060413b | 752 | :config (save-place-mode)) |
41d290a2 | 753 | |
47904cb7 | 754 | (use-package prog-mode |
41d290a2 AB |
755 | :config (global-prettify-symbols-mode) |
756 | (defun indicate-buffer-boundaries-left () | |
757 | (setq indicate-buffer-boundaries 'left)) | |
758 | (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left)) | |
759 | ||
47904cb7 | 760 | (use-package text-mode |
bc2f85e1 | 761 | :bind (:map text-mode-map ("C-*" . b/insert-asterism)) |
93a86536 AB |
762 | :hook ((text-mode . indicate-buffer-boundaries-left) |
763 | (text-mode . flyspell-mode))) | |
41d290a2 | 764 | |
47904cb7 | 765 | (use-package conf-mode |
300b7363 AB |
766 | :mode "\\.*rc$") |
767 | ||
5b990219 AB |
768 | (use-package sh-script |
769 | :mode ("\\.bashrc$" . sh-mode)) | |
300b7363 | 770 | |
41d290a2 | 771 | (use-package company |
ccade202 | 772 | :disabled |
41d290a2 AB |
773 | :bind |
774 | (:map company-active-map | |
775 | ([tab] . company-complete-common-or-cycle) | |
d39234b9 AB |
776 | ([escape] . company-abort) |
777 | ("C-p" . company-select-previous-or-abort) | |
778 | ("C-n" . company-select-next-or-abort)) | |
41d290a2 AB |
779 | :custom |
780 | (company-minimum-prefix-length 1) | |
781 | (company-selection-wrap-around t) | |
782 | (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]") | |
783 | (company-dabbrev-downcase nil) | |
784 | (company-dabbrev-ignore-case nil) | |
6eb104ff AB |
785 | ;; :config |
786 | ;; (global-company-mode t) | |
787 | ) | |
41d290a2 AB |
788 | |
789 | (use-package flycheck | |
fac1032c | 790 | :disabled |
41d290a2 AB |
791 | :defer 0.6 |
792 | :hook (prog-mode . flycheck-mode) | |
793 | :bind | |
794 | (:map flycheck-mode-map | |
795 | ("M-P" . flycheck-previous-error) | |
796 | ("M-N" . flycheck-next-error)) | |
797 | :config | |
798 | ;; Use the load-path from running Emacs when checking elisp files | |
799 | (setq flycheck-emacs-lisp-load-path 'inherit) | |
800 | ||
801 | ;; Only flycheck when I actually save the buffer | |
54209e74 AB |
802 | (setq flycheck-check-syntax-automatically '(mode-enabled save)) |
803 | :custom (flycheck-mode-line-prefix "flyc")) | |
804 | ||
fac1032c | 805 | ;; (use-package flyspell) |
41d290a2 AB |
806 | |
807 | ;; http://endlessparentheses.com/ispell-and-apostrophes.html | |
47904cb7 | 808 | (use-package ispell |
fac1032c | 809 | :disabled |
41d290a2 AB |
810 | :defer 0.6 |
811 | :config | |
812 | ;; ’ can be part of a word | |
813 | (setq ispell-local-dictionary-alist | |
814 | `((nil "[[:alpha:]]" "[^[:alpha:]]" | |
b1ed9ee8 AB |
815 | "['\x2019]" nil ("-B") nil utf-8)) |
816 | ispell-program-name (executable-find "hunspell")) | |
41d290a2 AB |
817 | ;; don't send ’ to the subprocess |
818 | (defun endless/replace-apostrophe (args) | |
819 | (cons (replace-regexp-in-string | |
820 | "’" "'" (car args)) | |
821 | (cdr args))) | |
822 | (advice-add #'ispell-send-string :filter-args | |
823 | #'endless/replace-apostrophe) | |
824 | ||
825 | ;; convert ' back to ’ from the subprocess | |
826 | (defun endless/replace-quote (args) | |
827 | (if (not (derived-mode-p 'org-mode)) | |
828 | args | |
829 | (cons (replace-regexp-in-string | |
830 | "'" "’" (car args)) | |
831 | (cdr args)))) | |
832 | (advice-add #'ispell-parse-output :filter-args | |
833 | #'endless/replace-quote)) | |
834 | ||
47904cb7 | 835 | (use-package abbrev |
1060413b | 836 | :hook (text-mode . abbrev-mode)) |
54209e74 | 837 | |
b57457b2 AB |
838 | \f |
839 | ;;; Programming modes | |
840 | ||
47904cb7 | 841 | (use-package lisp-mode |
41d290a2 | 842 | :config |
41d290a2 AB |
843 | (defun indent-spaces-mode () |
844 | (setq indent-tabs-mode nil)) | |
845 | (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode)) | |
846 | ||
fac1032c AB |
847 | (use-package alloy-mode |
848 | :mode "\\.\\(als\\|dsh\\)\\'" | |
849 | :config | |
850 | (setq alloy-basic-offset 2) | |
851 | ;; (defun b/alloy-simple-indent (start end) | |
852 | ;; (interactive "r") | |
853 | ;; ;; (if (region-active-p) | |
854 | ;; ;; (indent-rigidly start end alloy-basic-offset) | |
855 | ;; ;; (if (bolp) | |
856 | ;; ;; (indent-rigidly (line-beginning-position) | |
857 | ;; ;; (line-end-position) | |
858 | ;; ;; alloy-basic-offset))) | |
859 | ;; (indent-to (+ (current-column) alloy-basic-offset))) | |
860 | :bind (:map alloy-mode-map | |
861 | ("RET" . electric-newline-and-maybe-indent) | |
862 | ;; ("TAB" . b/alloy-simple-indent) | |
863 | ("TAB" . indent-for-tab-command)) | |
864 | :hook (alloy-mode . (lambda () (setq-local indent-tabs-mode nil)))) | |
865 | ||
33273849 | 866 | (use-package lean-mode |
46b0569f | 867 | :disabled |
33273849 | 868 | :defer 0.4 |
46b0569f | 869 | :init (eval-when-compile (defvar lean-mode-map)) |
33273849 AB |
870 | :bind (:map lean-mode-map |
871 | ("S-SPC" . company-complete)) | |
872 | :config | |
873 | (require 'lean-input) | |
874 | (setq default-input-method "Lean" | |
875 | lean-input-tweak-all '(lean-input-compose | |
876 | (lean-input-prepend "/") | |
877 | (lean-input-nonempty)) | |
878 | lean-input-user-translations '(("/" "/"))) | |
879 | (lean-input-setup)) | |
880 | ||
47904cb7 | 881 | (use-package sgml-mode |
41d290a2 | 882 | :config |
5dfaee4c | 883 | (setq sgml-basic-offset 0)) |
41d290a2 | 884 | |
47904cb7 | 885 | (use-package css-mode |
41d290a2 AB |
886 | :config |
887 | (setq css-indent-offset 2)) | |
888 | ||
41d290a2 | 889 | (use-package emmet-mode |
68b2cdaa | 890 | :after (:any mhtml-mode css-mode sgml-mode) |
41d290a2 AB |
891 | :bind* (("C-)" . emmet-next-edit-point) |
892 | ("C-(" . emmet-prev-edit-point)) | |
893 | :config | |
894 | (unbind-key "C-j" emmet-mode-keymap) | |
895 | (setq emmet-move-cursor-between-quotes t) | |
92ad9675 | 896 | :hook (css-mode html-mode sgml-mode)) |
41d290a2 | 897 | |
46b0569f AB |
898 | (use-package geiser |
899 | :disabled) | |
41d290a2 | 900 | |
47904cb7 | 901 | (use-package geiser-guile |
46b0569f | 902 | :disabled |
41d290a2 AB |
903 | :config |
904 | (setq geiser-guile-load-path "~/src/git/guix")) | |
905 | ||
46b0569f AB |
906 | (use-package guix |
907 | :disabled) | |
41d290a2 | 908 | |
47904cb7 AB |
909 | (use-package go-mode |
910 | :disabled) | |
99473567 | 911 | |
f704f564 | 912 | (use-package po-mode |
46b0569f | 913 | :disabled |
f704f564 AB |
914 | :hook |
915 | (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit)))) | |
916 | ||
a2feb3de AB |
917 | (use-package auctex |
918 | :disabled | |
919 | :custom | |
920 | (font-latex-fontify-sectioning 'color)) | |
921 | ||
47904cb7 | 922 | (use-package tex-mode |
748bd8ac AB |
923 | :config |
924 | (cl-delete-if | |
925 | (lambda (p) (string-match "^---?" (car p))) | |
0758ec38 AB |
926 | tex--prettify-symbols-alist) |
927 | :hook ((tex-mode . auto-fill-mode) | |
3457307b | 928 | (tex-mode . flyspell-mode))) |
748bd8ac | 929 | |
47904cb7 AB |
930 | ;; (use-package george-mode |
931 | ;; :straight (:host nil :repo "https://git.shemshak.org/amin/george-mode") | |
932 | ;; :mode "\\.grg\\'") | |
1d01c927 | 933 | |
b57457b2 AB |
934 | \f |
935 | ;;; Theme | |
936 | ||
46b0569f | 937 | (comment |
dca50cf5 AB |
938 | (add-to-list 'custom-theme-load-path |
939 | (expand-file-name | |
940 | (convert-standard-filename "lisp") user-emacs-directory)) | |
b57457b2 AB |
941 | (load-theme 'tangomod t) |
942 | ||
943 | (use-package smart-mode-line | |
944 | :commands (sml/apply-theme) | |
945 | :demand | |
946 | :config | |
8f2b3cb6 AB |
947 | ;; thanks, but no thnaks; don't make fixed-width fills. |
948 | (defun sml/fill-for-buffer-identification () "") | |
0f4b61b6 | 949 | (setq sml/theme 'tangomod) |
26906e22 AB |
950 | (sml/setup) |
951 | (smart-mode-line-enable)) | |
b57457b2 | 952 | |
cce35aca AB |
953 | (use-package doom-modeline |
954 | :disabled | |
955 | :demand | |
956 | :hook (after-init . doom-modeline-init) | |
957 | :custom | |
958 | (doom-modeline-buffer-file-name-style 'relative-to-project)) | |
959 | ||
96611976 | 960 | (use-package doom-themes) |
eb42934e | 961 | |
96611976 | 962 | (use-package moody |
d4afaf1b | 963 | :disabled |
eb42934e AB |
964 | :demand |
965 | :config | |
96611976 | 966 | (setq x-underline-at-descent-line t) |
eb42934e AB |
967 | (let ((line (face-attribute 'mode-line :underline))) |
968 | (set-face-attribute 'mode-line nil :overline line) | |
969 | (set-face-attribute 'mode-line-inactive nil :overline line) | |
970 | (set-face-attribute 'mode-line-inactive nil :underline line) | |
971 | (set-face-attribute 'mode-line nil :box nil) | |
972 | (set-face-attribute 'mode-line-inactive nil :box nil) | |
958286c5 | 973 | (set-face-attribute 'mode-line-inactive nil :background "#e1e1e1")) ; d3d7cf |
eb42934e AB |
974 | (moody-replace-mode-line-buffer-identification) |
975 | (moody-replace-vc-mode)) | |
b57457b2 | 976 | |
0b085e06 AB |
977 | (use-package mini-modeline |
978 | :disabled | |
979 | :demand | |
980 | :config (mini-modeline-mode)) | |
981 | ||
dca50cf5 | 982 | (defvar b/org-mode-font-lock-keywords |
b57457b2 AB |
983 | '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)" |
984 | (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive | |
985 | (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind | |
96611976 AB |
986 | (4 '(:foreground "#c5c8c6") t))) ; title |
987 | "For use with the `doom-tomorrow-night' theme.") | |
b57457b2 | 988 | |
dca50cf5 | 989 | (defun b/lights-on () |
b57457b2 AB |
990 | "Enable my favourite light theme." |
991 | (interactive) | |
992 | (mapc #'disable-theme custom-enabled-themes) | |
96611976 | 993 | (load-theme 'tangomod t) |
22fff83b AB |
994 | (when (featurep 'smart-mode-line) |
995 | (sml/apply-theme 'tangomod)) | |
96611976 | 996 | (font-lock-remove-keywords |
e6c67861 | 997 | 'org-mode b/org-mode-font-lock-keywords) |
d7e02391 AB |
998 | (when (featurep 'erc-hl-nicks) |
999 | (erc-hl-nicks-reset-face-table)) | |
e6c67861 AB |
1000 | (when (featurep 'exwm-systemtray) |
1001 | (exwm-systemtray--refresh))) | |
b57457b2 | 1002 | |
dca50cf5 | 1003 | (defun b/lights-off () |
b57457b2 AB |
1004 | "Go dark." |
1005 | (interactive) | |
1006 | (mapc #'disable-theme custom-enabled-themes) | |
96611976 | 1007 | (load-theme 'doom-one t) |
22fff83b AB |
1008 | (when (featurep 'smart-mode-line) |
1009 | (sml/apply-theme 'automatic)) | |
96611976 | 1010 | (font-lock-add-keywords |
e6c67861 | 1011 | 'org-mode b/org-mode-font-lock-keywords t) |
d7e02391 AB |
1012 | (when (featurep 'erc-hl-nicks) |
1013 | (erc-hl-nicks-reset-face-table)) | |
e6c67861 AB |
1014 | (when (featurep 'exwm-systemtray) |
1015 | (exwm-systemtray--refresh))) | |
b57457b2 AB |
1016 | |
1017 | (bind-keys | |
2e81c51a AB |
1018 | ("C-c t d" . b/lights-off) |
1019 | ("C-c t l" . b/lights-on)) | |
b57457b2 AB |
1020 | |
1021 | \f | |
1022 | ;;; Emacs enhancements & auxiliary packages | |
1023 | ||
dca50cf5 | 1024 | (use-package man |
41d290a2 AB |
1025 | :config (setq Man-width 80)) |
1026 | ||
1027 | (use-package which-key | |
1028 | :defer 0.4 | |
1029 | :config | |
1030 | (which-key-add-key-based-replacements | |
1031 | ;; prefixes for global prefixes and minor modes | |
1032 | "C-c @" "outline" | |
1033 | "C-c !" "flycheck" | |
b549b760 | 1034 | "C-x RET" "coding system" |
41d290a2 | 1035 | "C-x 8" "unicode" |
b549b760 | 1036 | "C-x @" "event modifiers" |
41d290a2 AB |
1037 | "C-x a" "abbrev/expand" |
1038 | "C-x r" "rectangle/register/bookmark" | |
b549b760 | 1039 | "C-x t" "tabs" |
41d290a2 | 1040 | "C-x v" "version control" |
b549b760 AB |
1041 | "C-x X" "edebug" |
1042 | "C-x C-a" "edebug" | |
1043 | "C-x C-k" "kmacro" | |
41d290a2 | 1044 | ;; prefixes for my personal bindings |
b549b760 | 1045 | "C-c &" "yasnippet" |
41d290a2 AB |
1046 | "C-c a" "applications" |
1047 | "C-c a e" "erc" | |
1048 | "C-c a o" "org" | |
1049 | "C-c a s" "shells" | |
2e81c51a | 1050 | "C-c b" "buffers" |
41d290a2 AB |
1051 | "C-c c" "compile-and-comments" |
1052 | "C-c e" "eval" | |
1053 | "C-c f" "files" | |
1054 | "C-c F" "frames" | |
ef6c487c | 1055 | "C-c g" "magit" |
41d290a2 AB |
1056 | "C-S-h" "help(ful)" |
1057 | "C-c m" "multiple-cursors" | |
47904cb7 AB |
1058 | "C-c p" "projectile" |
1059 | "C-c p s" "projectile/search" | |
1060 | "C-c p x" "projectile/execute" | |
1061 | "C-c p 4" "projectile/other-window" | |
41d290a2 | 1062 | "C-c q" "boxquote" |
2e81c51a AB |
1063 | "C-c t" "themes" |
1064 | ;; "s-O" "outline" | |
ef6c487c | 1065 | ) |
41d290a2 AB |
1066 | |
1067 | ;; prefixes for major modes | |
1068 | (which-key-add-major-mode-key-based-replacements 'message-mode | |
7cc51891 | 1069 | "C-c f n" "footnote") |
41d290a2 AB |
1070 | (which-key-add-major-mode-key-based-replacements 'org-mode |
1071 | "C-c C-v" "org-babel") | |
41d290a2 AB |
1072 | |
1073 | (which-key-mode) | |
1074 | :custom | |
1075 | (which-key-add-column-padding 5) | |
1076 | (which-key-max-description-length 32)) | |
1077 | ||
b57457b2 | 1078 | (use-package crux ; results in Waiting for git... [2 times] |
41d290a2 | 1079 | :defer 0.4 |
2a816b71 | 1080 | :bind (("C-c d" . crux-duplicate-current-line-or-region) |
ba45b932 | 1081 | ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region) |
205870c7 AB |
1082 | ("C-c f C" . crux-copy-file-preserve-attributes) |
1083 | ("C-c f D" . crux-delete-file-and-buffer) | |
1084 | ("C-c f R" . crux-rename-file-and-buffer) | |
41d290a2 AB |
1085 | ("C-c j" . crux-top-join-line) |
1086 | ("C-S-j" . crux-top-join-line))) | |
1087 | ||
41d290a2 | 1088 | (use-package projectile |
ccade202 | 1089 | :disabled |
26906e22 | 1090 | :defer 0.5 |
47904cb7 | 1091 | :bind-keymap ("C-c p" . projectile-command-map) |
41d290a2 AB |
1092 | :config |
1093 | (projectile-mode) | |
1094 | ||
dca50cf5 | 1095 | (defun b/projectile-mode-line-fun () |
26906e22 AB |
1096 | "Report project name and type in the modeline." |
1097 | (let ((project-name (projectile-project-name)) | |
1098 | (project-type (projectile-project-type))) | |
1099 | (format "%s%s" | |
1100 | projectile-mode-line-prefix | |
1101 | (if project-type | |
1102 | (format ":%s" project-type) | |
1103 | "")))) | |
dca50cf5 | 1104 | (setq projectile-mode-line-function 'b/projectile-mode-line-fun) |
26906e22 | 1105 | |
41d290a2 AB |
1106 | (defun my-projectile-invalidate-cache (&rest _args) |
1107 | ;; ignore the args to `magit-checkout' | |
1108 | (projectile-invalidate-cache nil)) | |
1109 | ||
1110 | (eval-after-load 'magit-branch | |
1111 | '(progn | |
1112 | (advice-add 'magit-checkout | |
1113 | :after #'my-projectile-invalidate-cache) | |
1114 | (advice-add 'magit-branch-and-checkout | |
1115 | :after #'my-projectile-invalidate-cache))) | |
54209e74 | 1116 | :custom |
295b1b10 | 1117 | (projectile-completion-system 'ivy) |
54209e74 | 1118 | (projectile-mode-line-prefix " proj")) |
41d290a2 AB |
1119 | |
1120 | (use-package helpful | |
1121 | :defer 0.6 | |
1122 | :bind | |
1123 | (("C-S-h c" . helpful-command) | |
1124 | ("C-S-h f" . helpful-callable) ; helpful-function | |
1125 | ("C-S-h v" . helpful-variable) | |
1126 | ("C-S-h k" . helpful-key) | |
1127 | ("C-S-h p" . helpful-at-point))) | |
1128 | ||
5b10d879 AB |
1129 | (use-package unkillable-scratch |
1130 | :defer 0.6 | |
1131 | :config | |
1132 | (unkillable-scratch 1) | |
1133 | :custom | |
1134 | (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$"))) | |
41d290a2 | 1135 | |
5b10d879 AB |
1136 | ;; ,---- |
1137 | ;; | make pretty boxed quotes like this | |
1138 | ;; `---- | |
1139 | (use-package boxquote | |
1140 | :defer 0.6 | |
1141 | :bind | |
1142 | (:prefix-map b/boxquote-prefix-map | |
1143 | :prefix "C-c q" | |
1144 | ("b" . boxquote-buffer) | |
1145 | ("B" . boxquote-insert-buffer) | |
1146 | ("d" . boxquote-defun) | |
1147 | ("F" . boxquote-insert-file) | |
1148 | ("hf" . boxquote-describe-function) | |
1149 | ("hk" . boxquote-describe-key) | |
1150 | ("hv" . boxquote-describe-variable) | |
1151 | ("hw" . boxquote-where-is) | |
1152 | ("k" . boxquote-kill) | |
1153 | ("p" . boxquote-paragraph) | |
1154 | ("q" . boxquote-boxquote) | |
1155 | ("r" . boxquote-region) | |
1156 | ("s" . boxquote-shell-command) | |
1157 | ("t" . boxquote-text) | |
1158 | ("T" . boxquote-title) | |
1159 | ("u" . boxquote-unbox) | |
1160 | ("U" . boxquote-unbox-region) | |
1161 | ("y" . boxquote-yank) | |
1162 | ("M-q" . boxquote-fill-paragraph) | |
1163 | ("M-w" . boxquote-kill-ring-save))) | |
41d290a2 AB |
1164 | |
1165 | (use-package orgalist | |
3619fcff AB |
1166 | ;; breaks auto-fill-mode, showing this error: |
1167 | ;; orgalist--boundaries: Lisp nesting exceeds ‘max-lisp-eval-depth’ | |
1168 | :disabled | |
41d290a2 AB |
1169 | :after message |
1170 | :hook (message-mode . orgalist-mode)) | |
1171 | ||
b57457b2 | 1172 | ;; highlight TODOs in buffers |
41d290a2 AB |
1173 | (use-package hl-todo |
1174 | :defer 0.5 | |
1175 | :config | |
1176 | (global-hl-todo-mode)) | |
1177 | ||
41d290a2 | 1178 | (use-package multi-term |
cce35aca | 1179 | :disabled |
41d290a2 | 1180 | :defer 0.6 |
fb078e63 AB |
1181 | :bind (("C-c a s m m" . multi-term) |
1182 | ("C-c a s m d" . multi-term-dedicated-toggle) | |
1183 | ("C-c a s m p" . multi-term-prev) | |
1184 | ("C-c a s m n" . multi-term-next) | |
41d290a2 | 1185 | :map term-mode-map |
0af1e91a | 1186 | ("C-c C-j" . term-char-mode)) |
41d290a2 | 1187 | :config |
96c704d7 AB |
1188 | (setq multi-term-program "screen" |
1189 | multi-term-program-switches (concat "-c" | |
1190 | (getenv "XDG_CONFIG_HOME") | |
1191 | "/screen/screenrc") | |
41d290a2 AB |
1192 | ;; TODO: add separate bindings for connecting to existing |
1193 | ;; session vs. always creating a new one | |
1194 | multi-term-dedicated-select-after-open-p t | |
1195 | multi-term-dedicated-window-height 20 | |
1196 | multi-term-dedicated-max-window-height 30 | |
1197 | term-bind-key-alist | |
1198 | '(("C-c C-c" . term-interrupt-subjob) | |
1199 | ("C-c C-e" . term-send-esc) | |
0af1e91a | 1200 | ("C-c C-j" . term-line-mode) |
41d290a2 | 1201 | ("C-k" . kill-line) |
fb078e63 AB |
1202 | ;; ("C-y" . term-paste) |
1203 | ("C-y" . term-send-raw) | |
41d290a2 AB |
1204 | ("M-f" . term-send-forward-word) |
1205 | ("M-b" . term-send-backward-word) | |
1206 | ("M-p" . term-send-up) | |
1207 | ("M-n" . term-send-down) | |
fb078e63 AB |
1208 | ("M-j" . term-send-raw-meta) |
1209 | ("M-y" . term-send-raw-meta) | |
1210 | ("M-/" . term-send-raw-meta) | |
1211 | ("M-0" . term-send-raw-meta) | |
1212 | ("M-1" . term-send-raw-meta) | |
1213 | ("M-2" . term-send-raw-meta) | |
1214 | ("M-3" . term-send-raw-meta) | |
1215 | ("M-4" . term-send-raw-meta) | |
1216 | ("M-5" . term-send-raw-meta) | |
1217 | ("M-6" . term-send-raw-meta) | |
1218 | ("M-7" . term-send-raw-meta) | |
1219 | ("M-8" . term-send-raw-meta) | |
1220 | ("M-9" . term-send-raw-meta) | |
41d290a2 AB |
1221 | ("<C-backspace>" . term-send-backward-kill-word) |
1222 | ("<M-DEL>" . term-send-backward-kill-word) | |
1223 | ("M-d" . term-send-delete-word) | |
1224 | ("M-," . term-send-raw) | |
1225 | ("M-." . comint-dynamic-complete)) | |
1226 | term-unbind-key-alist | |
fb078e63 AB |
1227 | '("C-z" "C-x" "C-c" "C-h" |
1228 | ;; "C-y" | |
1229 | "<ESC>"))) | |
41d290a2 AB |
1230 | |
1231 | (use-package page-break-lines | |
b57457b2 | 1232 | :defer 0.5 |
2f5d8190 AB |
1233 | :custom |
1234 | (page-break-lines-max-width fill-column) | |
41d290a2 AB |
1235 | :config |
1236 | (global-page-break-lines-mode)) | |
1237 | ||
1238 | (use-package expand-region | |
1239 | :bind ("C-=" . er/expand-region)) | |
1240 | ||
1241 | (use-package multiple-cursors | |
1242 | :bind | |
1243 | (("C-S-<mouse-1>" . mc/add-cursor-on-click) | |
dca50cf5 | 1244 | (:prefix-map b/mc-prefix-map |
41d290a2 AB |
1245 | :prefix "C-c m" |
1246 | ("c" . mc/edit-lines) | |
1247 | ("n" . mc/mark-next-like-this) | |
1248 | ("p" . mc/mark-previous-like-this) | |
1060413b | 1249 | ("a" . mc/mark-all-like-this)))) |
41d290a2 | 1250 | |
41d290a2 AB |
1251 | (use-package yasnippet |
1252 | :defer 0.6 | |
1253 | :config | |
1254 | (defconst yas-verbosity-cur yas-verbosity) | |
1255 | (setq yas-verbosity 2) | |
476f6228 | 1256 | (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t) |
41d290a2 AB |
1257 | (yas-reload-all) |
1258 | (setq yas-verbosity yas-verbosity-cur) | |
5b185efa AB |
1259 | |
1260 | (defun b/yas--maybe-expand-key-filter (cmd) | |
1261 | (when (and (yas--maybe-expand-key-filter cmd) | |
1262 | (not (bound-and-true-p git-commit-mode))) | |
1263 | cmd)) | |
1264 | (defconst b/yas-maybe-expand | |
1265 | '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter)) | |
1266 | (define-key yas-minor-mode-map | |
1267 | (kbd "SPC") b/yas-maybe-expand) | |
1268 | ||
476f6228 | 1269 | (yas-global-mode)) |
41d290a2 | 1270 | |
33273849 | 1271 | (use-package debbugs |
ba45b932 AB |
1272 | :bind |
1273 | (("C-c D d" . debbugs-gnu) | |
8cee0db4 | 1274 | ("C-c D b" . debbugs-gnu-bugs) |
ba45b932 AB |
1275 | ("C-c D e" . |
1276 | (lambda () | |
d6c37a13 | 1277 | (interactive) ; bug-gnu-emacs |
ba45b932 AB |
1278 | (setq debbugs-gnu-current-suppress t) |
1279 | (debbugs-gnu debbugs-gnu-default-severities '("emacs")))) | |
d6c37a13 | 1280 | ("C-c D g" . ; bug-gnuzilla |
ba45b932 AB |
1281 | (lambda () |
1282 | (interactive) | |
1283 | (setq debbugs-gnu-current-suppress t) | |
64b53575 | 1284 | (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla")))) |
d6c37a13 AB |
1285 | ("C-c D G b" . ; bug-guix |
1286 | (lambda () | |
1287 | (interactive) | |
1288 | (setq debbugs-gnu-current-suppress t) | |
1289 | (debbugs-gnu debbugs-gnu-default-severities '("guix")))) | |
1290 | ("C-c D G p" . ; guix-patches | |
64b53575 AB |
1291 | (lambda () |
1292 | (interactive) | |
1293 | (setq debbugs-gnu-current-suppress t) | |
d6c37a13 | 1294 | (debbugs-gnu debbugs-gnu-default-severities '("guix-patches")))))) |
41d290a2 AB |
1295 | |
1296 | (use-package org-ref | |
1297 | :init | |
dca50cf5 | 1298 | (b/setq-every '("~/usr/org/references.bib") |
41d290a2 AB |
1299 | reftex-default-bibliography |
1300 | org-ref-default-bibliography) | |
1301 | (setq | |
1302 | org-ref-bibliography-notes "~/usr/org/notes.org" | |
1303 | org-ref-pdf-directory "~/usr/org/bibtex-pdfs/")) | |
1304 | ||
2f5d8190 AB |
1305 | ;; (use-package fill-column-indicator) |
1306 | ||
47904cb7 | 1307 | (use-package window |
ed8c4fa9 | 1308 | :bind |
0b7f98f4 | 1309 | (("C-c w s l" . (lambda () |
edb03389 AB |
1310 | (interactive) |
1311 | (split-window-right) | |
1312 | (other-window 1))) | |
1313 | ("C-c w s j" . (lambda () | |
1314 | (interactive) | |
1315 | (split-window-below) | |
1316 | (other-window 1))) | |
446cb096 | 1317 | ("C-c w q" . quit-window)) |
92df6c4f AB |
1318 | :custom |
1319 | (split-width-threshold 150)) | |
ed8c4fa9 | 1320 | |
47904cb7 | 1321 | (use-package windmove |
ed8c4fa9 AB |
1322 | :defer 0.6 |
1323 | :bind | |
2e81c51a AB |
1324 | (("C-c w h" . windmove-left) |
1325 | ("C-c w j" . windmove-down) | |
1326 | ("C-c w k" . windmove-up) | |
1327 | ("C-c w l" . windmove-right) | |
1328 | ("C-c w H" . windmove-swap-states-left) | |
1329 | ("C-c w J" . windmove-swap-states-down) | |
1330 | ("C-c w K" . windmove-swap-states-up) | |
1331 | ("C-c w L" . windmove-swap-states-right))) | |
ed8c4fa9 | 1332 | |
05068e71 AB |
1333 | (use-package pass |
1334 | :commands pass | |
1335 | :bind ("C-c a p" . pass) | |
1336 | :hook (pass-mode . View-exit)) | |
1337 | ||
b188e798 AB |
1338 | (use-package pdf-tools |
1339 | :defer 0.5 | |
1340 | :bind (:map pdf-view-mode-map | |
0365678c AB |
1341 | ("<C-XF86Back>" . pdf-history-backward) |
1342 | ("<mouse-8>" . pdf-history-backward) | |
1343 | ("<drag-mouse-8>" . pdf-history-backward) | |
1344 | ("<C-XF86Forward>" . pdf-history-forward) | |
1345 | ("<mouse-9>" . pdf-history-forward) | |
1346 | ("<drag-mouse-9>" . pdf-history-forward) | |
4fa43cd8 AB |
1347 | ("M-RET" . image-previous-line) |
1348 | ("C-s" . isearch-forward) | |
1349 | ("s s" . isearch-forward)) | |
822ac360 AB |
1350 | :config (pdf-tools-install nil t) |
1351 | :custom (pdf-view-resize-factor 1.05)) | |
b188e798 | 1352 | |
62a2088e | 1353 | (use-package org-pdftools |
47904cb7 | 1354 | :disabled |
62a2088e AB |
1355 | :straight (:host github :repo "fuxialexander/org-pdftools") |
1356 | :demand | |
1357 | :after org | |
1358 | :config | |
1359 | (with-eval-after-load 'org | |
1360 | (require 'org-pdftools))) | |
1361 | ||
9de75957 AB |
1362 | (use-package biblio) |
1363 | ||
47904cb7 | 1364 | (use-package reftex |
9a5ffb33 AB |
1365 | :hook (latex-mode . reftex-mode)) |
1366 | ||
47904cb7 | 1367 | (use-package reftex-cite |
9a5ffb33 AB |
1368 | :after reftex |
1369 | :disabled ; enable to disable | |
1370 | ; reftex-cite's default choice | |
1371 | ; of previous word | |
1372 | :config | |
1373 | (defun reftex-get-bibkey-default () | |
1374 | "If the cursor is in a citation macro, return the word before the macro." | |
1375 | (let* ((macro (reftex-what-macro 1))) | |
1376 | (save-excursion | |
1377 | (when (and macro (string-match "cite" (car macro))) | |
1378 | (goto-char (cdr macro))) | |
1379 | (reftex-this-word))))) | |
1380 | ||
d141ce11 AB |
1381 | (use-package minions |
1382 | :demand | |
1383 | :config (minions-mode)) | |
1384 | ||
fa9943dc | 1385 | (use-package dmenu |
fa9943dc | 1386 | :custom |
fa9943dc AB |
1387 | (dmenu-prompt-string "run: ") |
1388 | (dmenu-save-file (b/var "dmenu-items"))) | |
1389 | ||
996bebf6 AB |
1390 | (use-package eosd |
1391 | ;; TODO: fix build by properly building the eosd-pixbuf.c module | |
1392 | ;; e.g. see https://github.com/raxod502/straight.el/issues/386 | |
1393 | :disabled | |
1394 | :straight (:host github :repo "clarete/eosd") | |
1395 | :demand | |
1396 | :after exwm | |
1397 | :config | |
1398 | (eosd-start)) | |
1399 | ||
9ed5410e | 1400 | (use-package eww |
03745e6e | 1401 | :bind ("C-c a e w" . eww) |
9ed5410e AB |
1402 | :custom |
1403 | (eww-download-directory (file-name-as-directory | |
1404 | (getenv "XDG_DOWNLOAD_DIR")))) | |
1405 | ||
b57457b2 | 1406 | \f |
b57457b2 AB |
1407 | ;;; Post initialization |
1408 | ||
8b1a2f32 | 1409 | ) |
41d290a2 AB |
1410 | (message "Loading %s...done (%.3fs)" user-init-file |
1411 | (float-time (time-subtract (current-time) | |
dca50cf5 | 1412 | b/before-user-init-time))) |
41d290a2 AB |
1413 | |
1414 | ;;; init.el ends here |