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