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