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.") | |
44 | ||
45 | (when (not (bound-and-true-p b/emacs-initialized)) | |
46 | (message "Loading Emacs...done (%.3fs)" | |
47 | (float-time (time-subtract b/before-user-init-time | |
48 | before-init-time)))) | |
41d290a2 | 49 | |
b57457b2 AB |
50 | ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage' |
51 | ;; during startup to reduce garbage collection frequency. clearing | |
52 | ;; `file-name-handler-alist' seems to help reduce startup time too. | |
dca50cf5 AB |
53 | (defvar b/gc-cons-threshold gc-cons-threshold) |
54 | (defvar b/gc-cons-percentage gc-cons-percentage) | |
55 | (defvar b/file-name-handler-alist file-name-handler-alist) | |
bc58e70a | 56 | (setq gc-cons-threshold (* 30 1024 1024) ; 30 MiB |
41d290a2 AB |
57 | gc-cons-percentage 0.6 |
58 | file-name-handler-alist nil | |
59 | ;; sidesteps a bug when profiling with esup | |
60 | esup-child-profile-require-level 0) | |
61 | ||
b57457b2 | 62 | ;; set them back to their defaults once we're done initializing |
dca50cf5 | 63 | (defun b/post-init () |
83364e5b AB |
64 | "My post-initialize function, run after loading `user-init-file'." |
65 | (setq b/emacs-initialized t | |
66 | gc-cons-threshold b/gc-cons-threshold | |
67 | gc-cons-percentage b/gc-cons-percentage | |
e8a3b8f7 | 68 | file-name-handler-alist b/file-name-handler-alist) |
c84be134 | 69 | (when (featurep 'exwm-workspace) |
8b1a2f32 AB |
70 | (with-eval-after-load 'exwm-workspace |
71 | (setq-default | |
72 | mode-line-format | |
73 | (append | |
74 | mode-line-format | |
75 | '((:eval | |
76 | (format | |
77 | "[%s]" (number-to-string | |
8c4704d0 AB |
78 | exwm-workspace-current-index)))))))) |
79 | ||
80 | ;; make some mode-line spaces smaller | |
81 | (csetq | |
82 | mode-line-format | |
83 | (mapcar | |
84 | (lambda (x) | |
85 | (if (and (stringp x) (or (string= x " ") (string= x " "))) | |
86 | " " | |
87 | x)) | |
88 | mode-line-format) | |
89 | mode-line-buffer-identification | |
90 | (propertized-buffer-identification "%10b"))) | |
dca50cf5 | 91 | (add-hook 'after-init-hook #'b/post-init) |
41d290a2 | 92 | |
b57457b2 | 93 | ;; increase number of lines kept in *Messages* log |
41d290a2 AB |
94 | (setq message-log-max 20000) |
95 | ||
b57457b2 AB |
96 | ;; optionally, uncomment to supress some byte-compiler warnings |
97 | ;; (see C-h v byte-compile-warnings RET for more info) | |
41d290a2 AB |
98 | ;; (setq byte-compile-warnings |
99 | ;; '(not free-vars unresolved noruntime lexical make-local)) | |
100 | ||
b57457b2 AB |
101 | \f |
102 | ;;; whoami | |
103 | ||
41d290a2 | 104 | (setq user-full-name "Amin Bandali" |
33b1a7ea | 105 | user-mail-address "bandali@gnu.org") |
41d290a2 | 106 | |
b57457b2 | 107 | \f |
33273849 AB |
108 | ;;; Package management |
109 | ||
8c4704d0 AB |
110 | ;; (progn ; `borg' |
111 | ;; (add-to-list 'load-path | |
112 | ;; (expand-file-name "lib/borg" user-emacs-directory)) | |
113 | ;; (require 'borg) | |
114 | ;; (borg-initialize) | |
115 | ;; (setq borg-rewrite-urls-alist | |
116 | ;; '(("git@github.com:" . "https://github.com/") | |
117 | ;; ("git@gitlab.com:" . "https://gitlab.com/")))) | |
118 | ||
119 | ;; variables of interest: | |
120 | ;; package-archive-priorities | |
121 | ;; package-load-list | |
122 | ;; package-pinned-packages | |
123 | ||
124 | ;; (let* ((b (find-file-noselect "refinery-theme.el")) | |
125 | ;; (d (with-current-buffer b (package-buffer-info)))) | |
126 | ;; (package-generate-description-file d "refinery-theme-pkg.el")) | |
127 | (run-with-idle-timer 0.01 nil #'require 'package) | |
128 | (with-eval-after-load 'package | |
129 | (when (= (length package-archives) 1) | |
130 | (csetq | |
131 | package-archives | |
132 | `(,@package-archives | |
133 | ("org" . "https://orgmode.org/elpa/") | |
134 | ("bndl" . "https://p.bndl.org/elpa/")))) | |
135 | (package-initialize)) | |
136 | ||
137 | (csetq package-archive-upload-base "/ssh:caffeine:~/www/p/elpa") | |
41d290a2 | 138 | |
b57457b2 AB |
139 | \f |
140 | ;;; Initial setup | |
141 | ||
142 | ;; keep ~/.emacs.d clean | |
0596e3cf AB |
143 | (defvar b/etc-dir |
144 | (expand-file-name | |
145 | (convert-standard-filename "etc/") user-emacs-directory) | |
146 | "The directory where packages place their configuration files.") | |
147 | (defvar b/var-dir | |
148 | (expand-file-name | |
149 | (convert-standard-filename "var/") user-emacs-directory) | |
150 | "The directory where packages place their persistent data files.") | |
8c4704d0 AB |
151 | (defvar b/lisp-dir |
152 | (expand-file-name | |
153 | (convert-standard-filename "lisp/") user-emacs-directory) | |
154 | "The directory where packages place their persistent data files.") | |
0596e3cf AB |
155 | (defun b/etc (file) |
156 | "Expand filename FILE relative to `b/etc-dir'." | |
157 | (expand-file-name (convert-standard-filename file) b/etc-dir)) | |
158 | (defun b/var (file) | |
159 | "Expand filename FILE relative to `b/var-dir'." | |
160 | (expand-file-name (convert-standard-filename file) b/var-dir)) | |
8c4704d0 AB |
161 | (defun b/lisp (file) |
162 | "Expand filename FILE relative to `b/lisp-dir'." | |
163 | (expand-file-name (convert-standard-filename file) b/lisp-dir)) | |
0596e3cf AB |
164 | |
165 | (csetq | |
166 | auto-save-list-file-prefix (b/var "auto-save/sessions/") | |
167 | nsm-settings-file (b/var "nsm-settings.el")) | |
c84be134 | 168 | |
b57457b2 | 169 | ;; separate custom file (don't want it mixing with init.el) |
c84be134 | 170 | (with-eval-after-load 'custom |
dca50cf5 | 171 | (setq custom-file (b/etc "custom.el")) |
41d290a2 AB |
172 | (when (file-exists-p custom-file) |
173 | (load custom-file)) | |
b57457b2 | 174 | ;; while at it, treat themes as safe |
8c4704d0 | 175 | ;; (setf custom-safe-themes t) |
60ff805e AB |
176 | ;; only one custom theme at a time |
177 | (comment | |
178 | (defadvice load-theme (before clear-previous-themes activate) | |
179 | "Clear existing theme settings instead of layering them" | |
180 | (mapc #'disable-theme custom-enabled-themes)))) | |
41d290a2 | 181 | |
b57457b2 | 182 | ;; load the secrets file if it exists, otherwise show a warning |
dca50cf5 AB |
183 | (comment |
184 | (with-demoted-errors | |
185 | (load (b/etc "secrets")))) | |
41d290a2 | 186 | |
b57457b2 AB |
187 | ;; start up emacs server. see |
188 | ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server | |
c84be134 AB |
189 | (run-with-idle-timer 0.5 nil #'require 'server) |
190 | (with-eval-after-load 'server | |
2087ae39 | 191 | (declare-function server-edit "server") |
0596e3cf | 192 | (global-set-key (kbd "C-c F D") #'server-edit) |
2087ae39 AB |
193 | (declare-function server-running-p "server") |
194 | (or (server-running-p) (server-mode))) | |
41d290a2 | 195 | |
60ff805e | 196 | \f |
60ff805e AB |
197 | ;;; Defaults |
198 | ||
199 | ;;;; C-level customizations | |
200 | ||
c84be134 | 201 | (csetq |
60ff805e AB |
202 | ;; minibuffer |
203 | enable-recursive-minibuffers t | |
204 | resize-mini-windows t | |
205 | ;; more useful frame titles | |
7c558c9b AB |
206 | ;; frame-title-format '("" invocation-name " - " |
207 | ;; (:eval | |
208 | ;; (if (buffer-file-name) | |
209 | ;; (abbreviate-file-name (buffer-file-name)) | |
210 | ;; "%b"))) | |
60ff805e AB |
211 | ;; i don't feel like jumping out of my chair every now and again; so |
212 | ;; don't BEEP! at me, emacs | |
213 | ring-bell-function 'ignore | |
214 | ;; better scrolling | |
215 | ;; scroll-margin 1 | |
216 | ;; scroll-conservatively 10000 | |
217 | scroll-step 1 | |
bdd3a0bb | 218 | scroll-conservatively 101 |
60ff805e AB |
219 | scroll-preserve-screen-position 1 |
220 | ;; focus follows mouse | |
39cc9c96 | 221 | mouse-autoselect-window t) |
60ff805e AB |
222 | |
223 | (setq-default | |
224 | ;; always use space for indentation | |
225 | indent-tabs-mode nil | |
226 | tab-width 4 | |
7682baf8 AB |
227 | ;; case-sensitive search (and `dabbrev-expand') |
228 | ;; case-fold-search nil | |
60ff805e | 229 | ;; cursor shape |
567440fa | 230 | cursor-type t) |
60ff805e | 231 | |
7c558c9b AB |
232 | (set-fontset-font t 'arabic "Vazir") |
233 | ||
b57457b2 AB |
234 | ;; unicode support |
235 | (comment | |
236 | (dolist (ft (fontset-list)) | |
237 | (set-fontset-font | |
238 | ft | |
239 | 'unicode | |
240 | (font-spec :name "Source Code Pro" :size 14)) | |
241 | (set-fontset-font | |
242 | ft | |
243 | 'unicode | |
244 | (font-spec :name "DejaVu Sans Mono") | |
245 | nil | |
246 | 'append) | |
247 | ;; (set-fontset-font | |
248 | ;; ft | |
249 | ;; 'unicode | |
250 | ;; (font-spec | |
251 | ;; :name "Symbola monospacified for DejaVu Sans Mono") | |
252 | ;; nil | |
253 | ;; 'append) | |
254 | ;; (set-fontset-font | |
255 | ;; ft | |
256 | ;; #x2115 ; ℕ | |
257 | ;; (font-spec :name "DejaVu Sans Mono") | |
258 | ;; nil | |
259 | ;; 'append) | |
260 | (set-fontset-font | |
261 | ft | |
262 | (cons ?Α ?ω) | |
263 | (font-spec :name "DejaVu Sans Mono" :size 14) | |
264 | nil | |
265 | 'prepend))) | |
266 | ||
60ff805e | 267 | ;;;; Elisp-level customizations |
41d290a2 | 268 | |
c84be134 AB |
269 | ;; startup |
270 | ;; don't need to see the startup echo area message | |
271 | (advice-add #'display-startup-echo-area-message :override #'ignore) | |
272 | (csetq | |
273 | ;; i want *scratch* as my startup buffer | |
274 | initial-buffer-choice t | |
275 | ;; i don't need the default hint | |
276 | initial-scratch-message nil | |
277 | ;; use customizable text-mode as major mode for *scratch* | |
278 | ;; (initial-major-mode 'text-mode) | |
279 | ;; inhibit buffer list when more than 2 files are loaded | |
280 | inhibit-startup-buffer-menu t | |
281 | ;; don't need to see the startup screen or echo area message | |
282 | inhibit-startup-screen t | |
283 | inhibit-startup-echo-area-message user-login-name) | |
284 | ||
285 | ;; files | |
286 | (csetq | |
287 | ;; backups (C-h v make-backup-files RET) | |
288 | backup-by-copying t | |
0596e3cf | 289 | backup-directory-alist (list (cons "." (b/var "backup/"))) |
c84be134 AB |
290 | version-control t |
291 | delete-old-versions t | |
292 | ;; auto-save | |
293 | auto-save-file-name-transforms `((".*" ,(b/var "auto-save/") t)) | |
294 | ;; insert newline at the end of files | |
295 | require-final-newline t | |
296 | ;; open read-only file buffers in view-mode | |
297 | ;; (enables niceties like `q' for quit) | |
298 | view-read-only t) | |
299 | ||
300 | ;; novice | |
60ff805e | 301 | ;; disable disabled commands |
c84be134 | 302 | (csetq disabled-command-function nil) |
41d290a2 | 303 | |
60ff805e AB |
304 | ;; lazy-person-friendly yes/no prompts |
305 | (defalias 'yes-or-no-p #'y-or-n-p) | |
b57457b2 | 306 | |
8c4704d0 AB |
307 | ;; autorevert: enable automatic reloading of changed buffers and files |
308 | (csetq auto-revert-verbose nil | |
309 | global-auto-revert-non-file-buffers nil) | |
310 | (require 'autorevert) | |
311 | (global-auto-revert-mode 1) | |
b57457b2 AB |
312 | |
313 | ;; time and battery in mode-line | |
c84be134 AB |
314 | (csetq |
315 | display-time-default-load-average nil | |
316 | display-time-format " %a %b %-e %-l:%M%P" | |
317 | display-time-mail-icon '(image :type xpm | |
318 | :file "gnus/gnus-pointer.xpm" | |
319 | :ascent center) | |
320 | display-time-use-mail-icon t) | |
321 | (require 'time) | |
322 | (display-time-mode) | |
323 | ||
8c4704d0 | 324 | (csetq battery-mode-line-format " %p%% %t") |
c84be134 AB |
325 | (require 'battery) |
326 | (display-battery-mode) | |
327 | ||
328 | (require 'fringe) | |
329 | ;; smaller fringe | |
330 | ;; (fringe-mode '(3 . 1)) | |
331 | (fringe-mode nil) | |
332 | ||
333 | (require 'winner) | |
334 | ;; enable winner-mode (C-h f winner-mode RET) | |
335 | (winner-mode 1) | |
336 | ||
337 | (with-eval-after-load 'compile | |
60ff805e AB |
338 | ;; don't display *compilation* buffer on success. based on |
339 | ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf' | |
340 | ;; instead of the now obsolete `flet'. | |
dca50cf5 | 341 | (defun b/compilation-finish-function (buffer outstr) |
41d290a2 AB |
342 | (unless (string-match "finished" outstr) |
343 | (switch-to-buffer-other-window buffer)) | |
344 | t) | |
345 | ||
dca50cf5 | 346 | (setq compilation-finish-functions #'b/compilation-finish-function) |
41d290a2 AB |
347 | |
348 | (require 'cl-macs) | |
349 | ||
350 | (defadvice compilation-start | |
351 | (around inhibit-display | |
352 | (command &optional mode name-function highlight-regexp)) | |
353 | (if (not (string-match "^\\(find\\|grep\\)" command)) | |
354 | (cl-letf (((symbol-function 'display-buffer) #'ignore)) | |
355 | (save-window-excursion ad-do-it)) | |
356 | ad-do-it)) | |
357 | (ad-activate 'compilation-start)) | |
358 | ||
c84be134 AB |
359 | ;; isearch |
360 | (csetq | |
361 | ;; allow scrolling in Isearch | |
362 | isearch-allow-scroll t | |
363 | ;; search for non-ASCII characters: i’d like non-ASCII characters such | |
364 | ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII | |
365 | ;; counterpart. shoutout to | |
366 | ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html | |
367 | search-default-mode #'char-fold-to-regexp) | |
368 | ||
369 | ;; replace | |
60ff805e | 370 | ;; uncomment to extend the above behaviour to query-replace |
c84be134 AB |
371 | ;; (csetq replace-char-fold t) |
372 | ||
373 | ;; vc | |
374 | (global-set-key (kbd "C-x v C-=") #'vc-ediff) | |
375 | ||
376 | (with-eval-after-load 'vc-git | |
377 | (csetq vc-git-print-log-follow t)) | |
378 | ||
379 | (csetq ediff-window-setup-function 'ediff-setup-windows-plain | |
380 | ediff-split-window-function 'split-window-horizontally) | |
381 | (with-eval-after-load 'ediff | |
382 | (add-hook 'ediff-after-quit-hook-internal #'winner-undo)) | |
383 | ||
384 | ;; face-remap | |
385 | (csetq | |
386 | ;; gentler font resizing | |
387 | text-scale-mode-step 1.05) | |
388 | ||
389 | (run-with-idle-timer 0.4 nil #'require 'mwheel) | |
390 | (csetq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time | |
391 | mouse-wheel-progressive-speed nil ; don't accelerate scrolling | |
392 | mouse-wheel-follow-mouse t) ; scroll window under mouse | |
393 | ||
394 | (run-with-idle-timer 0.4 nil #'require 'pixel-scroll) | |
395 | (with-eval-after-load 'pixel-scroll | |
396 | (pixel-scroll-mode 1)) | |
397 | ||
398 | ;; epg-config | |
399 | (csetq | |
400 | epg-gpg-program (executable-find "gpg") | |
401 | ;; ask for GPG passphrase in minibuffer | |
402 | ;; this will fail if gpg>=2.1 is not available | |
403 | epg-pinentry-mode 'loopback) | |
404 | ||
405 | ;; (require 'pinentry) | |
406 | ;; workaround for systemd-based distros: | |
407 | ;; (setq pinentry--socket-dir server-socket-dir) | |
408 | ;; (pinentry-start) | |
409 | ||
410 | ;; auth-source | |
411 | (csetq | |
412 | auth-sources '("~/.authinfo.gpg") | |
413 | authinfo-hidden (regexp-opt '("password" "client-secret" "token"))) | |
b98dbb3d | 414 | |
b57457b2 | 415 | \f |
c84be134 | 416 | ;;; General key bindings |
b57457b2 | 417 | |
c84be134 AB |
418 | (global-set-key (kbd "C-a") #'b/move-indentation-or-beginning-of-line) |
419 | (global-set-key (kbd "C-c a i") #'ielm) | |
420 | (global-set-key (kbd "C-c d") #'b/duplicate-line-or-region) | |
421 | (global-set-key (kbd "C-S-j") #'b/join-line-top) | |
422 | (global-set-key (kbd "C-c x") #'execute-extended-command) | |
41d290a2 | 423 | |
c84be134 AB |
424 | ;; evaling and macro-expanding |
425 | (global-set-key (kbd "C-c e b") #'eval-buffer) | |
426 | (global-set-key (kbd "C-c e e") #'eval-last-sexp) | |
427 | (global-set-key (kbd "C-c e p") #'pp-macroexpand-last-sexp) | |
428 | (global-set-key (kbd "C-c e r") #'eval-region) | |
41d290a2 | 429 | |
c84be134 AB |
430 | ;; emacs things |
431 | (global-set-key (kbd "C-c e i") #'emacs-init-time) | |
432 | (global-set-key (kbd "C-c e u") #'emacs-uptime) | |
433 | (global-set-key (kbd "C-c e v") #'emacs-version) | |
41d290a2 | 434 | |
c84be134 AB |
435 | ;; finding |
436 | (global-set-key (kbd "C-c f .") #'find-file) | |
437 | (global-set-key (kbd "C-c f d") #'find-name-dired) | |
438 | (global-set-key (kbd "C-c f l") #'find-library) | |
567440fa | 439 | |
c84be134 AB |
440 | ;; frames |
441 | (global-set-key (kbd "C-c F m") #'make-frame-command) | |
442 | (global-set-key (kbd "C-c F d") #'delete-frame) | |
41d290a2 | 443 | |
c84be134 AB |
444 | ;; help/describe |
445 | (global-set-key (kbd "C-S-h C") #'describe-char) | |
446 | (global-set-key (kbd "C-S-h F") #'describe-face) | |
41d290a2 | 447 | |
c84be134 AB |
448 | ;; (global-set-key (kbd "C-x k") #'b/kill-current-buffer) |
449 | ;; (global-set-key (kbd "C-x K") #'kill-buffer) | |
450 | ;; (global-set-key (kbd "C-x s") #'save-buffer) | |
451 | ;; (global-set-key (kbd "C-x S") #'save-some-buffers) | |
e5c2d147 | 452 | |
c84be134 | 453 | (define-key emacs-lisp-mode-map (kbd "<C-return>") #'b/add-elisp-section) |
41d290a2 AB |
454 | |
455 | (when (display-graphic-p) | |
c84be134 | 456 | (global-unset-key (kbd "C-z"))) |
500004f4 | 457 | |
b57457b2 AB |
458 | \f |
459 | ;;; Essential packages | |
460 | ||
c84be134 | 461 | ;; (require 'bandali-exwm) |
33273849 | 462 | |
f7910e3d | 463 | (require 'bandali-org) |
41d290a2 | 464 | |
9c48decc AB |
465 | (require 'bandali-theme) |
466 | ||
0596e3cf | 467 | ;; magit, *the* right way to do git |
8c4704d0 | 468 | (comment |
0596e3cf AB |
469 | (csetq transient-history-file (b/var "transient/history.el") |
470 | transient-levels-file (b/etc "transient/levels.el") | |
471 | transient-values-file (b/etc "transient/values.el")) | |
c84be134 | 472 | (with-eval-after-load 'magit |
2087ae39 AB |
473 | (declare-function magit-add-section-hook "magit-section" |
474 | (hook function &optional at append local)) | |
41d290a2 AB |
475 | (magit-add-section-hook 'magit-status-sections-hook |
476 | 'magit-insert-modules | |
477 | 'magit-insert-stashes | |
478 | 'append) | |
3b3615f5 AB |
479 | ;; (magit-add-section-hook 'magit-status-sections-hook |
480 | ;; 'magit-insert-ignored-files | |
481 | ;; 'magit-insert-untracked-files | |
482 | ;; 'append) | |
c84be134 AB |
483 | (declare-function magit-display-buffer-fullframe-status-v1 |
484 | "magit-mode" (buffer)) | |
485 | (csetq | |
486 | magit-diff-refine-hunk t | |
487 | magit-repository-directories '(("~/.emacs.d/" . 0) | |
488 | ("~/src/git/" . 2)) | |
489 | ;; magit-completing-read-function 'magit-ido-completing-read | |
490 | magit-display-buffer-function | |
491 | #'magit-display-buffer-fullframe-status-v1) | |
41d290a2 AB |
492 | (nconc magit-section-initial-visibility-alist |
493 | '(([unpulled status] . show) | |
494 | ([unpushed status] . show))) | |
c84be134 AB |
495 | (custom-set-faces '(magit-diff-file-heading ((t (:weight normal))))) |
496 | ||
497 | (with-eval-after-load 'magit-extras | |
498 | (csetq | |
499 | magit-pop-revision-stack-format | |
500 | (pcase-let ((`(,pt ,_eob ,index-regexp) | |
501 | (default-value 'magit-pop-revision-stack-format))) | |
502 | `(,pt "[%N: %h]: %ci\n %s | |
7c558c9b | 503 | https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=%H" |
c84be134 AB |
504 | ,index-regexp))))) |
505 | ;; global key bindings | |
506 | (global-set-key (kbd "C-x g") #'magit-status) | |
507 | (global-set-key (kbd "C-c g b") #'magit-blame-addition) | |
508 | (global-set-key (kbd "C-c g l") #'magit-log-buffer-file) | |
509 | (global-set-key (kbd "C-c g y") #'magit-pop-revision-stack) | |
8c4704d0 | 510 | ) |
7c558c9b | 511 | |
b57457b2 | 512 | ;; recently opened files |
8c4704d0 AB |
513 | (csetq recentf-max-saved-items 2000 |
514 | recentf-save-file (b/var "recentf-save.el")) | |
c84be134 AB |
515 | (run-with-idle-timer 0.2 nil #'require 'recentf) |
516 | (with-eval-after-load 'recentf | |
8c4704d0 | 517 | ;; (add-to-list 'recentf-keep #'file-remote-p) |
c84be134 | 518 | (recentf-mode)) |
41d290a2 | 519 | |
679463c6 | 520 | ;; needed for history for counsel |
0596e3cf | 521 | (csetq amx-save-file (b/var "amx-save.el")) |
8c4704d0 AB |
522 | (add-to-list 'load-path (b/lisp "s")) |
523 | (add-to-list 'load-path (b/lisp "amx")) | |
c84be134 AB |
524 | (run-with-idle-timer 0.3 nil #'require 'amx) |
525 | (with-eval-after-load 'amx | |
6eb104ff AB |
526 | (amx-mode)) |
527 | ||
679463c6 | 528 | (require 'bandali-ivy) |
41d290a2 | 529 | |
679463c6 | 530 | (require 'bandali-eshell) |
41d290a2 | 531 | |
679463c6 | 532 | (require 'bandali-ibuffer) |
41d290a2 | 533 | |
c84be134 AB |
534 | ;; outline |
535 | ;; (with-eval-after-load 'outline | |
536 | ;; (when (featurep 'which-key) | |
537 | ;; (which-key-add-key-based-replacements | |
538 | ;; "C-c @" "outline" | |
539 | ;; "s-O" "outline")) | |
540 | ;; (define-key outline-minor-mode-map (kbd "<s-tab>") | |
541 | ;; #'outline-toggle-children) | |
542 | ;; (define-key outline-minor-mode-map (kbd "M-p") | |
543 | ;; #'outline-previous-visible-heading) | |
544 | ;; (define-key outline-minor-mode-map (kbd "M-n") | |
545 | ;; #'outline-next-visible-heading) | |
546 | ;; (defvar b/outline-prefix-map) | |
547 | ;; (define-prefix-command 'b/outline-prefix-map) | |
548 | ;; (define-key outline-minor-mode-map (kbd "s-O") | |
549 | ;; 'b/outline-prefix-map) | |
550 | ;; (define-key b/outline-prefix-map (kbd "TAB") | |
551 | ;; #'outline-toggle-children) | |
552 | ;; (define-key b/outline-prefix-map (kbd "a") | |
553 | ;; #'outline-hide-body) | |
554 | ;; (define-key b/outline-prefix-map (kbd "H") | |
555 | ;; #'outline-hide-body) | |
556 | ;; (define-key b/outline-prefix-map (kbd "S") | |
557 | ;; #'outline-show-all) | |
558 | ;; (define-key b/outline-prefix-map (kbd "h") | |
559 | ;; #'outline-hide-subtree) | |
560 | ;; (define-key b/outline-prefix-map (kbd "s") | |
561 | ;; #'outline-show-subtree)) | |
562 | ;; (add-hook 'prog-mode-hook #'outline-minor-mode) | |
41d290a2 | 563 | |
679463c6 | 564 | (require 'bandali-dired) |
41d290a2 | 565 | |
c84be134 | 566 | (with-eval-after-load 'help |
41d290a2 | 567 | (temp-buffer-resize-mode) |
8c4704d0 | 568 | (csetq help-window-select t)) |
41d290a2 | 569 | |
8c4704d0 | 570 | (with-eval-after-load 'help-mode |
c84be134 AB |
571 | ;; local key bindings |
572 | (define-key help-mode-map (kbd "p") #'backward-button) | |
573 | (define-key help-mode-map (kbd "n") #'forward-button)) | |
574 | ||
575 | (with-eval-after-load 'tramp | |
0596e3cf AB |
576 | (csetq tramp-auto-save-directory (b/var "tramp/auto-save/") |
577 | tramp-persistency-file-name (b/var "tramp/persistency.el")) | |
41d290a2 AB |
578 | (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:")) |
579 | (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)) | |
580 | (add-to-list 'tramp-default-proxies-alist | |
581 | (list (regexp-quote (system-name)) nil nil))) | |
582 | ||
c84be134 AB |
583 | (with-eval-after-load 'doc-view |
584 | (define-key doc-view-mode-map (kbd "M-RET") #'image-previous-line)) | |
41d290a2 | 585 | |
c84be134 | 586 | (csetq shr-max-width 80) |
7c558c9b | 587 | |
e2178fd3 | 588 | ;; Email (with Gnus, message, and EBDB) |
2087ae39 | 589 | (require 'bandali-gnus) |
c84be134 AB |
590 | (with-eval-after-load 'sendmail |
591 | (csetq sendmail-program (executable-find "msmtp") | |
592 | ;; message-sendmail-extra-arguments '("-v" "-d") | |
593 | mail-specify-envelope-from t | |
594 | mail-envelope-from 'header)) | |
2087ae39 | 595 | (require 'bandali-message) |
e2178fd3 | 596 | (require 'bandali-ebdb) |
2087ae39 | 597 | |
8c4704d0 | 598 | ;; IRC (with ERC) |
39c1c073 AB |
599 | (require 'bandali-erc) |
600 | ||
8c4704d0 | 601 | (add-to-list 'load-path (b/lisp "scpaste")) |
c84be134 AB |
602 | (with-eval-after-load 'scpaste |
603 | (csetq scpaste-http-destination "https://p.bndl.org" | |
604 | scpaste-scp-destination "p:~")) | |
8c4704d0 AB |
605 | (autoload 'scpaste "scpaste" nil t) |
606 | (autoload 'scpaste-region "scpaste" nil t) | |
0596e3cf AB |
607 | (global-set-key (kbd "C-c a p p") #'scpaste) |
608 | (global-set-key (kbd "C-c a p r") #'scpaste-region) | |
2331b5a0 | 609 | |
b57457b2 AB |
610 | \f |
611 | ;;; Editing | |
5750405c | 612 | |
b57457b2 | 613 | ;; display Lisp objects at point in the echo area |
c84be134 AB |
614 | (when (version< "25" emacs-version) |
615 | (with-eval-after-load 'eldoc | |
8c4704d0 AB |
616 | (csetq eldoc-minor-mode-string " eldoc") |
617 | (global-eldoc-mode))) | |
41d290a2 | 618 | |
b57457b2 | 619 | ;; highlight matching parens |
c84be134 AB |
620 | (require 'paren) |
621 | (show-paren-mode) | |
622 | ||
623 | ;; (require 'elec-pair) | |
624 | ;; (electric-pair-mode) | |
625 | ||
626 | (csetq | |
627 | ;; Save what I copy into clipboard from other applications into Emacs' | |
628 | ;; kill-ring, which would allow me to still be able to easily access | |
629 | ;; it in case I kill (cut or copy) something else inside Emacs before | |
630 | ;; yanking (pasting) what I'd originally intended to. | |
631 | save-interprogram-paste-before-kill t) | |
632 | (with-eval-after-load 'simple | |
8c4704d0 | 633 | (column-number-mode 1)) |
41d290a2 | 634 | |
b57457b2 | 635 | ;; save minibuffer history |
c84be134 | 636 | (require 'savehist) |
0596e3cf | 637 | (csetq savehist-file (b/var "savehist.el")) |
c84be134 AB |
638 | (savehist-mode) |
639 | (add-to-list 'savehist-additional-variables 'kill-ring) | |
41d290a2 | 640 | |
b57457b2 | 641 | ;; automatically save place in files |
c84be134 | 642 | (when (version< "25" emacs-version) |
0596e3cf | 643 | (csetq save-place-file (b/var "save-place.el")) |
c84be134 AB |
644 | (save-place-mode)) |
645 | ||
646 | (defun indicate-buffer-boundaries-left () | |
647 | (csetq indicate-buffer-boundaries 'left)) | |
648 | (with-eval-after-load 'prog-mode | |
649 | (global-prettify-symbols-mode)) | |
650 | (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left) | |
651 | ||
8c4704d0 | 652 | (define-key text-mode-map (kbd "C-<return>") #'b/insert-asterism) |
c84be134 AB |
653 | (add-hook 'text-mode-hook #'indicate-buffer-boundaries-left) |
654 | (add-hook 'text-mode-hook #'flyspell-mode) | |
655 | ||
656 | (add-to-list 'auto-mode-alist '("\\.*rc$" . conf-mode)) | |
657 | ||
658 | (add-to-list 'auto-mode-alist '("\\.bashrc$" . sh-mode)) | |
659 | ||
8c4704d0 AB |
660 | (with-eval-after-load 'flyspell |
661 | (csetq flyspell-mode-line-string " fly")) | |
662 | ||
c84be134 AB |
663 | ;; flycheck |
664 | ;; (run-with-idle-timer 0.6 nil #'require 'flycheck) | |
665 | ;; (with-eval-after-load 'flycheck | |
666 | ;; (csetq | |
667 | ;; ;; Use the load-path from running Emacs when checking elisp files | |
668 | ;; flycheck-emacs-lisp-load-path 'inherit | |
669 | ;; ;; Only flycheck when I actually save the buffer | |
670 | ;; flycheck-check-syntax-automatically '(mode-enabled save) | |
671 | ;; flycheck-mode-line-prefix "flyc")) | |
672 | ;; (define-key flycheck-mode-map (kbd "M-P") #'flycheck-previous-error) | |
673 | ;; (define-key flycheck-mode-map (kbd "M-N") #'flycheck-next-error) | |
674 | ;; (add-hook 'prog-mode-hook #'flycheck-mode) | |
675 | ||
676 | ;; ispell | |
41d290a2 | 677 | ;; http://endlessparentheses.com/ispell-and-apostrophes.html |
c84be134 AB |
678 | ;; (run-with-idle-timer 0.6 nil #'require 'ispell) |
679 | ;; (with-eval-after-load 'ispell | |
680 | ;; ;; ’ can be part of a word | |
681 | ;; (csetq ispell-local-dictionary-alist | |
682 | ;; `((nil "[[:alpha:]]" "[^[:alpha:]]" | |
683 | ;; "['\x2019]" nil ("-B") nil utf-8)) | |
684 | ;; ispell-program-name (executable-find "hunspell")) | |
685 | ;; ;; don't send ’ to the subprocess | |
686 | ;; (defun endless/replace-apostrophe (args) | |
687 | ;; (cons (replace-regexp-in-string | |
688 | ;; "’" "'" (car args)) | |
689 | ;; (cdr args))) | |
690 | ;; (advice-add #'ispell-send-string :filter-args | |
691 | ;; #'endless/replace-apostrophe) | |
692 | ;; ;; convert ' back to ’ from the subprocess | |
693 | ;; (defun endless/replace-quote (args) | |
694 | ;; (if (not (derived-mode-p 'org-mode)) | |
695 | ;; args | |
696 | ;; (cons (replace-regexp-in-string | |
697 | ;; "'" "’" (car args)) | |
698 | ;; (cdr args)))) | |
699 | ;; (advice-add #'ispell-parse-output :filter-args | |
700 | ;; #'endless/replace-quote)) | |
701 | ||
0596e3cf | 702 | ;; abbrev |
8c4704d0 | 703 | (csetq abbrev-file-name (b/etc "abbrev.el")) |
c84be134 | 704 | (add-hook 'text-mode-hook #'abbrev-mode) |
54209e74 | 705 | |
b57457b2 AB |
706 | \f |
707 | ;;; Programming modes | |
708 | ||
c84be134 | 709 | (with-eval-after-load 'lisp-mode |
41d290a2 AB |
710 | (defun indent-spaces-mode () |
711 | (setq indent-tabs-mode nil)) | |
712 | (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode)) | |
713 | ||
8c4704d0 AB |
714 | ;; alloy |
715 | (add-to-list 'load-path (b/lisp "alloy-mode")) | |
716 | (autoload 'alloy-mode "alloy-mode" nil t) | |
c84be134 AB |
717 | (with-eval-after-load 'alloy-mode |
718 | (csetq alloy-basic-offset 2) | |
fac1032c AB |
719 | ;; (defun b/alloy-simple-indent (start end) |
720 | ;; (interactive "r") | |
721 | ;; ;; (if (region-active-p) | |
722 | ;; ;; (indent-rigidly start end alloy-basic-offset) | |
723 | ;; ;; (if (bolp) | |
724 | ;; ;; (indent-rigidly (line-beginning-position) | |
725 | ;; ;; (line-end-position) | |
726 | ;; ;; alloy-basic-offset))) | |
727 | ;; (indent-to (+ (current-column) alloy-basic-offset))) | |
c84be134 AB |
728 | ;; local key bindings |
729 | (define-key alloy-mode-map (kbd "RET") #'electric-newline-and-maybe-indent) | |
730 | ;; (define-key alloy-mode-map (kbd "TAB") #'b/alloy-simple-indent) | |
731 | (define-key alloy-mode-map (kbd "TAB") #'indent-for-tab-command)) | |
732 | (add-to-list 'auto-mode-alist '("\\.\\(als\\|dsh\\)\\'" . alloy-mode)) | |
733 | (add-hook 'alloy-mode-hook (lambda nil (setq-local indent-tabs-mode nil))) | |
734 | ||
735 | ;; lean | |
736 | ;; (eval-when-compile (defvar lean-mode-map)) | |
737 | ;; (run-with-idle-timer 0.4 nil #'require 'lean-mode) | |
738 | ;; (with-eval-after-load 'lean-mode | |
739 | ;; (require 'lean-input) | |
740 | ;; (csetq default-input-method "Lean" | |
741 | ;; lean-input-tweak-all '(lean-input-compose | |
742 | ;; (lean-input-prepend "/") | |
743 | ;; (lean-input-nonempty)) | |
744 | ;; lean-input-user-translations '(("/" "/"))) | |
745 | ;; (lean-input-setup) | |
746 | ;; ;; local key bindings | |
747 | ;; (define-key lean-mode-map (kbd "S-SPC") #'company-complete)) | |
748 | ||
749 | (with-eval-after-load 'sgml-mode | |
750 | (csetq sgml-basic-offset 0)) | |
751 | ||
752 | (with-eval-after-load 'css-mode | |
753 | (csetq css-indent-offset 2)) | |
754 | ||
755 | ;; po-mode | |
756 | ;; (add-hook 'po-mode-hook (lambda nil (run-with-timer 0.1 nil 'View-exit))) | |
757 | ||
758 | ;; auctex | |
759 | ;; (csetq font-latex-fontify-sectioning 'color) | |
760 | ||
761 | (with-eval-after-load 'tex-mode | |
748bd8ac AB |
762 | (cl-delete-if |
763 | (lambda (p) (string-match "^---?" (car p))) | |
c84be134 AB |
764 | tex--prettify-symbols-alist)) |
765 | (add-hook 'tex-mode-hook #'auto-fill-mode) | |
766 | (add-hook 'tex-mode-hook #'flyspell-mode) | |
1d01c927 | 767 | |
b57457b2 | 768 | \f |
b57457b2 | 769 | ;;; Emacs enhancements & auxiliary packages |
1eb20313 | 770 | |
c84be134 AB |
771 | (with-eval-after-load 'man |
772 | (csetq Man-width 80)) | |
773 | ||
8c4704d0 AB |
774 | (defun b/*scratch* () |
775 | "Switch to `*scratch*' buffer, creating it if it does not exist." | |
776 | (interactive) | |
777 | (switch-to-buffer | |
778 | (or (get-buffer "*scratch*") | |
779 | (with-current-buffer (get-buffer-create "*scratch*") | |
780 | (set-buffer-major-mode (current-buffer)) | |
781 | (current-buffer))))) | |
782 | (global-set-key (kbd "C-c s") #'b/*scratch*) | |
41d290a2 | 783 | |
5b10d879 AB |
784 | ;; ,---- |
785 | ;; | make pretty boxed quotes like this | |
786 | ;; `---- | |
8c4704d0 | 787 | (add-to-list 'load-path (b/lisp "boxquote")) |
c84be134 AB |
788 | (run-with-idle-timer 0.6 nil #'require 'boxquote) |
789 | (with-eval-after-load 'boxquote | |
790 | (defvar b/boxquote-prefix-map) | |
791 | (define-prefix-command 'b/boxquote-prefix-map) | |
792 | (global-set-key (kbd "C-c q") 'b/boxquote-prefix-map) | |
793 | (define-key b/boxquote-prefix-map (kbd "b") #'boxquote-buffer) | |
794 | (define-key b/boxquote-prefix-map (kbd "B") #'boxquote-insert-buffer) | |
795 | (define-key b/boxquote-prefix-map (kbd "d") #'boxquote-defun) | |
796 | (define-key b/boxquote-prefix-map (kbd "F") #'boxquote-insert-file) | |
797 | (define-key b/boxquote-prefix-map (kbd "hf") #'boxquote-describe-function) | |
798 | (define-key b/boxquote-prefix-map (kbd "hk") #'boxquote-describe-key) | |
799 | (define-key b/boxquote-prefix-map (kbd "hv") #'boxquote-describe-variable) | |
800 | (define-key b/boxquote-prefix-map (kbd "hw") #'boxquote-where-is) | |
801 | (define-key b/boxquote-prefix-map (kbd "k") #'boxquote-kill) | |
802 | (define-key b/boxquote-prefix-map (kbd "p") #'boxquote-paragraph) | |
803 | (define-key b/boxquote-prefix-map (kbd "q") #'boxquote-boxquote) | |
804 | (define-key b/boxquote-prefix-map (kbd "r") #'boxquote-region) | |
805 | (define-key b/boxquote-prefix-map (kbd "s") #'boxquote-shell-command) | |
806 | (define-key b/boxquote-prefix-map (kbd "t") #'boxquote-text) | |
807 | (define-key b/boxquote-prefix-map (kbd "T") #'boxquote-title) | |
808 | (define-key b/boxquote-prefix-map (kbd "u") #'boxquote-unbox) | |
809 | (define-key b/boxquote-prefix-map (kbd "U") #'boxquote-unbox-region) | |
810 | (define-key b/boxquote-prefix-map (kbd "y") #'boxquote-yank) | |
811 | (define-key b/boxquote-prefix-map (kbd "M-q") #'boxquote-fill-paragraph) | |
812 | (define-key b/boxquote-prefix-map (kbd "M-w") #'boxquote-kill-ring-save)) | |
813 | ||
8c4704d0 | 814 | (add-to-list 'load-path (b/lisp "hl-todo")) |
c84be134 AB |
815 | (run-with-idle-timer 0.5 nil #'require 'hl-todo) |
816 | (with-eval-after-load 'hl-todo | |
1eb20313 | 817 | ;; highlight TODOs in buffers |
41d290a2 AB |
818 | (global-hl-todo-mode)) |
819 | ||
8c4704d0 | 820 | (add-to-list 'load-path (b/lisp "page-break-lines")) |
c84be134 AB |
821 | (run-with-idle-timer 0.5 nil #'require 'page-break-lines) |
822 | (with-eval-after-load 'page-break-lines | |
823 | (csetq page-break-lines-max-width fill-column) | |
41d290a2 AB |
824 | (global-page-break-lines-mode)) |
825 | ||
c84be134 AB |
826 | ;; expand-region |
827 | (global-set-key (kbd "C-=") #'er/expand-region) | |
828 | ||
829 | (run-with-idle-timer 0.6 nil #'require 'yasnippet) | |
830 | (with-eval-after-load 'yasnippet | |
831 | (declare-function yas-reload-all | |
832 | "yasnippet" (&optional no-jit interactive)) | |
833 | (declare-function yas-maybe-expand-abbrev-key-filter | |
834 | "yasnippet" (cmd)) | |
835 | ||
836 | (defconst yas-verbosity-cur yas-verbosity) | |
837 | (setq yas-verbosity 2) | |
0596e3cf | 838 | (csetq yas-snippet-dirs `(,(b/etc "yasnippet/snippets"))) |
c84be134 AB |
839 | (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t) |
840 | (yas-reload-all) | |
841 | (setq yas-verbosity yas-verbosity-cur) | |
842 | ||
843 | (defun b/yas-maybe-expand-abbrev-key-filter (cmd) | |
844 | (when (and (yas-maybe-expand-abbrev-key-filter cmd) | |
845 | (not (bound-and-true-p git-commit-mode))) | |
846 | cmd)) | |
847 | (defconst b/yas-maybe-expand | |
848 | '(menu-item "" yas-expand | |
849 | :filter b/yas-maybe-expand-abbrev-key-filter)) | |
850 | (define-key yas-minor-mode-map (kbd "SPC") b/yas-maybe-expand) | |
851 | ||
852 | (yas-global-mode)) | |
853 | ||
854 | ;; debbugs | |
855 | (global-set-key (kbd "C-c D d") #'debbugs-gnu) | |
856 | (global-set-key (kbd "C-c D b") #'debbugs-gnu-bugs) | |
857 | (global-set-key (kbd "C-c D e") ; bug-gnu-emacs | |
858 | (lambda () | |
859 | (interactive) | |
860 | (setq debbugs-gnu-current-suppress t) | |
861 | (debbugs-gnu debbugs-gnu-default-severities | |
862 | '("emacs")))) | |
863 | (global-set-key (kbd "C-c D g") ; bug-gnuzilla | |
864 | (lambda () | |
865 | (interactive) | |
866 | (setq debbugs-gnu-current-suppress t) | |
867 | (debbugs-gnu debbugs-gnu-default-severities | |
868 | '("gnuzilla")))) | |
869 | (global-set-key (kbd "C-c D G b") ; bug-guix | |
870 | (lambda () | |
871 | (interactive) | |
872 | (setq debbugs-gnu-current-suppress t) | |
873 | (debbugs-gnu debbugs-gnu-default-severities | |
874 | '("guix")))) | |
875 | (global-set-key (kbd "C-c D G p") ; guix-patches | |
876 | (lambda () | |
877 | (interactive) | |
878 | (setq debbugs-gnu-current-suppress t) | |
879 | (debbugs-gnu debbugs-gnu-default-severities | |
880 | '("guix-patches")))) | |
881 | ||
0596e3cf AB |
882 | ;; url and url-cache |
883 | (csetq | |
884 | url-configuration-directory (b/var "url/configuration/") | |
885 | url-cache-directory (b/var "url/cache/")) | |
886 | ||
c84be134 AB |
887 | ;; eww |
888 | (csetq eww-download-directory (file-name-as-directory | |
889 | (getenv "XDG_DOWNLOAD_DIR"))) | |
890 | (global-set-key (kbd "C-c a e w") #'eww) | |
41d290a2 | 891 | |
8c4704d0 AB |
892 | ;; ;; org-ref |
893 | ;; (csetq | |
894 | ;; reftex-default-bibliography '("~/usr/org/references.bib") | |
895 | ;; org-ref-default-bibliography '("~/usr/org/references.bib") | |
896 | ;; org-ref-bibliography-notes "~/usr/org/notes.org" | |
897 | ;; org-ref-pdf-directory "~/usr/org/bibtex-pdfs/") | |
c84be134 AB |
898 | |
899 | ;; fill-column-indicator ? | |
900 | ||
901 | ;; window | |
902 | (csetq split-width-threshold 150) | |
903 | (global-set-key (kbd "C-c w s l") | |
904 | (lambda () | |
905 | (interactive) | |
906 | (split-window-right) | |
907 | (other-window 1))) | |
908 | (global-set-key (kbd "C-c w s j") | |
909 | (lambda () | |
910 | (interactive) | |
911 | (split-window-below) | |
912 | (other-window 1))) | |
913 | (global-set-key (kbd "C-c w q") #'quit-window) | |
914 | ||
915 | (run-with-idle-timer 0.6 nil #'require 'windmove) | |
916 | (global-set-key (kbd "C-c w h") #'windmove-left) | |
917 | (global-set-key (kbd "C-c w j") #'windmove-down) | |
918 | (global-set-key (kbd "C-c w k") #'windmove-up) | |
919 | (global-set-key (kbd "C-c w l") #'windmove-right) | |
920 | (global-set-key (kbd "C-c w H") #'windmove-swap-states-left) | |
921 | (global-set-key (kbd "C-c w J") #'windmove-swap-states-down) | |
922 | (global-set-key (kbd "C-c w K") #'windmove-swap-states-up) | |
923 | (global-set-key (kbd "C-c w L") #'windmove-swap-states-right) | |
924 | ||
925 | ;; pass | |
8c4704d0 AB |
926 | ;; (global-set-key (kbd "C-c a p") #'pass) |
927 | ;; (add-hook 'pass-mode-hook #'View-exit) | |
c84be134 AB |
928 | |
929 | ;; reftex | |
930 | ;; uncomment to disable reftex-cite's default choice of previous word | |
931 | ;; (with-eval-after-load 'reftex | |
932 | ;; (require 'reftex-cite) | |
933 | ;; (defun reftex-get-bibkey-default () | |
934 | ;; "If the cursor is in a citation macro, return the word before the macro." | |
935 | ;; (let* ((macro (reftex-what-macro 1))) | |
936 | ;; (save-excursion | |
937 | ;; (when (and macro (string-match "cite" (car macro))) | |
938 | ;; (goto-char (cdr macro))) | |
939 | ;; (reftex-this-word))))) | |
940 | (add-hook 'latex-mode-hook #'reftex-mode) | |
941 | ||
942 | ;; dmenu | |
8c4704d0 AB |
943 | ;; (csetq |
944 | ;; dmenu-prompt-string "run: " | |
945 | ;; dmenu-save-file (b/var "dmenu-items")) | |
c84be134 AB |
946 | |
947 | ;; eosd ? | |
9ed5410e | 948 | |
8c4704d0 AB |
949 | ;; delight |
950 | (run-with-idle-timer 0.5 nil #'require 'delight) | |
951 | (with-eval-after-load 'delight | |
952 | (delight 'auto-fill-function " f" "simple") | |
953 | (delight 'abbrev-mode "" "abbrev") | |
954 | (delight 'page-break-lines-mode "" "page-break-lines") | |
955 | (delight 'ivy-mode "" "ivy") | |
956 | (delight 'counsel-mode "" "counsel") | |
957 | (delight 'mml-mode " mml" "mml") | |
958 | (delight 'yas-minor-mode "" "yasnippet")) | |
959 | ||
b57457b2 | 960 | \f |
b57457b2 AB |
961 | ;;; Post initialization |
962 | ||
41d290a2 AB |
963 | (message "Loading %s...done (%.3fs)" user-init-file |
964 | (float-time (time-subtract (current-time) | |
dca50cf5 | 965 | b/before-user-init-time))) |
41d290a2 AB |
966 | |
967 | ;;; init.el ends here |