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