Commit | Line | Data |
---|---|---|
49e9503b | 1 | ;;; init.el --- Amin Bandali's Emacs config -*- lexical-binding: t -*- |
41d290a2 AB |
2 | |
3 | ;; Copyright (C) 2018-2019 Amin Bandali <bandali@gnu.org> | |
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 | |
21 | ;; programmer, and free software advocate. | |
22 | ||
23 | ;; THIS FILE IS AUTO-GENERATED FROM `init.org'. | |
24 | ||
49e9503b AB |
25 | ;;; Code: |
26 | ||
41d290a2 AB |
27 | (defvar a/before-user-init-time (current-time) |
28 | "Value of `current-time' when Emacs begins loading `user-init-file'.") | |
29 | (message "Loading Emacs...done (%.3fs)" | |
30 | (float-time (time-subtract a/before-user-init-time | |
31 | before-init-time))) | |
32 | ||
33 | (defvar a/gc-cons-threshold gc-cons-threshold) | |
34 | (defvar a/gc-cons-percentage gc-cons-percentage) | |
35 | (defvar a/file-name-handler-alist file-name-handler-alist) | |
36 | (setq gc-cons-threshold (* 400 1024 1024) ; 400 MiB | |
37 | gc-cons-percentage 0.6 | |
38 | file-name-handler-alist nil | |
39 | ;; sidesteps a bug when profiling with esup | |
40 | esup-child-profile-require-level 0) | |
41 | ||
42 | (add-hook | |
43 | 'after-init-hook | |
44 | (lambda () | |
45 | (setq gc-cons-threshold a/gc-cons-threshold | |
46 | gc-cons-percentage a/gc-cons-percentage | |
47 | file-name-handler-alist a/file-name-handler-alist))) | |
48 | ||
49 | (setq message-log-max 20000) | |
50 | ||
51 | ;; (setq byte-compile-warnings | |
52 | ;; '(not free-vars unresolved noruntime lexical make-local)) | |
53 | ||
54 | (setq user-full-name "Amin Bandali" | |
55 | user-mail-address "amin@bndl.org") | |
56 | ||
57 | ;; Main engine start... | |
58 | ||
59 | (setq straight-repository-branch "develop" | |
60 | straight-check-for-modifications '(check-on-save find-when-checking)) | |
61 | ||
62 | (defun a/bootstrap-straight () | |
63 | (defvar bootstrap-version) | |
64 | (let ((bootstrap-file | |
65 | (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) | |
66 | (bootstrap-version 5)) | |
67 | (unless (file-exists-p bootstrap-file) | |
68 | (with-current-buffer | |
69 | (url-retrieve-synchronously | |
70 | "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" | |
71 | 'silent 'inhibit-cookies) | |
72 | (goto-char (point-max)) | |
73 | (eval-print-last-sexp))) | |
74 | (load bootstrap-file nil 'nomessage))) | |
75 | ||
76 | ;; Solid rocket booster ignition... | |
77 | ||
41d290a2 AB |
78 | (a/bootstrap-straight) |
79 | ||
80 | ;; We have lift off! | |
81 | ||
82 | (setq straight-use-package-by-default t) | |
83 | ||
84 | (defmacro use-feature (name &rest args) | |
85 | "Like `use-package', but with `straight-use-package-by-default' disabled." | |
86 | (declare (indent defun)) | |
87 | `(use-package ,name | |
88 | :straight nil | |
89 | ,@args)) | |
90 | ||
91 | (with-eval-after-load 'recentf | |
92 | (add-to-list 'recentf-exclude | |
93 | (expand-file-name "~/.emacs.d/straight/build/"))) | |
94 | ||
95 | (defun a/reload-init () | |
96 | "Reload init.el." | |
97 | (interactive) | |
98 | (straight-transaction | |
99 | (straight-mark-transaction-as-init) | |
29ea9439 | 100 | (load user-init-file))) |
41d290a2 AB |
101 | |
102 | (straight-use-package 'use-package) | |
103 | (if nil ; set to t when need to debug init | |
104 | (progn | |
105 | (setq use-package-verbose t | |
106 | use-package-expand-minimally nil | |
107 | use-package-compute-statistics t | |
108 | debug-on-error t) | |
109 | (require 'use-package)) | |
110 | (setq use-package-verbose nil | |
111 | use-package-expand-minimally t)) | |
112 | ||
113 | (setq use-package-always-defer t) | |
114 | (require 'bind-key) | |
115 | ||
116 | (use-package no-littering | |
117 | :demand t | |
118 | :config | |
119 | (savehist-mode 1) | |
120 | (add-to-list 'savehist-additional-variables 'kill-ring) | |
121 | (save-place-mode 1) | |
122 | (setq auto-save-file-name-transforms | |
123 | `((".*" ,(no-littering-expand-var-file-name "auto-save/") t)))) | |
124 | ||
125 | (use-feature custom | |
126 | :no-require t | |
127 | :config | |
128 | (setq custom-file (no-littering-expand-etc-file-name "custom.el")) | |
129 | (when (file-exists-p custom-file) | |
130 | (load custom-file)) | |
131 | (setf custom-safe-themes t)) | |
132 | ||
133 | (with-demoted-errors | |
134 | (load (no-littering-expand-etc-file-name "secrets"))) | |
135 | ||
136 | (use-package exec-path-from-shell | |
137 | :defer 0.4 | |
138 | :init | |
139 | (setq exec-path-from-shell-arguments nil | |
140 | exec-path-from-shell-check-startup-files nil) | |
141 | :config | |
142 | (exec-path-from-shell-initialize) | |
143 | ;; while we're at it, let's fix access to our running ssh-agent | |
144 | (exec-path-from-shell-copy-env "SSH_AGENT_PID") | |
145 | (exec-path-from-shell-copy-env "SSH_AUTH_SOCK")) | |
146 | ||
147 | (use-feature server | |
148 | :defer 0.4 | |
149 | :config (or (server-running-p) (server-mode))) | |
150 | ||
151 | (setq text-scale-mode-step 1.05) | |
152 | ||
153 | (setq mouse-autoselect-window t) | |
154 | ||
155 | (defun a/no-mouse-autoselect-window () | |
156 | (make-local-variable 'mouse-autoselect-window) | |
157 | (setq mouse-autoselect-window nil)) | |
158 | ||
159 | (setq ;; scroll-margin 1 | |
160 | ;; scroll-conservatively 10000 | |
161 | scroll-step 1 | |
162 | scroll-conservatively 10 | |
163 | scroll-preserve-screen-position 1) | |
164 | ||
165 | (use-feature mwheel | |
166 | :defer 0.4 | |
167 | :config | |
168 | (setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time | |
169 | mouse-wheel-progressive-speed nil ; don't accelerate scrolling | |
170 | mouse-wheel-follow-mouse t)) ; scroll window under mouse | |
171 | ||
172 | (use-feature pixel-scroll | |
173 | :defer 0.4 | |
174 | :config (pixel-scroll-mode 1)) | |
175 | ||
176 | (setq epg-pinentry-mode 'loopback) | |
177 | ||
178 | (require 'cl-lib) | |
179 | (require 'subr-x) | |
180 | ||
181 | (defmacro a/setq-every (value &rest vars) | |
182 | "Set all the variables from VARS to value VALUE." | |
183 | (declare (indent defun) (debug t)) | |
184 | `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars))) | |
185 | ||
186 | (defun a/start-process (program &rest args) | |
187 | "Same as `start-process', but doesn't bother about name and buffer." | |
188 | (let ((process-name (concat program "_process")) | |
189 | (buffer-name (generate-new-buffer-name | |
190 | (concat program "_output")))) | |
191 | (apply #'start-process | |
192 | process-name buffer-name program args))) | |
193 | ||
194 | (defun a/dired-start-process (program &optional args) | |
195 | "Open current file with a PROGRAM." | |
196 | ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can | |
197 | ;; be nil, so remove it). | |
198 | (apply #'a/start-process | |
199 | program | |
200 | (remove nil (list args (dired-get-file-for-visit))))) | |
201 | ||
202 | ;; (fringe-mode '(3 . 1)) | |
203 | (fringe-mode nil) | |
204 | ||
205 | (setq disabled-command-function nil) | |
206 | ||
207 | (setq save-interprogram-paste-before-kill t) | |
208 | ||
209 | (setq enable-recursive-minibuffers t | |
210 | resize-mini-windows t) | |
211 | ||
212 | (defalias 'yes-or-no-p #'y-or-n-p) | |
213 | ||
214 | (setq initial-buffer-choice t) | |
215 | ||
216 | (setq initial-scratch-message nil) | |
217 | ||
218 | (setq initial-major-mode 'text-mode) | |
219 | ||
220 | (setq inhibit-startup-buffer-menu t) | |
221 | ||
222 | (advice-add #'display-startup-echo-area-message :override #'ignore) | |
223 | (setq inhibit-startup-screen t | |
224 | inhibit-startup-echo-area-message user-login-name) | |
225 | ||
226 | (setq frame-title-format | |
227 | '("" invocation-name " - " | |
228 | (:eval (if (buffer-file-name) | |
229 | (abbreviate-file-name (buffer-file-name)) | |
230 | "%b")))) | |
231 | ||
232 | (setq backup-by-copying t | |
233 | version-control t | |
234 | delete-old-versions t) | |
235 | ||
236 | (global-auto-revert-mode 1) | |
237 | (setq auto-revert-verbose nil | |
238 | global-auto-revert-non-file-buffers nil) | |
239 | ||
240 | (setq-default | |
241 | indent-tabs-mode nil | |
242 | require-final-newline t | |
243 | tab-width 4) | |
244 | ||
245 | (winner-mode 1) | |
246 | ||
247 | (with-eval-after-load 'compile | |
248 | (defun a/compilation-finish-function (buffer outstr) | |
249 | (unless (string-match "finished" outstr) | |
250 | (switch-to-buffer-other-window buffer)) | |
251 | t) | |
252 | ||
253 | (setq compilation-finish-functions #'a/compilation-finish-function) | |
254 | ||
255 | (require 'cl-macs) | |
256 | ||
257 | (defadvice compilation-start | |
258 | (around inhibit-display | |
259 | (command &optional mode name-function highlight-regexp)) | |
260 | (if (not (string-match "^\\(find\\|grep\\)" command)) | |
261 | (cl-letf (((symbol-function 'display-buffer) #'ignore)) | |
262 | (save-window-excursion ad-do-it)) | |
263 | ad-do-it)) | |
264 | (ad-activate 'compilation-start)) | |
265 | ||
266 | (setq search-default-mode #'char-fold-to-regexp) | |
267 | ||
268 | ;; uncomment to extend this behaviour to query-replace | |
269 | ;; (setq replace-char-fold t) | |
270 | ||
271 | (setq-default cursor-type 'bar) | |
272 | ||
273 | (setq isearch-allow-scroll t) | |
274 | ||
275 | (bind-keys | |
276 | ("C-c a i" . ielm) | |
277 | ||
278 | ("C-c e b" . eval-buffer) | |
279 | ("C-c e r" . eval-region) | |
280 | ||
281 | ("C-c e i" . emacs-init-time) | |
282 | ("C-c e u" . emacs-uptime) | |
283 | ||
284 | ("C-c F m" . make-frame-command) | |
285 | ("C-c F d" . delete-frame) | |
286 | ("C-c F D" . delete-other-frames) | |
287 | ||
288 | ("C-c o" . other-window) | |
289 | ||
290 | ("C-S-h C" . describe-char) | |
291 | ("C-S-h F" . describe-face) | |
292 | ||
293 | ("C-x k" . kill-this-buffer) | |
294 | ("C-x K" . kill-buffer) | |
295 | ||
296 | ("s-p" . beginning-of-buffer) | |
297 | ("s-n" . end-of-buffer)) | |
298 | ||
299 | (when (display-graphic-p) | |
300 | (unbind-key "C-z" global-map)) | |
301 | ||
302 | (bind-keys | |
303 | :prefix-map a/straight-prefix-map | |
304 | :prefix "C-c p s" | |
305 | ("u" . straight-use-package) | |
306 | ("f" . straight-freeze-versions) | |
307 | ("t" . straight-thaw-versions) | |
308 | ("P" . straight-prune-build) | |
309 | ("g" . straight-get-recipe) | |
310 | ("r" . a/reload-init) | |
311 | ;; M-x ^straight-.*-all$ | |
312 | ("a c" . straight-check-all) | |
313 | ("a f" . straight-fetch-all) | |
314 | ("a m" . straight-merge-all) | |
315 | ("a n" . straight-normalize-all) | |
316 | ("a F" . straight-pull-all) | |
317 | ("a P" . straight-push-all) | |
318 | ("a r" . straight-rebuild-all) | |
319 | ;; M-x ^straight-.*-package$ | |
320 | ("p c" . straight-check-package) | |
321 | ("p f" . straight-fetch-package) | |
322 | ("p m" . straight-merge-package) | |
323 | ("p n" . straight-normalize-package) | |
324 | ("p F" . straight-pull-package) | |
325 | ("p P" . straight-push-package) | |
326 | ("p r" . straight-rebuild-package)) | |
327 | ||
328 | (use-package auto-compile | |
329 | :demand t | |
330 | :config | |
331 | (auto-compile-on-load-mode) | |
332 | (auto-compile-on-save-mode) | |
333 | (setq auto-compile-display-buffer nil | |
334 | auto-compile-mode-line-counter t | |
335 | auto-compile-source-recreate-deletes-dest t | |
336 | auto-compile-toggle-deletes-nonlib-dest t | |
337 | auto-compile-update-autoloads t) | |
338 | (add-hook 'auto-compile-inhibit-compile-hook | |
339 | 'auto-compile-inhibit-compile-detached-git-head)) | |
340 | ||
341 | (straight-use-package 'org-plus-contrib) | |
342 | ||
343 | (use-feature org | |
344 | :defer 0.5 | |
345 | :config | |
346 | (setq org-src-tab-acts-natively t | |
347 | org-src-preserve-indentation nil | |
348 | org-edit-src-content-indentation 0 | |
349 | org-link-email-description-format "Email %c: %s" ; %.30s | |
350 | org-highlight-latex-and-related '(entities) | |
351 | org-use-speed-commands t | |
352 | org-startup-folded 'content | |
353 | org-catch-invisible-edits 'show-and-error | |
354 | org-log-done 'time) | |
355 | (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t) | |
356 | :bind | |
357 | (("C-c a o a" . org-agenda) | |
358 | :map org-mode-map | |
359 | ("M-L" . org-insert-last-stored-link) | |
360 | ("s-T" . org-todo)) | |
361 | :hook ((org-mode . org-indent-mode) | |
362 | (org-mode . auto-fill-mode) | |
363 | (org-mode . flyspell-mode)) | |
364 | :custom | |
365 | (org-agenda-files '("~/usr/org/todos/personal.org" | |
366 | "~/usr/org/todos/masters.org")) | |
367 | (org-agenda-start-on-weekday 0) | |
368 | (org-latex-packages-alist '(("" "listings") ("" "color"))) | |
369 | :custom-face | |
370 | '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21")))) | |
371 | '(org-block ((t (:background "#1d1f21")))) | |
372 | '(org-latex-and-related ((t (:foreground "#b294bb"))))) | |
373 | ||
374 | (use-feature ox-latex | |
375 | :after ox | |
376 | :config | |
377 | (setq org-latex-listings 'listings | |
378 | ;; org-latex-prefer-user-labels t | |
379 | ) | |
380 | (add-to-list 'org-latex-classes | |
381 | '("IEEEtran" "\\documentclass[11pt]{IEEEtran}" | |
382 | ("\\section{%s}" . "\\section*{%s}") | |
383 | ("\\subsection{%s}" . "\\subsection*{%s}") | |
384 | ("\\subsubsection{%s}" . "\\subsubsection*{%s}") | |
385 | ("\\paragraph{%s}" . "\\paragraph*{%s}") | |
386 | ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) | |
387 | t) | |
388 | (require 'ox-beamer)) | |
389 | ||
390 | (use-feature ox-extra | |
391 | :config | |
392 | (ox-extras-activate '(latex-header-blocks ignore-headlines))) | |
393 | ||
394 | (with-eval-after-load 'org | |
395 | (defvar a/show-async-tangle-results nil | |
396 | "Keep *emacs* async buffers around for later inspection.") | |
397 | ||
398 | (defvar a/show-async-tangle-time nil | |
399 | "Show the time spent tangling the file.") | |
400 | ||
41d290a2 AB |
401 | (defun a/async-babel-tangle () |
402 | "Tangle org file asynchronously." | |
403 | (interactive) | |
404 | (let* ((file-tangle-start-time (current-time)) | |
405 | (file (buffer-file-name)) | |
406 | (file-nodir (file-name-nondirectory file)) | |
407 | ;; (async-quiet-switch "-q") | |
408 | (file-noext (file-name-sans-extension file))) | |
409 | (async-start | |
410 | `(lambda () | |
411 | (require 'org) | |
412 | (org-babel-tangle-file ,file)) | |
413 | (unless a/show-async-tangle-results | |
414 | `(lambda (result) | |
415 | (if result | |
29ea9439 AB |
416 | (message "Tangled %s%s" |
417 | ,file-nodir | |
418 | (if a/show-async-tangle-time | |
419 | (format " (%.3fs)" | |
420 | (float-time (time-subtract (current-time) | |
421 | ',file-tangle-start-time))) | |
422 | "")) | |
41d290a2 AB |
423 | (message "Tangling %s failed" ,file-nodir)))))))) |
424 | ||
425 | (add-to-list | |
426 | 'safe-local-variable-values | |
427 | '(eval add-hook 'after-save-hook #'a/async-babel-tangle 'append 'local)) | |
428 | ||
429 | (use-package magit | |
430 | :defer 0.5 | |
431 | :bind (("C-x g" . magit-status) | |
432 | ("s-g s" . magit-status) | |
433 | ("s-g l" . magit-log-buffer-file)) | |
434 | :config | |
435 | (magit-add-section-hook 'magit-status-sections-hook | |
436 | 'magit-insert-modules | |
437 | 'magit-insert-stashes | |
438 | 'append) | |
439 | (setq magit-repository-directories '(("~/" . 0) | |
440 | ("~/src/git/" . 1))) | |
441 | (nconc magit-section-initial-visibility-alist | |
442 | '(([unpulled status] . show) | |
443 | ([unpushed status] . show))) | |
444 | :custom-face (magit-diff-file-heading ((t (:weight normal))))) | |
445 | ||
446 | (use-feature recentf | |
447 | :defer 0.2 | |
448 | :config | |
449 | (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:") | |
450 | (setq recentf-max-saved-items 40)) | |
451 | ||
452 | (use-package smex) | |
453 | ||
454 | (use-package ivy | |
455 | :defer 0.3 | |
456 | :bind | |
457 | (:map ivy-minibuffer-map | |
458 | ([escape] . keyboard-escape-quit) | |
459 | ([S-up] . ivy-previous-history-element) | |
460 | ([S-down] . ivy-next-history-element) | |
461 | ("DEL" . ivy-backward-delete-char)) | |
462 | :config | |
463 | (setq ivy-wrap t | |
464 | ivy-height 14 | |
465 | ivy-use-virtual-buffers t | |
466 | ivy-virtual-abbreviate 'abbreviate | |
467 | ivy-count-format "%d/%d ") | |
468 | (ivy-mode 1) | |
469 | ;; :custom-face | |
470 | ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold)))) | |
471 | ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold)))) | |
472 | ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold)))) | |
473 | ) | |
474 | ||
475 | (use-package swiper | |
476 | :after ivy | |
477 | :bind (("C-s" . swiper-isearch) | |
478 | ("C-r" . swiper) | |
479 | ("C-S-s" . isearch-forward))) | |
480 | ||
481 | (use-package counsel | |
482 | :after ivy | |
483 | :bind (([remap execute-extended-command] . counsel-M-x) | |
484 | ([remap find-file] . counsel-find-file) | |
485 | ("C-c x" . counsel-M-x) | |
486 | ("C-c f ." . counsel-find-file) | |
487 | ("C-c f l" . counsel-find-library) | |
488 | :map minibuffer-local-map | |
489 | ("C-r" . counsel-minibuffer-history)) | |
490 | :config | |
491 | (counsel-mode 1) | |
492 | (defalias 'locate #'counsel-locate)) | |
493 | ||
494 | (use-feature eshell | |
495 | :defer 0.5 | |
496 | :commands eshell | |
497 | :bind ("C-c a s e" . eshell) | |
498 | :config | |
499 | (eval-when-compile (defvar eshell-prompt-regexp)) | |
500 | (defun a/eshell-quit-or-delete-char (arg) | |
501 | (interactive "p") | |
502 | (if (and (eolp) (looking-back eshell-prompt-regexp nil)) | |
503 | (eshell-life-is-too-much) | |
504 | (delete-char arg))) | |
505 | ||
506 | (defun a/eshell-clear () | |
507 | (interactive) | |
508 | (let ((inhibit-read-only t)) | |
509 | (erase-buffer)) | |
510 | (eshell-send-input)) | |
511 | ||
512 | (defun a/eshell-setup () | |
513 | (make-local-variable 'company-idle-delay) | |
514 | (defvar company-idle-delay) | |
515 | (setq company-idle-delay nil) | |
516 | (bind-keys :map eshell-mode-map | |
517 | ("C-d" . a/eshell-quit-or-delete-char) | |
518 | ("C-S-l" . a/eshell-clear) | |
519 | ("M-r" . counsel-esh-history) | |
520 | ([tab] . company-complete))) | |
521 | ||
522 | :hook (eshell-mode . a/eshell-setup) | |
523 | :custom | |
524 | (eshell-hist-ignoredups t) | |
525 | (eshell-input-filter 'eshell-input-filter-initial-space)) | |
526 | ||
527 | (use-feature ibuffer | |
528 | :bind | |
529 | (("C-x C-b" . ibuffer-other-window) | |
530 | :map ibuffer-mode-map | |
531 | ("P" . ibuffer-backward-filter-group) | |
532 | ("N" . ibuffer-forward-filter-group) | |
533 | ("M-p" . ibuffer-do-print) | |
534 | ("M-n" . ibuffer-do-shell-command-pipe-replace)) | |
535 | :config | |
536 | ;; Use human readable Size column instead of original one | |
537 | (define-ibuffer-column size-h | |
538 | (:name "Size" :inline t) | |
539 | (cond | |
540 | ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0))) | |
541 | ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0))) | |
542 | ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0))) | |
543 | (t (format "%8d" (buffer-size))))) | |
544 | :custom | |
545 | (ibuffer-saved-filter-groups | |
546 | '(("default" | |
547 | ("dired" (mode . dired-mode)) | |
548 | ("org" (mode . org-mode)) | |
549 | ("gnus" | |
550 | (or | |
551 | (mode . gnus-group-mode) | |
552 | (mode . gnus-summary-mode) | |
553 | (mode . gnus-article-mode) | |
554 | ;; not really, but... | |
555 | (mode . message-mode))) | |
556 | ("web" | |
557 | (or | |
558 | (mode . web-mode) | |
559 | (mode . css-mode) | |
560 | (mode . scss-mode) | |
561 | (mode . js2-mode))) | |
562 | ("shell" | |
563 | (or | |
564 | (mode . eshell-mode) | |
565 | (mode . shell-mode) | |
566 | (mode . term-mode))) | |
567 | ("programming" | |
568 | (or | |
569 | (mode . python-mode) | |
570 | (mode . c-mode) | |
571 | (mode . c++-mode) | |
572 | (mode . java-mode) | |
573 | (mode . emacs-lisp-mode) | |
574 | (mode . scheme-mode) | |
575 | (mode . haskell-mode) | |
576 | (mode . lean-mode) | |
577 | (mode . alloy-mode))) | |
578 | ("tex" | |
579 | (or | |
580 | (mode . bibtex-mode) | |
581 | (mode . latex-mode))) | |
582 | ("emacs" | |
583 | (or | |
584 | (name . "^\\*scratch\\*$") | |
585 | (name . "^\\*Messages\\*$"))) | |
586 | ("erc" (mode . erc-mode))))) | |
587 | (ibuffer-formats | |
588 | '((mark modified read-only locked " " | |
589 | (name 18 18 :left :elide) | |
590 | " " | |
591 | (size-h 9 -1 :right) | |
592 | " " | |
593 | (mode 16 16 :left :elide) | |
594 | " " filename-and-process) | |
595 | (mark " " | |
596 | (name 16 -1) | |
597 | " " filename))) | |
598 | :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default")))) | |
599 | ||
600 | (use-feature outline | |
601 | :hook (prog-mode . outline-minor-mode) | |
602 | :bind | |
603 | (:map | |
604 | outline-minor-mode-map | |
605 | ("<s-tab>" . outline-toggle-children) | |
606 | ("M-p" . outline-previous-visible-heading) | |
607 | ("M-n" . outline-next-visible-heading) | |
608 | :prefix-map a/outline-prefix-map | |
609 | :prefix "s-o" | |
610 | ("TAB" . outline-toggle-children) | |
611 | ("a" . outline-hide-body) | |
612 | ("H" . outline-hide-body) | |
613 | ("S" . outline-show-all) | |
614 | ("h" . outline-hide-subtree) | |
615 | ("s" . outline-show-subtree))) | |
616 | ||
617 | (use-feature ls-lisp | |
618 | :custom (ls-lisp-dirs-first t)) | |
619 | ||
620 | (use-feature dired | |
621 | :config | |
622 | (setq dired-listing-switches "-alh" | |
623 | ls-lisp-use-insert-directory-program nil) | |
624 | ||
625 | ;; easily diff 2 marked files | |
626 | ;; https://oremacs.com/2017/03/18/dired-ediff/ | |
627 | (defun dired-ediff-files () | |
628 | (interactive) | |
629 | (require 'dired-aux) | |
630 | (defvar ediff-after-quit-hook-internal) | |
631 | (let ((files (dired-get-marked-files)) | |
632 | (wnd (current-window-configuration))) | |
633 | (if (<= (length files) 2) | |
634 | (let ((file1 (car files)) | |
635 | (file2 (if (cdr files) | |
636 | (cadr files) | |
637 | (read-file-name | |
638 | "file: " | |
639 | (dired-dwim-target-directory))))) | |
640 | (if (file-newer-than-file-p file1 file2) | |
641 | (ediff-files file2 file1) | |
642 | (ediff-files file1 file2)) | |
643 | (add-hook 'ediff-after-quit-hook-internal | |
644 | (lambda () | |
645 | (setq ediff-after-quit-hook-internal nil) | |
646 | (set-window-configuration wnd)))) | |
647 | (error "no more than 2 files should be marked")))) | |
648 | :bind (:map dired-mode-map | |
649 | ("b" . dired-up-directory) | |
650 | ("e" . dired-ediff-files) | |
651 | ("E" . dired-toggle-read-only) | |
652 | ("\\" . dired-hide-details-mode) | |
653 | ("z" . (lambda () | |
654 | (interactive) | |
655 | (a/dired-start-process "zathura")))) | |
656 | :hook (dired-mode . dired-hide-details-mode)) | |
657 | ||
658 | (use-feature help | |
659 | :config | |
660 | (temp-buffer-resize-mode) | |
661 | (setq help-window-select t)) | |
662 | ||
663 | (use-feature tramp | |
664 | :config | |
665 | (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:")) | |
666 | (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)) | |
667 | (add-to-list 'tramp-default-proxies-alist | |
668 | (list (regexp-quote (system-name)) nil nil))) | |
669 | ||
670 | (use-package dash | |
671 | :config (dash-enable-font-lock)) | |
672 | ||
673 | (use-package doc-view | |
674 | :bind (:map doc-view-mode-map | |
675 | ("M-RET" . image-previous-line))) | |
676 | ||
677 | (use-package diff-hl | |
678 | :config | |
679 | (setq diff-hl-draw-borders nil) | |
680 | (global-diff-hl-mode) | |
681 | :hook (magit-post-refresh . diff-hl-magit-post-refresh)) | |
682 | ||
683 | (use-feature eldoc | |
684 | :when (version< "25" emacs-version) | |
685 | :config (global-eldoc-mode)) | |
686 | ||
687 | (use-feature paren | |
688 | :demand | |
689 | :config (show-paren-mode)) | |
690 | ||
691 | (use-feature simple | |
692 | :config (column-number-mode)) | |
693 | ||
694 | (use-feature savehist | |
695 | :config (savehist-mode)) | |
696 | ||
697 | (use-feature saveplace | |
698 | :when (version< "25" emacs-version) | |
699 | :config (save-place-mode)) | |
700 | ||
701 | (use-feature prog-mode | |
702 | :config (global-prettify-symbols-mode) | |
703 | (defun indicate-buffer-boundaries-left () | |
704 | (setq indicate-buffer-boundaries 'left)) | |
705 | (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left)) | |
706 | ||
707 | (use-feature text-mode | |
708 | :hook ((text-mode . indicate-buffer-boundaries-left) | |
709 | (text-mode . abbrev-mode))) | |
710 | ||
711 | (use-package company | |
712 | :defer 0.6 | |
713 | :bind | |
714 | (:map company-active-map | |
715 | ([tab] . company-complete-common-or-cycle) | |
716 | ([escape] . company-abort)) | |
717 | :custom | |
718 | (company-minimum-prefix-length 1) | |
719 | (company-selection-wrap-around t) | |
720 | (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]") | |
721 | (company-dabbrev-downcase nil) | |
722 | (company-dabbrev-ignore-case nil) | |
723 | :config | |
724 | (global-company-mode t)) | |
725 | ||
726 | (use-package flycheck | |
727 | :defer 0.6 | |
728 | :hook (prog-mode . flycheck-mode) | |
729 | :bind | |
730 | (:map flycheck-mode-map | |
731 | ("M-P" . flycheck-previous-error) | |
732 | ("M-N" . flycheck-next-error)) | |
733 | :config | |
734 | ;; Use the load-path from running Emacs when checking elisp files | |
735 | (setq flycheck-emacs-lisp-load-path 'inherit) | |
736 | ||
737 | ;; Only flycheck when I actually save the buffer | |
738 | (setq flycheck-check-syntax-automatically '(mode-enabled save))) | |
739 | ||
740 | ;; http://endlessparentheses.com/ispell-and-apostrophes.html | |
741 | (use-package ispell | |
742 | :defer 0.6 | |
743 | :config | |
744 | ;; ’ can be part of a word | |
745 | (setq ispell-local-dictionary-alist | |
746 | `((nil "[[:alpha:]]" "[^[:alpha:]]" | |
747 | "['\x2019]" nil ("-B") nil utf-8))) | |
748 | ;; don't send ’ to the subprocess | |
749 | (defun endless/replace-apostrophe (args) | |
750 | (cons (replace-regexp-in-string | |
751 | "’" "'" (car args)) | |
752 | (cdr args))) | |
753 | (advice-add #'ispell-send-string :filter-args | |
754 | #'endless/replace-apostrophe) | |
755 | ||
756 | ;; convert ' back to ’ from the subprocess | |
757 | (defun endless/replace-quote (args) | |
758 | (if (not (derived-mode-p 'org-mode)) | |
759 | args | |
760 | (cons (replace-regexp-in-string | |
761 | "'" "’" (car args)) | |
762 | (cdr args)))) | |
763 | (advice-add #'ispell-parse-output :filter-args | |
764 | #'endless/replace-quote)) | |
765 | ||
766 | (use-feature lisp-mode | |
767 | :config | |
768 | (add-hook 'emacs-lisp-mode-hook 'outline-minor-mode) | |
769 | (add-hook 'emacs-lisp-mode-hook 'reveal-mode) | |
770 | (defun indent-spaces-mode () | |
771 | (setq indent-tabs-mode nil)) | |
772 | (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode)) | |
773 | ||
774 | (use-package alloy-mode | |
775 | :straight (:host github :repo "dwwmmn/alloy-mode") | |
776 | :mode "\\.als\\'" | |
777 | :config (setq alloy-basic-offset 2)) | |
778 | ||
779 | (use-package proof-site ; Proof General | |
780 | :straight proof-general) | |
781 | ||
782 | (eval-when-compile (defvar lean-mode-map)) | |
783 | (use-package lean-mode | |
784 | :defer 0.4 | |
785 | :bind (:map lean-mode-map | |
786 | ("S-SPC" . company-complete)) | |
787 | :config | |
788 | (require 'lean-input) | |
789 | (setq default-input-method "Lean" | |
790 | lean-input-tweak-all '(lean-input-compose | |
791 | (lean-input-prepend "/") | |
792 | (lean-input-nonempty)) | |
793 | lean-input-user-translations '(("/" "/"))) | |
794 | (lean-input-setup)) | |
795 | ||
796 | (use-package haskell-mode | |
797 | :config | |
798 | (setq haskell-indentation-layout-offset 4 | |
799 | haskell-indentation-left-offset 4 | |
800 | flycheck-checker 'haskell-hlint | |
801 | flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc))) | |
802 | ||
803 | (use-package dante | |
804 | :after haskell-mode | |
805 | :commands dante-mode | |
806 | :hook (haskell-mode . dante-mode)) | |
807 | ||
808 | (use-package hlint-refactor | |
809 | :after haskell-mode | |
810 | :bind (:map hlint-refactor-mode-map | |
811 | ("C-c l b" . hlint-refactor-refactor-buffer) | |
812 | ("C-c l r" . hlint-refactor-refactor-at-point)) | |
813 | :hook (haskell-mode . hlint-refactor-mode)) | |
814 | ||
815 | (use-package flycheck-haskell | |
816 | :after haskell-mode) | |
817 | ||
818 | (use-package sgml-mode | |
819 | :config | |
820 | (setq sgml-basic-offset 2)) | |
821 | ||
822 | (use-package css-mode | |
823 | :config | |
824 | (setq css-indent-offset 2)) | |
825 | ||
826 | (use-package web-mode | |
827 | :mode "\\.html\\'" | |
828 | :config | |
829 | (a/setq-every 2 | |
830 | web-mode-code-indent-offset | |
831 | web-mode-css-indent-offset | |
832 | web-mode-markup-indent-offset)) | |
833 | ||
834 | (use-package emmet-mode | |
835 | :after (:any web-mode css-mode sgml-mode) | |
836 | :bind* (("C-)" . emmet-next-edit-point) | |
837 | ("C-(" . emmet-prev-edit-point)) | |
838 | :config | |
839 | (unbind-key "C-j" emmet-mode-keymap) | |
840 | (setq emmet-move-cursor-between-quotes t) | |
841 | :hook (web-mode css-mode html-mode sgml-mode)) | |
842 | ||
843 | (use-package geiser) | |
844 | ||
845 | (use-feature geiser-guile | |
846 | :config | |
847 | (setq geiser-guile-load-path "~/src/git/guix")) | |
848 | ||
849 | (use-package guix) | |
850 | ||
851 | (use-feature man | |
852 | :config (setq Man-width 80)) | |
853 | ||
854 | (use-package which-key | |
855 | :defer 0.4 | |
856 | :config | |
857 | (which-key-add-key-based-replacements | |
858 | ;; prefixes for global prefixes and minor modes | |
859 | "C-c @" "outline" | |
860 | "C-c !" "flycheck" | |
861 | "C-c 8" "typo" | |
862 | "C-c 8 -" "typo/dashes" | |
863 | "C-c 8 <" "typo/left-brackets" | |
864 | "C-c 8 >" "typo/right-brackets" | |
865 | "C-x 8" "unicode" | |
866 | "C-x a" "abbrev/expand" | |
867 | "C-x r" "rectangle/register/bookmark" | |
868 | "C-x v" "version control" | |
869 | ;; prefixes for my personal bindings | |
870 | "C-c a" "applications" | |
871 | "C-c a e" "erc" | |
872 | "C-c a o" "org" | |
873 | "C-c a s" "shells" | |
874 | "C-c p" "package-management" | |
875 | ;; "C-c p e" "package-management/epkg" | |
876 | "C-c p s" "straight.el" | |
877 | "C-c psa" "all" | |
878 | "C-c psp" "package" | |
879 | "C-c c" "compile-and-comments" | |
880 | "C-c e" "eval" | |
881 | "C-c f" "files" | |
882 | "C-c F" "frames" | |
883 | "C-S-h" "help(ful)" | |
884 | "C-c m" "multiple-cursors" | |
885 | "C-c P" "projectile" | |
886 | "C-c P s" "projectile/search" | |
887 | "C-c P x" "projectile/execute" | |
888 | "C-c P 4" "projectile/other-window" | |
889 | "C-c q" "boxquote" | |
890 | "s-g" "magit" | |
891 | "s-o" "outline" | |
892 | "s-t" "themes") | |
893 | ||
894 | ;; prefixes for major modes | |
895 | (which-key-add-major-mode-key-based-replacements 'message-mode | |
896 | "C-c f" "footnote") | |
897 | (which-key-add-major-mode-key-based-replacements 'org-mode | |
898 | "C-c C-v" "org-babel") | |
899 | (which-key-add-major-mode-key-based-replacements 'web-mode | |
900 | "C-c C-a" "web/attributes" | |
901 | "C-c C-b" "web/blocks" | |
902 | "C-c C-d" "web/dom" | |
903 | "C-c C-e" "web/element" | |
904 | "C-c C-t" "web/tags") | |
905 | ||
906 | (which-key-mode) | |
907 | :custom | |
908 | (which-key-add-column-padding 5) | |
909 | (which-key-max-description-length 32)) | |
910 | ||
911 | (add-to-list 'custom-theme-load-path "~/.emacs.d/lisp") | |
912 | (load-theme 'tangomod t) | |
913 | ||
914 | (use-package smart-mode-line | |
915 | :commands (sml/apply-theme) | |
916 | :demand | |
917 | :config | |
918 | (sml/setup)) | |
919 | ||
920 | (use-package doom-themes) | |
921 | ||
922 | (defvar a/org-mode-font-lock-keywords | |
923 | '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)" | |
924 | (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive | |
925 | (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind | |
926 | (4 '(:foreground "#c5c8c6") t)))) ; title | |
927 | ||
928 | (defun a/lights-on () | |
929 | "Enable my favourite light theme." | |
930 | (interactive) | |
931 | (mapc #'disable-theme custom-enabled-themes) | |
932 | (load-theme 'tangomod t) | |
933 | (sml/apply-theme 'automatic) | |
934 | (font-lock-remove-keywords | |
935 | 'org-mode a/org-mode-font-lock-keywords)) | |
936 | ||
937 | (defun a/lights-off () | |
938 | "Go dark." | |
939 | (interactive) | |
940 | (mapc #'disable-theme custom-enabled-themes) | |
941 | (load-theme 'doom-tomorrow-night t) | |
942 | (sml/apply-theme 'automatic) | |
943 | (font-lock-add-keywords | |
944 | 'org-mode a/org-mode-font-lock-keywords t)) | |
945 | ||
946 | (bind-keys | |
947 | ("s-t d" . a/lights-off) | |
948 | ("s-t l" . a/lights-on)) | |
949 | ||
950 | (use-package crux ; results in Waiting for git... [2 times] | |
951 | :defer 0.4 | |
952 | :bind (("C-c b k" . crux-kill-other-buffers) | |
953 | ("C-c d" . crux-duplicate-current-line-or-region) | |
954 | ("C-c D" . crux-duplicate-and-comment-current-line-or-region) | |
955 | ("C-c f c" . crux-copy-file-preserve-attributes) | |
956 | ("C-c f d" . crux-delete-file-and-buffer) | |
957 | ("C-c f r" . crux-rename-file-and-buffer) | |
958 | ("C-c j" . crux-top-join-line) | |
959 | ("C-S-j" . crux-top-join-line))) | |
960 | ||
961 | (use-package mwim | |
962 | :bind (("C-a" . mwim-beginning-of-code-or-line) | |
963 | ("C-e" . mwim-end-of-code-or-line) | |
964 | ("<home>" . mwim-beginning-of-line-or-code) | |
965 | ("<end>" . mwim-end-of-line-or-code))) | |
966 | ||
967 | (use-package projectile | |
968 | :bind-keymap ("C-c P" . projectile-command-map) | |
969 | :config | |
970 | (projectile-mode) | |
971 | ||
972 | (defun my-projectile-invalidate-cache (&rest _args) | |
973 | ;; ignore the args to `magit-checkout' | |
974 | (projectile-invalidate-cache nil)) | |
975 | ||
976 | (eval-after-load 'magit-branch | |
977 | '(progn | |
978 | (advice-add 'magit-checkout | |
979 | :after #'my-projectile-invalidate-cache) | |
980 | (advice-add 'magit-branch-and-checkout | |
981 | :after #'my-projectile-invalidate-cache))) | |
982 | :custom (projectile-completion-system 'ivy)) | |
983 | ||
984 | (use-package helpful | |
985 | :defer 0.6 | |
986 | :bind | |
987 | (("C-S-h c" . helpful-command) | |
988 | ("C-S-h f" . helpful-callable) ; helpful-function | |
989 | ("C-S-h v" . helpful-variable) | |
990 | ("C-S-h k" . helpful-key) | |
991 | ("C-S-h p" . helpful-at-point))) | |
992 | ||
993 | (use-package unkillable-scratch | |
994 | :defer 0.6 | |
995 | :config | |
996 | (unkillable-scratch 1) | |
997 | :custom | |
998 | (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$"))) | |
999 | ||
1000 | (use-package boxquote | |
1001 | :defer 0.6 | |
1002 | :bind | |
1003 | (:prefix-map a/boxquote-prefix-map | |
1004 | :prefix "C-c q" | |
1005 | ("b" . boxquote-buffer) | |
1006 | ("B" . boxquote-insert-buffer) | |
1007 | ("d" . boxquote-defun) | |
1008 | ("F" . boxquote-insert-file) | |
1009 | ("hf" . boxquote-describe-function) | |
1010 | ("hk" . boxquote-describe-key) | |
1011 | ("hv" . boxquote-describe-variable) | |
1012 | ("hw" . boxquote-where-is) | |
1013 | ("k" . boxquote-kill) | |
1014 | ("p" . boxquote-paragraph) | |
1015 | ("q" . boxquote-boxquote) | |
1016 | ("r" . boxquote-region) | |
1017 | ("s" . boxquote-shell-command) | |
1018 | ("t" . boxquote-text) | |
1019 | ("T" . boxquote-title) | |
1020 | ("u" . boxquote-unbox) | |
1021 | ("U" . boxquote-unbox-region) | |
1022 | ("y" . boxquote-yank) | |
1023 | ("M-q" . boxquote-fill-paragraph) | |
1024 | ("M-w" . boxquote-kill-ring-save))) | |
1025 | ||
1026 | (use-package orgalist | |
1027 | :disabled t | |
1028 | :after message | |
1029 | :hook (message-mode . orgalist-mode)) | |
1030 | ||
1031 | (use-package typo | |
1032 | :defer 0.5 | |
1033 | :config | |
1034 | (typo-global-mode 1) | |
1035 | :hook (text-mode . typo-mode)) | |
1036 | ||
1037 | (use-package hl-todo | |
1038 | :defer 0.5 | |
1039 | :config | |
1040 | (global-hl-todo-mode)) | |
1041 | ||
1042 | (use-package shrink-path | |
1043 | :defer 0.5 | |
1044 | :after eshell | |
1045 | :config | |
1046 | (defvar user-@-host (concat (user-login-name) "@" (system-name) " ")) | |
1047 | (defun +eshell/prompt () | |
1048 | (let ((base/dir (shrink-path-prompt default-directory))) | |
1049 | (concat (propertize user-@-host 'face 'default) | |
1050 | (propertize (car base/dir) | |
1051 | 'face 'font-lock-comment-face) | |
1052 | (propertize (cdr base/dir) | |
1053 | 'face 'font-lock-constant-face) | |
1054 | (propertize "> " 'face 'default)))) | |
1055 | (setq eshell-prompt-regexp (concat user-@-host ".*> ") | |
1056 | eshell-prompt-function #'+eshell/prompt)) | |
1057 | ||
1058 | (use-package eshell-up | |
1059 | :after eshell | |
1060 | :commands eshell-up) | |
1061 | ||
1062 | (use-package multi-term | |
1063 | :defer 0.6 | |
1064 | :bind (("C-c a s m" . multi-term-dedicated-toggle) | |
1065 | :map term-mode-map | |
1066 | ("C-c C-j" . term-char-mode) | |
1067 | :map term-raw-map | |
1068 | ("C-c C-j" . term-line-mode)) | |
1069 | :config | |
1070 | (setq multi-term-program "/bin/screen" | |
1071 | ;; TODO: add separate bindings for connecting to existing | |
1072 | ;; session vs. always creating a new one | |
1073 | multi-term-dedicated-select-after-open-p t | |
1074 | multi-term-dedicated-window-height 20 | |
1075 | multi-term-dedicated-max-window-height 30 | |
1076 | term-bind-key-alist | |
1077 | '(("C-c C-c" . term-interrupt-subjob) | |
1078 | ("C-c C-e" . term-send-esc) | |
1079 | ("C-k" . kill-line) | |
1080 | ("C-y" . term-paste) | |
1081 | ("M-f" . term-send-forward-word) | |
1082 | ("M-b" . term-send-backward-word) | |
1083 | ("M-p" . term-send-up) | |
1084 | ("M-n" . term-send-down) | |
1085 | ("<C-backspace>" . term-send-backward-kill-word) | |
1086 | ("<M-DEL>" . term-send-backward-kill-word) | |
1087 | ("M-d" . term-send-delete-word) | |
1088 | ("M-," . term-send-raw) | |
1089 | ("M-." . comint-dynamic-complete)) | |
1090 | term-unbind-key-alist | |
1091 | '("C-z" "C-x" "C-c" "C-h" "C-y" "<ESC>"))) | |
1092 | ||
1093 | (use-package page-break-lines | |
1094 | :config | |
1095 | (global-page-break-lines-mode)) | |
1096 | ||
1097 | (use-package expand-region | |
1098 | :bind ("C-=" . er/expand-region)) | |
1099 | ||
1100 | (use-package multiple-cursors | |
1101 | :bind | |
1102 | (("C-S-<mouse-1>" . mc/add-cursor-on-click) | |
1103 | (:prefix-map a/mc-prefix-map | |
1104 | :prefix "C-c m" | |
1105 | ("c" . mc/edit-lines) | |
1106 | ("n" . mc/mark-next-like-this) | |
1107 | ("p" . mc/mark-previous-like-this) | |
1108 | ("a" . mc/mark-all-like-this)))) | |
1109 | ||
1110 | (use-package forge | |
1111 | :after magit | |
1112 | :demand) | |
1113 | ||
1114 | (use-package yasnippet | |
1115 | :defer 0.6 | |
1116 | :config | |
1117 | (defconst yas-verbosity-cur yas-verbosity) | |
1118 | (setq yas-verbosity 2) | |
1119 | (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets") | |
1120 | (yas-reload-all) | |
1121 | (setq yas-verbosity yas-verbosity-cur) | |
1122 | :hook | |
1123 | (text-mode . yas-minor-mode)) | |
1124 | ||
1125 | (use-package debbugs | |
1126 | :straight (debbugs | |
1127 | :host github | |
1128 | :repo "emacs-straight/debbugs" | |
1129 | :files (:defaults "Debbugs.wsdl"))) | |
1130 | ||
1131 | (use-package org-ref | |
1132 | :init | |
1133 | (a/setq-every '("~/usr/org/references.bib") | |
1134 | reftex-default-bibliography | |
1135 | org-ref-default-bibliography) | |
1136 | (setq | |
1137 | org-ref-bibliography-notes "~/usr/org/notes.org" | |
1138 | org-ref-pdf-directory "~/usr/org/bibtex-pdfs/")) | |
1139 | ||
1140 | (use-package slack | |
1141 | :commands (slack-start) | |
1142 | :init | |
1143 | (eval-when-compile ; silence the byte-compiler | |
1144 | (defvar url-http-data nil) | |
1145 | (defvar url-http-extra-headers nil) | |
1146 | (defvar url-http-method nil) | |
1147 | (defvar url-callback-function nil) | |
1148 | (defvar url-callback-arguments nil) | |
1149 | (defvar oauth--token-data nil)) | |
1150 | (setq slack-buffer-emojify t | |
1151 | slack-prefer-current-team t) | |
1152 | :config | |
1153 | (slack-register-team | |
1154 | :name "nday-students" | |
1155 | :default t | |
1156 | :token nday-students-token | |
1157 | :subscribed-channels '(general) | |
1158 | :full-and-display-names t) | |
1159 | (add-to-list 'swiper-font-lock-exclude 'slack-message-buffer-mode t) | |
1160 | (setq lui-time-stamp-format "[%Y-%m-%d %H:%M:%S]" | |
1161 | lui-time-stamp-only-when-changed-p t | |
1162 | lui-time-stamp-position 'right) | |
1163 | :bind | |
1164 | (("C-c s s" . slack-start) | |
1165 | ("C-c s u" . slack-select-unread-rooms) | |
1166 | ("C-c s b" . slack-select-rooms) | |
1167 | ("C-c s t" . slack-change-current-team) | |
1168 | ("C-c s c" . slack-ws-close) | |
1169 | :map slack-mode-map | |
1170 | ("M-p" . slack-buffer-goto-prev-message) | |
1171 | ("M-n" . slack-buffer-goto-next-message) | |
1172 | ("C-c e" . slack-message-edit) | |
1173 | ("C-c k" . slack-message-delete) | |
1174 | ("C-c C-k" . slack-channel-leave) | |
1175 | ("C-c r a" . slack-message-add-reaction) | |
1176 | ("C-c r r" . slack-message-remove-reaction) | |
1177 | ("C-c r s" . slack-message-show-reaction-users) | |
1178 | ("C-c p l" . slack-room-pins-list) | |
1179 | ("C-c p a" . slack-message-pins-add) | |
1180 | ("C-c p r" . slack-message-pins-remove) | |
1181 | ("@" . slack-message-embed-mention) | |
1182 | ("#" . slack-message-embed-channel))) | |
1183 | ||
1184 | (use-package alert | |
1185 | :commands (alert) | |
1186 | :init | |
1187 | (setq alert-default-style 'notifier)) | |
1188 | ||
1189 | (defvar a/maildir (expand-file-name "~/mail/")) | |
1190 | (with-eval-after-load 'recentf | |
1191 | (add-to-list 'recentf-exclude a/maildir)) | |
1192 | ||
1193 | (setq | |
1194 | a/gnus-init-file (no-littering-expand-etc-file-name "gnus") | |
1195 | mail-user-agent 'gnus-user-agent | |
1196 | read-mail-command 'gnus) | |
1197 | ||
1198 | (use-feature gnus | |
1199 | :bind (("s-m" . gnus) | |
1200 | ("s-M" . gnus-unplugged)) | |
1201 | :init | |
1202 | (setq | |
1203 | gnus-select-method '(nnnil "") | |
1204 | gnus-secondary-select-methods | |
1205 | '((nnimap "amin" | |
1206 | (nnimap-stream plain) | |
1207 | (nnimap-address "127.0.0.1") | |
1208 | (nnimap-server-port 143) | |
1209 | (nnimap-authenticator plain) | |
1210 | (nnimap-user "amin@bndl.org")) | |
1211 | (nnimap "uwaterloo" | |
1212 | (nnimap-stream plain) | |
1213 | (nnimap-address "127.0.0.1") | |
1214 | (nnimap-server-port 143) | |
1215 | (nnimap-authenticator plain) | |
1216 | (nnimap-user "abandali@uwaterloo.ca")) | |
1217 | (nnimap "csclub" | |
1218 | (nnimap-stream plain) | |
1219 | (nnimap-address "127.0.0.1") | |
1220 | (nnimap-server-port 143) | |
1221 | (nnimap-authenticator plain) | |
1222 | (nnimap-user "abandali@csclub.uw"))) | |
1223 | gnus-message-archive-group "nnimap+amin:Sent" | |
1224 | gnus-parameters | |
1225 | '(("gnu\\.deepspec" | |
1226 | (to-address . "deepspec@lists.cs.princeton.edu") | |
1227 | (to-list . "deepspec@lists.cs.princeton.edu")) | |
1228 | ("gnu\\.emacs-devel" | |
1229 | (to-address . "emacs-devel@gnu.org") | |
1230 | (to-list . "emacs-devel@gnu.org")) | |
1231 | ("gnu\\.emacs-orgmode" | |
1232 | (to-address . "emacs-orgmode@gnu.org") | |
1233 | (to-list . "emacs-orgmode@gnu.org")) | |
1234 | ("gnu\\.emacsconf-discuss" | |
1235 | (to-address . "emacsconf-discuss@gnu.org") | |
1236 | (to-list . "emacsconf-discuss@gnu.org")) | |
1237 | ("gnu\\.fencepost-users" | |
1238 | (to-address . "fencepost-users@gnu.org") | |
1239 | (to-list . "fencepost-users@gnu.org")) | |
1240 | ("gnu\\.gnunet-developers" | |
1241 | (to-address . "gnunet-developers@gnu.org") | |
1242 | (to-list . "gnunet-developers@gnu.org")) | |
1243 | ("gnu\\.guile-devel" | |
1244 | (to-address . "guile-devel@gnu.org") | |
1245 | (to-list . "guile-devel@gnu.org")) | |
1246 | ("gnu\\.guix-devel" | |
1247 | (to-address . "guix-devel@gnu.org") | |
1248 | (to-list . "guix-devel@gnu.org")) | |
1249 | ("gnu\\.haskell-art" | |
1250 | (to-address . "haskell-art@we.lurk.org") | |
1251 | (to-list . "haskell-art@we.lurk.org")) | |
1252 | ("gnu\\.haskell-cafe" | |
1253 | (to-address . "haskell-cafe@haskell.org") | |
1254 | (to-list . "haskell-cafe@haskell.org")) | |
1255 | ("gnu\\.help-gnu-emacs" | |
1256 | (to-address . "help-gnu-emacs@gnu.org") | |
1257 | (to-list . "help-gnu-emacs@gnu.org")) | |
1258 | ("gnu\\.info-gnu-emacs" | |
1259 | (to-address . "info-gnu-emacs@gnu.org") | |
1260 | (to-list . "info-gnu-emacs@gnu.org")) | |
1261 | ("gnu\\.info-guix" | |
1262 | (to-address . "info-guix@gnu.org") | |
1263 | (to-list . "info-guix@gnu.org")) | |
1264 | ("gnu\\.notmuch" | |
1265 | (to-address . "notmuch@notmuchmail.org") | |
1266 | (to-list . "notmuch@notmuchmail.org")) | |
1267 | ("gnu\\.parabola-dev" | |
1268 | (to-address . "dev@lists.parabola.nu") | |
1269 | (to-list . "dev@lists.parabola.nu")) | |
1270 | ("gnu\\.webmasters" | |
1271 | (to-address . "webmasters@gnu.org") | |
1272 | (to-list . "webmasters@gnu.org")) | |
1273 | ("gnu\\.www-commits" | |
1274 | (to-address . "www-commits@gnu.org") | |
1275 | (to-list . "www-commits@gnu.org")) | |
1276 | ("gnu\\.www-discuss" | |
1277 | (to-address . "www-discuss@gnu.org") | |
1278 | (to-list . "www-discuss@gnu.org")) | |
1279 | ("gnu\\.~bandali\\.public-inbox" | |
1280 | (to-address . "~bandali/public-inbox@lists.sr.ht") | |
1281 | (to-list . "~bandali/public-inbox@lists.sr.ht")) | |
1282 | ("gnu\\.~sircmpwn\\.srht-admins" | |
1283 | (to-address . "~sircmpwn/sr.ht-admins@lists.sr.ht") | |
1284 | (to-list . "~sircmpwn/sr.ht-admins@lists.sr.ht")) | |
1285 | ("gnu\\.~sircmpwn\\.srht-announce" | |
1286 | (to-address . "~sircmpwn/sr.ht-announce@lists.sr.ht") | |
1287 | (to-list . "~sircmpwn/sr.ht-announce@lists.sr.ht")) | |
1288 | ("gnu\\.~sircmpwn\\.srht-dev" | |
1289 | (to-address . "~sircmpwn/sr.ht-dev@lists.sr.ht") | |
1290 | (to-list . "~sircmpwn/sr.ht-dev@lists.sr.ht")) | |
1291 | ("gnu\\.~sircmpwn\\.srht-discuss" | |
1292 | (to-address . "~sircmpwn/sr.ht-discuss@lists.sr.ht") | |
1293 | (to-list . "~sircmpwn/sr.ht-discuss@lists.sr.ht")) | |
1294 | ("gnu.*" | |
1295 | (gcc-self . t)) | |
1296 | ("gnu\\." | |
1297 | (subscribed . t))) | |
1298 | gnus-large-newsgroup 50 | |
1299 | gnus-home-directory (no-littering-expand-var-file-name "gnus/") | |
1300 | gnus-directory (concat gnus-home-directory "news/") | |
1301 | message-directory (concat gnus-home-directory "mail/") | |
1302 | nndraft-directory (concat gnus-home-directory "drafts/") | |
1303 | gnus-save-newsrc-file nil | |
1304 | gnus-read-newsrc-file nil | |
1305 | gnus-interactive-exit nil | |
1306 | gnus-gcc-mark-as-read t) | |
1307 | :config | |
1308 | (require 'ebdb) | |
1309 | (require 'ebdb-mua) | |
1310 | (require 'ebdb-gnus) | |
1311 | ||
1312 | (with-eval-after-load 'recentf | |
1313 | (add-to-list 'recentf-exclude gnus-home-directory))) | |
1314 | ||
1315 | (use-feature gnus-art | |
1316 | :config | |
1317 | (setq | |
1318 | gnus-visible-headers | |
1319 | (concat gnus-visible-headers "\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:") | |
1320 | gnus-sorted-header-list | |
1321 | '("^From:" "^Subject:" "^Summary:" "^Keywords:" | |
1322 | "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator" | |
1323 | "^Newsgroups:" "List-Id:" "^Organization:" | |
1324 | "^User-Agent:" "^Date:") | |
1325 | ;; local-lapsed article dates | |
1326 | ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11 | |
1327 | gnus-article-date-headers '(user-defined) | |
1328 | gnus-article-time-format | |
1329 | (lambda (time) | |
1330 | (let* ((date (format-time-string "%a, %d %b %Y %T %z" time)) | |
1331 | (local (article-make-date-line date 'local)) | |
1332 | (combined-lapsed (article-make-date-line date | |
1333 | 'combined-lapsed)) | |
1334 | (lapsed (progn | |
1335 | (string-match " (.+" combined-lapsed) | |
1336 | (match-string 0 combined-lapsed)))) | |
1337 | (concat local lapsed)))) | |
1338 | (bind-keys | |
1339 | :map gnus-article-mode-map | |
1340 | ("M-L" . org-store-link))) | |
1341 | ||
1342 | (use-feature gnus-sum | |
1343 | :bind (:map gnus-summary-mode-map | |
1344 | :prefix-map a/gnus-summary-prefix-map | |
1345 | :prefix "v" | |
1346 | ("r" . gnus-summary-reply) | |
1347 | ("w" . gnus-summary-wide-reply) | |
1348 | ("v" . gnus-summary-show-raw-article)) | |
1349 | :config | |
1350 | (bind-keys | |
1351 | :map gnus-summary-mode-map | |
1352 | ("M-L" . org-store-link)) | |
1353 | :hook (gnus-summary-mode . a/no-mouse-autoselect-window)) | |
1354 | ||
1355 | (use-feature gnus-msg | |
1356 | :config | |
1357 | (setq gnus-posting-styles | |
1358 | '((".*" | |
1359 | (address "amin@bndl.org") | |
1360 | (body "\nBest,\n") | |
1361 | (eval (setq a/message-cite-say-hi t))) | |
1362 | ("gnu.*" | |
1363 | (address "bandali@gnu.org") | |
1364 | (eval (set (make-local-variable 'message-user-fqdn) "fencepost.gnu.org"))) | |
1365 | ((header "subject" "ThankCRM") | |
1366 | (to "webmasters-comment@gnu.org") | |
1367 | (body "Added to 2019supporters.html.\n\nMoving to campaigns.\n\n-amin\n") | |
1368 | (eval (setq a/message-cite-say-hi nil))) | |
1369 | ("nnimap\\+uwaterloo:.*" | |
1370 | (address "abandali@uwaterloo.ca") | |
1371 | (gcc "\"nnimap+uwaterloo:Sent Items\"")) | |
1372 | ("nnimap\\+csclub:.*" | |
1373 | (address "abandali@csclub.uwaterloo.ca") | |
1374 | (gcc "nnimap+csclub:Sent"))))) | |
1375 | ||
1376 | (use-feature gnus-topic | |
1377 | :hook (gnus-group-mode . gnus-topic-mode) | |
1378 | :config (setq gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n")) | |
1379 | ||
1380 | (use-feature gnus-agent | |
1381 | :config | |
1382 | (setq gnus-agent-synchronize-flags 'ask) | |
1383 | :hook (gnus-group-mode . gnus-agent-mode)) | |
1384 | ||
1385 | (use-feature gnus-group | |
1386 | :config | |
1387 | (setq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)")) | |
1388 | ||
1389 | (use-feature mm-decode | |
1390 | :config | |
1391 | (setq mm-discouraged-alternatives '("text/html" "text/richtext"))) | |
1392 | ||
1393 | (use-feature sendmail | |
1394 | :config | |
1395 | (setq sendmail-program "/usr/bin/msmtp" | |
1396 | ;; message-sendmail-extra-arguments '("-v" "-d") | |
1397 | mail-specify-envelope-from t | |
1398 | mail-envelope-from 'header)) | |
1399 | ||
1400 | (use-feature message | |
1401 | :config | |
1402 | ;; redefine for a simplified In-Reply-To header | |
1403 | ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67) | |
1404 | (defun message-make-in-reply-to () | |
1405 | "Return the In-Reply-To header for this message." | |
1406 | (when message-reply-headers | |
1407 | (let ((from (mail-header-from message-reply-headers)) | |
1408 | (msg-id (mail-header-id message-reply-headers))) | |
1409 | (when from | |
1410 | msg-id)))) | |
1411 | ||
1412 | (defconst a/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:") | |
1413 | (defconst message-cite-style-bandali | |
1414 | '((message-cite-function 'message-cite-original) | |
1415 | (message-citation-line-function 'message-insert-formatted-citation-line) | |
1416 | (message-cite-reply-position 'traditional) | |
1417 | (message-yank-prefix "> ") | |
1418 | (message-yank-cited-prefix ">") | |
1419 | (message-yank-empty-prefix ">") | |
1420 | (message-citation-line-format | |
1421 | (if a/message-cite-say-hi | |
1422 | (concat "Hi %F,\n\n" a/message-cite-style-format) | |
1423 | a/message-cite-style-format))) | |
1424 | "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.") | |
1425 | (setq ;; message-cite-style 'message-cite-style-bandali | |
1426 | message-kill-buffer-on-exit t | |
1427 | message-send-mail-function 'message-send-mail-with-sendmail | |
1428 | message-sendmail-envelope-from 'header | |
1429 | message-subscribed-address-functions | |
1430 | '(gnus-find-subscribed-addresses) | |
1431 | message-dont-reply-to-names | |
1432 | "\\(\\(amin@bndl\\.org\\)\\|\\(.*@\\(aminb\\|amin\\.bndl\\)\\.org\\)\\|\\(\\(bandali\\|aminb?\\|mab\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)") | |
1433 | (require 'company-ebdb) | |
1434 | :hook (;; (message-setup . mml-secure-message-sign-pgpmime) | |
1435 | (message-mode . flyspell-mode) | |
1436 | (message-mode . (lambda () | |
1437 | ;; (setq fill-column 65 | |
1438 | ;; message-fill-column 65) | |
1439 | (make-local-variable 'company-idle-delay) | |
1440 | (setq company-idle-delay 0.2)))) | |
1441 | ;; :custom-face | |
1442 | ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold)))) | |
1443 | ;; (message-header-to ((t (:foreground "#111" :weight normal)))) | |
1444 | ;; (message-header-cc ((t (:foreground "#333" :weight normal)))) | |
1445 | ) | |
1446 | ||
1447 | (with-eval-after-load 'mml-sec | |
1448 | (setq mml-secure-openpgp-encrypt-to-self t | |
1449 | mml-secure-openpgp-sign-with-sender t)) | |
1450 | ||
1451 | (use-feature footnote | |
1452 | :after message | |
1453 | ;; :config | |
1454 | ;; (setq footnote-start-tag "" | |
1455 | ;; footnote-end-tag "" | |
1456 | ;; footnote-style 'unicode) | |
1457 | :bind | |
1458 | (:map message-mode-map | |
1459 | :prefix-map a/footnote-prefix-map | |
1460 | :prefix "C-c f" | |
1461 | ("a" . footnote-add-footnote) | |
1462 | ("b" . footnote-back-to-message) | |
1463 | ("c" . footnote-cycle-style) | |
1464 | ("d" . footnote-delete-footnote) | |
1465 | ("g" . footnote-goto-footnote) | |
1466 | ("r" . footnote-renumber-footnotes) | |
1467 | ("s" . footnote-set-style))) | |
1468 | ||
1469 | (use-package ebdb | |
1470 | :straight (:host github :repo "girzel/ebdb") | |
1471 | :after gnus | |
1472 | :bind (:map gnus-group-mode-map ("e" . ebdb)) | |
1473 | :config | |
1474 | (setq ebdb-sources (no-littering-expand-var-file-name "ebdb")) | |
1475 | (with-eval-after-load 'swiper | |
1476 | (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t))) | |
1477 | ||
1478 | (use-feature ebdb-com | |
1479 | :after ebdb) | |
1480 | ||
1481 | ;; (use-package ebdb-complete | |
1482 | ;; :after ebdb | |
1483 | ;; :config | |
1484 | ;; (ebdb-complete-enable)) | |
1485 | ||
1486 | (use-package company-ebdb | |
1487 | :config | |
1488 | (defun company-ebdb--post-complete (_) nil)) | |
1489 | ||
1490 | (use-feature ebdb-gnus | |
1491 | :after ebdb | |
1492 | :custom | |
1493 | (ebdb-gnus-window-configuration | |
1494 | '(article | |
1495 | (vertical 1.0 | |
1496 | (summary 0.25 point) | |
1497 | (horizontal 1.0 | |
1498 | (article 1.0) | |
1499 | (ebdb-gnus 0.3)))))) | |
1500 | ||
1501 | (use-feature ebdb-mua | |
1502 | :after ebdb | |
1503 | ;; :custom (ebdb-mua-pop-up nil) | |
1504 | ) | |
1505 | ||
1506 | ;; (use-package ebdb-message | |
1507 | ;; :after ebdb) | |
1508 | ||
1509 | ||
1510 | ;; (use-package ebdb-vcard | |
1511 | ;; :after ebdb) | |
1512 | ||
1513 | (use-package message-x) | |
1514 | ||
1515 | (use-package znc | |
1516 | :straight (:host nil :repo "https://git.bndl.org/amin/znc.el") | |
1517 | :bind (("C-c a e e" . znc-erc) | |
1518 | ("C-c a e a" . znc-all)) | |
1519 | :config | |
1520 | (let ((pwd (let ((auth (auth-source-search :host "znca"))) | |
1521 | (cond | |
1522 | ((null auth) (error "Couldn't find znca's authinfo")) | |
1523 | (t (funcall (plist-get (car auth) :secret))))))) | |
1524 | (setq znc-servers | |
1525 | `(("znc.bndl.org" 1337 t | |
1526 | ((freenode "amin/freenode" ,pwd))) | |
1527 | ("znc.bndl.org" 1337 t | |
1528 | ((moznet "amin/moznet" ,pwd))))))) | |
1529 | ||
1530 | (message "Loading %s...done (%.3fs)" user-init-file | |
1531 | (float-time (time-subtract (current-time) | |
1532 | a/before-user-init-time))) | |
1533 | ||
1534 | ;;; init.el ends here |