1 ;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
3 ;; Copyright (C) 2018-2019 Amin Bandali <bandali@gnu.org>
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.
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.
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/>.
20 ;; Emacs configuration of Amin Bandali, computer scientist, functional
21 ;; programmer, and free software activist. Uses straight.el for
22 ;; purely functional and fully reproducible package management.
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:
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
38 ;;; Emacs initialization
40 (defvar b
/before-user-init-time
(current-time)
41 "Value of `current-time' when Emacs begins loading `user-init-file'.")
42 (message "Loading Emacs...done (%.3fs)"
43 (float-time (time-subtract b
/before-user-init-time
46 ;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage'
47 ;; during startup to reduce garbage collection frequency. clearing
48 ;; `file-name-handler-alist' seems to help reduce startup time too.
49 (defvar b
/gc-cons-threshold gc-cons-threshold
)
50 (defvar b
/gc-cons-percentage gc-cons-percentage
)
51 (defvar b
/file-name-handler-alist file-name-handler-alist
)
52 (setq gc-cons-threshold
(* 400 1024 1024) ; 400 MiB
53 gc-cons-percentage
0.6
54 file-name-handler-alist nil
55 ;; sidesteps a bug when profiling with esup
56 esup-child-profile-require-level
0)
58 ;; set them back to their defaults once we're done initializing
60 (setq gc-cons-threshold b
/gc-cons-threshold
61 gc-cons-percentage b
/gc-cons-percentage
62 file-name-handler-alist b
/file-name-handler-alist
))
63 (add-hook 'after-init-hook
#'b
/post-init
)
65 ;; increase number of lines kept in *Messages* log
66 (setq message-log-max
20000)
68 ;; optionally, uncomment to supress some byte-compiler warnings
69 ;; (see C-h v byte-compile-warnings RET for more info)
70 ;; (setq byte-compile-warnings
71 ;; '(not free-vars unresolved noruntime lexical make-local))
76 (setq user-full-name
"Amin Bandali"
77 user-mail-address
"bandali@gnu.org")
82 ;; useful for commenting out multiple sexps at a time
83 (defmacro comment
(&rest _
)
84 "Comment out one or more s-expressions."
85 (declare (indent defun
))
89 ;;; Package management
91 ;; No package.el (for emacs 26 and before, uncomment the following)
92 ;; Not necessary when using straight.el
93 ;; (C-h v straight-package-neutering-mode RET)
96 (not (featurep 'straight
))
97 (version< emacs-version
"27"))
98 (setq package-enable-at-startup nil
)
99 ;; (package-initialize)
102 ;; for emacs 27 and later, we use early-init.el. see
103 ;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b
107 ;; Main engine start...
109 (setq straight-repository-branch
"develop"
110 straight-check-for-modifications
'(check-on-save find-when-checking
))
112 (defun b/bootstrap-straight
()
113 (defvar bootstrap-version
)
114 (let ((bootstrap-file
115 (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory
))
116 (bootstrap-version 5))
117 (unless (file-exists-p bootstrap-file
)
119 (url-retrieve-synchronously
120 "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
121 'silent
'inhibit-cookies
)
122 (goto-char (point-max))
123 (eval-print-last-sexp)))
124 (load bootstrap-file nil
'nomessage
)))
126 ;; Solid rocket booster ignition...
128 (b/bootstrap-straight
)
132 (setq straight-use-package-by-default t
)
134 (defmacro use-feature
(name &rest args
)
135 "Like `use-package', but with `straight-use-package-by-default' disabled."
141 (with-eval-after-load 'use-package-core
142 (let ((upflk (car use-package-font-lock-keywords
)))
143 (font-lock-add-keywords
145 `((,(replace-regexp-in-string
146 "use-package" "use-feature"
150 (with-eval-after-load 'recentf
151 (add-to-list 'recentf-exclude
152 (expand-file-name "~/.emacs.d/straight/build/")))
154 (defun b/reload-init
()
157 (setq b
/file-name-handler-alist file-name-handler-alist
)
158 (load user-init-file nil
'nomessage
)
162 (straight-use-package 'use-package
)
164 (if nil
; set to t when need to debug init
166 (setq use-package-verbose t
167 use-package-expand-minimally nil
168 use-package-compute-statistics t
170 (require 'use-package
))
171 (setq use-package-verbose nil
172 use-package-expand-minimally t
))
174 (setq use-package-always-defer t
)
177 (use-package delight
)
182 ;; keep ~/.emacs.d clean
183 (use-package no-littering
186 (defalias 'b
/etc
'no-littering-expand-etc-file-name
)
187 (defalias 'b
/var
'no-littering-expand-var-file-name
))
189 ;; separate custom file (don't want it mixing with init.el)
193 (setq custom-file
(b/etc
"custom.el"))
194 (when (file-exists-p custom-file
)
196 ;; while at it, treat themes as safe
197 (setf custom-safe-themes t
))
199 ;; load the secrets file if it exists, otherwise show a warning
202 (load (b/etc
"secrets"))))
204 ;; better $PATH (and other environment variable) handling
205 (use-package exec-path-from-shell
208 (setq exec-path-from-shell-arguments nil
209 exec-path-from-shell-check-startup-files nil
)
211 (exec-path-from-shell-initialize)
212 ;; while we're at it, let's fix access to our running ssh-agent
213 (exec-path-from-shell-copy-env "SSH_AGENT_PID")
214 (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
216 ;; only one custom theme at a time
218 (defadvice load-theme
(before clear-previous-themes activate
)
219 "Clear existing theme settings instead of layering them"
220 (mapc #'disable-theme custom-enabled-themes
)))
222 ;; start up emacs server. see
223 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
226 :config
(or (server-running-p) (server-mode)))
230 (dolist (ft (fontset-list))
234 (font-spec :name
"Source Code Pro" :size
14))
238 (font-spec :name
"DejaVu Sans Mono")
245 ;; :name "Symbola monospacified for DejaVu Sans Mono")
251 ;; (font-spec :name "DejaVu Sans Mono")
257 (font-spec :name
"DejaVu Sans Mono" :size
14)
261 ;; gentler font resizing
262 (setq text-scale-mode-step
1.05)
264 ;; focus follows mouse
265 (setq mouse-autoselect-window t
)
267 (defun b/no-mouse-autoselect-window
()
268 "Conveniently disable `focus-follows-mouse'.
269 For disabling the behaviour for certain buffers and/or modes."
270 (make-local-variable 'mouse-autoselect-window
)
271 (setq mouse-autoselect-window nil
))
274 (setq ;; scroll-margin 1
275 ;; scroll-conservatively 10000
277 scroll-conservatively
10
278 scroll-preserve-screen-position
1)
283 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
284 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
285 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
287 (use-feature pixel-scroll
289 :config
(pixel-scroll-mode 1))
291 (use-feature epg-config
293 ((epg-gpg-program (executable-find "gpg"))))
302 (defmacro b
/setq-every
(value &rest vars
)
303 "Set all the variables from VARS to value VALUE."
304 (declare (indent defun
) (debug t
))
305 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
307 (defun b/start-process
(program &rest args
)
308 "Same as `start-process', but doesn't bother about name and buffer."
309 (let ((process-name (concat program
"_process"))
310 (buffer-name (generate-new-buffer-name
311 (concat program
"_output"))))
312 (apply #'start-process
313 process-name buffer-name program args
)))
315 (defun b/dired-start-process
(program &optional args
)
316 "Open current file with a PROGRAM."
317 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
318 ;; be nil, so remove it).
319 (apply #'b
/start-process
321 (remove nil
(list args
(dired-get-file-for-visit)))))
323 (defun b/add-elisp-section
()
327 (insert "\n\f\n;;; "))
332 ;; time and battery in mode-line
336 (setq display-time-default-load-average nil
)
342 (display-battery-mode)))
345 ;; (fringe-mode '(3 . 1))
348 ;; disable disabled commands
349 (setq disabled-command-function nil
)
351 ;; Save what I copy into clipboard from other applications into Emacs'
352 ;; kill-ring, which would allow me to still be able to easily access
353 ;; it in case I kill (cut or copy) something else inside Emacs before
354 ;; yanking (pasting) what I'd originally intended to.
355 (setq save-interprogram-paste-before-kill t
)
358 (setq enable-recursive-minibuffers t
359 resize-mini-windows t
)
361 ;; lazy-person-friendly yes/no prompts
362 (defalias 'yes-or-no-p
#'y-or-n-p
)
364 ;; i want *scratch* as my startup buffer
365 (setq initial-buffer-choice t
)
367 ;; i don't need the default hint
368 (setq initial-scratch-message nil
)
370 ;; use customizable text-mode as major mode for *scratch*
371 (setq initial-major-mode
'text-mode
)
373 ;; inhibit buffer list when more than 2 files are loaded
374 (setq inhibit-startup-buffer-menu t
)
376 ;; don't need to see the startup screen or the echo area message
377 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
378 (setq inhibit-startup-screen t
379 inhibit-startup-echo-area-message user-login-name
)
381 ;; more useful frame titles
382 (setq frame-title-format
383 '("" invocation-name
" - "
384 (:eval
(if (buffer-file-name)
385 (abbreviate-file-name (buffer-file-name))
388 ;; backups (C-h v make-backup-files RET)
389 (setq backup-by-copying t
391 delete-old-versions t
)
393 ;; enable automatic reloading of changed buffers and files
394 (global-auto-revert-mode 1)
395 (setq auto-revert-verbose nil
396 global-auto-revert-non-file-buffers nil
)
398 ;; always use space for indentation
401 require-final-newline t
404 ;; enable winner-mode (C-h f winner-mode RET)
407 ;; don't display *compilation* buffer on success. based on
408 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
409 ;; instead of the now obsolete `flet'.
410 (with-eval-after-load 'compile
411 (defun b/compilation-finish-function
(buffer outstr
)
412 (unless (string-match "finished" outstr
)
413 (switch-to-buffer-other-window buffer
))
416 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
420 (defadvice compilation-start
421 (around inhibit-display
422 (command &optional mode name-function highlight-regexp
))
423 (if (not (string-match "^\\(find\\|grep\\)" command
))
424 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
425 (save-window-excursion ad-do-it
))
427 (ad-activate 'compilation-start
))
429 ;; search for non-ASCII characters: i’d like non-ASCII characters such
430 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
431 ;; counterpart. shoutout to
432 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
433 (setq search-default-mode
#'char-fold-to-regexp
)
434 ;; uncomment to extend this behaviour to query-replace
435 ;; (setq replace-char-fold t)
438 (setq-default cursor-type
'bar
)
440 ;; allow scrolling in Isearch
441 (setq isearch-allow-scroll t
)
443 ;; open read-only file buffers in view-mode
444 ;; (enables niceties like `q' for quit)
445 (setq view-read-only t
)
448 :bind
("C-x v C-=" . vc-ediff
))
451 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
452 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
453 (ediff-split-window-function 'split-window-horizontally
)))
455 ;; i don't feel like jumping out of my chair every now and again; so
456 ;; don't BEEP! at me, emacs
457 (setq ring-bell-function
'ignore
)
465 ("C-c e b" . eval-buffer
)
466 ("C-c e e" . eval-last-sexp
)
467 ("C-c e r" . eval-region
)
469 ("C-c e i" . emacs-init-time
)
470 ("C-c e u" . emacs-uptime
)
471 ("C-c e v" . emacs-version
)
473 ("C-c F m" . make-frame-command
)
474 ("C-c F d" . delete-frame
)
475 ("C-c F D" . server-edit
)
477 ("C-S-h C" . describe-char
)
478 ("C-S-h F" . describe-face
)
480 ("C-x k" . kill-this-buffer
)
481 ("C-x K" . kill-buffer
)
482 ("C-x s" . save-buffer
)
483 ("C-x S" . save-some-buffers
)
485 :map emacs-lisp-mode-map
486 ("<C-return>" . b
/add-elisp-section
))
488 (when (display-graphic-p)
489 (unbind-key "C-z" global-map
))
492 ;; for back and forward mouse keys
493 ("<mouse-8>" . previous-buffer
)
494 ("<drag-mouse-8>" . previous-buffer
)
495 ("<mouse-9>" . next-buffer
)
496 ("<drag-mouse-9>" . next-buffer
)
497 ("<drag-mouse-2>" . kill-this-buffer
)
498 ("<drag-mouse-3>" . ivy-switch-buffer
))
501 :prefix-map mab
/straight-prefix-map
503 ("u" . straight-use-package
)
504 ("f" . straight-freeze-versions
)
505 ("t" . straight-thaw-versions
)
506 ("P" . straight-prune-build
)
507 ("g" . straight-get-recipe
)
508 ("r" . mab
/reload-init
)
509 ;; M-x ^straight-.*-all$
510 ("a c" . straight-check-all
)
511 ("a f" . straight-fetch-all
)
512 ("a m" . straight-merge-all
)
513 ("a n" . straight-normalize-all
)
514 ("a F" . straight-pull-all
)
515 ("a P" . straight-push-all
)
516 ("a r" . straight-rebuild-all
)
517 ;; M-x ^straight-.*-package$
518 ("p c" . straight-check-package
)
519 ("p f" . straight-fetch-package
)
520 ("p m" . straight-merge-package
)
521 ("p n" . straight-normalize-package
)
522 ("p F" . straight-pull-package
)
523 ("p P" . straight-push-package
)
524 ("p r" . straight-rebuild-package
))
527 ;;; Essential packages
529 ;; use the org-plus-contrib package to get the whole deal
530 (use-package org-plus-contrib
)
535 (setq org-src-tab-acts-natively t
536 org-src-preserve-indentation nil
537 org-edit-src-content-indentation
0
538 org-link-email-description-format
"Email %c: %s" ; %.30s
539 org-highlight-latex-and-related
'(entities)
540 org-use-speed-commands t
541 org-startup-folded
'content
542 org-catch-invisible-edits
'show-and-error
544 (when (version< org-version
"9.3")
545 (setq org-email-link-description-format
546 org-link-email-description-format
))
547 (add-to-list 'org-structure-template-alist
'("L" .
"src emacs-lisp") t
)
548 (add-to-list 'org-modules
'org-habit
)
550 (("C-c a o a" . org-agenda
)
552 ("M-L" . org-insert-last-stored-link
)
553 ("M-O" . org-toggle-link-display
))
554 :hook
((org-mode . org-indent-mode
)
555 (org-mode . auto-fill-mode
)
556 (org-mode . flyspell-mode
))
558 (org-pretty-entities t
)
559 (org-agenda-files '("~/usr/org/todos/personal.org"
560 "~/usr/org/todos/habits.org"
561 "~/src/git/masters-thesis/todo.org"))
562 (org-agenda-start-on-weekday 0)
563 (org-agenda-time-leading-zero t
)
564 (org-habit-graph-column 44)
565 (org-latex-packages-alist '(("" "listings") ("" "color")))
567 '(org-block-begin-line ((t (:foreground
"#5a5b5a" :background
"#1d1f21"))))
568 '(org-block ((t (:background
"#1d1f21"))))
569 '(org-latex-and-related ((t (:foreground
"#b294bb")))))
571 (use-feature ox-latex
574 (setq org-latex-listings
'listings
575 ;; org-latex-prefer-user-labels t
577 (add-to-list 'org-latex-classes
578 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
579 ("\\section{%s}" .
"\\section*{%s}")
580 ("\\subsection{%s}" .
"\\subsection*{%s}")
581 ("\\subsubsection{%s}" .
"\\subsubsection*{%s}")
582 ("\\paragraph{%s}" .
"\\paragraph*{%s}")
583 ("\\subparagraph{%s}" .
"\\subparagraph*{%s}"))
585 (require 'ox-beamer
))
587 (use-feature ox-extra
589 (ox-extras-activate '(latex-header-blocks ignore-headlines
)))
591 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
592 ;; org file. closely inspired by
593 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
594 (with-eval-after-load 'org
595 (defvar b
/show-async-tangle-results nil
596 "Keep *emacs* async buffers around for later inspection.")
598 (defvar b
/show-async-tangle-time nil
599 "Show the time spent tangling the file.")
601 (defun b/async-babel-tangle
()
602 "Tangle org file asynchronously."
604 (let* ((file-tangle-start-time (current-time))
605 (file (buffer-file-name))
606 (file-nodir (file-name-nondirectory file
))
607 ;; (async-quiet-switch "-q")
608 (file-noext (file-name-sans-extension file
)))
612 (org-babel-tangle-file ,file
))
613 (unless b
/show-async-tangle-results
616 (message "Tangled %s%s"
618 (if b
/show-async-tangle-time
620 (float-time (time-subtract (current-time)
621 ',file-tangle-start-time
)))
623 (message "Tangling %s failed" ,file-nodir
))))))))
626 'safe-local-variable-values
627 '(eval add-hook
'after-save-hook
#'b
/async-babel-tangle
'append
'local
))
629 ;; *the* right way to do git
632 :bind
(("C-x g" . magit-status
)
633 ("C-c g g" . magit-status
)
634 ("C-c g b" . magit-blame-addition
)
635 ("C-c g l" . magit-log-buffer-file
))
637 (magit-add-section-hook 'magit-status-sections-hook
638 'magit-insert-modules
639 'magit-insert-stashes
641 ;; (magit-add-section-hook 'magit-status-sections-hook
642 ;; 'magit-insert-ignored-files
643 ;; 'magit-insert-untracked-files
645 (setq magit-repository-directories
'(("~/" .
0)
647 (nconc magit-section-initial-visibility-alist
648 '(([unpulled status
] . show
)
649 ([unpushed status
] . show
)))
650 :custom
(magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1
)
651 :custom-face
(magit-diff-file-heading ((t (:weight normal
)))))
653 ;; recently opened files
657 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
659 (recentf-max-saved-items 2000))
661 ;; smart M-x enhancement (needed by counsel for history)
668 (:map ivy-minibuffer-map
669 ([escape] . keyboard-escape-quit)
670 ([S-up] . ivy-previous-history-element)
671 ([S-down] . ivy-next-history-element)
672 ("DEL" . ivy-backward-delete-char))
676 ivy-use-virtual-buffers t
677 ivy-virtual-abbreviate 'abbreviate
678 ivy-count-format "%d/%d ")
680 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
681 (defun b/ivy-ignore-buffer-p (str)
682 "Return non-nil if str names a buffer with a major mode
683 derived from one of `b/ivy-ignore-buffer-modes'.
685 This function is intended for use with `ivy-ignore-buffers'."
686 (let* ((buf (get-buffer str))
687 (mode (and buf (buffer-local-value 'major-mode buf))))
689 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
690 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
694 ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
695 ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
696 ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
701 :bind (("C-s" . swiper-isearch)
703 ("C-S-s" . isearch-forward)))
708 :bind (([remap execute-extended-command] . counsel-M-x)
709 ([remap find-file] . counsel-find-file)
710 ("C-c b b" . ivy-switch-buffer)
711 ("C-c f ." . counsel-find-file)
712 ("C-c f l" . counsel-find-library)
713 ("C-c f r" . counsel-recentf)
714 ("C-c x" . counsel-M-x)
715 :map minibuffer-local-map
716 ("C-r" . counsel-minibuffer-history))
719 (defalias 'locate #'counsel-locate))
723 :commands (helm-M-x helm-mini helm-resume)
724 :bind (("M-x" . helm-M-x)
725 ("M-y" . helm-show-kill-ring)
726 ("C-x b" . helm-mini)
727 ("C-x C-b" . helm-buffers-list)
728 ("C-x C-f" . helm-find-files)
729 ("C-h r" . helm-info-emacs)
730 ("C-s-r" . helm-resume)
732 ("<tab>" . helm-execute-persistent-action)
733 ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals
734 ("C-z" . helm-select-action)) ; List actions
735 :config (helm-mode 1)))
740 :bind ("C-c a s e" . eshell)
742 (eval-when-compile (defvar eshell-prompt-regexp))
743 (defun b/eshell-quit-or-delete-char (arg)
745 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
746 (eshell-life-is-too-much)
749 (defun b/eshell-clear ()
751 (let ((inhibit-read-only t))
755 (defun b/eshell-setup ()
756 (make-local-variable 'company-idle-delay)
757 (defvar company-idle-delay)
758 (setq company-idle-delay nil)
759 (bind-keys :map eshell-mode-map
760 ("C-d" . b/eshell-quit-or-delete-char)
761 ("C-S-l" . b/eshell-clear)
762 ("M-r" . counsel-esh-history)
763 ([tab] . company-complete)))
765 :hook (eshell-mode . b/eshell-setup)
767 (eshell-hist-ignoredups t)
768 (eshell-input-filter 'eshell-input-filter-initial-space))
772 (("C-x C-b" . ibuffer)
773 :map ibuffer-mode-map
774 ("P" . ibuffer-backward-filter-group)
775 ("N" . ibuffer-forward-filter-group)
776 ("M-p" . ibuffer-do-print)
777 ("M-n" . ibuffer-do-shell-command-pipe-replace))
779 ;; Use human readable Size column instead of original one
780 (define-ibuffer-column size-h
781 (:name "Size" :inline t)
783 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
784 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
785 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
786 (t (format "%8d" (buffer-size)))))
788 (ibuffer-saved-filter-groups
790 ("dired" (mode . dired-mode))
791 ("org" (mode . org-mode))
794 (mode . gnus-group-mode)
795 (mode . gnus-summary-mode)
796 (mode . gnus-article-mode)
797 ;; not really, but...
798 (mode . message-mode)))
816 (mode . emacs-lisp-mode)
818 (mode . haskell-mode)
821 (mode . alloy-mode)))
825 (mode . latex-mode)))
828 (name . "^\\*scratch\\*$")
829 (name . "^\\*Messages\\*$")))
830 ("erc" (mode . erc-mode)))))
832 '((mark modified read-only locked " "
833 (name 18 18 :left :elide)
837 (mode 16 16 :left :elide)
838 " " filename-and-process)
842 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
846 :hook (prog-mode . outline-minor-mode)
847 :delight (outline-minor-mode " outl")
850 outline-minor-mode-map
851 ("<s-tab>" . outline-toggle-children)
852 ("M-p" . outline-previous-visible-heading)
853 ("M-n" . outline-next-visible-heading)
854 :prefix-map b/outline-prefix-map
856 ("TAB" . outline-toggle-children)
857 ("a" . outline-hide-body)
858 ("H" . outline-hide-body)
859 ("S" . outline-show-all)
860 ("h" . outline-hide-subtree)
861 ("s" . outline-show-subtree)))
864 :custom (ls-lisp-dirs-first t))
868 (setq dired-listing-switches "-alh"
869 ls-lisp-use-insert-directory-program nil)
871 ;; easily diff 2 marked files
872 ;; https://oremacs.com/2017/03/18/dired-ediff/
873 (defun dired-ediff-files ()
876 (defvar ediff-after-quit-hook-internal)
877 (let ((files (dired-get-marked-files))
878 (wnd (current-window-configuration)))
879 (if (<= (length files) 2)
880 (let ((file1 (car files))
881 (file2 (if (cdr files)
885 (dired-dwim-target-directory)))))
886 (if (file-newer-than-file-p file1 file2)
887 (ediff-files file2 file1)
888 (ediff-files file1 file2))
889 (add-hook 'ediff-after-quit-hook-internal
891 (setq ediff-after-quit-hook-internal nil)
892 (set-window-configuration wnd))))
893 (error "no more than 2 files should be marked"))))
896 (setq dired-guess-shell-alist-user
897 '(("\\.pdf\\'" "evince" "zathura" "okular")
898 ("\\.doc\\'" "libreoffice")
899 ("\\.docx\\'" "libreoffice")
900 ("\\.ppt\\'" "libreoffice")
901 ("\\.pptx\\'" "libreoffice")
902 ("\\.xls\\'" "libreoffice")
903 ("\\.xlsx\\'" "libreoffice")
904 ("\\.flac\\'" "mpv")))
905 :bind (:map dired-mode-map
906 ("b" . dired-up-directory)
907 ("e" . dired-ediff-files)
908 ("E" . dired-toggle-read-only)
909 ("\\" . dired-hide-details-mode)
912 (b/dired-start-process "zathura"))))
913 :hook (dired-mode . dired-hide-details-mode))
917 (temp-buffer-resize-mode)
918 (setq help-window-select t))
922 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
923 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
924 (add-to-list 'tramp-default-proxies-alist
925 (list (regexp-quote (system-name)) nil nil)))
928 :config (dash-enable-font-lock))
930 (use-feature doc-view
931 :bind (:map doc-view-mode-map
932 ("M-RET" . image-previous-line)))
937 ;; highlight uncommitted changes in the left fringe
941 (setq diff-hl-draw-borders nil)
942 (global-diff-hl-mode)
943 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
945 ;; display Lisp objects at point in the echo area
947 :when (version< "25" emacs-version)
949 :config (global-eldoc-mode))
951 ;; highlight matching parens
954 :config (show-paren-mode))
956 (use-feature elec-pair
958 :config (electric-pair-mode))
961 :delight (auto-fill-function " fill")
962 :config (column-number-mode))
964 ;; save minibuffer history
965 (use-feature savehist
969 (add-to-list 'savehist-additional-variables 'kill-ring))
971 ;; automatically save place in files
972 (use-feature saveplace
973 :when (version< "25" emacs-version)
974 :config (save-place-mode))
976 (use-feature prog-mode
977 :config (global-prettify-symbols-mode)
978 (defun indicate-buffer-boundaries-left ()
979 (setq indicate-buffer-boundaries 'left))
980 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
982 (use-feature text-mode
983 :hook (text-mode . indicate-buffer-boundaries-left))
985 (use-feature conf-mode
995 (:map company-active-map
996 ([tab] . company-complete-common-or-cycle)
997 ([escape] . company-abort
))
999 (company-minimum-prefix-length 1)
1000 (company-selection-wrap-around t
)
1001 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1002 (company-dabbrev-downcase nil
)
1003 (company-dabbrev-ignore-case nil
)
1005 (global-company-mode t
))
1007 (use-package flycheck
1009 :hook
(prog-mode . flycheck-mode
)
1011 (:map flycheck-mode-map
1012 ("M-P" . flycheck-previous-error
)
1013 ("M-N" . flycheck-next-error
))
1015 ;; Use the load-path from running Emacs when checking elisp files
1016 (setq flycheck-emacs-lisp-load-path
'inherit
)
1018 ;; Only flycheck when I actually save the buffer
1019 (setq flycheck-check-syntax-automatically
'(mode-enabled save
))
1020 :custom
(flycheck-mode-line-prefix "flyc"))
1022 (use-feature flyspell
1025 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1029 ;; ’ can be part of a word
1030 (setq ispell-local-dictionary-alist
1031 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1032 "['\x2019]" nil
("-B") nil utf-8
))
1033 ispell-program-name
(executable-find "hunspell"))
1034 ;; don't send ’ to the subprocess
1035 (defun endless/replace-apostrophe
(args)
1036 (cons (replace-regexp-in-string
1039 (advice-add #'ispell-send-string
:filter-args
1040 #'endless
/replace-apostrophe
)
1042 ;; convert ' back to ’ from the subprocess
1043 (defun endless/replace-quote
(args)
1044 (if (not (derived-mode-p 'org-mode
))
1046 (cons (replace-regexp-in-string
1049 (advice-add #'ispell-parse-output
:filter-args
1050 #'endless
/replace-quote
))
1054 :hook
(text-mode . abbrev-mode
))
1057 ;;; Programming modes
1059 (use-feature lisp-mode
1061 (defun indent-spaces-mode ()
1062 (setq indent-tabs-mode nil
))
1063 (add-hook 'lisp-interaction-mode-hook
#'indent-spaces-mode
))
1066 :delight
(reveal-mode " reveal")
1067 :hook
(emacs-lisp-mode . reveal-mode
))
1069 (use-feature elisp-mode
1070 :delight
(emacs-lisp-mode "Elisp" :major
))
1073 (use-package alloy-mode
1074 :straight
(:host github
:repo
"dwwmmn/alloy-mode")
1076 :config
(setq alloy-basic-offset
2))
1078 (eval-when-compile (defvar lean-mode-map
))
1079 (use-package lean-mode
1080 :straight
(:host github
:repo
"leanprover/lean-mode"
1081 :fork
(:repo
"notbandali/lean-mode" :branch
"remove-cl"))
1083 :bind
(:map lean-mode-map
1084 ("S-SPC" . company-complete
))
1086 (require 'lean-input
)
1087 (setq default-input-method
"Lean"
1088 lean-input-tweak-all
'(lean-input-compose
1089 (lean-input-prepend "/")
1090 (lean-input-nonempty))
1091 lean-input-user-translations
'(("/" "/")))
1095 (use-package proof-site
; for Coq
1096 :straight proof-general
)
1098 (use-package haskell-mode
1100 (setq haskell-indentation-layout-offset
4
1101 haskell-indentation-left-offset
4
1102 flycheck-checker
'haskell-hlint
1103 flycheck-disabled-checkers
'(haskell-stack-ghc haskell-ghc
)))
1107 :commands dante-mode
1108 :hook
(haskell-mode . dante-mode
))
1110 (use-package hlint-refactor
1112 :bind
(:map hlint-refactor-mode-map
1113 ("C-c l b" . hlint-refactor-refactor-buffer
)
1114 ("C-c l r" . hlint-refactor-refactor-at-point
))
1115 :hook
(haskell-mode . hlint-refactor-mode
))
1117 (use-package flycheck-haskell
1118 :after haskell-mode
)
1119 ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el
1122 (use-feature sgml-mode
1124 (setq sgml-basic-offset
2))
1126 (use-feature css-mode
1128 (setq css-indent-offset
2))
1130 (use-package web-mode
1134 web-mode-code-indent-offset
1135 web-mode-css-indent-offset
1136 web-mode-markup-indent-offset
))
1138 (use-package emmet-mode
1139 :after
(:any web-mode css-mode sgml-mode
)
1140 :bind
* (("C-)" . emmet-next-edit-point
)
1141 ("C-(" . emmet-prev-edit-point
))
1143 (unbind-key "C-j" emmet-mode-keymap
)
1144 (setq emmet-move-cursor-between-quotes t
)
1145 :hook
(web-mode css-mode html-mode sgml-mode
))
1148 (use-package meghanada
1150 (:map meghanada-mode-map
1151 (("C-M-o" . meghanada-optimize-import
)
1152 ("C-M-t" . meghanada-import-all
)))
1153 :hook
(java-mode . meghanada-mode
)))
1156 (use-package treemacs
1157 :config
(setq treemacs-never-persist t
))
1159 (use-package yasnippet
1161 ;; (yas-global-mode)
1164 (use-package lsp-mode
1165 :init
(setq lsp-eldoc-render-all nil
1166 lsp-highlight-symbol-at-point nil
)
1171 (use-package company-lsp
1174 (setq company-lsp-cache-candidates t
1175 company-lsp-async t
))
1179 (setq lsp-ui-sideline-update-mode
'point
))
1181 (use-package lsp-java
1183 (add-hook 'java-mode-hook
1185 (setq-local company-backends
(list 'company-lsp
))))
1187 (add-hook 'java-mode-hook
'lsp-java-enable
)
1188 (add-hook 'java-mode-hook
'flycheck-mode
)
1189 (add-hook 'java-mode-hook
'company-mode
)
1190 (add-hook 'java-mode-hook
'lsp-ui-mode
))
1192 (use-package dap-mode
1198 (use-package dap-java
1201 (use-package lsp-java-treemacs
1206 :bind
(:map eclim-mode-map
("S-SPC" . company-complete
))
1207 :hook
((java-mode . eclim-mode
)
1208 (eclim-mode .
(lambda ()
1209 (make-local-variable 'company-idle-delay
)
1210 (defvar company-idle-delay
)
1211 ;; (setq company-idle-delay 0.7)
1212 (setq company-idle-delay nil
))))
1214 (eclim-auto-save nil
)
1215 ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp")
1216 (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim")
1217 (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse"))))
1219 (use-package geiser
)
1221 (use-feature geiser-guile
1223 (setq geiser-guile-load-path
"~/src/git/guix"))
1230 (font-latex-fontify-sectioning 'color
)))
1232 (use-package go-mode
)
1234 (use-package po-mode
1236 (po-mode .
(lambda () (run-with-timer 0.1 nil
'View-exit
))))
1238 (use-feature tex-mode
1241 (lambda (p) (string-match "^---?" (car p
)))
1242 tex--prettify-symbols-alist
)
1243 :hook
((tex-mode . auto-fill-mode
)
1244 (tex-mode . flyspell-mode
)
1245 (tex-mode .
(lambda () (electric-indent-local-mode -
1)))))
1250 (add-to-list 'custom-theme-load-path
1252 (convert-standard-filename "lisp") user-emacs-directory
))
1253 (load-theme 'tangomod t
)
1255 (use-package smart-mode-line
1256 :commands
(sml/apply-theme
)
1260 (smart-mode-line-enable))
1262 (use-package doom-themes
)
1264 (defvar b
/org-mode-font-lock-keywords
1265 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1266 (1 '(:foreground
"#5a5b5a" :background
"#292b2b") t
) ; directive
1267 (3 '(:foreground
"#81a2be" :background
"#292b2b") t
) ; kind
1268 (4 '(:foreground
"#c5c8c6") t
)))) ; title
1270 (defun b/lights-on
()
1271 "Enable my favourite light theme."
1273 (mapc #'disable-theme custom-enabled-themes
)
1274 (load-theme 'tangomod t
)
1275 (sml/apply-theme
'automatic
)
1276 (font-lock-remove-keywords
1277 'org-mode b
/org-mode-font-lock-keywords
))
1279 (defun b/lights-off
()
1282 (mapc #'disable-theme custom-enabled-themes
)
1283 ;; (load-theme 'doom-tomorrow-night t)
1284 (sml/apply-theme
'automatic
)
1285 (font-lock-add-keywords
1286 'org-mode b
/org-mode-font-lock-keywords t
))
1289 ("C-c t d" . b
/lights-off
)
1290 ("C-c t l" . b
/lights-on
))
1293 ;;; Emacs enhancements & auxiliary packages
1296 :config
(setq Man-width
80))
1298 (use-package which-key
1302 (which-key-add-key-based-replacements
1303 ;; prefixes for global prefixes and minor modes
1307 "C-c 8 -" "typo/dashes"
1308 "C-c 8 <" "typo/left-brackets"
1309 "C-c 8 >" "typo/right-brackets"
1311 "C-x a" "abbrev/expand"
1312 "C-x r" "rectangle/register/bookmark"
1313 "C-x v" "version control"
1314 ;; prefixes for my personal bindings
1315 "C-c a" "applications"
1320 "C-c c" "compile-and-comments"
1326 "C-c m" "multiple-cursors"
1327 "C-c P" "projectile"
1328 "C-c P s" "projectile/search"
1329 "C-c P x" "projectile/execute"
1330 "C-c P 4" "projectile/other-window"
1336 ;; prefixes for major modes
1337 (which-key-add-major-mode-key-based-replacements 'message-mode
1339 (which-key-add-major-mode-key-based-replacements 'org-mode
1340 "C-c C-v" "org-babel")
1341 (which-key-add-major-mode-key-based-replacements 'web-mode
1342 "C-c C-a" "web/attributes"
1343 "C-c C-b" "web/blocks"
1345 "C-c C-e" "web/element"
1346 "C-c C-t" "web/tags")
1350 (which-key-add-column-padding 5)
1351 (which-key-max-description-length 32))
1353 (use-package crux
; results in Waiting for git... [2 times]
1355 :bind
(("C-c d" . crux-duplicate-current-line-or-region
)
1356 ("C-c D" . crux-duplicate-and-comment-current-line-or-region
)
1357 ("C-c f c" . crux-copy-file-preserve-attributes
)
1358 ("C-c f d" . crux-delete-file-and-buffer
)
1359 ("C-c f r" . crux-rename-file-and-buffer
)
1360 ("C-c j" . crux-top-join-line
)
1361 ("C-S-j" . crux-top-join-line
)))
1364 :bind
(("C-a" . mwim-beginning-of-code-or-line
)
1365 ("C-e" . mwim-end-of-code-or-line
)
1366 ("<home>" . mwim-beginning-of-line-or-code
)
1367 ("<end>" . mwim-end-of-line-or-code
)))
1369 (use-package projectile
1371 :bind-keymap
("C-c P" . projectile-command-map
)
1375 (defun b/projectile-mode-line-fun
()
1376 "Report project name and type in the modeline."
1377 (let ((project-name (projectile-project-name))
1378 (project-type (projectile-project-type)))
1380 projectile-mode-line-prefix
1382 (format ":%s" project-type
)
1384 (setq projectile-mode-line-function
'b
/projectile-mode-line-fun
)
1386 (defun my-projectile-invalidate-cache (&rest _args
)
1387 ;; ignore the args to `magit-checkout'
1388 (projectile-invalidate-cache nil
))
1390 (eval-after-load 'magit-branch
1392 (advice-add 'magit-checkout
1393 :after
#'my-projectile-invalidate-cache
)
1394 (advice-add 'magit-branch-and-checkout
1395 :after
#'my-projectile-invalidate-cache
)))
1397 (projectile-completion-system 'ivy
)
1398 (projectile-mode-line-prefix " proj"))
1400 (use-package helpful
1403 (("C-S-h c" . helpful-command
)
1404 ("C-S-h f" . helpful-callable
) ; helpful-function
1405 ("C-S-h v" . helpful-variable
)
1406 ("C-S-h k" . helpful-key
)
1407 ("C-S-h p" . helpful-at-point
)))
1409 (use-package unkillable-scratch
1412 (unkillable-scratch 1)
1414 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1417 ;; | make pretty boxed quotes like this
1419 (use-package boxquote
1422 (:prefix-map b
/boxquote-prefix-map
1424 ("b" . boxquote-buffer
)
1425 ("B" . boxquote-insert-buffer
)
1426 ("d" . boxquote-defun
)
1427 ("F" . boxquote-insert-file
)
1428 ("hf" . boxquote-describe-function
)
1429 ("hk" . boxquote-describe-key
)
1430 ("hv" . boxquote-describe-variable
)
1431 ("hw" . boxquote-where-is
)
1432 ("k" . boxquote-kill
)
1433 ("p" . boxquote-paragraph
)
1434 ("q" . boxquote-boxquote
)
1435 ("r" . boxquote-region
)
1436 ("s" . boxquote-shell-command
)
1437 ("t" . boxquote-text
)
1438 ("T" . boxquote-title
)
1439 ("u" . boxquote-unbox
)
1440 ("U" . boxquote-unbox-region
)
1441 ("y" . boxquote-yank
)
1442 ("M-q" . boxquote-fill-paragraph
)
1443 ("M-w" . boxquote-kill-ring-save
)))
1445 (use-package orgalist
1446 ;; http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00007.html
1449 :hook
(message-mode . orgalist-mode
))
1451 ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
1456 (typo-global-mode 1)
1457 :hook
(((text-mode erc-mode
) . typo-mode
)
1458 (tex-mode .
(lambda ()(typo-mode -
1)))))
1460 ;; highlight TODOs in buffers
1461 (use-package hl-todo
1464 (global-hl-todo-mode))
1466 (use-package shrink-path
1470 (defvar user-
@-host
(concat (user-login-name) "@" (system-name) " "))
1471 (defun +eshell
/prompt
()
1472 (let ((base/dir
(shrink-path-prompt default-directory
)))
1473 (concat (propertize user-
@-host
'face
'default
)
1474 (propertize (car base
/dir
)
1475 'face
'font-lock-comment-face
)
1476 (propertize (cdr base
/dir
)
1477 'face
'font-lock-constant-face
)
1478 (propertize "> " 'face
'default
))))
1479 (setq eshell-prompt-regexp
(concat user-
@-host
".*> ")
1480 eshell-prompt-function
#'+eshell
/prompt
))
1482 (use-package eshell-up
1484 :commands eshell-up
)
1486 (use-package multi-term
1488 :bind
(("C-c a s m m" . multi-term
)
1489 ("C-c a s m d" . multi-term-dedicated-toggle
)
1490 ("C-c a s m p" . multi-term-prev
)
1491 ("C-c a s m n" . multi-term-next
)
1493 ("C-c C-j" . term-char-mode
))
1495 (setq multi-term-program
"screen"
1496 multi-term-program-switches
(concat "-c"
1497 (getenv "XDG_CONFIG_HOME")
1499 ;; TODO: add separate bindings for connecting to existing
1500 ;; session vs. always creating a new one
1501 multi-term-dedicated-select-after-open-p t
1502 multi-term-dedicated-window-height
20
1503 multi-term-dedicated-max-window-height
30
1505 '(("C-c C-c" . term-interrupt-subjob
)
1506 ("C-c C-e" . term-send-esc
)
1507 ("C-c C-j" . term-line-mode
)
1509 ;; ("C-y" . term-paste)
1510 ("C-y" . term-send-raw
)
1511 ("M-f" . term-send-forward-word
)
1512 ("M-b" . term-send-backward-word
)
1513 ("M-p" . term-send-up
)
1514 ("M-n" . term-send-down
)
1515 ("M-j" . term-send-raw-meta
)
1516 ("M-y" . term-send-raw-meta
)
1517 ("M-/" . term-send-raw-meta
)
1518 ("M-0" . term-send-raw-meta
)
1519 ("M-1" . term-send-raw-meta
)
1520 ("M-2" . term-send-raw-meta
)
1521 ("M-3" . term-send-raw-meta
)
1522 ("M-4" . term-send-raw-meta
)
1523 ("M-5" . term-send-raw-meta
)
1524 ("M-6" . term-send-raw-meta
)
1525 ("M-7" . term-send-raw-meta
)
1526 ("M-8" . term-send-raw-meta
)
1527 ("M-9" . term-send-raw-meta
)
1528 ("<C-backspace>" . term-send-backward-kill-word
)
1529 ("<M-DEL>" . term-send-backward-kill-word
)
1530 ("M-d" . term-send-delete-word
)
1531 ("M-," . term-send-raw
)
1532 ("M-." . comint-dynamic-complete
))
1533 term-unbind-key-alist
1534 '("C-z" "C-x" "C-c" "C-h"
1538 (use-package page-break-lines
1542 (page-break-lines-max-width fill-column
)
1544 (global-page-break-lines-mode))
1546 (use-package expand-region
1547 :bind
("C-=" . er
/expand-region
))
1549 (use-package multiple-cursors
1551 (("C-S-<mouse-1>" . mc
/add-cursor-on-click
)
1552 (:prefix-map b
/mc-prefix-map
1554 ("c" . mc
/edit-lines
)
1555 ("n" . mc
/mark-next-like-this
)
1556 ("p" . mc
/mark-previous-like-this
)
1557 ("a" . mc
/mark-all-like-this
))))
1565 (use-package yasnippet
1568 (defconst yas-verbosity-cur yas-verbosity
)
1569 (setq yas-verbosity
2)
1570 (add-to-list 'yas-snippet-dirs
"~/src/git/guix/etc/snippets" t
)
1572 (setq yas-verbosity yas-verbosity-cur
)
1574 (defun b/yas--maybe-expand-key-filter
(cmd)
1575 (when (and (yas--maybe-expand-key-filter cmd
)
1576 (not (bound-and-true-p git-commit-mode
)))
1578 (defconst b
/yas-maybe-expand
1579 '(menu-item "" yas-expand
:filter b
/yas--maybe-expand-key-filter
))
1580 (define-key yas-minor-mode-map
1581 (kbd "SPC") b
/yas-maybe-expand
)
1585 (use-package debbugs
1588 :repo
"emacs-straight/debbugs"
1589 :files
(:defaults
"Debbugs.wsdl")))
1591 (use-package org-ref
1593 (b/setq-every
'("~/usr/org/references.bib")
1594 reftex-default-bibliography
1595 org-ref-default-bibliography
)
1597 org-ref-bibliography-notes
"~/usr/org/notes.org"
1598 org-ref-pdf-directory
"~/usr/org/bibtex-pdfs/"))
1602 :init
(setq alert-default-style
'notifications
))
1604 ;; (use-package fill-column-indicator)
1606 (use-package emojify
1607 :hook
(erc-mode . emojify-mode
))
1611 (("C-c w <right>" . split-window-right
)
1612 ("C-c w <down>" . split-window-below
)
1613 ("C-c w s l" . split-window-right
)
1614 ("C-c w s j" . split-window-below
)
1615 ("C-c w q" . quit-window
))
1617 (split-width-threshold 150))
1619 (use-feature windmove
1622 (("C-c w h" . windmove-left
)
1623 ("C-c w j" . windmove-down
)
1624 ("C-c w k" . windmove-up
)
1625 ("C-c w l" . windmove-right
)
1626 ("C-c w H" . windmove-swap-states-left
)
1627 ("C-c w J" . windmove-swap-states-down
)
1628 ("C-c w K" . windmove-swap-states-up
)
1629 ("C-c w L" . windmove-swap-states-right
)))
1633 :bind
("C-c a p" . pass
)
1634 :hook
(pass-mode . View-exit
))
1636 (use-package pdf-tools
1638 :bind
(:map pdf-view-mode-map
1639 ("<XF86Back>" . pdf-history-backward
)
1640 ("<XF86Forward>" . pdf-history-forward
)
1641 ("M-RET" . image-previous-line
))
1642 :config
(pdf-tools-install nil t
)
1643 :custom
(pdf-view-resize-factor 1.05))
1645 (use-package biblio
)
1648 :hook
(latex-mode . reftex-mode
))
1650 (use-feature reftex-cite
1652 :disabled
; enable to disable
1653 ; reftex-cite's default choice
1656 (defun reftex-get-bibkey-default ()
1657 "If the cursor is in a citation macro, return the word before the macro."
1658 (let* ((macro (reftex-what-macro 1)))
1660 (when (and macro
(string-match "cite" (car macro
)))
1661 (goto-char (cdr macro
)))
1662 (reftex-this-word)))))
1665 :custom
(auto-save-file-name-transforms
1666 `((".*" ,(b/var
"auto-save/") t
))))
1669 ;;; Email (with Gnus)
1671 (defvar b
/maildir
(expand-file-name "~/mail/"))
1672 (with-eval-after-load 'recentf
1673 (add-to-list 'recentf-exclude b
/maildir
))
1676 b
/gnus-init-file
(b/etc
"gnus")
1677 mail-user-agent
'gnus-user-agent
1678 read-mail-command
'gnus
)
1681 :bind
(("s-m" . gnus
)
1682 ("s-M" . gnus-unplugged
)
1684 ("C-c a M" . gnus-unplugged
))
1687 gnus-select-method
'(nnnil "")
1688 gnus-secondary-select-methods
1689 '((nnimap "shemshak"
1690 (nnimap-stream plain
)
1691 (nnimap-address "127.0.0.1")
1692 (nnimap-server-port 143)
1693 (nnimap-authenticator plain
)
1694 (nnimap-user "amin@shemshak.local"))
1696 (nnimap-stream plain
)
1697 (nnimap-address "127.0.0.1")
1698 (nnimap-server-port 143)
1699 (nnimap-authenticator plain
)
1700 (nnimap-user "bandali@gnu.local")
1701 (nnimap-inbox "INBOX")
1702 (nnimap-split-methods 'nnimap-split-fancy
)
1703 (nnimap-split-fancy (|
1704 ;; (: gnus-registry-split-fancy-with-parent)
1705 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1707 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1708 ;; *@lists.sr.ht, omitting one dot if present
1709 ;; add more \\.?\\([^.@]*\\) if needed
1710 (list ".*<~\\(.*\\)/\\([^.@]*\\)\\.?\\([^.@]*\\)@lists.sr.ht>.*" "l.~\\1.\\2\\3")
1712 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1714 (list ".*atreus.freelists.org" "l.atreus")
1715 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1716 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1717 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1718 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1719 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1720 ;; ----------------------------------
1721 ;; legend: (u)nsubscribed | (d)ead
1722 ;; ----------------------------------
1723 ;; otherwise, leave mail in INBOX
1726 (nnimap-stream plain
)
1727 (nnimap-address "127.0.0.1")
1728 (nnimap-server-port 143)
1729 (nnimap-authenticator plain
)
1730 (nnimap-user "abandali@uw.local")
1731 (nnimap-inbox "INBOX")
1732 (nnimap-split-methods 'nnimap-split-fancy
)
1733 (nnimap-split-fancy (|
1734 ;; (: gnus-registry-split-fancy-with-parent)
1736 ("subject" "SE\\s-?212" "course.se212-f19")
1737 (from "SE\\s-?212" "course.se212-f19")
1741 (nnimap-stream plain
)
1742 (nnimap-address "127.0.0.1")
1743 (nnimap-server-port 143)
1744 (nnimap-authenticator plain
)
1745 (nnimap-user "abandali@csc.uw.local")))
1746 gnus-message-archive-group
"nnimap+shemshak:Sent"
1749 (to-address .
"atreus@freelists.org")
1750 (to-list .
"atreus@freelists.org"))
1752 (to-address .
"deepspec@lists.cs.princeton.edu")
1753 (to-list .
"deepspec@lists.cs.princeton.edu")
1754 (list-identifier .
"\\[deepspec\\]"))
1756 (to-address .
"emacs-devel@gnu.org")
1757 (to-list .
"emacs-devel@gnu.org"))
1758 ("l\\.help-gnu-emacs"
1759 (to-address .
"help-gnu-emacs@gnu.org")
1760 (to-list .
"help-gnu-emacs@gnu.org"))
1761 ("l\\.info-gnu-emacs"
1762 (to-address .
"info-gnu-emacs@gnu.org")
1763 (to-list .
"info-gnu-emacs@gnu.org"))
1764 ("l\\.emacs-orgmode"
1765 (to-address .
"emacs-orgmode@gnu.org")
1766 (to-list .
"emacs-orgmode@gnu.org")
1767 (list-identifier .
"\\[O\\]"))
1768 ("l\\.emacs-tangents"
1769 (to-address .
"emacs-tangents@gnu.org")
1770 (to-list .
"emacs-tangents@gnu.org"))
1771 ("l\\.emacsconf-discuss"
1772 (to-address .
"emacsconf-discuss@gnu.org")
1773 (to-list .
"emacsconf-discuss@gnu.org"))
1774 ("l\\.emacsconf-register"
1775 (to-address .
"emacsconf-register@gnu.org")
1776 (to-list .
"emacsconf-register@gnu.org"))
1777 ("l\\.emacsconf-submit"
1778 (to-address .
"emacsconf-submit@gnu.org")
1779 (to-list .
"emacsconf-submit@gnu.org"))
1780 ("l\\.fencepost-users"
1781 (to-address .
"fencepost-users@gnu.org")
1782 (to-list .
"fencepost-users@gnu.org")
1783 (list-identifier .
"\\[Fencepost-users\\]"))
1784 ("l\\.gnewsense-art"
1785 (to-address .
"gnewsense-art@nongnu.org")
1786 (to-list .
"gnewsense-art@nongnu.org")
1787 (list-identifier .
"\\[gNewSense-art\\]"))
1788 ("l\\.gnewsense-dev"
1789 (to-address .
"gnewsense-dev@nongnu.org")
1790 (to-list .
"gnewsense-dev@nongnu.org")
1791 (list-identifier .
"\\[Gnewsense-dev\\]"))
1792 ("l\\.gnewsense-users"
1793 (to-address .
"gnewsense-users@nongnu.org")
1794 (to-list .
"gnewsense-users@nongnu.org")
1795 (list-identifier .
"\\[gNewSense-users\\]"))
1796 ("l\\.gnunet-developers"
1797 (to-address .
"gnunet-developers@gnu.org")
1798 (to-list .
"gnunet-developers@gnu.org")
1799 (list-identifier .
"\\[GNUnet-developers\\]"))
1801 (to-address .
"help-gnunet@gnu.org")
1802 (to-list .
"help-gnunet@gnu.org")
1803 (list-identifier .
"\\[Help-gnunet\\]"))
1805 (to-address .
"bug-gnuzilla@gnu.org")
1806 (to-list .
"bug-gnuzilla@gnu.org")
1807 (list-identifier .
"\\[Bug-gnuzilla\\]"))
1809 (to-address .
"gnuzilla-dev@gnu.org")
1810 (to-list .
"gnuzilla-dev@gnu.org")
1811 (list-identifier .
"\\[Gnuzilla-dev\\]"))
1813 (to-address .
"guile-devel@gnu.org")
1814 (to-list .
"guile-devel@gnu.org"))
1816 (to-address .
"guile-user@gnu.org")
1817 (to-list .
"guile-user@gnu.org"))
1819 (to-address .
"guix-devel@gnu.org")
1820 (to-list .
"guix-devel@gnu.org"))
1822 (to-address .
"help-guix@gnu.org")
1823 (to-list .
"help-guix@gnu.org"))
1825 (to-address .
"info-guix@gnu.org")
1826 (to-list .
"info-guix@gnu.org"))
1827 ("l\\.savannah-hackers-public"
1828 (to-address .
"savannah-hackers-public@gnu.org")
1829 (to-list .
"savannah-hackers-public@gnu.org"))
1830 ("l\\.savannah-users"
1831 (to-address .
"savannah-users@gnu.org")
1832 (to-list .
"savannah-users@gnu.org"))
1834 (to-address .
"www-commits@gnu.org")
1835 (to-list .
"www-commits@gnu.org"))
1837 (to-address .
"www-discuss@gnu.org")
1838 (to-list .
"www-discuss@gnu.org"))
1840 (to-address .
"haskell-art@we.lurk.org")
1841 (to-list .
"haskell-art@we.lurk.org")
1842 (list-identifier .
"\\[haskell-art\\]"))
1844 (to-address .
"haskell-cafe@haskell.org")
1845 (to-list .
"haskell-cafe@haskell.org")
1846 (list-identifier .
"\\[Haskell-cafe\\]"))
1848 (to-address .
"notmuch@notmuchmail.org")
1849 (to-list .
"notmuch@notmuchmail.org"))
1851 (to-address .
"dev@lists.parabola.nu")
1852 (to-list .
"dev@lists.parabola.nu")
1853 (list-identifier .
"\\[Dev\\]"))
1854 ("l\\.~bandali\\.public-inbox"
1855 (to-address .
"~bandali/public-inbox@lists.sr.ht")
1856 (to-list .
"~bandali/public-inbox@lists.sr.ht"))
1857 ("l\\.~sircmpwn\\.free-writers-club"
1858 (to-address .
"~sircmpwn/free-writers-club@lists.sr.ht")
1859 (to-list .
"~sircmpwn/free-writers-club@lists.sr.ht"))
1860 ("l\\.~sircmpwn\\.srht-admins"
1861 (to-address .
"~sircmpwn/sr.ht-admins@lists.sr.ht")
1862 (to-list .
"~sircmpwn/sr.ht-admins@lists.sr.ht"))
1863 ("l\\.~sircmpwn\\.srht-announce"
1864 (to-address .
"~sircmpwn/sr.ht-announce@lists.sr.ht")
1865 (to-list .
"~sircmpwn/sr.ht-announce@lists.sr.ht"))
1866 ("l\\.~sircmpwn\\.srht-dev"
1867 (to-address .
"~sircmpwn/sr.ht-dev@lists.sr.ht")
1868 (to-list .
"~sircmpwn/sr.ht-dev@lists.sr.ht"))
1869 ("l\\.~sircmpwn\\.srht-discuss"
1870 (to-address .
"~sircmpwn/sr.ht-discuss@lists.sr.ht")
1871 (to-list .
"~sircmpwn/sr.ht-discuss@lists.sr.ht"))
1873 (to-address .
"webmasters@gnu.org")
1874 (to-list .
"webmasters@gnu.org"))
1881 gnus-large-newsgroup
50
1882 gnus-home-directory
(b/var
"gnus/")
1883 gnus-directory
(concat gnus-home-directory
"news/")
1884 message-directory
(concat gnus-home-directory
"mail/")
1885 nndraft-directory
(concat gnus-home-directory
"drafts/")
1886 gnus-save-newsrc-file nil
1887 gnus-read-newsrc-file nil
1888 gnus-interactive-exit nil
1889 gnus-gcc-mark-as-read t
)
1893 (require 'ebdb-gnus
)
1895 (when (version< emacs-version
"27")
1897 'nnmail-split-abbrev-alist
1898 '(list .
"list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
1901 ;; (gnus-registry-initialize)
1903 (with-eval-after-load 'recentf
1904 (add-to-list 'recentf-exclude gnus-home-directory
)))
1906 (use-feature gnus-art
1909 gnus-buttonized-mime-types
'("multipart/\\(signed\\|encrypted\\)")
1910 gnus-visible-headers
1911 (concat gnus-visible-headers
"\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
1912 gnus-sorted-header-list
1913 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
1914 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
1915 "^Newsgroups:" "List-Id:" "^Organization:"
1916 "^User-Agent:" "^Date:")
1917 ;; local-lapsed article dates
1918 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1919 gnus-article-date-headers
'(user-defined)
1920 gnus-article-time-format
1922 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time
))
1923 (local (article-make-date-line date
'local
))
1924 (combined-lapsed (article-make-date-line date
1927 (string-match " (.+" combined-lapsed
)
1928 (match-string 0 combined-lapsed
))))
1929 (concat local lapsed
))))
1931 :map gnus-article-mode-map
1932 ("M-L" . org-store-link
)))
1934 (use-feature gnus-sum
1935 :bind
(:map gnus-summary-mode-map
1936 :prefix-map b
/gnus-summary-prefix-map
1938 ("r" . gnus-summary-reply
)
1939 ("w" . gnus-summary-wide-reply
)
1940 ("v" . gnus-summary-show-raw-article
))
1943 :map gnus-summary-mode-map
1944 ("M-L" . org-store-link
))
1945 :hook
(gnus-summary-mode . b
/no-mouse-autoselect-window
))
1947 (use-feature gnus-msg
1949 (defvar b
/signature
"Amin Bandali
1950 Free Software Activist | GNU Webmaster & Volunteer
1951 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
1952 https://shemshak.org/~amin")
1953 (defvar b
/gnu-signature
"Amin Bandali
1954 Free Software Activist | GNU Webmaster & Volunteer
1955 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
1956 https://bandali.eu.org")
1957 (defvar b
/uw-signature
"Amin Bandali, MMath Student
1958 Cheriton School of Computer Science
1959 University of Waterloo
1960 https://bandali.eu.org")
1961 (defvar b
/csc-signature
"Amin Bandali
1963 Computer Science Club, University of Waterloo
1964 https://csclub.uwaterloo.ca/~abandali")
1965 (setq gnus-posting-styles
1967 (address "amin@shemshak.org")
1969 (signature b
/signature
)
1970 (eval (setq b
/message-cite-say-hi t
)))
1972 (address "bandali@gnu.org")
1973 (signature b
/gnu-signature
)
1974 (eval (set (make-local-variable 'message-user-fqdn
) "fencepost.gnu.org")))
1975 ((header "subject" "ThankCRM")
1976 (to "webmasters-comment@gnu.org")
1978 (eval (setq b
/message-cite-say-hi nil
)))
1980 (address "abandali@uwaterloo.ca")
1981 (signature b
/uw-signature
))
1982 ("nnimap\\+uw:INBOX"
1983 (gcc "\"nnimap+uw:Sent Items\""))
1985 (address "abandali@csclub.uwaterloo.ca")
1986 (signature b
/csc-signature
)
1987 (gcc "nnimap+csc:Sent")))))
1989 (use-feature gnus-topic
1990 :hook
(gnus-group-mode . gnus-topic-mode
)
1991 :config
(setq gnus-topic-line-format
"%i[ %A: %(%{%n%}%) ]%v\n"))
1993 (use-feature gnus-agent
1995 (setq gnus-agent-synchronize-flags
'ask
)
1996 :hook
(gnus-group-mode . gnus-agent-mode
))
1998 (use-feature gnus-group
2000 (setq gnus-permanently-visible-groups
"\\(:INBOX$\\|:gnu$\\)"))
2003 ;; problematic with ebdb's popup, *EBDB-Gnus*
2004 (use-feature gnus-win
2006 (setq gnus-use-full-window nil
)))
2008 (use-feature gnus-dired
2009 :commands gnus-dired-mode
2011 (add-hook 'dired-mode-hook
'gnus-dired-mode
))
2013 (use-feature mm-decode
2015 (setq mm-discouraged-alternatives
'("text/html" "text/richtext")
2016 mm-decrypt-option
'known
2017 mm-verify-option
'known
))
2019 (use-feature sendmail
2021 (setq sendmail-program
(executable-find "msmtp")
2022 ;; message-sendmail-extra-arguments '("-v" "-d")
2023 mail-specify-envelope-from t
2024 mail-envelope-from
'header
))
2026 (use-feature message
2028 ;; redefine for a simplified In-Reply-To header
2029 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2030 (defun message-make-in-reply-to ()
2031 "Return the In-Reply-To header for this message."
2032 (when message-reply-headers
2033 (let ((from (mail-header-from message-reply-headers
))
2034 (msg-id (mail-header-id message-reply-headers
)))
2038 (defconst b
/message-cite-style-format
"On %Y-%m-%d %l:%M %p, %N wrote:")
2039 (defconst message-cite-style-bandali
2040 '((message-cite-function 'message-cite-original
)
2041 (message-citation-line-function 'message-insert-formatted-citation-line
)
2042 (message-cite-reply-position 'traditional
)
2043 (message-yank-prefix "> ")
2044 (message-yank-cited-prefix ">")
2045 (message-yank-empty-prefix ">")
2046 (message-citation-line-format
2047 (if b
/message-cite-say-hi
2048 (concat "Hi %F,\n\n" b
/message-cite-style-format
)
2049 b
/message-cite-style-format
)))
2050 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2051 (setq ;; message-cite-style 'message-cite-style-bandali
2052 message-kill-buffer-on-exit t
2053 message-send-mail-function
'message-send-mail-with-sendmail
2054 message-sendmail-envelope-from
'header
2055 message-subscribed-address-functions
2056 '(gnus-find-subscribed-addresses)
2057 message-dont-reply-to-names
2058 "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(amin@bndl\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)")
2059 (require 'company-ebdb
)
2060 :hook
(;; (message-setup . mml-secure-message-sign-pgpmime)
2061 (message-mode . flyspell-mode
)
2062 (message-mode .
(lambda ()
2063 ;; (setq fill-column 65
2064 ;; message-fill-column 65)
2065 (make-local-variable 'company-idle-delay
)
2066 (setq company-idle-delay
0.2))))
2068 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2069 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2070 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2076 (use-feature mml-sec
2078 (mml-secure-openpgp-encrypt-to-self t
)
2079 (mml-secure-openpgp-sign-with-sender t
))
2081 (use-feature footnote
2084 ;; (setq footnote-start-tag ""
2085 ;; footnote-end-tag ""
2086 ;; footnote-style 'unicode)
2088 (:map message-mode-map
2089 :prefix-map b
/footnote-prefix-map
2091 ("a" . footnote-add-footnote
)
2092 ("b" . footnote-back-to-message
)
2093 ("c" . footnote-cycle-style
)
2094 ("d" . footnote-delete-footnote
)
2095 ("g" . footnote-goto-footnote
)
2096 ("r" . footnote-renumber-footnotes
)
2097 ("s" . footnote-set-style
)))
2101 :bind
(:map gnus-group-mode-map
("e" . ebdb
))
2103 (setq ebdb-sources
(b/var
"ebdb"))
2104 (with-eval-after-load 'swiper
2105 (add-to-list 'swiper-font-lock-exclude
'ebdb-mode t
)))
2107 (use-feature ebdb-com
2110 ;; (use-package ebdb-complete
2113 ;; (ebdb-complete-enable))
2115 (use-package company-ebdb
2117 (defun company-ebdb--post-complete (_) nil
))
2119 (use-feature ebdb-gnus
2122 (ebdb-gnus-window-configuration
2125 (summary 0.25 point
)
2128 (ebdb-gnus 0.3))))))
2130 (use-feature ebdb-mua
2132 ;; :custom (ebdb-mua-pop-up nil)
2135 ;; (use-package ebdb-message
2138 ;; (use-package ebdb-vcard
2141 (use-package message-x
)
2144 (use-package message-x
2146 (message-x-completion-alist
2148 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address
)
2151 (quote message-newgroups-header-regexp
))
2152 message-newgroups-header-regexp message-newsgroups-header-regexp
)
2153 . message-expand-group
))))))
2156 (use-package gnus-harvest
2157 :commands gnus-harvest-install
2160 (if (featurep 'message-x
)
2161 (gnus-harvest-install 'message-x
)
2162 (gnus-harvest-install))))
2165 ;;; IRC (with ERC and ZNC)
2168 :bind
(("C-c b e" . erc-switch-to-buffer
)
2170 ("M-a" . erc-track-switch-buffer
))
2172 (erc-join-buffer 'bury
)
2173 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2174 (erc-nick "bandali")
2176 (erc-rename-buffers t
)
2177 (erc-server-reconnect-attempts 5)
2178 (erc-server-reconnect-timeout 3)
2180 (defun erc-cmd-OPME ()
2181 "Request chanserv to op me."
2182 (erc-message "PRIVMSG"
2183 (format "chanserv op %s %s"
2184 (erc-default-target)
2185 (erc-current-nick)) nil
))
2186 (defun erc-cmd-DEOPME ()
2187 "Deop myself from current channel."
2188 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2189 (add-to-list 'erc-modules
'keep-place
)
2190 (add-to-list 'erc-modules
'notifications
)
2191 (add-to-list 'erc-modules
'spelling
)
2192 (add-to-list 'erc-modules
'scrolltoplace
)
2193 (erc-update-modules)
2195 (when (and (version<= "24.4" emacs-version
)
2196 (version< emacs-version
"27"))
2197 ;; fix erc-lurker bug
2198 ;; patch submitted: https://bugs.gnu.org/36843#10
2199 ;; TODO: remove when patch is merged and emacs 27 is released
2200 (defvar erc-message-parsed
)
2201 (defun erc-display-message (parsed type buffer msg
&rest args
)
2202 "Display MSG in BUFFER.
2204 ARGS, PARSED, and TYPE are used to format MSG sensibly.
2206 See also `erc-format-message' and `erc-display-line'."
2207 (let ((string (if (symbolp msg
)
2208 (apply #'erc-format-message msg args
)
2210 (erc-message-parsed parsed
))
2216 (mapc (lambda (type)
2218 (erc-display-message-highlight type string
)))
2222 (erc-display-message-highlight type string
))))
2224 (if (not (erc-response-p parsed
))
2225 (erc-display-line string buffer
)
2226 (unless (erc-hide-current-message-p parsed
)
2227 (erc-put-text-property 0 (length string
) 'erc-parsed parsed string
)
2228 (erc-put-text-property 0 (length string
) 'rear-sticky t string
)
2229 (when (erc-response.tags parsed
)
2230 (erc-put-text-property 0 (length string
) 'tags
(erc-response.tags parsed
)
2232 (erc-display-line string buffer
)))))
2234 (defun erc-lurker-update-status (_message)
2235 "Update `erc-lurker-state' if necessary.
2237 This function is called from `erc-insert-pre-hook'. If the
2238 current message is a PRIVMSG, update `erc-lurker-state' to
2239 reflect the fact that its sender has issued a PRIVMSG at the
2240 current time. Otherwise, take no action.
2242 This function depends on the fact that `erc-display-message'
2243 lexically binds `erc-message-parsed', which is used to check if
2244 the current message is a PRIVMSG and to determine its sender.
2245 See also `erc-lurker-trim-nicks' and `erc-lurker-ignore-chars'.
2247 In order to limit memory consumption, this function also calls
2248 `erc-lurker-cleanup' once every `erc-lurker-cleanup-interval'
2249 updates of `erc-lurker-state'."
2250 (when (and (boundp 'erc-message-parsed
)
2251 (erc-response-p erc-message-parsed
))
2252 (let* ((command (erc-response.command erc-message-parsed
))
2254 (erc-lurker-maybe-trim
2255 (car (erc-parse-user (erc-response.sender erc-message-parsed
)))))
2257 (erc-canonicalize-server-name erc-server-announced-name
)))
2258 (when (equal command
"PRIVMSG")
2259 (when (>= (cl-incf erc-lurker-cleanup-count
)
2260 erc-lurker-cleanup-interval
)
2261 (setq erc-lurker-cleanup-count
0)
2262 (erc-lurker-cleanup))
2263 (unless (gethash server erc-lurker-state
)
2264 (puthash server
(make-hash-table :test
'equal
) erc-lurker-state
))
2265 (puthash sender
(current-time)
2266 (gethash server erc-lurker-state
))))))))
2268 (use-feature erc-fill
2271 (erc-fill-column 77)
2272 (erc-fill-function 'erc-fill-static
)
2273 (erc-fill-static-center 18))
2275 (use-feature erc-pcomplete
2278 (erc-pcomplete-nick-postfix ","))
2280 (use-feature erc-track
2282 :bind
(("C-c a e t d" . erc-track-disable
)
2283 ("C-c a e t e" . erc-track-enable
))
2285 (erc-track-enable-keybindings nil
)
2286 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2287 "324" "329" "332" "333" "353" "477"))
2288 (erc-track-priority-faces-only 'all
)
2289 (erc-track-shorten-function nil
))
2291 (use-package erc-hl-nicks
2294 (use-package erc-scrolltoplace
2298 :straight
(:host nil
:repo
"https://git.shemshak.org/amin/znc.el")
2299 :bind
(("C-c a e e" . znc-erc
)
2300 ("C-c a e a" . znc-all
))
2302 (let ((pwd (let ((auth (auth-source-search :host
"znca")))
2304 ((null auth
) (error "Couldn't find znca's authinfo"))
2305 (t (funcall (plist-get (car auth
) :secret
)))))))
2307 `(("znc.shemshak.org" 1337 t
2308 ((freenode "amin/freenode" ,pwd
)))
2309 ("znc.shemshak.org" 1337 t
2310 ((moznet "amin/moznet" ,pwd
)))
2311 ("znc.shemshak.org" 1337 t
2312 ((oftc "amin/oftc" ,pwd
)))))))
2315 ;;; Post initialization
2317 (message "Loading %s...done (%.3fs)" user-init-file
2318 (float-time (time-subtract (current-time)
2319 b
/before-user-init-time
)))
2321 ;;; init.el ends here