Commit | Line | Data |
---|---|---|
dca50cf5 | 1 | ;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*- |
41d290a2 | 2 | |
4ed3a945 | 3 | ;; Copyright (C) 2018-2019 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 | ||
20 | ;; Emacs configuration of Amin Bandali, computer scientist, functional | |
33273849 AB |
21 | ;; programmer, and free software activist. Uses straight.el for |
22 | ;; purely functional and fully reproducible package management. | |
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 AB |
41 | "Value of `current-time' when Emacs begins loading `user-init-file'.") |
42 | (message "Loading Emacs...done (%.3fs)" | |
dca50cf5 | 43 | (float-time (time-subtract b/before-user-init-time |
41d290a2 AB |
44 | before-init-time))) |
45 | ||
b57457b2 AB |
46 | ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage' |
47 | ;; during startup to reduce garbage collection frequency. clearing | |
48 | ;; `file-name-handler-alist' seems to help reduce startup time too. | |
dca50cf5 AB |
49 | (defvar b/gc-cons-threshold gc-cons-threshold) |
50 | (defvar b/gc-cons-percentage gc-cons-percentage) | |
51 | (defvar b/file-name-handler-alist file-name-handler-alist) | |
41d290a2 AB |
52 | (setq gc-cons-threshold (* 400 1024 1024) ; 400 MiB |
53 | gc-cons-percentage 0.6 | |
54 | file-name-handler-alist nil | |
55 | ;; sidesteps a bug when profiling with esup | |
56 | esup-child-profile-require-level 0) | |
57 | ||
b57457b2 | 58 | ;; set them back to their defaults once we're done initializing |
dca50cf5 AB |
59 | (defun b/post-init () |
60 | (setq gc-cons-threshold b/gc-cons-threshold | |
61 | gc-cons-percentage b/gc-cons-percentage | |
62 | file-name-handler-alist b/file-name-handler-alist)) | |
63 | (add-hook 'after-init-hook #'b/post-init) | |
41d290a2 | 64 | |
b57457b2 | 65 | ;; increase number of lines kept in *Messages* log |
41d290a2 AB |
66 | (setq message-log-max 20000) |
67 | ||
b57457b2 AB |
68 | ;; optionally, uncomment to supress some byte-compiler warnings |
69 | ;; (see C-h v byte-compile-warnings RET for more info) | |
41d290a2 AB |
70 | ;; (setq byte-compile-warnings |
71 | ;; '(not free-vars unresolved noruntime lexical make-local)) | |
72 | ||
b57457b2 AB |
73 | \f |
74 | ;;; whoami | |
75 | ||
41d290a2 | 76 | (setq user-full-name "Amin Bandali" |
dca50cf5 | 77 | user-mail-address "bandali@gnu.org") |
41d290a2 | 78 | |
b57457b2 AB |
79 | \f |
80 | ;;; comment macro | |
81 | ||
82 | ;; useful for commenting out multiple sexps at a time | |
83 | (defmacro comment (&rest _) | |
84 | "Comment out one or more s-expressions." | |
85 | (declare (indent defun)) | |
86 | nil) | |
87 | ||
88 | \f | |
33273849 AB |
89 | ;;; Package management |
90 | ||
91 | ;; No package.el (for emacs 26 and before, uncomment the following) | |
92 | ;; Not necessary when using straight.el | |
93 | ;; (C-h v straight-package-neutering-mode RET) | |
94 | ||
95 | (when (and | |
96 | (not (featurep 'straight)) | |
97 | (version< emacs-version "27")) | |
98 | (setq package-enable-at-startup nil) | |
99 | ;; (package-initialize) | |
100 | ) | |
101 | ||
102 | ;; for emacs 27 and later, we use early-init.el. see | |
103 | ;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b | |
104 | ||
105 | ;; straight.el | |
106 | ||
107 | ;; Main engine start... | |
108 | ||
109 | (setq straight-repository-branch "develop" | |
110 | straight-check-for-modifications '(check-on-save find-when-checking)) | |
111 | ||
112 | (defun b/bootstrap-straight () | |
113 | (defvar bootstrap-version) | |
114 | (let ((bootstrap-file | |
115 | (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) | |
116 | (bootstrap-version 5)) | |
117 | (unless (file-exists-p bootstrap-file) | |
118 | (with-current-buffer | |
119 | (url-retrieve-synchronously | |
120 | "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" | |
121 | 'silent 'inhibit-cookies) | |
122 | (goto-char (point-max)) | |
123 | (eval-print-last-sexp))) | |
124 | (load bootstrap-file nil 'nomessage))) | |
125 | ||
126 | ;; Solid rocket booster ignition... | |
127 | ||
128 | (b/bootstrap-straight) | |
129 | ||
130 | ;; We have lift off! | |
131 | ||
132 | (setq straight-use-package-by-default t) | |
133 | ||
134 | (defmacro use-feature (name &rest args) | |
135 | "Like `use-package', but with `straight-use-package-by-default' disabled." | |
136 | (declare (indent 1)) | |
137 | `(use-package ,name | |
138 | :straight nil | |
139 | ,@args)) | |
140 | ||
2c483b3e AB |
141 | (with-eval-after-load 'use-package-core |
142 | (let ((upflk (car use-package-font-lock-keywords))) | |
143 | (font-lock-add-keywords | |
144 | 'emacs-lisp-mode | |
145 | `((,(replace-regexp-in-string | |
146 | "use-package" "use-feature" | |
147 | (car upflk)) | |
148 | ,@(cdr upflk)))))) | |
149 | ||
33273849 AB |
150 | (with-eval-after-load 'recentf |
151 | (add-to-list 'recentf-exclude | |
152 | (expand-file-name "~/.emacs.d/straight/build/"))) | |
153 | ||
154 | (defun b/reload-init () | |
155 | "Reload init.el." | |
156 | (interactive) | |
157 | (setq b/file-name-handler-alist file-name-handler-alist) | |
158 | (load user-init-file nil 'nomessage) | |
159 | (b/post-init)) | |
160 | ||
161 | ;; use-package | |
162 | (straight-use-package 'use-package) | |
163 | ||
41d290a2 AB |
164 | (if nil ; set to t when need to debug init |
165 | (progn | |
166 | (setq use-package-verbose t | |
167 | use-package-expand-minimally nil | |
168 | use-package-compute-statistics t | |
169 | debug-on-error t) | |
170 | (require 'use-package)) | |
171 | (setq use-package-verbose nil | |
172 | use-package-expand-minimally t)) | |
173 | ||
174 | (setq use-package-always-defer t) | |
175 | (require 'bind-key) | |
176 | ||
54209e74 AB |
177 | (use-package delight) |
178 | ||
b57457b2 AB |
179 | \f |
180 | ;;; Initial setup | |
181 | ||
182 | ;; keep ~/.emacs.d clean | |
1060413b AB |
183 | (use-package no-littering |
184 | :demand | |
185 | :config | |
186 | (defalias 'b/etc 'no-littering-expand-etc-file-name) | |
187 | (defalias 'b/var 'no-littering-expand-var-file-name)) | |
41d290a2 | 188 | |
b57457b2 | 189 | ;; separate custom file (don't want it mixing with init.el) |
33273849 | 190 | (use-feature custom |
41d290a2 AB |
191 | :no-require t |
192 | :config | |
dca50cf5 | 193 | (setq custom-file (b/etc "custom.el")) |
41d290a2 AB |
194 | (when (file-exists-p custom-file) |
195 | (load custom-file)) | |
b57457b2 | 196 | ;; while at it, treat themes as safe |
41d290a2 AB |
197 | (setf custom-safe-themes t)) |
198 | ||
b57457b2 | 199 | ;; load the secrets file if it exists, otherwise show a warning |
dca50cf5 AB |
200 | (comment |
201 | (with-demoted-errors | |
202 | (load (b/etc "secrets")))) | |
41d290a2 | 203 | |
b57457b2 | 204 | ;; better $PATH (and other environment variable) handling |
41d290a2 AB |
205 | (use-package exec-path-from-shell |
206 | :defer 0.4 | |
207 | :init | |
208 | (setq exec-path-from-shell-arguments nil | |
209 | exec-path-from-shell-check-startup-files nil) | |
210 | :config | |
211 | (exec-path-from-shell-initialize) | |
212 | ;; while we're at it, let's fix access to our running ssh-agent | |
213 | (exec-path-from-shell-copy-env "SSH_AGENT_PID") | |
214 | (exec-path-from-shell-copy-env "SSH_AUTH_SOCK")) | |
215 | ||
b57457b2 AB |
216 | ;; only one custom theme at a time |
217 | (comment | |
218 | (defadvice load-theme (before clear-previous-themes activate) | |
219 | "Clear existing theme settings instead of layering them" | |
220 | (mapc #'disable-theme custom-enabled-themes))) | |
221 | ||
222 | ;; start up emacs server. see | |
223 | ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server | |
33273849 | 224 | (use-feature server |
41d290a2 AB |
225 | :defer 0.4 |
226 | :config (or (server-running-p) (server-mode))) | |
227 | ||
b57457b2 AB |
228 | ;; unicode support |
229 | (comment | |
230 | (dolist (ft (fontset-list)) | |
231 | (set-fontset-font | |
232 | ft | |
233 | 'unicode | |
234 | (font-spec :name "Source Code Pro" :size 14)) | |
235 | (set-fontset-font | |
236 | ft | |
237 | 'unicode | |
238 | (font-spec :name "DejaVu Sans Mono") | |
239 | nil | |
240 | 'append) | |
241 | ;; (set-fontset-font | |
242 | ;; ft | |
243 | ;; 'unicode | |
244 | ;; (font-spec | |
245 | ;; :name "Symbola monospacified for DejaVu Sans Mono") | |
246 | ;; nil | |
247 | ;; 'append) | |
248 | ;; (set-fontset-font | |
249 | ;; ft | |
250 | ;; #x2115 ; ℕ | |
251 | ;; (font-spec :name "DejaVu Sans Mono") | |
252 | ;; nil | |
253 | ;; 'append) | |
254 | (set-fontset-font | |
255 | ft | |
256 | (cons ?Α ?ω) | |
257 | (font-spec :name "DejaVu Sans Mono" :size 14) | |
258 | nil | |
259 | 'prepend))) | |
260 | ||
261 | ;; gentler font resizing | |
41d290a2 AB |
262 | (setq text-scale-mode-step 1.05) |
263 | ||
b57457b2 | 264 | ;; focus follows mouse |
41d290a2 AB |
265 | (setq mouse-autoselect-window t) |
266 | ||
dca50cf5 | 267 | (defun b/no-mouse-autoselect-window () |
b57457b2 AB |
268 | "Conveniently disable `focus-follows-mouse'. |
269 | For disabling the behaviour for certain buffers and/or modes." | |
41d290a2 AB |
270 | (make-local-variable 'mouse-autoselect-window) |
271 | (setq mouse-autoselect-window nil)) | |
272 | ||
b57457b2 | 273 | ;; better scrolling |
41d290a2 AB |
274 | (setq ;; scroll-margin 1 |
275 | ;; scroll-conservatively 10000 | |
276 | scroll-step 1 | |
277 | scroll-conservatively 10 | |
278 | scroll-preserve-screen-position 1) | |
279 | ||
33273849 | 280 | (use-feature mwheel |
41d290a2 AB |
281 | :defer 0.4 |
282 | :config | |
283 | (setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time | |
284 | mouse-wheel-progressive-speed nil ; don't accelerate scrolling | |
285 | mouse-wheel-follow-mouse t)) ; scroll window under mouse | |
286 | ||
33273849 | 287 | (use-feature pixel-scroll |
41d290a2 AB |
288 | :defer 0.4 |
289 | :config (pixel-scroll-mode 1)) | |
290 | ||
33273849 | 291 | (use-feature epg-config |
9fc30d4c | 292 | :custom |
f18c7384 | 293 | ((epg-gpg-program (executable-find "gpg")))) |
41d290a2 | 294 | |
b57457b2 | 295 | ;; useful libraries |
41d290a2 AB |
296 | (require 'cl-lib) |
297 | (require 'subr-x) | |
298 | ||
b57457b2 AB |
299 | \f |
300 | ;;; Useful utilities | |
301 | ||
dca50cf5 | 302 | (defmacro b/setq-every (value &rest vars) |
41d290a2 AB |
303 | "Set all the variables from VARS to value VALUE." |
304 | (declare (indent defun) (debug t)) | |
305 | `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars))) | |
306 | ||
dca50cf5 | 307 | (defun b/start-process (program &rest args) |
41d290a2 AB |
308 | "Same as `start-process', but doesn't bother about name and buffer." |
309 | (let ((process-name (concat program "_process")) | |
310 | (buffer-name (generate-new-buffer-name | |
311 | (concat program "_output")))) | |
312 | (apply #'start-process | |
313 | process-name buffer-name program args))) | |
314 | ||
dca50cf5 | 315 | (defun b/dired-start-process (program &optional args) |
41d290a2 AB |
316 | "Open current file with a PROGRAM." |
317 | ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can | |
318 | ;; be nil, so remove it). | |
dca50cf5 | 319 | (apply #'b/start-process |
41d290a2 AB |
320 | program |
321 | (remove nil (list args (dired-get-file-for-visit))))) | |
322 | ||
dca50cf5 | 323 | (defun b/add-elisp-section () |
b57457b2 AB |
324 | (interactive) |
325 | (insert "\n") | |
326 | (previous-line) | |
327 | (insert "\n\f\n;;; ")) | |
328 | ||
329 | \f | |
330 | ;;; Defaults | |
331 | ||
332 | ;; time and battery in mode-line | |
333 | (comment | |
334 | (use-package time | |
335 | :init | |
336 | (setq display-time-default-load-average nil) | |
337 | :config | |
338 | (display-time-mode)) | |
339 | ||
340 | (use-package battery | |
341 | :config | |
342 | (display-battery-mode))) | |
343 | ||
344 | ;; smaller fringe | |
41d290a2 AB |
345 | ;; (fringe-mode '(3 . 1)) |
346 | (fringe-mode nil) | |
347 | ||
b57457b2 | 348 | ;; disable disabled commands |
41d290a2 AB |
349 | (setq disabled-command-function nil) |
350 | ||
b57457b2 AB |
351 | ;; Save what I copy into clipboard from other applications into Emacs' |
352 | ;; kill-ring, which would allow me to still be able to easily access | |
353 | ;; it in case I kill (cut or copy) something else inside Emacs before | |
354 | ;; yanking (pasting) what I'd originally intended to. | |
41d290a2 AB |
355 | (setq save-interprogram-paste-before-kill t) |
356 | ||
b57457b2 | 357 | ;; minibuffer |
41d290a2 AB |
358 | (setq enable-recursive-minibuffers t |
359 | resize-mini-windows t) | |
360 | ||
b57457b2 | 361 | ;; lazy-person-friendly yes/no prompts |
41d290a2 AB |
362 | (defalias 'yes-or-no-p #'y-or-n-p) |
363 | ||
b57457b2 | 364 | ;; i want *scratch* as my startup buffer |
41d290a2 AB |
365 | (setq initial-buffer-choice t) |
366 | ||
b57457b2 | 367 | ;; i don't need the default hint |
41d290a2 AB |
368 | (setq initial-scratch-message nil) |
369 | ||
b57457b2 | 370 | ;; use customizable text-mode as major mode for *scratch* |
41d290a2 AB |
371 | (setq initial-major-mode 'text-mode) |
372 | ||
b57457b2 | 373 | ;; inhibit buffer list when more than 2 files are loaded |
41d290a2 AB |
374 | (setq inhibit-startup-buffer-menu t) |
375 | ||
b57457b2 | 376 | ;; don't need to see the startup screen or the echo area message |
41d290a2 AB |
377 | (advice-add #'display-startup-echo-area-message :override #'ignore) |
378 | (setq inhibit-startup-screen t | |
379 | inhibit-startup-echo-area-message user-login-name) | |
380 | ||
b57457b2 | 381 | ;; more useful frame titles |
41d290a2 AB |
382 | (setq frame-title-format |
383 | '("" invocation-name " - " | |
384 | (:eval (if (buffer-file-name) | |
385 | (abbreviate-file-name (buffer-file-name)) | |
386 | "%b")))) | |
387 | ||
b57457b2 | 388 | ;; backups (C-h v make-backup-files RET) |
41d290a2 AB |
389 | (setq backup-by-copying t |
390 | version-control t | |
391 | delete-old-versions t) | |
392 | ||
b57457b2 | 393 | ;; enable automatic reloading of changed buffers and files |
41d290a2 AB |
394 | (global-auto-revert-mode 1) |
395 | (setq auto-revert-verbose nil | |
396 | global-auto-revert-non-file-buffers nil) | |
397 | ||
b57457b2 | 398 | ;; always use space for indentation |
41d290a2 AB |
399 | (setq-default |
400 | indent-tabs-mode nil | |
401 | require-final-newline t | |
402 | tab-width 4) | |
403 | ||
b57457b2 | 404 | ;; enable winner-mode (C-h f winner-mode RET) |
41d290a2 AB |
405 | (winner-mode 1) |
406 | ||
b57457b2 AB |
407 | ;; don't display *compilation* buffer on success. based on |
408 | ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf' | |
409 | ;; instead of the now obsolete `flet'. | |
41d290a2 | 410 | (with-eval-after-load 'compile |
dca50cf5 | 411 | (defun b/compilation-finish-function (buffer outstr) |
41d290a2 AB |
412 | (unless (string-match "finished" outstr) |
413 | (switch-to-buffer-other-window buffer)) | |
414 | t) | |
415 | ||
dca50cf5 | 416 | (setq compilation-finish-functions #'b/compilation-finish-function) |
41d290a2 AB |
417 | |
418 | (require 'cl-macs) | |
419 | ||
420 | (defadvice compilation-start | |
421 | (around inhibit-display | |
422 | (command &optional mode name-function highlight-regexp)) | |
423 | (if (not (string-match "^\\(find\\|grep\\)" command)) | |
424 | (cl-letf (((symbol-function 'display-buffer) #'ignore)) | |
425 | (save-window-excursion ad-do-it)) | |
426 | ad-do-it)) | |
427 | (ad-activate 'compilation-start)) | |
428 | ||
b57457b2 AB |
429 | ;; search for non-ASCII characters: i’d like non-ASCII characters such |
430 | ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII | |
431 | ;; counterpart. shoutout to | |
432 | ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html | |
41d290a2 | 433 | (setq search-default-mode #'char-fold-to-regexp) |
41d290a2 AB |
434 | ;; uncomment to extend this behaviour to query-replace |
435 | ;; (setq replace-char-fold t) | |
436 | ||
b57457b2 | 437 | ;; cursor shape |
41d290a2 AB |
438 | (setq-default cursor-type 'bar) |
439 | ||
b57457b2 | 440 | ;; allow scrolling in Isearch |
41d290a2 AB |
441 | (setq isearch-allow-scroll t) |
442 | ||
b9901074 AB |
443 | ;; open read-only file buffers in view-mode |
444 | ;; (enables niceties like `q' for quit) | |
445 | (setq view-read-only t) | |
446 | ||
33273849 | 447 | (use-feature vc |
b1a5d811 AB |
448 | :bind ("C-x v C-=" . vc-ediff)) |
449 | ||
33273849 | 450 | (use-feature ediff |
b1a5d811 AB |
451 | :config (add-hook 'ediff-after-quit-hook-internal 'winner-undo) |
452 | :custom ((ediff-window-setup-function 'ediff-setup-windows-plain) | |
453 | (ediff-split-window-function 'split-window-horizontally))) | |
454 | ||
1d405cde AB |
455 | ;; i don't feel like jumping out of my chair every now and again; so |
456 | ;; don't BEEP! at me, emacs | |
457 | (setq ring-bell-function 'ignore) | |
458 | ||
b57457b2 AB |
459 | \f |
460 | ;;; General bindings | |
461 | ||
41d290a2 AB |
462 | (bind-keys |
463 | ("C-c a i" . ielm) | |
464 | ||
465 | ("C-c e b" . eval-buffer) | |
2a816b71 | 466 | ("C-c e e" . eval-last-sexp) |
41d290a2 AB |
467 | ("C-c e r" . eval-region) |
468 | ||
469 | ("C-c e i" . emacs-init-time) | |
470 | ("C-c e u" . emacs-uptime) | |
dca50cf5 | 471 | ("C-c e v" . emacs-version) |
41d290a2 AB |
472 | |
473 | ("C-c F m" . make-frame-command) | |
474 | ("C-c F d" . delete-frame) | |
435306f6 | 475 | ("C-c F D" . server-edit) |
41d290a2 | 476 | |
41d290a2 AB |
477 | ("C-S-h C" . describe-char) |
478 | ("C-S-h F" . describe-face) | |
479 | ||
480 | ("C-x k" . kill-this-buffer) | |
481 | ("C-x K" . kill-buffer) | |
2a816b71 AB |
482 | ("C-x s" . save-buffer) |
483 | ("C-x S" . save-some-buffers) | |
41d290a2 | 484 | |
b57457b2 | 485 | :map emacs-lisp-mode-map |
dca50cf5 | 486 | ("<C-return>" . b/add-elisp-section)) |
41d290a2 AB |
487 | |
488 | (when (display-graphic-p) | |
489 | (unbind-key "C-z" global-map)) | |
490 | ||
500004f4 AB |
491 | (bind-keys |
492 | ;; for back and forward mouse keys | |
493 | ("<mouse-8>" . previous-buffer) | |
494 | ("<drag-mouse-8>" . previous-buffer) | |
495 | ("<mouse-9>" . next-buffer) | |
496 | ("<drag-mouse-9>" . next-buffer) | |
497 | ("<drag-mouse-2>" . kill-this-buffer) | |
498 | ("<drag-mouse-3>" . ivy-switch-buffer)) | |
499 | ||
33273849 AB |
500 | (bind-keys |
501 | :prefix-map mab/straight-prefix-map | |
502 | :prefix "C-c p s" | |
503 | ("u" . straight-use-package) | |
504 | ("f" . straight-freeze-versions) | |
505 | ("t" . straight-thaw-versions) | |
506 | ("P" . straight-prune-build) | |
507 | ("g" . straight-get-recipe) | |
508 | ("r" . mab/reload-init) | |
509 | ;; M-x ^straight-.*-all$ | |
510 | ("a c" . straight-check-all) | |
511 | ("a f" . straight-fetch-all) | |
512 | ("a m" . straight-merge-all) | |
513 | ("a n" . straight-normalize-all) | |
514 | ("a F" . straight-pull-all) | |
515 | ("a P" . straight-push-all) | |
516 | ("a r" . straight-rebuild-all) | |
517 | ;; M-x ^straight-.*-package$ | |
518 | ("p c" . straight-check-package) | |
519 | ("p f" . straight-fetch-package) | |
520 | ("p m" . straight-merge-package) | |
521 | ("p n" . straight-normalize-package) | |
522 | ("p F" . straight-pull-package) | |
523 | ("p P" . straight-push-package) | |
524 | ("p r" . straight-rebuild-package)) | |
525 | ||
b57457b2 AB |
526 | \f |
527 | ;;; Essential packages | |
528 | ||
33273849 AB |
529 | ;; use the org-plus-contrib package to get the whole deal |
530 | (use-package org-plus-contrib) | |
531 | ||
532 | (use-feature org | |
41d290a2 AB |
533 | :defer 0.5 |
534 | :config | |
535 | (setq org-src-tab-acts-natively t | |
536 | org-src-preserve-indentation nil | |
537 | org-edit-src-content-indentation 0 | |
538 | org-link-email-description-format "Email %c: %s" ; %.30s | |
539 | org-highlight-latex-and-related '(entities) | |
540 | org-use-speed-commands t | |
541 | org-startup-folded 'content | |
542 | org-catch-invisible-edits 'show-and-error | |
543 | org-log-done 'time) | |
66ec16e4 AB |
544 | (when (version< org-version "9.3") |
545 | (setq org-email-link-description-format | |
546 | org-link-email-description-format)) | |
41d290a2 | 547 | (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t) |
506ba717 | 548 | (add-to-list 'org-modules 'org-habit) |
41d290a2 AB |
549 | :bind |
550 | (("C-c a o a" . org-agenda) | |
551 | :map org-mode-map | |
552 | ("M-L" . org-insert-last-stored-link) | |
2e81c51a | 553 | ("M-O" . org-toggle-link-display)) |
41d290a2 AB |
554 | :hook ((org-mode . org-indent-mode) |
555 | (org-mode . auto-fill-mode) | |
556 | (org-mode . flyspell-mode)) | |
557 | :custom | |
561b2e77 | 558 | (org-pretty-entities t) |
41d290a2 | 559 | (org-agenda-files '("~/usr/org/todos/personal.org" |
506ba717 | 560 | "~/usr/org/todos/habits.org" |
561b2e77 | 561 | "~/src/git/masters-thesis/todo.org")) |
41d290a2 | 562 | (org-agenda-start-on-weekday 0) |
506ba717 AB |
563 | (org-agenda-time-leading-zero t) |
564 | (org-habit-graph-column 44) | |
41d290a2 AB |
565 | (org-latex-packages-alist '(("" "listings") ("" "color"))) |
566 | :custom-face | |
567 | '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21")))) | |
568 | '(org-block ((t (:background "#1d1f21")))) | |
569 | '(org-latex-and-related ((t (:foreground "#b294bb"))))) | |
570 | ||
33273849 | 571 | (use-feature ox-latex |
41d290a2 AB |
572 | :after ox |
573 | :config | |
574 | (setq org-latex-listings 'listings | |
575 | ;; org-latex-prefer-user-labels t | |
576 | ) | |
577 | (add-to-list 'org-latex-classes | |
578 | '("IEEEtran" "\\documentclass[11pt]{IEEEtran}" | |
579 | ("\\section{%s}" . "\\section*{%s}") | |
580 | ("\\subsection{%s}" . "\\subsection*{%s}") | |
581 | ("\\subsubsection{%s}" . "\\subsubsection*{%s}") | |
582 | ("\\paragraph{%s}" . "\\paragraph*{%s}") | |
583 | ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) | |
584 | t) | |
585 | (require 'ox-beamer)) | |
586 | ||
33273849 | 587 | (use-feature ox-extra |
41d290a2 AB |
588 | :config |
589 | (ox-extras-activate '(latex-header-blocks ignore-headlines))) | |
590 | ||
b57457b2 AB |
591 | ;; asynchronous tangle, using emacs-async to asynchronously tangle an |
592 | ;; org file. closely inspired by | |
593 | ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles | |
41d290a2 | 594 | (with-eval-after-load 'org |
dca50cf5 | 595 | (defvar b/show-async-tangle-results nil |
41d290a2 AB |
596 | "Keep *emacs* async buffers around for later inspection.") |
597 | ||
dca50cf5 | 598 | (defvar b/show-async-tangle-time nil |
41d290a2 AB |
599 | "Show the time spent tangling the file.") |
600 | ||
dca50cf5 | 601 | (defun b/async-babel-tangle () |
41d290a2 AB |
602 | "Tangle org file asynchronously." |
603 | (interactive) | |
604 | (let* ((file-tangle-start-time (current-time)) | |
605 | (file (buffer-file-name)) | |
606 | (file-nodir (file-name-nondirectory file)) | |
607 | ;; (async-quiet-switch "-q") | |
608 | (file-noext (file-name-sans-extension file))) | |
609 | (async-start | |
610 | `(lambda () | |
611 | (require 'org) | |
612 | (org-babel-tangle-file ,file)) | |
dca50cf5 | 613 | (unless b/show-async-tangle-results |
41d290a2 AB |
614 | `(lambda (result) |
615 | (if result | |
29ea9439 AB |
616 | (message "Tangled %s%s" |
617 | ,file-nodir | |
dca50cf5 | 618 | (if b/show-async-tangle-time |
29ea9439 AB |
619 | (format " (%.3fs)" |
620 | (float-time (time-subtract (current-time) | |
621 | ',file-tangle-start-time))) | |
622 | "")) | |
41d290a2 AB |
623 | (message "Tangling %s failed" ,file-nodir)))))))) |
624 | ||
625 | (add-to-list | |
626 | 'safe-local-variable-values | |
dca50cf5 | 627 | '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local)) |
41d290a2 | 628 | |
b57457b2 | 629 | ;; *the* right way to do git |
41d290a2 AB |
630 | (use-package magit |
631 | :defer 0.5 | |
2a816b71 AB |
632 | :bind (("C-x g" . magit-status) |
633 | ("C-c g g" . magit-status) | |
ef6c487c AB |
634 | ("C-c g b" . magit-blame-addition) |
635 | ("C-c g l" . magit-log-buffer-file)) | |
41d290a2 AB |
636 | :config |
637 | (magit-add-section-hook 'magit-status-sections-hook | |
638 | 'magit-insert-modules | |
639 | 'magit-insert-stashes | |
640 | 'append) | |
3b3615f5 AB |
641 | ;; (magit-add-section-hook 'magit-status-sections-hook |
642 | ;; 'magit-insert-ignored-files | |
643 | ;; 'magit-insert-untracked-files | |
644 | ;; 'append) | |
41d290a2 AB |
645 | (setq magit-repository-directories '(("~/" . 0) |
646 | ("~/src/git/" . 1))) | |
647 | (nconc magit-section-initial-visibility-alist | |
648 | '(([unpulled status] . show) | |
649 | ([unpushed status] . show))) | |
afbbf23a | 650 | :custom (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1) |
41d290a2 AB |
651 | :custom-face (magit-diff-file-heading ((t (:weight normal))))) |
652 | ||
b57457b2 | 653 | ;; recently opened files |
33273849 | 654 | (use-feature recentf |
41d290a2 | 655 | :defer 0.2 |
dca50cf5 | 656 | ;; :config |
9424b3d6 | 657 | ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:") |
dca50cf5 | 658 | :custom |
1060413b | 659 | (recentf-max-saved-items 2000)) |
41d290a2 | 660 | |
b57457b2 | 661 | ;; smart M-x enhancement (needed by counsel for history) |
1060413b | 662 | (use-package smex) |
41d290a2 AB |
663 | |
664 | (use-package ivy | |
665 | :defer 0.3 | |
54209e74 | 666 | :delight ;; " 🙒" |
41d290a2 AB |
667 | :bind |
668 | (:map ivy-minibuffer-map | |
669 | ([escape] . keyboard-escape-quit) | |
670 | ([S-up] . ivy-previous-history-element) | |
671 | ([S-down] . ivy-next-history-element) | |
672 | ("DEL" . ivy-backward-delete-char)) | |
673 | :config | |
674 | (setq ivy-wrap t | |
675 | ivy-height 14 | |
676 | ivy-use-virtual-buffers t | |
677 | ivy-virtual-abbreviate 'abbreviate | |
678 | ivy-count-format "%d/%d ") | |
fcd36528 AB |
679 | |
680 | (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode)) | |
681 | (defun b/ivy-ignore-buffer-p (str) | |
682 | "Return non-nil if str names a buffer with a major mode | |
683 | derived from one of `b/ivy-ignore-buffer-modes'. | |
684 | ||
685 | This function is intended for use with `ivy-ignore-buffers'." | |
686 | (let* ((buf (get-buffer str)) | |
687 | (mode (and buf (buffer-local-value 'major-mode buf)))) | |
688 | (and mode | |
689 | (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes)))) | |
690 | (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p) | |
691 | ||
41d290a2 AB |
692 | (ivy-mode 1) |
693 | ;; :custom-face | |
694 | ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold)))) | |
695 | ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold)))) | |
696 | ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold)))) | |
697 | ) | |
698 | ||
699 | (use-package swiper | |
700 | :after ivy | |
701 | :bind (("C-s" . swiper-isearch) | |
702 | ("C-r" . swiper) | |
703 | ("C-S-s" . isearch-forward))) | |
704 | ||
705 | (use-package counsel | |
706 | :after ivy | |
54209e74 | 707 | :delight |
41d290a2 AB |
708 | :bind (([remap execute-extended-command] . counsel-M-x) |
709 | ([remap find-file] . counsel-find-file) | |
057a8382 | 710 | ("C-c b b" . ivy-switch-buffer) |
41d290a2 AB |
711 | ("C-c f ." . counsel-find-file) |
712 | ("C-c f l" . counsel-find-library) | |
2b53c994 | 713 | ("C-c f r" . counsel-recentf) |
057a8382 | 714 | ("C-c x" . counsel-M-x) |
41d290a2 AB |
715 | :map minibuffer-local-map |
716 | ("C-r" . counsel-minibuffer-history)) | |
717 | :config | |
718 | (counsel-mode 1) | |
719 | (defalias 'locate #'counsel-locate)) | |
720 | ||
b57457b2 AB |
721 | (comment |
722 | (use-package helm | |
723 | :commands (helm-M-x helm-mini helm-resume) | |
724 | :bind (("M-x" . helm-M-x) | |
725 | ("M-y" . helm-show-kill-ring) | |
726 | ("C-x b" . helm-mini) | |
727 | ("C-x C-b" . helm-buffers-list) | |
728 | ("C-x C-f" . helm-find-files) | |
729 | ("C-h r" . helm-info-emacs) | |
b57457b2 AB |
730 | ("C-s-r" . helm-resume) |
731 | :map helm-map | |
732 | ("<tab>" . helm-execute-persistent-action) | |
733 | ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals | |
734 | ("C-z" . helm-select-action)) ; List actions | |
735 | :config (helm-mode 1))) | |
736 | ||
33273849 | 737 | (use-feature eshell |
41d290a2 AB |
738 | :defer 0.5 |
739 | :commands eshell | |
740 | :bind ("C-c a s e" . eshell) | |
741 | :config | |
742 | (eval-when-compile (defvar eshell-prompt-regexp)) | |
dca50cf5 | 743 | (defun b/eshell-quit-or-delete-char (arg) |
41d290a2 AB |
744 | (interactive "p") |
745 | (if (and (eolp) (looking-back eshell-prompt-regexp nil)) | |
746 | (eshell-life-is-too-much) | |
747 | (delete-char arg))) | |
748 | ||
dca50cf5 | 749 | (defun b/eshell-clear () |
41d290a2 AB |
750 | (interactive) |
751 | (let ((inhibit-read-only t)) | |
752 | (erase-buffer)) | |
753 | (eshell-send-input)) | |
754 | ||
dca50cf5 | 755 | (defun b/eshell-setup () |
41d290a2 AB |
756 | (make-local-variable 'company-idle-delay) |
757 | (defvar company-idle-delay) | |
758 | (setq company-idle-delay nil) | |
759 | (bind-keys :map eshell-mode-map | |
dca50cf5 AB |
760 | ("C-d" . b/eshell-quit-or-delete-char) |
761 | ("C-S-l" . b/eshell-clear) | |
41d290a2 AB |
762 | ("M-r" . counsel-esh-history) |
763 | ([tab] . company-complete))) | |
764 | ||
dca50cf5 | 765 | :hook (eshell-mode . b/eshell-setup) |
41d290a2 AB |
766 | :custom |
767 | (eshell-hist-ignoredups t) | |
768 | (eshell-input-filter 'eshell-input-filter-initial-space)) | |
769 | ||
33273849 | 770 | (use-feature ibuffer |
41d290a2 | 771 | :bind |
92df6c4f | 772 | (("C-x C-b" . ibuffer) |
41d290a2 AB |
773 | :map ibuffer-mode-map |
774 | ("P" . ibuffer-backward-filter-group) | |
775 | ("N" . ibuffer-forward-filter-group) | |
776 | ("M-p" . ibuffer-do-print) | |
777 | ("M-n" . ibuffer-do-shell-command-pipe-replace)) | |
778 | :config | |
779 | ;; Use human readable Size column instead of original one | |
780 | (define-ibuffer-column size-h | |
781 | (:name "Size" :inline t) | |
782 | (cond | |
783 | ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0))) | |
784 | ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0))) | |
785 | ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0))) | |
786 | (t (format "%8d" (buffer-size))))) | |
787 | :custom | |
788 | (ibuffer-saved-filter-groups | |
789 | '(("default" | |
790 | ("dired" (mode . dired-mode)) | |
791 | ("org" (mode . org-mode)) | |
792 | ("gnus" | |
793 | (or | |
794 | (mode . gnus-group-mode) | |
795 | (mode . gnus-summary-mode) | |
796 | (mode . gnus-article-mode) | |
797 | ;; not really, but... | |
798 | (mode . message-mode))) | |
799 | ("web" | |
800 | (or | |
801 | (mode . web-mode) | |
802 | (mode . css-mode) | |
803 | (mode . scss-mode) | |
804 | (mode . js2-mode))) | |
805 | ("shell" | |
806 | (or | |
807 | (mode . eshell-mode) | |
808 | (mode . shell-mode) | |
809 | (mode . term-mode))) | |
810 | ("programming" | |
811 | (or | |
812 | (mode . python-mode) | |
813 | (mode . c-mode) | |
814 | (mode . c++-mode) | |
815 | (mode . java-mode) | |
816 | (mode . emacs-lisp-mode) | |
817 | (mode . scheme-mode) | |
818 | (mode . haskell-mode) | |
819 | (mode . lean-mode) | |
99473567 | 820 | (mode . go-mode) |
41d290a2 AB |
821 | (mode . alloy-mode))) |
822 | ("tex" | |
823 | (or | |
824 | (mode . bibtex-mode) | |
825 | (mode . latex-mode))) | |
826 | ("emacs" | |
827 | (or | |
828 | (name . "^\\*scratch\\*$") | |
829 | (name . "^\\*Messages\\*$"))) | |
830 | ("erc" (mode . erc-mode))))) | |
831 | (ibuffer-formats | |
832 | '((mark modified read-only locked " " | |
833 | (name 18 18 :left :elide) | |
834 | " " | |
835 | (size-h 9 -1 :right) | |
836 | " " | |
837 | (mode 16 16 :left :elide) | |
838 | " " filename-and-process) | |
839 | (mark " " | |
840 | (name 16 -1) | |
841 | " " filename))) | |
842 | :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default")))) | |
843 | ||
33273849 | 844 | (use-feature outline |
2e81c51a | 845 | :disabled |
41d290a2 | 846 | :hook (prog-mode . outline-minor-mode) |
54209e74 | 847 | :delight (outline-minor-mode " outl") |
41d290a2 AB |
848 | :bind |
849 | (:map | |
850 | outline-minor-mode-map | |
851 | ("<s-tab>" . outline-toggle-children) | |
852 | ("M-p" . outline-previous-visible-heading) | |
853 | ("M-n" . outline-next-visible-heading) | |
dca50cf5 | 854 | :prefix-map b/outline-prefix-map |
ed8c4fa9 | 855 | :prefix "s-O" |
41d290a2 AB |
856 | ("TAB" . outline-toggle-children) |
857 | ("a" . outline-hide-body) | |
858 | ("H" . outline-hide-body) | |
859 | ("S" . outline-show-all) | |
860 | ("h" . outline-hide-subtree) | |
861 | ("s" . outline-show-subtree))) | |
862 | ||
33273849 | 863 | (use-feature ls-lisp |
41d290a2 AB |
864 | :custom (ls-lisp-dirs-first t)) |
865 | ||
33273849 | 866 | (use-feature dired |
41d290a2 AB |
867 | :config |
868 | (setq dired-listing-switches "-alh" | |
869 | ls-lisp-use-insert-directory-program nil) | |
870 | ||
871 | ;; easily diff 2 marked files | |
872 | ;; https://oremacs.com/2017/03/18/dired-ediff/ | |
873 | (defun dired-ediff-files () | |
874 | (interactive) | |
875 | (require 'dired-aux) | |
876 | (defvar ediff-after-quit-hook-internal) | |
877 | (let ((files (dired-get-marked-files)) | |
878 | (wnd (current-window-configuration))) | |
879 | (if (<= (length files) 2) | |
880 | (let ((file1 (car files)) | |
881 | (file2 (if (cdr files) | |
882 | (cadr files) | |
883 | (read-file-name | |
884 | "file: " | |
885 | (dired-dwim-target-directory))))) | |
886 | (if (file-newer-than-file-p file1 file2) | |
887 | (ediff-files file2 file1) | |
888 | (ediff-files file1 file2)) | |
889 | (add-hook 'ediff-after-quit-hook-internal | |
890 | (lambda () | |
891 | (setq ediff-after-quit-hook-internal nil) | |
892 | (set-window-configuration wnd)))) | |
893 | (error "no more than 2 files should be marked")))) | |
06ee5a00 AB |
894 | |
895 | (require 'dired-x) | |
896 | (setq dired-guess-shell-alist-user | |
897 | '(("\\.pdf\\'" "evince" "zathura" "okular") | |
898 | ("\\.doc\\'" "libreoffice") | |
899 | ("\\.docx\\'" "libreoffice") | |
900 | ("\\.ppt\\'" "libreoffice") | |
901 | ("\\.pptx\\'" "libreoffice") | |
902 | ("\\.xls\\'" "libreoffice") | |
903 | ("\\.xlsx\\'" "libreoffice") | |
904 | ("\\.flac\\'" "mpv"))) | |
41d290a2 AB |
905 | :bind (:map dired-mode-map |
906 | ("b" . dired-up-directory) | |
907 | ("e" . dired-ediff-files) | |
908 | ("E" . dired-toggle-read-only) | |
909 | ("\\" . dired-hide-details-mode) | |
910 | ("z" . (lambda () | |
911 | (interactive) | |
dca50cf5 | 912 | (b/dired-start-process "zathura")))) |
41d290a2 AB |
913 | :hook (dired-mode . dired-hide-details-mode)) |
914 | ||
33273849 | 915 | (use-feature help |
41d290a2 AB |
916 | :config |
917 | (temp-buffer-resize-mode) | |
918 | (setq help-window-select t)) | |
919 | ||
33273849 | 920 | (use-feature tramp |
41d290a2 AB |
921 | :config |
922 | (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:")) | |
923 | (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)) | |
924 | (add-to-list 'tramp-default-proxies-alist | |
925 | (list (regexp-quote (system-name)) nil nil))) | |
926 | ||
927 | (use-package dash | |
928 | :config (dash-enable-font-lock)) | |
929 | ||
33273849 | 930 | (use-feature doc-view |
41d290a2 AB |
931 | :bind (:map doc-view-mode-map |
932 | ("M-RET" . image-previous-line))) | |
933 | ||
b57457b2 AB |
934 | \f |
935 | ;;; Editing | |
936 | ||
937 | ;; highlight uncommitted changes in the left fringe | |
41d290a2 | 938 | (use-package diff-hl |
df1c9bc8 | 939 | :defer 0.6 |
41d290a2 AB |
940 | :config |
941 | (setq diff-hl-draw-borders nil) | |
942 | (global-diff-hl-mode) | |
943 | :hook (magit-post-refresh . diff-hl-magit-post-refresh)) | |
944 | ||
b57457b2 | 945 | ;; display Lisp objects at point in the echo area |
33273849 | 946 | (use-feature eldoc |
41d290a2 | 947 | :when (version< "25" emacs-version) |
54209e74 | 948 | :delight " eldoc" |
41d290a2 AB |
949 | :config (global-eldoc-mode)) |
950 | ||
b57457b2 | 951 | ;; highlight matching parens |
33273849 | 952 | (use-feature paren |
41d290a2 AB |
953 | :demand |
954 | :config (show-paren-mode)) | |
955 | ||
33273849 | 956 | (use-feature elec-pair |
40eddfea AB |
957 | :demand |
958 | :config (electric-pair-mode)) | |
959 | ||
33273849 | 960 | (use-feature simple |
54209e74 | 961 | :delight (auto-fill-function " fill") |
41d290a2 AB |
962 | :config (column-number-mode)) |
963 | ||
b57457b2 | 964 | ;; save minibuffer history |
33273849 | 965 | (use-feature savehist |
1060413b | 966 | :demand |
dca50cf5 AB |
967 | :config |
968 | (savehist-mode) | |
1060413b | 969 | (add-to-list 'savehist-additional-variables 'kill-ring)) |
41d290a2 | 970 | |
b57457b2 | 971 | ;; automatically save place in files |
33273849 | 972 | (use-feature saveplace |
41d290a2 | 973 | :when (version< "25" emacs-version) |
1060413b | 974 | :config (save-place-mode)) |
41d290a2 | 975 | |
33273849 | 976 | (use-feature prog-mode |
41d290a2 AB |
977 | :config (global-prettify-symbols-mode) |
978 | (defun indicate-buffer-boundaries-left () | |
979 | (setq indicate-buffer-boundaries 'left)) | |
980 | (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left)) | |
981 | ||
33273849 | 982 | (use-feature text-mode |
54209e74 | 983 | :hook (text-mode . indicate-buffer-boundaries-left)) |
41d290a2 | 984 | |
33273849 | 985 | (use-feature conf-mode |
300b7363 AB |
986 | :mode "\\.*rc$") |
987 | ||
33273849 | 988 | (use-feature sh-mode |
300b7363 AB |
989 | :mode "\\.bashrc$") |
990 | ||
41d290a2 AB |
991 | (use-package company |
992 | :defer 0.6 | |
0c53f5ae | 993 | :delight " comp" |
41d290a2 AB |
994 | :bind |
995 | (:map company-active-map | |
996 | ([tab] . company-complete-common-or-cycle) | |
997 | ([escape] . company-abort)) | |
998 | :custom | |
999 | (company-minimum-prefix-length 1) | |
1000 | (company-selection-wrap-around t) | |
1001 | (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]") | |
1002 | (company-dabbrev-downcase nil) | |
1003 | (company-dabbrev-ignore-case nil) | |
1004 | :config | |
1005 | (global-company-mode t)) | |
1006 | ||
1007 | (use-package flycheck | |
1008 | :defer 0.6 | |
1009 | :hook (prog-mode . flycheck-mode) | |
1010 | :bind | |
1011 | (:map flycheck-mode-map | |
1012 | ("M-P" . flycheck-previous-error) | |
1013 | ("M-N" . flycheck-next-error)) | |
1014 | :config | |
1015 | ;; Use the load-path from running Emacs when checking elisp files | |
1016 | (setq flycheck-emacs-lisp-load-path 'inherit) | |
1017 | ||
1018 | ;; Only flycheck when I actually save the buffer | |
54209e74 AB |
1019 | (setq flycheck-check-syntax-automatically '(mode-enabled save)) |
1020 | :custom (flycheck-mode-line-prefix "flyc")) | |
1021 | ||
33273849 | 1022 | (use-feature flyspell |
54209e74 | 1023 | :delight " flysp") |
41d290a2 AB |
1024 | |
1025 | ;; http://endlessparentheses.com/ispell-and-apostrophes.html | |
33273849 | 1026 | (use-feature ispell |
41d290a2 AB |
1027 | :defer 0.6 |
1028 | :config | |
1029 | ;; ’ can be part of a word | |
1030 | (setq ispell-local-dictionary-alist | |
1031 | `((nil "[[:alpha:]]" "[^[:alpha:]]" | |
b1ed9ee8 AB |
1032 | "['\x2019]" nil ("-B") nil utf-8)) |
1033 | ispell-program-name (executable-find "hunspell")) | |
41d290a2 AB |
1034 | ;; don't send ’ to the subprocess |
1035 | (defun endless/replace-apostrophe (args) | |
1036 | (cons (replace-regexp-in-string | |
1037 | "’" "'" (car args)) | |
1038 | (cdr args))) | |
1039 | (advice-add #'ispell-send-string :filter-args | |
1040 | #'endless/replace-apostrophe) | |
1041 | ||
1042 | ;; convert ' back to ’ from the subprocess | |
1043 | (defun endless/replace-quote (args) | |
1044 | (if (not (derived-mode-p 'org-mode)) | |
1045 | args | |
1046 | (cons (replace-regexp-in-string | |
1047 | "'" "’" (car args)) | |
1048 | (cdr args)))) | |
1049 | (advice-add #'ispell-parse-output :filter-args | |
1050 | #'endless/replace-quote)) | |
1051 | ||
33273849 | 1052 | (use-feature abbrev |
54209e74 | 1053 | :delight " abbr" |
1060413b | 1054 | :hook (text-mode . abbrev-mode)) |
54209e74 | 1055 | |
b57457b2 AB |
1056 | \f |
1057 | ;;; Programming modes | |
1058 | ||
33273849 | 1059 | (use-feature lisp-mode |
41d290a2 | 1060 | :config |
41d290a2 AB |
1061 | (defun indent-spaces-mode () |
1062 | (setq indent-tabs-mode nil)) | |
1063 | (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode)) | |
1064 | ||
33273849 | 1065 | (use-feature reveal |
54209e74 AB |
1066 | :delight (reveal-mode " reveal") |
1067 | :hook (emacs-lisp-mode . reveal-mode)) | |
1068 | ||
33273849 | 1069 | (use-feature elisp-mode |
54209e74 AB |
1070 | :delight (emacs-lisp-mode "Elisp" :major)) |
1071 | ||
dca50cf5 | 1072 | |
33273849 AB |
1073 | (use-package alloy-mode |
1074 | :straight (:host github :repo "dwwmmn/alloy-mode") | |
1075 | :mode "\\.als\\'" | |
1076 | :config (setq alloy-basic-offset 2)) | |
1077 | ||
1078 | (eval-when-compile (defvar lean-mode-map)) | |
1079 | (use-package lean-mode | |
1080 | :straight (:host github :repo "leanprover/lean-mode" | |
1081 | :fork (:repo "notbandali/lean-mode" :branch "remove-cl")) | |
1082 | :defer 0.4 | |
1083 | :bind (:map lean-mode-map | |
1084 | ("S-SPC" . company-complete)) | |
1085 | :config | |
1086 | (require 'lean-input) | |
1087 | (setq default-input-method "Lean" | |
1088 | lean-input-tweak-all '(lean-input-compose | |
1089 | (lean-input-prepend "/") | |
1090 | (lean-input-nonempty)) | |
1091 | lean-input-user-translations '(("/" "/"))) | |
1092 | (lean-input-setup)) | |
1093 | ||
1094 | (comment | |
dca50cf5 AB |
1095 | (use-package proof-site ; for Coq |
1096 | :straight proof-general) | |
1097 | ||
dca50cf5 AB |
1098 | (use-package haskell-mode |
1099 | :config | |
1100 | (setq haskell-indentation-layout-offset 4 | |
1101 | haskell-indentation-left-offset 4 | |
1102 | flycheck-checker 'haskell-hlint | |
1103 | flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc))) | |
1104 | ||
1105 | (use-package dante | |
1106 | :after haskell-mode | |
1107 | :commands dante-mode | |
1108 | :hook (haskell-mode . dante-mode)) | |
1109 | ||
1110 | (use-package hlint-refactor | |
1111 | :after haskell-mode | |
1112 | :bind (:map hlint-refactor-mode-map | |
1113 | ("C-c l b" . hlint-refactor-refactor-buffer) | |
1114 | ("C-c l r" . hlint-refactor-refactor-at-point)) | |
1115 | :hook (haskell-mode . hlint-refactor-mode)) | |
1116 | ||
1117 | (use-package flycheck-haskell | |
1118 | :after haskell-mode) | |
1119 | ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el | |
1120 | ) | |
41d290a2 | 1121 | |
33273849 | 1122 | (use-feature sgml-mode |
41d290a2 AB |
1123 | :config |
1124 | (setq sgml-basic-offset 2)) | |
1125 | ||
33273849 | 1126 | (use-feature css-mode |
41d290a2 AB |
1127 | :config |
1128 | (setq css-indent-offset 2)) | |
1129 | ||
1130 | (use-package web-mode | |
1131 | :mode "\\.html\\'" | |
1132 | :config | |
dca50cf5 | 1133 | (b/setq-every 2 |
41d290a2 AB |
1134 | web-mode-code-indent-offset |
1135 | web-mode-css-indent-offset | |
1136 | web-mode-markup-indent-offset)) | |
1137 | ||
1138 | (use-package emmet-mode | |
1139 | :after (:any web-mode css-mode sgml-mode) | |
1140 | :bind* (("C-)" . emmet-next-edit-point) | |
1141 | ("C-(" . emmet-prev-edit-point)) | |
1142 | :config | |
1143 | (unbind-key "C-j" emmet-mode-keymap) | |
1144 | (setq emmet-move-cursor-between-quotes t) | |
1145 | :hook (web-mode css-mode html-mode sgml-mode)) | |
1146 | ||
b57457b2 AB |
1147 | (comment |
1148 | (use-package meghanada | |
1149 | :bind | |
1150 | (:map meghanada-mode-map | |
1151 | (("C-M-o" . meghanada-optimize-import) | |
1152 | ("C-M-t" . meghanada-import-all))) | |
1153 | :hook (java-mode . meghanada-mode))) | |
1154 | ||
1155 | (comment | |
1156 | (use-package treemacs | |
1157 | :config (setq treemacs-never-persist t)) | |
1158 | ||
1159 | (use-package yasnippet | |
1160 | :config | |
1161 | ;; (yas-global-mode) | |
1162 | ) | |
1163 | ||
1164 | (use-package lsp-mode | |
1165 | :init (setq lsp-eldoc-render-all nil | |
1166 | lsp-highlight-symbol-at-point nil) | |
1167 | ) | |
1168 | ||
1169 | (use-package hydra) | |
1170 | ||
1171 | (use-package company-lsp | |
1172 | :after company | |
1173 | :config | |
1174 | (setq company-lsp-cache-candidates t | |
1175 | company-lsp-async t)) | |
1176 | ||
1177 | (use-package lsp-ui | |
1178 | :config | |
1179 | (setq lsp-ui-sideline-update-mode 'point)) | |
1180 | ||
1181 | (use-package lsp-java | |
1182 | :config | |
1183 | (add-hook 'java-mode-hook | |
1184 | (lambda () | |
1185 | (setq-local company-backends (list 'company-lsp)))) | |
1186 | ||
1187 | (add-hook 'java-mode-hook 'lsp-java-enable) | |
1188 | (add-hook 'java-mode-hook 'flycheck-mode) | |
1189 | (add-hook 'java-mode-hook 'company-mode) | |
1190 | (add-hook 'java-mode-hook 'lsp-ui-mode)) | |
1191 | ||
1192 | (use-package dap-mode | |
1193 | :after lsp-mode | |
1194 | :config | |
1195 | (dap-mode t) | |
1196 | (dap-ui-mode t)) | |
1197 | ||
1198 | (use-package dap-java | |
1199 | :after (lsp-java)) | |
1200 | ||
1201 | (use-package lsp-java-treemacs | |
1202 | :after (treemacs))) | |
1203 | ||
1204 | (comment | |
1205 | (use-package eclim | |
1206 | :bind (:map eclim-mode-map ("S-SPC" . company-complete)) | |
1207 | :hook ((java-mode . eclim-mode) | |
1208 | (eclim-mode . (lambda () | |
1209 | (make-local-variable 'company-idle-delay) | |
1210 | (defvar company-idle-delay) | |
1211 | ;; (setq company-idle-delay 0.7) | |
1212 | (setq company-idle-delay nil)))) | |
1213 | :custom | |
1214 | (eclim-auto-save nil) | |
1215 | ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp") | |
1216 | (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim") | |
1217 | (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse")))) | |
1218 | ||
1060413b | 1219 | (use-package geiser) |
41d290a2 | 1220 | |
33273849 | 1221 | (use-feature geiser-guile |
41d290a2 AB |
1222 | :config |
1223 | (setq geiser-guile-load-path "~/src/git/guix")) | |
1224 | ||
1225 | (use-package guix) | |
1226 | ||
b57457b2 AB |
1227 | (comment |
1228 | (use-package auctex | |
1229 | :custom | |
1230 | (font-latex-fontify-sectioning 'color))) | |
1231 | ||
99473567 AB |
1232 | (use-package go-mode) |
1233 | ||
f704f564 AB |
1234 | (use-package po-mode |
1235 | :hook | |
1236 | (po-mode . (lambda () (run-with-timer 0.1 nil 'View-exit)))) | |
1237 | ||
33273849 | 1238 | (use-feature tex-mode |
748bd8ac AB |
1239 | :config |
1240 | (cl-delete-if | |
1241 | (lambda (p) (string-match "^---?" (car p))) | |
0758ec38 AB |
1242 | tex--prettify-symbols-alist) |
1243 | :hook ((tex-mode . auto-fill-mode) | |
1244 | (tex-mode . flyspell-mode) | |
1245 | (tex-mode . (lambda () (electric-indent-local-mode -1))))) | |
748bd8ac | 1246 | |
b57457b2 AB |
1247 | \f |
1248 | ;;; Theme | |
1249 | ||
dca50cf5 AB |
1250 | (add-to-list 'custom-theme-load-path |
1251 | (expand-file-name | |
1252 | (convert-standard-filename "lisp") user-emacs-directory)) | |
b57457b2 AB |
1253 | (load-theme 'tangomod t) |
1254 | ||
1255 | (use-package smart-mode-line | |
1256 | :commands (sml/apply-theme) | |
1257 | :demand | |
1258 | :config | |
26906e22 AB |
1259 | (sml/setup) |
1260 | (smart-mode-line-enable)) | |
b57457b2 | 1261 | |
33273849 | 1262 | (use-package doom-themes) |
b57457b2 | 1263 | |
dca50cf5 | 1264 | (defvar b/org-mode-font-lock-keywords |
b57457b2 AB |
1265 | '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)" |
1266 | (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive | |
1267 | (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind | |
1268 | (4 '(:foreground "#c5c8c6") t)))) ; title | |
1269 | ||
dca50cf5 | 1270 | (defun b/lights-on () |
b57457b2 AB |
1271 | "Enable my favourite light theme." |
1272 | (interactive) | |
1273 | (mapc #'disable-theme custom-enabled-themes) | |
1274 | (load-theme 'tangomod t) | |
1275 | (sml/apply-theme 'automatic) | |
1276 | (font-lock-remove-keywords | |
dca50cf5 | 1277 | 'org-mode b/org-mode-font-lock-keywords)) |
b57457b2 | 1278 | |
dca50cf5 | 1279 | (defun b/lights-off () |
b57457b2 AB |
1280 | "Go dark." |
1281 | (interactive) | |
1282 | (mapc #'disable-theme custom-enabled-themes) | |
dca50cf5 | 1283 | ;; (load-theme 'doom-tomorrow-night t) |
b57457b2 AB |
1284 | (sml/apply-theme 'automatic) |
1285 | (font-lock-add-keywords | |
dca50cf5 | 1286 | 'org-mode b/org-mode-font-lock-keywords t)) |
b57457b2 AB |
1287 | |
1288 | (bind-keys | |
2e81c51a AB |
1289 | ("C-c t d" . b/lights-off) |
1290 | ("C-c t l" . b/lights-on)) | |
b57457b2 AB |
1291 | |
1292 | \f | |
1293 | ;;; Emacs enhancements & auxiliary packages | |
1294 | ||
dca50cf5 | 1295 | (use-package man |
41d290a2 AB |
1296 | :config (setq Man-width 80)) |
1297 | ||
1298 | (use-package which-key | |
1299 | :defer 0.4 | |
54209e74 | 1300 | :delight |
41d290a2 AB |
1301 | :config |
1302 | (which-key-add-key-based-replacements | |
1303 | ;; prefixes for global prefixes and minor modes | |
1304 | "C-c @" "outline" | |
1305 | "C-c !" "flycheck" | |
1306 | "C-c 8" "typo" | |
1307 | "C-c 8 -" "typo/dashes" | |
1308 | "C-c 8 <" "typo/left-brackets" | |
1309 | "C-c 8 >" "typo/right-brackets" | |
1310 | "C-x 8" "unicode" | |
1311 | "C-x a" "abbrev/expand" | |
1312 | "C-x r" "rectangle/register/bookmark" | |
1313 | "C-x v" "version control" | |
1314 | ;; prefixes for my personal bindings | |
1315 | "C-c a" "applications" | |
1316 | "C-c a e" "erc" | |
1317 | "C-c a o" "org" | |
1318 | "C-c a s" "shells" | |
2e81c51a | 1319 | "C-c b" "buffers" |
41d290a2 AB |
1320 | "C-c c" "compile-and-comments" |
1321 | "C-c e" "eval" | |
1322 | "C-c f" "files" | |
1323 | "C-c F" "frames" | |
ef6c487c | 1324 | "C-c g" "magit" |
41d290a2 AB |
1325 | "C-S-h" "help(ful)" |
1326 | "C-c m" "multiple-cursors" | |
1327 | "C-c P" "projectile" | |
1328 | "C-c P s" "projectile/search" | |
1329 | "C-c P x" "projectile/execute" | |
1330 | "C-c P 4" "projectile/other-window" | |
1331 | "C-c q" "boxquote" | |
2e81c51a AB |
1332 | "C-c t" "themes" |
1333 | ;; "s-O" "outline" | |
ef6c487c | 1334 | ) |
41d290a2 AB |
1335 | |
1336 | ;; prefixes for major modes | |
1337 | (which-key-add-major-mode-key-based-replacements 'message-mode | |
1338 | "C-c f" "footnote") | |
1339 | (which-key-add-major-mode-key-based-replacements 'org-mode | |
1340 | "C-c C-v" "org-babel") | |
1341 | (which-key-add-major-mode-key-based-replacements 'web-mode | |
1342 | "C-c C-a" "web/attributes" | |
1343 | "C-c C-b" "web/blocks" | |
1344 | "C-c C-d" "web/dom" | |
1345 | "C-c C-e" "web/element" | |
1346 | "C-c C-t" "web/tags") | |
1347 | ||
1348 | (which-key-mode) | |
1349 | :custom | |
1350 | (which-key-add-column-padding 5) | |
1351 | (which-key-max-description-length 32)) | |
1352 | ||
b57457b2 | 1353 | (use-package crux ; results in Waiting for git... [2 times] |
41d290a2 | 1354 | :defer 0.4 |
2a816b71 | 1355 | :bind (("C-c d" . crux-duplicate-current-line-or-region) |
41d290a2 AB |
1356 | ("C-c D" . crux-duplicate-and-comment-current-line-or-region) |
1357 | ("C-c f c" . crux-copy-file-preserve-attributes) | |
1358 | ("C-c f d" . crux-delete-file-and-buffer) | |
1359 | ("C-c f r" . crux-rename-file-and-buffer) | |
1360 | ("C-c j" . crux-top-join-line) | |
1361 | ("C-S-j" . crux-top-join-line))) | |
1362 | ||
5b10d879 AB |
1363 | (use-package mwim |
1364 | :bind (("C-a" . mwim-beginning-of-code-or-line) | |
1365 | ("C-e" . mwim-end-of-code-or-line) | |
1366 | ("<home>" . mwim-beginning-of-line-or-code) | |
1367 | ("<end>" . mwim-end-of-line-or-code))) | |
41d290a2 AB |
1368 | |
1369 | (use-package projectile | |
26906e22 | 1370 | :defer 0.5 |
41d290a2 AB |
1371 | :bind-keymap ("C-c P" . projectile-command-map) |
1372 | :config | |
1373 | (projectile-mode) | |
1374 | ||
dca50cf5 | 1375 | (defun b/projectile-mode-line-fun () |
26906e22 AB |
1376 | "Report project name and type in the modeline." |
1377 | (let ((project-name (projectile-project-name)) | |
1378 | (project-type (projectile-project-type))) | |
1379 | (format "%s%s" | |
1380 | projectile-mode-line-prefix | |
1381 | (if project-type | |
1382 | (format ":%s" project-type) | |
1383 | "")))) | |
dca50cf5 | 1384 | (setq projectile-mode-line-function 'b/projectile-mode-line-fun) |
26906e22 | 1385 | |
41d290a2 AB |
1386 | (defun my-projectile-invalidate-cache (&rest _args) |
1387 | ;; ignore the args to `magit-checkout' | |
1388 | (projectile-invalidate-cache nil)) | |
1389 | ||
1390 | (eval-after-load 'magit-branch | |
1391 | '(progn | |
1392 | (advice-add 'magit-checkout | |
1393 | :after #'my-projectile-invalidate-cache) | |
1394 | (advice-add 'magit-branch-and-checkout | |
1395 | :after #'my-projectile-invalidate-cache))) | |
54209e74 AB |
1396 | :custom |
1397 | (projectile-completion-system 'ivy) | |
1398 | (projectile-mode-line-prefix " proj")) | |
41d290a2 AB |
1399 | |
1400 | (use-package helpful | |
1401 | :defer 0.6 | |
1402 | :bind | |
1403 | (("C-S-h c" . helpful-command) | |
1404 | ("C-S-h f" . helpful-callable) ; helpful-function | |
1405 | ("C-S-h v" . helpful-variable) | |
1406 | ("C-S-h k" . helpful-key) | |
1407 | ("C-S-h p" . helpful-at-point))) | |
1408 | ||
5b10d879 AB |
1409 | (use-package unkillable-scratch |
1410 | :defer 0.6 | |
1411 | :config | |
1412 | (unkillable-scratch 1) | |
1413 | :custom | |
1414 | (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$"))) | |
41d290a2 | 1415 | |
5b10d879 AB |
1416 | ;; ,---- |
1417 | ;; | make pretty boxed quotes like this | |
1418 | ;; `---- | |
1419 | (use-package boxquote | |
1420 | :defer 0.6 | |
1421 | :bind | |
1422 | (:prefix-map b/boxquote-prefix-map | |
1423 | :prefix "C-c q" | |
1424 | ("b" . boxquote-buffer) | |
1425 | ("B" . boxquote-insert-buffer) | |
1426 | ("d" . boxquote-defun) | |
1427 | ("F" . boxquote-insert-file) | |
1428 | ("hf" . boxquote-describe-function) | |
1429 | ("hk" . boxquote-describe-key) | |
1430 | ("hv" . boxquote-describe-variable) | |
1431 | ("hw" . boxquote-where-is) | |
1432 | ("k" . boxquote-kill) | |
1433 | ("p" . boxquote-paragraph) | |
1434 | ("q" . boxquote-boxquote) | |
1435 | ("r" . boxquote-region) | |
1436 | ("s" . boxquote-shell-command) | |
1437 | ("t" . boxquote-text) | |
1438 | ("T" . boxquote-title) | |
1439 | ("u" . boxquote-unbox) | |
1440 | ("U" . boxquote-unbox-region) | |
1441 | ("y" . boxquote-yank) | |
1442 | ("M-q" . boxquote-fill-paragraph) | |
1443 | ("M-w" . boxquote-kill-ring-save))) | |
41d290a2 AB |
1444 | |
1445 | (use-package orgalist | |
b57457b2 | 1446 | ;; http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00007.html |
41d290a2 AB |
1447 | :disabled t |
1448 | :after message | |
1449 | :hook (message-mode . orgalist-mode)) | |
1450 | ||
b57457b2 | 1451 | ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹› |
41d290a2 AB |
1452 | (use-package typo |
1453 | :defer 0.5 | |
54209e74 | 1454 | :delight " typo" |
41d290a2 AB |
1455 | :config |
1456 | (typo-global-mode 1) | |
9a5905d6 AB |
1457 | :hook (((text-mode erc-mode) . typo-mode) |
1458 | (tex-mode . (lambda ()(typo-mode -1))))) | |
41d290a2 | 1459 | |
b57457b2 | 1460 | ;; highlight TODOs in buffers |
41d290a2 AB |
1461 | (use-package hl-todo |
1462 | :defer 0.5 | |
1463 | :config | |
1464 | (global-hl-todo-mode)) | |
1465 | ||
5b10d879 AB |
1466 | (use-package shrink-path |
1467 | :defer 0.5 | |
1468 | :after eshell | |
1469 | :config | |
1470 | (defvar user-@-host (concat (user-login-name) "@" (system-name) " ")) | |
1471 | (defun +eshell/prompt () | |
1472 | (let ((base/dir (shrink-path-prompt default-directory))) | |
1473 | (concat (propertize user-@-host 'face 'default) | |
1474 | (propertize (car base/dir) | |
1475 | 'face 'font-lock-comment-face) | |
1476 | (propertize (cdr base/dir) | |
1477 | 'face 'font-lock-constant-face) | |
1478 | (propertize "> " 'face 'default)))) | |
1479 | (setq eshell-prompt-regexp (concat user-@-host ".*> ") | |
1480 | eshell-prompt-function #'+eshell/prompt)) | |
41d290a2 AB |
1481 | |
1482 | (use-package eshell-up | |
1483 | :after eshell | |
1484 | :commands eshell-up) | |
1485 | ||
1486 | (use-package multi-term | |
1487 | :defer 0.6 | |
fb078e63 AB |
1488 | :bind (("C-c a s m m" . multi-term) |
1489 | ("C-c a s m d" . multi-term-dedicated-toggle) | |
1490 | ("C-c a s m p" . multi-term-prev) | |
1491 | ("C-c a s m n" . multi-term-next) | |
41d290a2 | 1492 | :map term-mode-map |
0af1e91a | 1493 | ("C-c C-j" . term-char-mode)) |
41d290a2 | 1494 | :config |
96c704d7 AB |
1495 | (setq multi-term-program "screen" |
1496 | multi-term-program-switches (concat "-c" | |
1497 | (getenv "XDG_CONFIG_HOME") | |
1498 | "/screen/screenrc") | |
41d290a2 AB |
1499 | ;; TODO: add separate bindings for connecting to existing |
1500 | ;; session vs. always creating a new one | |
1501 | multi-term-dedicated-select-after-open-p t | |
1502 | multi-term-dedicated-window-height 20 | |
1503 | multi-term-dedicated-max-window-height 30 | |
1504 | term-bind-key-alist | |
1505 | '(("C-c C-c" . term-interrupt-subjob) | |
1506 | ("C-c C-e" . term-send-esc) | |
0af1e91a | 1507 | ("C-c C-j" . term-line-mode) |
41d290a2 | 1508 | ("C-k" . kill-line) |
fb078e63 AB |
1509 | ;; ("C-y" . term-paste) |
1510 | ("C-y" . term-send-raw) | |
41d290a2 AB |
1511 | ("M-f" . term-send-forward-word) |
1512 | ("M-b" . term-send-backward-word) | |
1513 | ("M-p" . term-send-up) | |
1514 | ("M-n" . term-send-down) | |
fb078e63 AB |
1515 | ("M-j" . term-send-raw-meta) |
1516 | ("M-y" . term-send-raw-meta) | |
1517 | ("M-/" . term-send-raw-meta) | |
1518 | ("M-0" . term-send-raw-meta) | |
1519 | ("M-1" . term-send-raw-meta) | |
1520 | ("M-2" . term-send-raw-meta) | |
1521 | ("M-3" . term-send-raw-meta) | |
1522 | ("M-4" . term-send-raw-meta) | |
1523 | ("M-5" . term-send-raw-meta) | |
1524 | ("M-6" . term-send-raw-meta) | |
1525 | ("M-7" . term-send-raw-meta) | |
1526 | ("M-8" . term-send-raw-meta) | |
1527 | ("M-9" . term-send-raw-meta) | |
41d290a2 AB |
1528 | ("<C-backspace>" . term-send-backward-kill-word) |
1529 | ("<M-DEL>" . term-send-backward-kill-word) | |
1530 | ("M-d" . term-send-delete-word) | |
1531 | ("M-," . term-send-raw) | |
1532 | ("M-." . comint-dynamic-complete)) | |
1533 | term-unbind-key-alist | |
fb078e63 AB |
1534 | '("C-z" "C-x" "C-c" "C-h" |
1535 | ;; "C-y" | |
1536 | "<ESC>"))) | |
41d290a2 AB |
1537 | |
1538 | (use-package page-break-lines | |
b57457b2 | 1539 | :defer 0.5 |
54209e74 | 1540 | :delight " pgln" |
2f5d8190 AB |
1541 | :custom |
1542 | (page-break-lines-max-width fill-column) | |
41d290a2 AB |
1543 | :config |
1544 | (global-page-break-lines-mode)) | |
1545 | ||
1546 | (use-package expand-region | |
1547 | :bind ("C-=" . er/expand-region)) | |
1548 | ||
1549 | (use-package multiple-cursors | |
1550 | :bind | |
1551 | (("C-S-<mouse-1>" . mc/add-cursor-on-click) | |
dca50cf5 | 1552 | (:prefix-map b/mc-prefix-map |
41d290a2 AB |
1553 | :prefix "C-c m" |
1554 | ("c" . mc/edit-lines) | |
1555 | ("n" . mc/mark-next-like-this) | |
1556 | ("p" . mc/mark-previous-like-this) | |
1060413b | 1557 | ("a" . mc/mark-all-like-this)))) |
41d290a2 | 1558 | |
dca50cf5 AB |
1559 | (comment |
1560 | ;; TODO | |
1561 | (use-package forge | |
1562 | :after magit | |
1563 | :demand)) | |
41d290a2 AB |
1564 | |
1565 | (use-package yasnippet | |
1566 | :defer 0.6 | |
1567 | :config | |
1568 | (defconst yas-verbosity-cur yas-verbosity) | |
1569 | (setq yas-verbosity 2) | |
476f6228 | 1570 | (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t) |
41d290a2 AB |
1571 | (yas-reload-all) |
1572 | (setq yas-verbosity yas-verbosity-cur) | |
5b185efa AB |
1573 | |
1574 | (defun b/yas--maybe-expand-key-filter (cmd) | |
1575 | (when (and (yas--maybe-expand-key-filter cmd) | |
1576 | (not (bound-and-true-p git-commit-mode))) | |
1577 | cmd)) | |
1578 | (defconst b/yas-maybe-expand | |
1579 | '(menu-item "" yas-expand :filter b/yas--maybe-expand-key-filter)) | |
1580 | (define-key yas-minor-mode-map | |
1581 | (kbd "SPC") b/yas-maybe-expand) | |
1582 | ||
476f6228 | 1583 | (yas-global-mode)) |
41d290a2 | 1584 | |
33273849 AB |
1585 | (use-package debbugs |
1586 | :straight (debbugs | |
1587 | :host github | |
1588 | :repo "emacs-straight/debbugs" | |
1589 | :files (:defaults "Debbugs.wsdl"))) | |
41d290a2 AB |
1590 | |
1591 | (use-package org-ref | |
1592 | :init | |
dca50cf5 | 1593 | (b/setq-every '("~/usr/org/references.bib") |
41d290a2 AB |
1594 | reftex-default-bibliography |
1595 | org-ref-default-bibliography) | |
1596 | (setq | |
1597 | org-ref-bibliography-notes "~/usr/org/notes.org" | |
1598 | org-ref-pdf-directory "~/usr/org/bibtex-pdfs/")) | |
1599 | ||
41d290a2 AB |
1600 | (use-package alert |
1601 | :commands (alert) | |
83a17ce5 | 1602 | :init (setq alert-default-style 'notifications)) |
41d290a2 | 1603 | |
2f5d8190 AB |
1604 | ;; (use-package fill-column-indicator) |
1605 | ||
b46ed2ba AB |
1606 | (use-package emojify |
1607 | :hook (erc-mode . emojify-mode)) | |
1608 | ||
33273849 | 1609 | (use-feature window |
ed8c4fa9 | 1610 | :bind |
2e81c51a AB |
1611 | (("C-c w <right>" . split-window-right) |
1612 | ("C-c w <down>" . split-window-below) | |
1613 | ("C-c w s l" . split-window-right) | |
1614 | ("C-c w s j" . split-window-below) | |
1615 | ("C-c w q" . quit-window)) | |
92df6c4f AB |
1616 | :custom |
1617 | (split-width-threshold 150)) | |
ed8c4fa9 | 1618 | |
33273849 | 1619 | (use-feature windmove |
ed8c4fa9 AB |
1620 | :defer 0.6 |
1621 | :bind | |
2e81c51a AB |
1622 | (("C-c w h" . windmove-left) |
1623 | ("C-c w j" . windmove-down) | |
1624 | ("C-c w k" . windmove-up) | |
1625 | ("C-c w l" . windmove-right) | |
1626 | ("C-c w H" . windmove-swap-states-left) | |
1627 | ("C-c w J" . windmove-swap-states-down) | |
1628 | ("C-c w K" . windmove-swap-states-up) | |
1629 | ("C-c w L" . windmove-swap-states-right))) | |
ed8c4fa9 | 1630 | |
05068e71 AB |
1631 | (use-package pass |
1632 | :commands pass | |
1633 | :bind ("C-c a p" . pass) | |
1634 | :hook (pass-mode . View-exit)) | |
1635 | ||
b188e798 AB |
1636 | (use-package pdf-tools |
1637 | :defer 0.5 | |
1638 | :bind (:map pdf-view-mode-map | |
822ac360 AB |
1639 | ("<XF86Back>" . pdf-history-backward) |
1640 | ("<XF86Forward>" . pdf-history-forward) | |
1641 | ("M-RET" . image-previous-line)) | |
1642 | :config (pdf-tools-install nil t) | |
1643 | :custom (pdf-view-resize-factor 1.05)) | |
b188e798 | 1644 | |
9de75957 AB |
1645 | (use-package biblio) |
1646 | ||
33273849 | 1647 | (use-feature reftex |
9a5ffb33 AB |
1648 | :hook (latex-mode . reftex-mode)) |
1649 | ||
33273849 | 1650 | (use-feature reftex-cite |
9a5ffb33 AB |
1651 | :after reftex |
1652 | :disabled ; enable to disable | |
1653 | ; reftex-cite's default choice | |
1654 | ; of previous word | |
1655 | :config | |
1656 | (defun reftex-get-bibkey-default () | |
1657 | "If the cursor is in a citation macro, return the word before the macro." | |
1658 | (let* ((macro (reftex-what-macro 1))) | |
1659 | (save-excursion | |
1660 | (when (and macro (string-match "cite" (car macro))) | |
1661 | (goto-char (cdr macro))) | |
1662 | (reftex-this-word))))) | |
1663 | ||
1060413b AB |
1664 | (use-feature files |
1665 | :custom (auto-save-file-name-transforms | |
1666 | `((".*" ,(b/var "auto-save/") t)))) | |
1667 | ||
b57457b2 AB |
1668 | \f |
1669 | ;;; Email (with Gnus) | |
1670 | ||
dca50cf5 | 1671 | (defvar b/maildir (expand-file-name "~/mail/")) |
41d290a2 | 1672 | (with-eval-after-load 'recentf |
dca50cf5 | 1673 | (add-to-list 'recentf-exclude b/maildir)) |
41d290a2 AB |
1674 | |
1675 | (setq | |
dca50cf5 | 1676 | b/gnus-init-file (b/etc "gnus") |
41d290a2 AB |
1677 | mail-user-agent 'gnus-user-agent |
1678 | read-mail-command 'gnus) | |
1679 | ||
33273849 | 1680 | (use-feature gnus |
2e81c51a AB |
1681 | :bind (("s-m" . gnus) |
1682 | ("s-M" . gnus-unplugged) | |
1683 | ("C-c a m" . gnus) | |
1684 | ("C-c a M" . gnus-unplugged)) | |
41d290a2 AB |
1685 | :init |
1686 | (setq | |
1687 | gnus-select-method '(nnnil "") | |
1688 | gnus-secondary-select-methods | |
d4cc5497 | 1689 | '((nnimap "shemshak" |
41d290a2 AB |
1690 | (nnimap-stream plain) |
1691 | (nnimap-address "127.0.0.1") | |
1692 | (nnimap-server-port 143) | |
1693 | (nnimap-authenticator plain) | |
4ed3a945 | 1694 | (nnimap-user "amin@shemshak.local")) |
2e9074a4 AB |
1695 | (nnimap "gnu" |
1696 | (nnimap-stream plain) | |
1697 | (nnimap-address "127.0.0.1") | |
1698 | (nnimap-server-port 143) | |
1699 | (nnimap-authenticator plain) | |
7f88c321 AB |
1700 | (nnimap-user "bandali@gnu.local") |
1701 | (nnimap-inbox "INBOX") | |
1702 | (nnimap-split-methods 'nnimap-split-fancy) | |
1703 | (nnimap-split-fancy (| | |
29e42dc1 | 1704 | ;; (: gnus-registry-split-fancy-with-parent) |
7f88c321 AB |
1705 | ;; (: gnus-group-split-fancy "INBOX" t "INBOX") |
1706 | ;; gnu | |
f02d2b28 | 1707 | (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1") |
e81c7cd4 AB |
1708 | ;; *@lists.sr.ht, omitting one dot if present |
1709 | ;; add more \\.?\\([^.@]*\\) if needed | |
1710 | (list ".*<~\\(.*\\)/\\([^.@]*\\)\\.?\\([^.@]*\\)@lists.sr.ht>.*" "l.~\\1.\\2\\3") | |
9747f63f AB |
1711 | ;; webmasters |
1712 | (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters") | |
7f88c321 | 1713 | ;; other |
859ba2a0 | 1714 | (list ".*atreus.freelists.org" "l.atreus") |
7f88c321 | 1715 | (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec") |
f02d2b28 | 1716 | ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d |
a23fd4a0 | 1717 | (list ".*haskell-cafe.haskell.org" "l.haskell-cafe") |
f02d2b28 AB |
1718 | ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u |
1719 | ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u | |
1720 | ;; ---------------------------------- | |
1721 | ;; legend: (u)nsubscribed | (d)ead | |
1722 | ;; ---------------------------------- | |
1723 | ;; otherwise, leave mail in INBOX | |
7f88c321 | 1724 | "INBOX"))) |
727d14d3 | 1725 | (nnimap "uw" |
41d290a2 AB |
1726 | (nnimap-stream plain) |
1727 | (nnimap-address "127.0.0.1") | |
1728 | (nnimap-server-port 143) | |
1729 | (nnimap-authenticator plain) | |
f0d99991 AB |
1730 | (nnimap-user "abandali@uw.local") |
1731 | (nnimap-inbox "INBOX") | |
1732 | (nnimap-split-methods 'nnimap-split-fancy) | |
1733 | (nnimap-split-fancy (| | |
29e42dc1 | 1734 | ;; (: gnus-registry-split-fancy-with-parent) |
5b8a18a4 | 1735 | ;; se212-f19 |
90dc3a58 AB |
1736 | ("subject" "SE\\s-?212" "course.se212-f19") |
1737 | (from "SE\\s-?212" "course.se212-f19") | |
f0d99991 AB |
1738 | ;; catch-all |
1739 | "INBOX"))) | |
727d14d3 | 1740 | (nnimap "csc" |
41d290a2 AB |
1741 | (nnimap-stream plain) |
1742 | (nnimap-address "127.0.0.1") | |
1743 | (nnimap-server-port 143) | |
1744 | (nnimap-authenticator plain) | |
727d14d3 | 1745 | (nnimap-user "abandali@csc.uw.local"))) |
d4cc5497 | 1746 | gnus-message-archive-group "nnimap+shemshak:Sent" |
41d290a2 | 1747 | gnus-parameters |
859ba2a0 AB |
1748 | '(("l\\.atreus" |
1749 | (to-address . "atreus@freelists.org") | |
1750 | (to-list . "atreus@freelists.org")) | |
1751 | ("l\\.deepspec" | |
41d290a2 | 1752 | (to-address . "deepspec@lists.cs.princeton.edu") |
778202b8 AB |
1753 | (to-list . "deepspec@lists.cs.princeton.edu") |
1754 | (list-identifier . "\\[deepspec\\]")) | |
cb4015f6 | 1755 | ("l\\.emacs-devel" |
74fd778e AB |
1756 | (to-address . "emacs-devel@gnu.org") |
1757 | (to-list . "emacs-devel@gnu.org")) | |
cb4015f6 | 1758 | ("l\\.help-gnu-emacs" |
74fd778e AB |
1759 | (to-address . "help-gnu-emacs@gnu.org") |
1760 | (to-list . "help-gnu-emacs@gnu.org")) | |
cb4015f6 | 1761 | ("l\\.info-gnu-emacs" |
74fd778e AB |
1762 | (to-address . "info-gnu-emacs@gnu.org") |
1763 | (to-list . "info-gnu-emacs@gnu.org")) | |
cb4015f6 | 1764 | ("l\\.emacs-orgmode" |
41d290a2 | 1765 | (to-address . "emacs-orgmode@gnu.org") |
778202b8 AB |
1766 | (to-list . "emacs-orgmode@gnu.org") |
1767 | (list-identifier . "\\[O\\]")) | |
cb4015f6 | 1768 | ("l\\.emacs-tangents" |
40b9eac1 AB |
1769 | (to-address . "emacs-tangents@gnu.org") |
1770 | (to-list . "emacs-tangents@gnu.org")) | |
cb4015f6 | 1771 | ("l\\.emacsconf-discuss" |
41d290a2 AB |
1772 | (to-address . "emacsconf-discuss@gnu.org") |
1773 | (to-list . "emacsconf-discuss@gnu.org")) | |
cb4015f6 | 1774 | ("l\\.emacsconf-register" |
690a977d AB |
1775 | (to-address . "emacsconf-register@gnu.org") |
1776 | (to-list . "emacsconf-register@gnu.org")) | |
cb4015f6 | 1777 | ("l\\.emacsconf-submit" |
690a977d AB |
1778 | (to-address . "emacsconf-submit@gnu.org") |
1779 | (to-list . "emacsconf-submit@gnu.org")) | |
cb4015f6 | 1780 | ("l\\.fencepost-users" |
41d290a2 | 1781 | (to-address . "fencepost-users@gnu.org") |
778202b8 AB |
1782 | (to-list . "fencepost-users@gnu.org") |
1783 | (list-identifier . "\\[Fencepost-users\\]")) | |
e7a169d1 AB |
1784 | ("l\\.gnewsense-art" |
1785 | (to-address . "gnewsense-art@nongnu.org") | |
1786 | (to-list . "gnewsense-art@nongnu.org") | |
1787 | (list-identifier . "\\[gNewSense-art\\]")) | |
1788 | ("l\\.gnewsense-dev" | |
1789 | (to-address . "gnewsense-dev@nongnu.org") | |
1790 | (to-list . "gnewsense-dev@nongnu.org") | |
1791 | (list-identifier . "\\[Gnewsense-dev\\]")) | |
7f3d862f | 1792 | ("l\\.gnewsense-users" |
e7a169d1 AB |
1793 | (to-address . "gnewsense-users@nongnu.org") |
1794 | (to-list . "gnewsense-users@nongnu.org") | |
1795 | (list-identifier . "\\[gNewSense-users\\]")) | |
cb4015f6 | 1796 | ("l\\.gnunet-developers" |
41d290a2 | 1797 | (to-address . "gnunet-developers@gnu.org") |
778202b8 AB |
1798 | (to-list . "gnunet-developers@gnu.org") |
1799 | (list-identifier . "\\[GNUnet-developers\\]")) | |
cb4015f6 | 1800 | ("l\\.help-gnunet" |
74fd778e AB |
1801 | (to-address . "help-gnunet@gnu.org") |
1802 | (to-list . "help-gnunet@gnu.org") | |
1803 | (list-identifier . "\\[Help-gnunet\\]")) | |
cb4015f6 | 1804 | ("l\\.bug-gnuzilla" |
74fd778e AB |
1805 | (to-address . "bug-gnuzilla@gnu.org") |
1806 | (to-list . "bug-gnuzilla@gnu.org") | |
1807 | (list-identifier . "\\[Bug-gnuzilla\\]")) | |
cb4015f6 | 1808 | ("l\\.gnuzilla-dev" |
74fd778e AB |
1809 | (to-address . "gnuzilla-dev@gnu.org") |
1810 | (to-list . "gnuzilla-dev@gnu.org") | |
1811 | (list-identifier . "\\[Gnuzilla-dev\\]")) | |
cb4015f6 | 1812 | ("l\\.guile-devel" |
41d290a2 AB |
1813 | (to-address . "guile-devel@gnu.org") |
1814 | (to-list . "guile-devel@gnu.org")) | |
cb4015f6 | 1815 | ("l\\.guile-user" |
29e42dc1 AB |
1816 | (to-address . "guile-user@gnu.org") |
1817 | (to-list . "guile-user@gnu.org")) | |
cb4015f6 | 1818 | ("l\\.guix-devel" |
41d290a2 AB |
1819 | (to-address . "guix-devel@gnu.org") |
1820 | (to-list . "guix-devel@gnu.org")) | |
cb4015f6 | 1821 | ("l\\.help-guix" |
837a23a5 AB |
1822 | (to-address . "help-guix@gnu.org") |
1823 | (to-list . "help-guix@gnu.org")) | |
cb4015f6 | 1824 | ("l\\.info-guix" |
74fd778e AB |
1825 | (to-address . "info-guix@gnu.org") |
1826 | (to-list . "info-guix@gnu.org")) | |
cb4015f6 | 1827 | ("l\\.savannah-hackers-public" |
6f25cef1 AB |
1828 | (to-address . "savannah-hackers-public@gnu.org") |
1829 | (to-list . "savannah-hackers-public@gnu.org")) | |
cb4015f6 | 1830 | ("l\\.savannah-users" |
6f25cef1 AB |
1831 | (to-address . "savannah-users@gnu.org") |
1832 | (to-list . "savannah-users@gnu.org")) | |
cb4015f6 | 1833 | ("l\\.www-commits" |
74fd778e AB |
1834 | (to-address . "www-commits@gnu.org") |
1835 | (to-list . "www-commits@gnu.org")) | |
cb4015f6 | 1836 | ("l\\.www-discuss" |
74fd778e AB |
1837 | (to-address . "www-discuss@gnu.org") |
1838 | (to-list . "www-discuss@gnu.org")) | |
cb4015f6 | 1839 | ("l\\.haskell-art" |
41d290a2 | 1840 | (to-address . "haskell-art@we.lurk.org") |
778202b8 AB |
1841 | (to-list . "haskell-art@we.lurk.org") |
1842 | (list-identifier . "\\[haskell-art\\]")) | |
cb4015f6 | 1843 | ("l\\.haskell-cafe" |
41d290a2 | 1844 | (to-address . "haskell-cafe@haskell.org") |
778202b8 AB |
1845 | (to-list . "haskell-cafe@haskell.org") |
1846 | (list-identifier . "\\[Haskell-cafe\\]")) | |
74fd778e | 1847 | ("l\\.notmuch" |
41d290a2 AB |
1848 | (to-address . "notmuch@notmuchmail.org") |
1849 | (to-list . "notmuch@notmuchmail.org")) | |
cb4015f6 | 1850 | ("l\\.parabola-dev" |
41d290a2 | 1851 | (to-address . "dev@lists.parabola.nu") |
778202b8 AB |
1852 | (to-list . "dev@lists.parabola.nu") |
1853 | (list-identifier . "\\[Dev\\]")) | |
74fd778e | 1854 | ("l\\.~bandali\\.public-inbox" |
41d290a2 AB |
1855 | (to-address . "~bandali/public-inbox@lists.sr.ht") |
1856 | (to-list . "~bandali/public-inbox@lists.sr.ht")) | |
7c281dfc AB |
1857 | ("l\\.~sircmpwn\\.free-writers-club" |
1858 | (to-address . "~sircmpwn/free-writers-club@lists.sr.ht") | |
1859 | (to-list . "~sircmpwn/free-writers-club@lists.sr.ht")) | |
cb4015f6 | 1860 | ("l\\.~sircmpwn\\.srht-admins" |
41d290a2 AB |
1861 | (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht") |
1862 | (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht")) | |
cb4015f6 | 1863 | ("l\\.~sircmpwn\\.srht-announce" |
41d290a2 AB |
1864 | (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht") |
1865 | (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht")) | |
cb4015f6 | 1866 | ("l\\.~sircmpwn\\.srht-dev" |
41d290a2 AB |
1867 | (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht") |
1868 | (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht")) | |
cb4015f6 | 1869 | ("l\\.~sircmpwn\\.srht-discuss" |
41d290a2 AB |
1870 | (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht") |
1871 | (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht")) | |
74fd778e AB |
1872 | ("webmasters" |
1873 | (to-address . "webmasters@gnu.org") | |
1874 | (to-list . "webmasters@gnu.org")) | |
41d290a2 AB |
1875 | ("gnu.*" |
1876 | (gcc-self . t)) | |
1877 | ("gnu\\." | |
262483ba AB |
1878 | (subscribed . t)) |
1879 | ("nnimap\\+uw:.*" | |
1880 | (gcc-self . t))) | |
41d290a2 | 1881 | gnus-large-newsgroup 50 |
dca50cf5 | 1882 | gnus-home-directory (b/var "gnus/") |
41d290a2 AB |
1883 | gnus-directory (concat gnus-home-directory "news/") |
1884 | message-directory (concat gnus-home-directory "mail/") | |
1885 | nndraft-directory (concat gnus-home-directory "drafts/") | |
1886 | gnus-save-newsrc-file nil | |
1887 | gnus-read-newsrc-file nil | |
1888 | gnus-interactive-exit nil | |
1889 | gnus-gcc-mark-as-read t) | |
1890 | :config | |
5b10d879 AB |
1891 | (require 'ebdb) |
1892 | (require 'ebdb-mua) | |
1893 | (require 'ebdb-gnus) | |
41d290a2 | 1894 | |
f02d2b28 AB |
1895 | (when (version< emacs-version "27") |
1896 | (add-to-list | |
1897 | 'nnmail-split-abbrev-alist | |
1898 | '(list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop") | |
1899 | t)) | |
1900 | ||
29e42dc1 | 1901 | ;; (gnus-registry-initialize) |
7f88c321 | 1902 | |
41d290a2 AB |
1903 | (with-eval-after-load 'recentf |
1904 | (add-to-list 'recentf-exclude gnus-home-directory))) | |
1905 | ||
33273849 | 1906 | (use-feature gnus-art |
41d290a2 AB |
1907 | :config |
1908 | (setq | |
7e1cad06 | 1909 | gnus-buttonized-mime-types '("multipart/\\(signed\\|encrypted\\)") |
41d290a2 AB |
1910 | gnus-visible-headers |
1911 | (concat gnus-visible-headers "\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:") | |
1912 | gnus-sorted-header-list | |
1913 | '("^From:" "^Subject:" "^Summary:" "^Keywords:" | |
1914 | "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator" | |
1915 | "^Newsgroups:" "List-Id:" "^Organization:" | |
1916 | "^User-Agent:" "^Date:") | |
1917 | ;; local-lapsed article dates | |
1918 | ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11 | |
1919 | gnus-article-date-headers '(user-defined) | |
1920 | gnus-article-time-format | |
1921 | (lambda (time) | |
1922 | (let* ((date (format-time-string "%a, %d %b %Y %T %z" time)) | |
1923 | (local (article-make-date-line date 'local)) | |
1924 | (combined-lapsed (article-make-date-line date | |
1925 | 'combined-lapsed)) | |
1926 | (lapsed (progn | |
1927 | (string-match " (.+" combined-lapsed) | |
1928 | (match-string 0 combined-lapsed)))) | |
1929 | (concat local lapsed)))) | |
1930 | (bind-keys | |
1931 | :map gnus-article-mode-map | |
1932 | ("M-L" . org-store-link))) | |
1933 | ||
33273849 | 1934 | (use-feature gnus-sum |
41d290a2 | 1935 | :bind (:map gnus-summary-mode-map |
dca50cf5 | 1936 | :prefix-map b/gnus-summary-prefix-map |
41d290a2 AB |
1937 | :prefix "v" |
1938 | ("r" . gnus-summary-reply) | |
1939 | ("w" . gnus-summary-wide-reply) | |
1940 | ("v" . gnus-summary-show-raw-article)) | |
1941 | :config | |
1942 | (bind-keys | |
1943 | :map gnus-summary-mode-map | |
1944 | ("M-L" . org-store-link)) | |
dca50cf5 | 1945 | :hook (gnus-summary-mode . b/no-mouse-autoselect-window)) |
41d290a2 | 1946 | |
33273849 | 1947 | (use-feature gnus-msg |
41d290a2 | 1948 | :config |
dca50cf5 | 1949 | (defvar b/signature "Amin Bandali |
ce72f966 AB |
1950 | Free Software Activist | GNU Webmaster & Volunteer |
1951 | GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103 | |
4ed3a945 | 1952 | https://shemshak.org/~amin") |
dca50cf5 | 1953 | (defvar b/gnu-signature "Amin Bandali |
515674c5 AB |
1954 | Free Software Activist | GNU Webmaster & Volunteer |
1955 | GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103 | |
0cff213c | 1956 | https://bandali.eu.org") |
dca50cf5 | 1957 | (defvar b/uw-signature "Amin Bandali, MMath Student |
4d19e255 | 1958 | Cheriton School of Computer Science |
e0e5275d | 1959 | University of Waterloo |
0cff213c | 1960 | https://bandali.eu.org") |
dca50cf5 | 1961 | (defvar b/csc-signature "Amin Bandali |
dc12958b AB |
1962 | Systems Committee |
1963 | Computer Science Club, University of Waterloo | |
1964 | https://csclub.uwaterloo.ca/~abandali") | |
41d290a2 AB |
1965 | (setq gnus-posting-styles |
1966 | '((".*" | |
4ed3a945 | 1967 | (address "amin@shemshak.org") |
41d290a2 | 1968 | (body "\nBest,\n") |
dca50cf5 AB |
1969 | (signature b/signature) |
1970 | (eval (setq b/message-cite-say-hi t))) | |
7f88c321 | 1971 | ("nnimap\\+gnu:.*" |
4ed3a945 | 1972 | (address "bandali@gnu.org") |
dca50cf5 | 1973 | (signature b/gnu-signature) |
41d290a2 AB |
1974 | (eval (set (make-local-variable 'message-user-fqdn) "fencepost.gnu.org"))) |
1975 | ((header "subject" "ThankCRM") | |
1976 | (to "webmasters-comment@gnu.org") | |
55495e2f | 1977 | (body "") |
dca50cf5 | 1978 | (eval (setq b/message-cite-say-hi nil))) |
63c1969d | 1979 | ("nnimap\\+uw:.*" |
4d19e255 | 1980 | (address "abandali@uwaterloo.ca") |
dca50cf5 | 1981 | (signature b/uw-signature)) |
262483ba | 1982 | ("nnimap\\+uw:INBOX" |
63c1969d AB |
1983 | (gcc "\"nnimap+uw:Sent Items\"")) |
1984 | ("nnimap\\+csc:.*" | |
41d290a2 | 1985 | (address "abandali@csclub.uwaterloo.ca") |
dca50cf5 | 1986 | (signature b/csc-signature) |
63c1969d | 1987 | (gcc "nnimap+csc:Sent"))))) |
41d290a2 | 1988 | |
33273849 | 1989 | (use-feature gnus-topic |
41d290a2 AB |
1990 | :hook (gnus-group-mode . gnus-topic-mode) |
1991 | :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n")) | |
1992 | ||
33273849 | 1993 | (use-feature gnus-agent |
41d290a2 AB |
1994 | :config |
1995 | (setq gnus-agent-synchronize-flags 'ask) | |
1996 | :hook (gnus-group-mode . gnus-agent-mode)) | |
1997 | ||
33273849 | 1998 | (use-feature gnus-group |
41d290a2 AB |
1999 | :config |
2000 | (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)")) | |
2001 | ||
082360a8 AB |
2002 | (comment |
2003 | ;; problematic with ebdb's popup, *EBDB-Gnus* | |
33273849 | 2004 | (use-feature gnus-win |
082360a8 AB |
2005 | :config |
2006 | (setq gnus-use-full-window nil))) | |
f485f78e | 2007 | |
33273849 | 2008 | (use-feature gnus-dired |
348511ef AB |
2009 | :commands gnus-dired-mode |
2010 | :init | |
2011 | (add-hook 'dired-mode-hook 'gnus-dired-mode)) | |
2012 | ||
33273849 | 2013 | (use-feature mm-decode |
41d290a2 | 2014 | :config |
7e1cad06 AB |
2015 | (setq mm-discouraged-alternatives '("text/html" "text/richtext") |
2016 | mm-decrypt-option 'known | |
2017 | mm-verify-option 'known)) | |
41d290a2 | 2018 | |
33273849 | 2019 | (use-feature sendmail |
41d290a2 | 2020 | :config |
8f8d4c32 | 2021 | (setq sendmail-program (executable-find "msmtp") |
41d290a2 AB |
2022 | ;; message-sendmail-extra-arguments '("-v" "-d") |
2023 | mail-specify-envelope-from t | |
2024 | mail-envelope-from 'header)) | |
2025 | ||
33273849 | 2026 | (use-feature message |
41d290a2 AB |
2027 | :config |
2028 | ;; redefine for a simplified In-Reply-To header | |
2029 | ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67) | |
2030 | (defun message-make-in-reply-to () | |
2031 | "Return the In-Reply-To header for this message." | |
2032 | (when message-reply-headers | |
2033 | (let ((from (mail-header-from message-reply-headers)) | |
2034 | (msg-id (mail-header-id message-reply-headers))) | |
2035 | (when from | |
2036 | msg-id)))) | |
2037 | ||
dca50cf5 | 2038 | (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:") |
41d290a2 AB |
2039 | (defconst message-cite-style-bandali |
2040 | '((message-cite-function 'message-cite-original) | |
2041 | (message-citation-line-function 'message-insert-formatted-citation-line) | |
2042 | (message-cite-reply-position 'traditional) | |
2043 | (message-yank-prefix "> ") | |
2044 | (message-yank-cited-prefix ">") | |
2045 | (message-yank-empty-prefix ">") | |
2046 | (message-citation-line-format | |
dca50cf5 AB |
2047 | (if b/message-cite-say-hi |
2048 | (concat "Hi %F,\n\n" b/message-cite-style-format) | |
2049 | b/message-cite-style-format))) | |
41d290a2 AB |
2050 | "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.") |
2051 | (setq ;; message-cite-style 'message-cite-style-bandali | |
2052 | message-kill-buffer-on-exit t | |
2053 | message-send-mail-function 'message-send-mail-with-sendmail | |
2054 | message-sendmail-envelope-from 'header | |
2055 | message-subscribed-address-functions | |
2056 | '(gnus-find-subscribed-addresses) | |
2057 | message-dont-reply-to-names | |
4ed3a945 | 2058 | "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(amin@bndl\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)") |
5b10d879 | 2059 | (require 'company-ebdb) |
41d290a2 AB |
2060 | :hook (;; (message-setup . mml-secure-message-sign-pgpmime) |
2061 | (message-mode . flyspell-mode) | |
2062 | (message-mode . (lambda () | |
2063 | ;; (setq fill-column 65 | |
2064 | ;; message-fill-column 65) | |
2065 | (make-local-variable 'company-idle-delay) | |
2066 | (setq company-idle-delay 0.2)))) | |
2067 | ;; :custom-face | |
2068 | ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold)))) | |
2069 | ;; (message-header-to ((t (:foreground "#111" :weight normal)))) | |
2070 | ;; (message-header-cc ((t (:foreground "#333" :weight normal)))) | |
2071 | ) | |
2072 | ||
33273849 | 2073 | (use-feature mml |
54209e74 AB |
2074 | :delight " mml") |
2075 | ||
33273849 | 2076 | (use-feature mml-sec |
54209e74 AB |
2077 | :custom |
2078 | (mml-secure-openpgp-encrypt-to-self t) | |
2079 | (mml-secure-openpgp-sign-with-sender t)) | |
41d290a2 | 2080 | |
33273849 | 2081 | (use-feature footnote |
41d290a2 AB |
2082 | :after message |
2083 | ;; :config | |
2084 | ;; (setq footnote-start-tag "" | |
2085 | ;; footnote-end-tag "" | |
2086 | ;; footnote-style 'unicode) | |
2087 | :bind | |
2088 | (:map message-mode-map | |
dca50cf5 | 2089 | :prefix-map b/footnote-prefix-map |
41d290a2 AB |
2090 | :prefix "C-c f" |
2091 | ("a" . footnote-add-footnote) | |
2092 | ("b" . footnote-back-to-message) | |
2093 | ("c" . footnote-cycle-style) | |
2094 | ("d" . footnote-delete-footnote) | |
2095 | ("g" . footnote-goto-footnote) | |
2096 | ("r" . footnote-renumber-footnotes) | |
2097 | ("s" . footnote-set-style))) | |
2098 | ||
5b10d879 AB |
2099 | (use-package ebdb |
2100 | :after gnus | |
2101 | :bind (:map gnus-group-mode-map ("e" . ebdb)) | |
2102 | :config | |
2103 | (setq ebdb-sources (b/var "ebdb")) | |
2104 | (with-eval-after-load 'swiper | |
2105 | (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t))) | |
41d290a2 | 2106 | |
33273849 | 2107 | (use-feature ebdb-com |
5b10d879 | 2108 | :after ebdb) |
41d290a2 | 2109 | |
5b10d879 AB |
2110 | ;; (use-package ebdb-complete |
2111 | ;; :after ebdb | |
2112 | ;; :config | |
2113 | ;; (ebdb-complete-enable)) | |
41d290a2 | 2114 | |
5b10d879 AB |
2115 | (use-package company-ebdb |
2116 | :config | |
2117 | (defun company-ebdb--post-complete (_) nil)) | |
41d290a2 | 2118 | |
33273849 | 2119 | (use-feature ebdb-gnus |
5b10d879 AB |
2120 | :after ebdb |
2121 | :custom | |
2122 | (ebdb-gnus-window-configuration | |
2123 | '(article | |
2124 | (vertical 1.0 | |
2125 | (summary 0.25 point) | |
2126 | (horizontal 1.0 | |
2127 | (article 1.0) | |
2128 | (ebdb-gnus 0.3)))))) | |
2129 | ||
33273849 | 2130 | (use-feature ebdb-mua |
5b10d879 AB |
2131 | :after ebdb |
2132 | ;; :custom (ebdb-mua-pop-up nil) | |
2133 | ) | |
41d290a2 | 2134 | |
5b10d879 AB |
2135 | ;; (use-package ebdb-message |
2136 | ;; :after ebdb) | |
41d290a2 | 2137 | |
5b10d879 AB |
2138 | ;; (use-package ebdb-vcard |
2139 | ;; :after ebdb) | |
41d290a2 | 2140 | |
5b10d879 | 2141 | (use-package message-x) |
41d290a2 | 2142 | |
b57457b2 AB |
2143 | (comment |
2144 | (use-package message-x | |
2145 | :custom | |
2146 | (message-x-completion-alist | |
2147 | (quote | |
2148 | (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address) | |
2149 | ((if | |
2150 | (boundp | |
2151 | (quote message-newgroups-header-regexp)) | |
2152 | message-newgroups-header-regexp message-newsgroups-header-regexp) | |
2153 | . message-expand-group)))))) | |
2154 | ||
2155 | (comment | |
2156 | (use-package gnus-harvest | |
2157 | :commands gnus-harvest-install | |
2158 | :demand t | |
2159 | :config | |
2160 | (if (featurep 'message-x) | |
2161 | (gnus-harvest-install 'message-x) | |
2162 | (gnus-harvest-install)))) | |
2163 | ||
2164 | \f | |
e3e5e846 | 2165 | ;;; IRC (with ERC and ZNC) |
b57457b2 | 2166 | |
33273849 | 2167 | (use-feature erc |
057a8382 | 2168 | :bind (("C-c b e" . erc-switch-to-buffer) |
96840c88 AB |
2169 | :map erc-mode-map |
2170 | ("M-a" . erc-track-switch-buffer)) | |
2171 | :custom | |
96840c88 AB |
2172 | (erc-join-buffer 'bury) |
2173 | (erc-lurker-hide-list '("JOIN" "PART" "QUIT")) | |
2174 | (erc-nick "bandali") | |
4d5a11b3 | 2175 | (erc-prompt "erc>") |
96840c88 AB |
2176 | (erc-rename-buffers t) |
2177 | (erc-server-reconnect-attempts 5) | |
2178 | (erc-server-reconnect-timeout 3) | |
96840c88 | 2179 | :config |
96840c88 AB |
2180 | (defun erc-cmd-OPME () |
2181 | "Request chanserv to op me." | |
2182 | (erc-message "PRIVMSG" | |
2183 | (format "chanserv op %s %s" | |
2184 | (erc-default-target) | |
2185 | (erc-current-nick)) nil)) | |
2186 | (defun erc-cmd-DEOPME () | |
2187 | "Deop myself from current channel." | |
2188 | (erc-cmd-DEOP (format "%s" (erc-current-nick)))) | |
2189 | (add-to-list 'erc-modules 'keep-place) | |
2190 | (add-to-list 'erc-modules 'notifications) | |
2191 | (add-to-list 'erc-modules 'spelling) | |
5b10d879 | 2192 | (add-to-list 'erc-modules 'scrolltoplace) |
1c9d04d7 AB |
2193 | (erc-update-modules) |
2194 | ||
2195 | (when (and (version<= "24.4" emacs-version) | |
2196 | (version< emacs-version "27")) | |
2197 | ;; fix erc-lurker bug | |
2198 | ;; patch submitted: https://bugs.gnu.org/36843#10 | |
2199 | ;; TODO: remove when patch is merged and emacs 27 is released | |
2200 | (defvar erc-message-parsed) | |
2201 | (defun erc-display-message (parsed type buffer msg &rest args) | |
2202 | "Display MSG in BUFFER. | |
2203 | ||
2204 | ARGS, PARSED, and TYPE are used to format MSG sensibly. | |
2205 | ||
2206 | See also `erc-format-message' and `erc-display-line'." | |
2207 | (let ((string (if (symbolp msg) | |
2208 | (apply #'erc-format-message msg args) | |
2209 | msg)) | |
2210 | (erc-message-parsed parsed)) | |
2211 | (setq string | |
2212 | (cond | |
2213 | ((null type) | |
2214 | string) | |
2215 | ((listp type) | |
2216 | (mapc (lambda (type) | |
2217 | (setq string | |
2218 | (erc-display-message-highlight type string))) | |
2219 | type) | |
2220 | string) | |
2221 | ((symbolp type) | |
2222 | (erc-display-message-highlight type string)))) | |
2223 | ||
2224 | (if (not (erc-response-p parsed)) | |
2225 | (erc-display-line string buffer) | |
2226 | (unless (erc-hide-current-message-p parsed) | |
2227 | (erc-put-text-property 0 (length string) 'erc-parsed parsed string) | |
2228 | (erc-put-text-property 0 (length string) 'rear-sticky t string) | |
2229 | (when (erc-response.tags parsed) | |
2230 | (erc-put-text-property 0 (length string) 'tags (erc-response.tags parsed) | |
2231 | string)) | |
2232 | (erc-display-line string buffer))))) | |
2233 | ||
2234 | (defun erc-lurker-update-status (_message) | |
2235 | "Update `erc-lurker-state' if necessary. | |
2236 | ||
2237 | This function is called from `erc-insert-pre-hook'. If the | |
2238 | current message is a PRIVMSG, update `erc-lurker-state' to | |
2239 | reflect the fact that its sender has issued a PRIVMSG at the | |
2240 | current time. Otherwise, take no action. | |
2241 | ||
2242 | This function depends on the fact that `erc-display-message' | |
2243 | lexically binds `erc-message-parsed', which is used to check if | |
2244 | the current message is a PRIVMSG and to determine its sender. | |
2245 | See also `erc-lurker-trim-nicks' and `erc-lurker-ignore-chars'. | |
2246 | ||
2247 | In order to limit memory consumption, this function also calls | |
2248 | `erc-lurker-cleanup' once every `erc-lurker-cleanup-interval' | |
2249 | updates of `erc-lurker-state'." | |
2250 | (when (and (boundp 'erc-message-parsed) | |
2251 | (erc-response-p erc-message-parsed)) | |
2252 | (let* ((command (erc-response.command erc-message-parsed)) | |
2253 | (sender | |
2254 | (erc-lurker-maybe-trim | |
2255 | (car (erc-parse-user (erc-response.sender erc-message-parsed))))) | |
2256 | (server | |
2257 | (erc-canonicalize-server-name erc-server-announced-name))) | |
2258 | (when (equal command "PRIVMSG") | |
2259 | (when (>= (cl-incf erc-lurker-cleanup-count) | |
2260 | erc-lurker-cleanup-interval) | |
2261 | (setq erc-lurker-cleanup-count 0) | |
2262 | (erc-lurker-cleanup)) | |
2263 | (unless (gethash server erc-lurker-state) | |
2264 | (puthash server (make-hash-table :test 'equal) erc-lurker-state)) | |
2265 | (puthash sender (current-time) | |
2266 | (gethash server erc-lurker-state)))))))) | |
96840c88 | 2267 | |
33273849 | 2268 | (use-feature erc-fill |
e3e5e846 AB |
2269 | :after erc |
2270 | :custom | |
92df6c4f | 2271 | (erc-fill-column 77) |
e3e5e846 AB |
2272 | (erc-fill-function 'erc-fill-static) |
2273 | (erc-fill-static-center 18)) | |
2274 | ||
33273849 | 2275 | (use-feature erc-pcomplete |
e3e5e846 AB |
2276 | :after erc |
2277 | :custom | |
2278 | (erc-pcomplete-nick-postfix ",")) | |
2279 | ||
33273849 | 2280 | (use-feature erc-track |
e3e5e846 | 2281 | :after erc |
2e81c51a AB |
2282 | :bind (("C-c a e t d" . erc-track-disable) |
2283 | ("C-c a e t e" . erc-track-enable)) | |
e3e5e846 | 2284 | :custom |
2384d161 | 2285 | (erc-track-enable-keybindings nil) |
e3e5e846 AB |
2286 | (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT" |
2287 | "324" "329" "332" "333" "353" "477")) | |
2288 | (erc-track-priority-faces-only 'all) | |
2289 | (erc-track-shorten-function nil)) | |
2290 | ||
96840c88 AB |
2291 | (use-package erc-hl-nicks |
2292 | :after erc) | |
2293 | ||
5b10d879 AB |
2294 | (use-package erc-scrolltoplace |
2295 | :after erc) | |
96840c88 | 2296 | |
41d290a2 | 2297 | (use-package znc |
33273849 | 2298 | :straight (:host nil :repo "https://git.shemshak.org/amin/znc.el") |
41d290a2 AB |
2299 | :bind (("C-c a e e" . znc-erc) |
2300 | ("C-c a e a" . znc-all)) | |
2301 | :config | |
2302 | (let ((pwd (let ((auth (auth-source-search :host "znca"))) | |
2303 | (cond | |
2304 | ((null auth) (error "Couldn't find znca's authinfo")) | |
2305 | (t (funcall (plist-get (car auth) :secret))))))) | |
2306 | (setq znc-servers | |
cad07800 | 2307 | `(("znc.shemshak.org" 1337 t |
4ed3a945 | 2308 | ((freenode "amin/freenode" ,pwd))) |
cad07800 | 2309 | ("znc.shemshak.org" 1337 t |
4ed3a945 | 2310 | ((moznet "amin/moznet" ,pwd))) |
cad07800 | 2311 | ("znc.shemshak.org" 1337 t |
4ed3a945 | 2312 | ((oftc "amin/oftc" ,pwd))))))) |
41d290a2 | 2313 | |
b57457b2 AB |
2314 | \f |
2315 | ;;; Post initialization | |
2316 | ||
41d290a2 AB |
2317 | (message "Loading %s...done (%.3fs)" user-init-file |
2318 | (float-time (time-subtract (current-time) | |
dca50cf5 | 2319 | b/before-user-init-time))) |
41d290a2 AB |
2320 | |
2321 | ;;; init.el ends here |