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