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 'recentf
142 (add-to-list 'recentf-exclude
143 (expand-file-name "~/.emacs.d/straight/build/")))
145 (defun b/reload-init
()
148 (setq b
/file-name-handler-alist file-name-handler-alist
)
149 (load user-init-file nil
'nomessage
)
153 (straight-use-package 'use-package
)
155 (if nil
; set to t when need to debug init
157 (setq use-package-verbose t
158 use-package-expand-minimally nil
159 use-package-compute-statistics t
161 (require 'use-package
))
162 (setq use-package-verbose nil
163 use-package-expand-minimally t
))
165 (setq use-package-always-defer t
)
168 (use-package delight
)
173 ;; keep ~/.emacs.d clean
176 (convert-standard-filename "etc/") user-emacs-directory
)
177 "The directory where packages place their configuration files.")
181 (convert-standard-filename "var/") user-emacs-directory
)
182 "The directory where packages place their persistent data files.")
185 "Expand filename FILE relative to `b/etc-dir'."
186 (expand-file-name (convert-standard-filename file
) b
/etc-dir
))
189 "Expand filename FILE relative to `b/var-dir'."
190 (expand-file-name (convert-standard-filename file
) b
/var-dir
))
193 auto-save-list-file-prefix
(b/var
"auto-save/sessions/")
194 nsm-settings-file
(b/var
"nsm-settings.el"))
196 ;; separate custom file (don't want it mixing with init.el)
200 (setq custom-file
(b/etc
"custom.el"))
201 (when (file-exists-p custom-file
)
203 ;; while at it, treat themes as safe
204 (setf custom-safe-themes t
))
206 ;; load the secrets file if it exists, otherwise show a warning
209 (load (b/etc
"secrets"))))
211 ;; better $PATH (and other environment variable) handling
212 (use-package exec-path-from-shell
215 (setq exec-path-from-shell-arguments nil
216 exec-path-from-shell-check-startup-files nil
)
218 (exec-path-from-shell-initialize)
219 ;; while we're at it, let's fix access to our running ssh-agent
220 (exec-path-from-shell-copy-env "SSH_AGENT_PID")
221 (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
223 ;; only one custom theme at a time
225 (defadvice load-theme
(before clear-previous-themes activate
)
226 "Clear existing theme settings instead of layering them"
227 (mapc #'disable-theme custom-enabled-themes
)))
229 ;; start up emacs server. see
230 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
233 :config
(or (server-running-p) (server-mode)))
237 (dolist (ft (fontset-list))
241 (font-spec :name
"Source Code Pro" :size
14))
245 (font-spec :name
"DejaVu Sans Mono")
252 ;; :name "Symbola monospacified for DejaVu Sans Mono")
258 ;; (font-spec :name "DejaVu Sans Mono")
264 (font-spec :name
"DejaVu Sans Mono" :size
14)
268 ;; gentler font resizing
269 (setq text-scale-mode-step
1.05)
271 ;; focus follows mouse
272 (setq mouse-autoselect-window t
)
274 (defun b/no-mouse-autoselect-window
()
275 "Conveniently disable `focus-follows-mouse'.
276 For disabling the behaviour for certain buffers and/or modes."
277 (make-local-variable 'mouse-autoselect-window
)
278 (setq mouse-autoselect-window nil
))
281 (setq ;; scroll-margin 1
282 ;; scroll-conservatively 10000
284 scroll-conservatively
10
285 scroll-preserve-screen-position
1)
290 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
291 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
292 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
294 (use-feature pixel-scroll
296 :config
(pixel-scroll-mode 1))
298 ;; ask for GPG passphrase in minibuffer
301 ; this will fail if gpg>=2.1 is not available
302 (epa-pinentry-mode 'loopback
))
304 (use-feature epg-config
307 ((epg-gpg-program (executable-find "gpg"))
308 (epg-pinentry-mode 'loopback
)))
313 (use-package pinentry
315 :after
(epa epg server
)
317 (setq pinentry--socket-dir server-socket-dir
)
327 (defmacro b
/setq-every
(value &rest vars
)
328 "Set all the variables from VARS to value VALUE."
329 (declare (indent defun
) (debug t
))
330 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
332 (defun b/start-process
(program &rest args
)
333 "Same as `start-process', but doesn't bother about name and buffer."
334 (let ((process-name (concat program
"_process"))
335 (buffer-name (generate-new-buffer-name
336 (concat program
"_output"))))
337 (apply #'start-process
338 process-name buffer-name program args
)))
340 (defun b/dired-start-process
(program &optional args
)
341 "Open current file with a PROGRAM."
342 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
343 ;; be nil, so remove it).
344 (apply #'b
/start-process
346 (remove nil
(list args
(dired-get-file-for-visit)))))
348 (defun b/add-elisp-section
()
352 (insert "\n\f\n;;; "))
357 ;; time and battery in mode-line
361 (setq display-time-default-load-average nil
)
367 (display-battery-mode)))
370 ;; (fringe-mode '(3 . 1))
373 ;; disable disabled commands
374 (setq disabled-command-function nil
)
376 ;; Save what I copy into clipboard from other applications into Emacs'
377 ;; kill-ring, which would allow me to still be able to easily access
378 ;; it in case I kill (cut or copy) something else inside Emacs before
379 ;; yanking (pasting) what I'd originally intended to.
380 (setq save-interprogram-paste-before-kill t
)
383 (setq enable-recursive-minibuffers t
384 resize-mini-windows t
)
386 ;; lazy-person-friendly yes/no prompts
387 (defalias 'yes-or-no-p
#'y-or-n-p
)
389 ;; i want *scratch* as my startup buffer
390 (setq initial-buffer-choice t
)
392 ;; i don't need the default hint
393 (setq initial-scratch-message nil
)
395 ;; use customizable text-mode as major mode for *scratch*
396 (setq initial-major-mode
'text-mode
)
398 ;; inhibit buffer list when more than 2 files are loaded
399 (setq inhibit-startup-buffer-menu t
)
401 ;; don't need to see the startup screen or the echo area message
402 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
403 (setq inhibit-startup-screen t
404 inhibit-startup-echo-area-message user-login-name
)
406 ;; more useful frame titles
407 (setq frame-title-format
408 '("" invocation-name
" - "
409 (:eval
(if (buffer-file-name)
410 (abbreviate-file-name (buffer-file-name))
413 ;; backups (C-h v make-backup-files RET)
414 (setq backup-by-copying t
415 backup-directory-alist
(list (cons "." (b/var
"backup/")))
417 delete-old-versions t
)
419 ;; enable automatic reloading of changed buffers and files
420 (global-auto-revert-mode 1)
421 (setq auto-revert-verbose nil
422 global-auto-revert-non-file-buffers nil
)
424 ;; always use space for indentation
427 require-final-newline t
430 ;; enable winner-mode (C-h f winner-mode RET)
433 ;; don't display *compilation* buffer on success. based on
434 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
435 ;; instead of the now obsolete `flet'.
436 (with-eval-after-load 'compile
437 (defun b/compilation-finish-function
(buffer outstr
)
438 (unless (string-match "finished" outstr
)
439 (switch-to-buffer-other-window buffer
))
442 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
446 (defadvice compilation-start
447 (around inhibit-display
448 (command &optional mode name-function highlight-regexp
))
449 (if (not (string-match "^\\(find\\|grep\\)" command
))
450 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
451 (save-window-excursion ad-do-it
))
453 (ad-activate 'compilation-start
))
455 ;; search for non-ASCII characters: i’d like non-ASCII characters such
456 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
457 ;; counterpart. shoutout to
458 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
459 (setq search-default-mode
#'char-fold-to-regexp
)
460 ;; uncomment to extend this behaviour to query-replace
461 ;; (setq replace-char-fold t)
464 (setq-default cursor-type
'bar
)
466 ;; allow scrolling in Isearch
467 (setq isearch-allow-scroll t
)
469 ;; open read-only file buffers in view-mode
470 ;; (enables niceties like `q' for quit)
471 (setq view-read-only t
)
474 :bind
("C-x v C-=" . vc-ediff
))
477 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
478 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
479 (ediff-split-window-function 'split-window-horizontally
)))
481 ;; i don't feel like jumping out of my chair every now and again; so
482 ;; don't BEEP! at me, emacs
483 (setq ring-bell-function
'ignore
)
491 ("C-c e b" . eval-buffer
)
492 ("C-c e e" . eval-last-sexp
)
493 ("C-c e r" . eval-region
)
495 ("C-c e i" . emacs-init-time
)
496 ("C-c e u" . emacs-uptime
)
497 ("C-c e v" . emacs-version
)
499 ("C-c F m" . make-frame-command
)
500 ("C-c F d" . delete-frame
)
501 ("C-c F D" . server-edit
)
503 ("C-S-h C" . describe-char
)
504 ("C-S-h F" . describe-face
)
506 ("C-x k" . kill-this-buffer
)
507 ("C-x K" . kill-buffer
)
508 ("C-x s" . save-buffer
)
509 ("C-x S" . save-some-buffers
)
511 :map emacs-lisp-mode-map
512 ("<C-return>" . b
/add-elisp-section
))
514 (when (display-graphic-p)
515 (unbind-key "C-z" global-map
))
518 ;; for back and forward mouse keys
519 ("<mouse-8>" . previous-buffer
)
520 ("<drag-mouse-8>" . previous-buffer
)
521 ("<mouse-9>" . next-buffer
)
522 ("<drag-mouse-9>" . next-buffer
)
523 ("<drag-mouse-2>" . kill-this-buffer
)
524 ("<drag-mouse-3>" . ivy-switch-buffer
))
527 :prefix-map mab
/straight-prefix-map
529 ("u" . straight-use-package
)
530 ("f" . straight-freeze-versions
)
531 ("t" . straight-thaw-versions
)
532 ("P" . straight-prune-build
)
533 ("g" . straight-get-recipe
)
534 ("r" . mab
/reload-init
)
535 ;; M-x ^straight-.*-all$
536 ("a c" . straight-check-all
)
537 ("a f" . straight-fetch-all
)
538 ("a m" . straight-merge-all
)
539 ("a n" . straight-normalize-all
)
540 ("a F" . straight-pull-all
)
541 ("a P" . straight-push-all
)
542 ("a r" . straight-rebuild-all
)
543 ;; M-x ^straight-.*-package$
544 ("p c" . straight-check-package
)
545 ("p f" . straight-fetch-package
)
546 ("p m" . straight-merge-package
)
547 ("p n" . straight-normalize-package
)
548 ("p F" . straight-pull-package
)
549 ("p P" . straight-push-package
)
550 ("p r" . straight-rebuild-package
))
553 ;;; Essential packages
555 ;; use the org-plus-contrib package to get the whole deal
556 (use-package org-plus-contrib
)
561 (setq org-src-tab-acts-natively t
562 org-src-preserve-indentation nil
563 org-edit-src-content-indentation
0
564 org-link-email-description-format
"Email %c: %s" ; %.30s
565 org-highlight-latex-and-related
'(entities)
566 org-use-speed-commands t
567 org-startup-folded
'content
568 org-catch-invisible-edits
'show-and-error
570 (when (version< org-version
"9.3")
571 (setq org-email-link-description-format
572 org-link-email-description-format
))
573 (add-to-list 'org-structure-template-alist
'("L" .
"src emacs-lisp") t
)
574 (add-to-list 'org-modules
'org-habit
)
576 (("C-c a o a" . org-agenda
)
578 ("M-L" . org-insert-last-stored-link
)
579 ("M-O" . org-toggle-link-display
))
580 :hook
((org-mode . org-indent-mode
)
581 (org-mode . auto-fill-mode
)
582 (org-mode . flyspell-mode
))
584 (org-pretty-entities t
)
585 (org-agenda-files '("~/usr/org/todos/personal.org"
586 "~/usr/org/todos/habits.org"
587 "~/src/git/masters-thesis/todo.org"))
588 (org-agenda-start-on-weekday 0)
589 (org-agenda-time-leading-zero t
)
590 (org-habit-graph-column 44)
591 (org-latex-packages-alist '(("" "listings") ("" "color")))
593 '(org-block-begin-line ((t (:foreground
"#5a5b5a" :background
"#1d1f21"))))
594 '(org-block ((t (:background
"#1d1f21"))))
595 '(org-latex-and-related ((t (:foreground
"#b294bb")))))
597 (use-feature ox-latex
600 (setq org-latex-listings
'listings
601 ;; org-latex-prefer-user-labels t
603 (add-to-list 'org-latex-classes
604 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
605 ("\\section{%s}" .
"\\section*{%s}")
606 ("\\subsection{%s}" .
"\\subsection*{%s}")
607 ("\\subsubsection{%s}" .
"\\subsubsection*{%s}")
608 ("\\paragraph{%s}" .
"\\paragraph*{%s}")
609 ("\\subparagraph{%s}" .
"\\subparagraph*{%s}"))
611 (require 'ox-beamer
))
613 (use-feature ox-extra
615 (ox-extras-activate '(latex-header-blocks ignore-headlines
)))
617 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
618 ;; org file. closely inspired by
619 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
620 (with-eval-after-load 'org
621 (defvar b
/show-async-tangle-results nil
622 "Keep *emacs* async buffers around for later inspection.")
624 (defvar b
/show-async-tangle-time nil
625 "Show the time spent tangling the file.")
627 (defun b/async-babel-tangle
()
628 "Tangle org file asynchronously."
630 (let* ((file-tangle-start-time (current-time))
631 (file (buffer-file-name))
632 (file-nodir (file-name-nondirectory file
))
633 ;; (async-quiet-switch "-q")
634 (file-noext (file-name-sans-extension file
)))
638 (org-babel-tangle-file ,file
))
639 (unless b
/show-async-tangle-results
642 (message "Tangled %s%s"
644 (if b
/show-async-tangle-time
646 (float-time (time-subtract (current-time)
647 ',file-tangle-start-time
)))
649 (message "Tangling %s failed" ,file-nodir
))))))))
652 'safe-local-variable-values
653 '(eval add-hook
'after-save-hook
#'b
/async-babel-tangle
'append
'local
))
655 ;; *the* right way to do git
658 :bind
(("C-x g" . magit-status
)
659 ("C-c g g" . magit-status
)
660 ("C-c g b" . magit-blame-addition
)
661 ("C-c g l" . magit-log-buffer-file
))
663 (magit-add-section-hook 'magit-status-sections-hook
664 'magit-insert-modules
665 'magit-insert-stashes
667 ;; (magit-add-section-hook 'magit-status-sections-hook
668 ;; 'magit-insert-ignored-files
669 ;; 'magit-insert-untracked-files
671 (setq magit-repository-directories
'(("~/" .
0)
673 (nconc magit-section-initial-visibility-alist
674 '(([unpulled status
] . show
)
675 ([unpushed status
] . show
)))
676 (setq transient-history-file
(b/var
"transient/history.el")
677 transient-levels-file
(b/etc
"transient/levels.el")
678 transient-values-file
(b/etc
"transient/values.el"))
679 :custom
(magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1
)
680 :custom-face
(magit-diff-file-heading ((t (:weight normal
)))))
682 ;; recently opened files
686 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
688 (recentf-max-saved-items 2000)
689 (recentf-save-file (b/var
"recentf-save.el")))
691 ;; smart M-x enhancement (needed by counsel for history)
694 (setq smex-save-file
(b/var
"smex-save.el")))
700 (:map ivy-minibuffer-map
701 ([escape] . keyboard-escape-quit)
702 ([S-up] . ivy-previous-history-element)
703 ([S-down] . ivy-next-history-element)
704 ("DEL" . ivy-backward-delete-char))
708 ivy-use-virtual-buffers t
709 ivy-virtual-abbreviate 'abbreviate
710 ivy-count-format "%d/%d ")
712 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
713 (defun b/ivy-ignore-buffer-p (str)
714 "Return non-nil if str names a buffer with a major mode
715 derived from one of `b/ivy-ignore-buffer-modes'.
717 This function is intended for use with `ivy-ignore-buffers'."
718 (let* ((buf (get-buffer str))
719 (mode (and buf (buffer-local-value 'major-mode buf))))
721 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
722 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
726 ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
727 ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
728 ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
733 :bind (("C-s" . swiper-isearch)
735 ("C-S-s" . isearch-forward)))
740 :bind (([remap execute-extended-command] . counsel-M-x)
741 ([remap find-file] . counsel-find-file)
742 ("C-c b b" . ivy-switch-buffer)
743 ("C-c f ." . counsel-find-file)
744 ("C-c f l" . counsel-find-library)
745 ("C-c f r" . counsel-recentf)
746 ("C-c x" . counsel-M-x)
747 :map minibuffer-local-map
748 ("C-r" . counsel-minibuffer-history))
751 (defalias 'locate #'counsel-locate))
755 :commands (helm-M-x helm-mini helm-resume)
756 :bind (("M-x" . helm-M-x)
757 ("M-y" . helm-show-kill-ring)
758 ("C-x b" . helm-mini)
759 ("C-x C-b" . helm-buffers-list)
760 ("C-x C-f" . helm-find-files)
761 ("C-h r" . helm-info-emacs)
762 ("C-s-r" . helm-resume)
764 ("<tab>" . helm-execute-persistent-action)
765 ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals
766 ("C-z" . helm-select-action)) ; List actions
767 :config (helm-mode 1)))
772 :bind ("C-c a s e" . eshell)
774 (eval-when-compile (defvar eshell-prompt-regexp))
775 (defun b/eshell-quit-or-delete-char (arg)
777 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
778 (eshell-life-is-too-much)
781 (defun b/eshell-clear ()
783 (let ((inhibit-read-only t))
787 (defun b/eshell-setup ()
788 (make-local-variable 'company-idle-delay)
789 (defvar company-idle-delay)
790 (setq company-idle-delay nil)
791 (bind-keys :map eshell-mode-map
792 ("C-d" . b/eshell-quit-or-delete-char)
793 ("C-S-l" . b/eshell-clear)
794 ("M-r" . counsel-esh-history)
795 ([tab] . company-complete)))
797 :hook (eshell-mode . b/eshell-setup)
799 (eshell-directory-name (b/var "eshell/"))
800 (eshell-hist-ignoredups t)
801 (eshell-input-filter 'eshell-input-filter-initial-space))
805 (("C-x C-b" . ibuffer)
806 :map ibuffer-mode-map
807 ("P" . ibuffer-backward-filter-group)
808 ("N" . ibuffer-forward-filter-group)
809 ("M-p" . ibuffer-do-print)
810 ("M-n" . ibuffer-do-shell-command-pipe-replace))
812 ;; Use human readable Size column instead of original one
813 (define-ibuffer-column size-h
814 (:name "Size" :inline t)
816 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
817 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
818 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
819 (t (format "%8d" (buffer-size)))))
821 (ibuffer-saved-filter-groups
823 ("dired" (mode . dired-mode))
824 ("org" (mode . org-mode))
827 (mode . gnus-group-mode)
828 (mode . gnus-summary-mode)
829 (mode . gnus-article-mode)
830 ;; not really, but...
831 (mode . message-mode)))
849 (mode . emacs-lisp-mode)
851 (mode . haskell-mode)
854 (mode . alloy-mode)))
858 (mode . latex-mode)))
861 (name . "^\\*scratch\\*$")
862 (name . "^\\*Messages\\*$")))
863 ("erc" (mode . erc-mode)))))
865 '((mark modified read-only locked " "
866 (name 18 18 :left :elide)
870 (mode 16 16 :left :elide)
871 " " filename-and-process)
875 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
879 :hook (prog-mode . outline-minor-mode)
880 :delight (outline-minor-mode " outl")
883 outline-minor-mode-map
884 ("<s-tab>" . outline-toggle-children)
885 ("M-p" . outline-previous-visible-heading)
886 ("M-n" . outline-next-visible-heading)
887 :prefix-map b/outline-prefix-map
889 ("TAB" . outline-toggle-children)
890 ("a" . outline-hide-body)
891 ("H" . outline-hide-body)
892 ("S" . outline-show-all)
893 ("h" . outline-hide-subtree)
894 ("s" . outline-show-subtree)))
897 :custom (ls-lisp-dirs-first t))
901 (setq dired-listing-switches "-alh"
902 ls-lisp-use-insert-directory-program nil)
904 ;; easily diff 2 marked files
905 ;; https://oremacs.com/2017/03/18/dired-ediff/
906 (defun dired-ediff-files ()
909 (defvar ediff-after-quit-hook-internal)
910 (let ((files (dired-get-marked-files))
911 (wnd (current-window-configuration)))
912 (if (<= (length files) 2)
913 (let ((file1 (car files))
914 (file2 (if (cdr files)
918 (dired-dwim-target-directory)))))
919 (if (file-newer-than-file-p file1 file2)
920 (ediff-files file2 file1)
921 (ediff-files file1 file2))
922 (add-hook 'ediff-after-quit-hook-internal
924 (setq ediff-after-quit-hook-internal nil)
925 (set-window-configuration wnd))))
926 (error "no more than 2 files should be marked"))))
929 (setq dired-guess-shell-alist-user
930 '(("\\.pdf\\'" "evince" "zathura" "okular")
931 ("\\.doc\\'" "libreoffice")
932 ("\\.docx\\'" "libreoffice")
933 ("\\.ppt\\'" "libreoffice")
934 ("\\.pptx\\'" "libreoffice")
935 ("\\.xls\\'" "libreoffice")
936 ("\\.xlsx\\'" "libreoffice")
937 ("\\.flac\\'" "mpv")))
938 :bind (:map dired-mode-map
939 ("b" . dired-up-directory)
940 ("e" . dired-ediff-files)
941 ("E" . dired-toggle-read-only)
942 ("\\" . dired-hide-details-mode)
945 (b/dired-start-process "zathura"))))
946 :hook (dired-mode . dired-hide-details-mode))
950 (temp-buffer-resize-mode)
951 (setq help-window-select t))
955 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
956 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
957 (add-to-list 'tramp-default-proxies-alist
958 (list (regexp-quote (system-name)) nil nil)))
961 :config (dash-enable-font-lock))
963 (use-feature doc-view
964 :bind (:map doc-view-mode-map
965 ("M-RET" . image-previous-line)))
970 ;; highlight uncommitted changes in the left fringe
974 (setq diff-hl-draw-borders nil)
975 (global-diff-hl-mode)
976 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
978 ;; display Lisp objects at point in the echo area
980 :when (version< "25" emacs-version)
982 :config (global-eldoc-mode))
984 ;; highlight matching parens
987 :config (show-paren-mode))
989 (use-feature elec-pair
991 :config (electric-pair-mode))
994 :delight (auto-fill-function " fill")
995 :config (column-number-mode))
997 ;; save minibuffer history
998 (use-feature savehist
1002 (savehist-file (b/var "savehist.el")))
1004 ;; automatically save place in files
1005 (use-feature saveplace
1006 :when (version< "25" emacs-version)
1007 :config (save-place-mode)
1009 (save-place-file (b/var "save-place.el")))
1011 (use-feature prog-mode
1012 :config (global-prettify-symbols-mode)
1013 (defun indicate-buffer-boundaries-left ()
1014 (setq indicate-buffer-boundaries 'left))
1015 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1017 (use-feature text-mode
1018 :hook (text-mode . indicate-buffer-boundaries-left))
1020 (use-feature conf-mode
1023 (use-feature sh-mode
1026 (use-package company
1030 (:map company-active-map
1031 ([tab] . company-complete-common-or-cycle)
1032 ([escape] . company-abort
))
1034 (company-minimum-prefix-length 1)
1035 (company-selection-wrap-around t
)
1036 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1037 (company-dabbrev-downcase nil
)
1038 (company-dabbrev-ignore-case nil
)
1040 (global-company-mode t
))
1042 (use-package flycheck
1044 :hook
(prog-mode . flycheck-mode
)
1046 (:map flycheck-mode-map
1047 ("M-P" . flycheck-previous-error
)
1048 ("M-N" . flycheck-next-error
))
1050 ;; Use the load-path from running Emacs when checking elisp files
1051 (setq flycheck-emacs-lisp-load-path
'inherit
)
1053 ;; Only flycheck when I actually save the buffer
1054 (setq flycheck-check-syntax-automatically
'(mode-enabled save
))
1055 :custom
(flycheck-mode-line-prefix "flyc"))
1057 (use-feature flyspell
1060 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1064 ;; ’ can be part of a word
1065 (setq ispell-local-dictionary-alist
1066 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1067 "['\x2019]" nil
("-B") nil utf-8
))
1068 ispell-program-name
(executable-find "hunspell"))
1069 ;; don't send ’ to the subprocess
1070 (defun endless/replace-apostrophe
(args)
1071 (cons (replace-regexp-in-string
1074 (advice-add #'ispell-send-string
:filter-args
1075 #'endless
/replace-apostrophe
)
1077 ;; convert ' back to ’ from the subprocess
1078 (defun endless/replace-quote
(args)
1079 (if (not (derived-mode-p 'org-mode
))
1081 (cons (replace-regexp-in-string
1084 (advice-add #'ispell-parse-output
:filter-args
1085 #'endless
/replace-quote
))
1089 :hook
(text-mode . abbrev-mode
)
1091 (abbrev-file-name (b/var
"abbrev.el")))
1094 ;;; Programming modes
1096 (use-feature lisp-mode
1098 (defun indent-spaces-mode ()
1099 (setq indent-tabs-mode nil
))
1100 (add-hook 'lisp-interaction-mode-hook
#'indent-spaces-mode
))
1103 :delight
(reveal-mode " reveal")
1104 :hook
(emacs-lisp-mode . reveal-mode
))
1106 (use-feature elisp-mode
1107 :delight
(emacs-lisp-mode "Elisp" :major
))
1110 (use-package alloy-mode
1111 :straight
(:host github
:repo
"dwwmmn/alloy-mode")
1113 :config
(setq alloy-basic-offset
2))
1115 (eval-when-compile (defvar lean-mode-map
))
1116 (use-package lean-mode
1117 :straight
(:host github
:repo
"leanprover/lean-mode"
1118 :fork
(:repo
"notbandali/lean-mode" :branch
"remove-cl"))
1120 :bind
(:map lean-mode-map
1121 ("S-SPC" . company-complete
))
1123 (require 'lean-input
)
1124 (setq default-input-method
"Lean"
1125 lean-input-tweak-all
'(lean-input-compose
1126 (lean-input-prepend "/")
1127 (lean-input-nonempty))
1128 lean-input-user-translations
'(("/" "/")))
1132 (use-package proof-site
; for Coq
1133 :straight proof-general
)
1135 (use-package haskell-mode
1137 (setq haskell-indentation-layout-offset
4
1138 haskell-indentation-left-offset
4
1139 flycheck-checker
'haskell-hlint
1140 flycheck-disabled-checkers
'(haskell-stack-ghc haskell-ghc
)))
1144 :commands dante-mode
1145 :hook
(haskell-mode . dante-mode
))
1147 (use-package hlint-refactor
1149 :bind
(:map hlint-refactor-mode-map
1150 ("C-c l b" . hlint-refactor-refactor-buffer
)
1151 ("C-c l r" . hlint-refactor-refactor-at-point
))
1152 :hook
(haskell-mode . hlint-refactor-mode
))
1154 (use-package flycheck-haskell
1155 :after haskell-mode
)
1156 ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el
1159 (use-feature sgml-mode
1161 (setq sgml-basic-offset
2))
1163 (use-feature css-mode
1165 (setq css-indent-offset
2))
1167 (use-package web-mode
1171 web-mode-code-indent-offset
1172 web-mode-css-indent-offset
1173 web-mode-markup-indent-offset
))
1175 (use-package emmet-mode
1176 :after
(:any web-mode css-mode sgml-mode
)
1177 :bind
* (("C-)" . emmet-next-edit-point
)
1178 ("C-(" . emmet-prev-edit-point
))
1180 (unbind-key "C-j" emmet-mode-keymap
)
1181 (setq emmet-move-cursor-between-quotes t
)
1182 :hook
(web-mode css-mode html-mode sgml-mode
))
1185 (use-package meghanada
1187 (:map meghanada-mode-map
1188 (("C-M-o" . meghanada-optimize-import
)
1189 ("C-M-t" . meghanada-import-all
)))
1190 :hook
(java-mode . meghanada-mode
)))
1193 (use-package treemacs
1194 :config
(setq treemacs-never-persist t
))
1196 (use-package yasnippet
1198 ;; (yas-global-mode)
1201 (use-package lsp-mode
1202 :init
(setq lsp-eldoc-render-all nil
1203 lsp-highlight-symbol-at-point nil
)
1208 (use-package company-lsp
1211 (setq company-lsp-cache-candidates t
1212 company-lsp-async t
))
1216 (setq lsp-ui-sideline-update-mode
'point
))
1218 (use-package lsp-java
1220 (add-hook 'java-mode-hook
1222 (setq-local company-backends
(list 'company-lsp
))))
1224 (add-hook 'java-mode-hook
'lsp-java-enable
)
1225 (add-hook 'java-mode-hook
'flycheck-mode
)
1226 (add-hook 'java-mode-hook
'company-mode
)
1227 (add-hook 'java-mode-hook
'lsp-ui-mode
))
1229 (use-package dap-mode
1235 (use-package dap-java
1238 (use-package lsp-java-treemacs
1243 :bind
(:map eclim-mode-map
("S-SPC" . company-complete
))
1244 :hook
((java-mode . eclim-mode
)
1245 (eclim-mode .
(lambda ()
1246 (make-local-variable 'company-idle-delay
)
1247 (defvar company-idle-delay
)
1248 ;; (setq company-idle-delay 0.7)
1249 (setq company-idle-delay nil
))))
1251 (eclim-auto-save nil
)
1252 ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp")
1253 (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim")
1254 (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse"))))
1258 (make-directory (b/var
"geiser/") t
)
1259 (setq geiser-repl-history-filename
(b/var
"geiser/repl-history")))
1261 (use-feature geiser-guile
1263 (setq geiser-guile-load-path
"~/src/git/guix"))
1270 (font-latex-fontify-sectioning 'color
)))
1272 (use-package go-mode
)
1274 (use-package po-mode
1276 (po-mode .
(lambda () (run-with-timer 0.1 nil
'View-exit
))))
1278 (use-feature tex-mode
1281 (lambda (p) (string-match "^---?" (car p
)))
1282 tex--prettify-symbols-alist
)
1283 :hook
((tex-mode . auto-fill-mode
)
1284 (tex-mode . flyspell-mode
)
1285 (tex-mode .
(lambda () (electric-indent-local-mode -
1)))))
1290 (add-to-list 'custom-theme-load-path
1292 (convert-standard-filename "lisp") user-emacs-directory
))
1293 (load-theme 'tangomod t
)
1295 (use-package smart-mode-line
1296 :commands
(sml/apply-theme
)
1300 (smart-mode-line-enable))
1302 (use-package doom-themes
)
1304 (defvar b
/org-mode-font-lock-keywords
1305 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1306 (1 '(:foreground
"#5a5b5a" :background
"#292b2b") t
) ; directive
1307 (3 '(:foreground
"#81a2be" :background
"#292b2b") t
) ; kind
1308 (4 '(:foreground
"#c5c8c6") t
)))) ; title
1310 (defun b/lights-on
()
1311 "Enable my favourite light theme."
1313 (mapc #'disable-theme custom-enabled-themes
)
1314 (load-theme 'tangomod t
)
1315 (sml/apply-theme
'automatic
)
1316 (font-lock-remove-keywords
1317 'org-mode b
/org-mode-font-lock-keywords
))
1319 (defun b/lights-off
()
1322 (mapc #'disable-theme custom-enabled-themes
)
1323 ;; (load-theme 'doom-tomorrow-night t)
1324 (sml/apply-theme
'automatic
)
1325 (font-lock-add-keywords
1326 'org-mode b
/org-mode-font-lock-keywords t
))
1329 ("C-c t d" . b
/lights-off
)
1330 ("C-c t l" . b
/lights-on
))
1333 ;;; Emacs enhancements & auxiliary packages
1336 :config
(setq Man-width
80))
1338 (use-package which-key
1342 (which-key-add-key-based-replacements
1343 ;; prefixes for global prefixes and minor modes
1347 "C-c 8 -" "typo/dashes"
1348 "C-c 8 <" "typo/left-brackets"
1349 "C-c 8 >" "typo/right-brackets"
1351 "C-x a" "abbrev/expand"
1352 "C-x r" "rectangle/register/bookmark"
1353 "C-x v" "version control"
1354 ;; prefixes for my personal bindings
1355 "C-c a" "applications"
1360 "C-c c" "compile-and-comments"
1366 "C-c m" "multiple-cursors"
1367 "C-c P" "projectile"
1368 "C-c P s" "projectile/search"
1369 "C-c P x" "projectile/execute"
1370 "C-c P 4" "projectile/other-window"
1376 ;; prefixes for major modes
1377 (which-key-add-major-mode-key-based-replacements 'message-mode
1379 (which-key-add-major-mode-key-based-replacements 'org-mode
1380 "C-c C-v" "org-babel")
1381 (which-key-add-major-mode-key-based-replacements 'web-mode
1382 "C-c C-a" "web/attributes"
1383 "C-c C-b" "web/blocks"
1385 "C-c C-e" "web/element"
1386 "C-c C-t" "web/tags")
1390 (which-key-add-column-padding 5)
1391 (which-key-max-description-length 32))
1393 (use-package crux
; results in Waiting for git... [2 times]
1395 :bind
(("C-c d" . crux-duplicate-current-line-or-region
)
1396 ("C-c D" . crux-duplicate-and-comment-current-line-or-region
)
1397 ("C-c f c" . crux-copy-file-preserve-attributes
)
1398 ("C-c f d" . crux-delete-file-and-buffer
)
1399 ("C-c f r" . crux-rename-file-and-buffer
)
1400 ("C-c j" . crux-top-join-line
)
1401 ("C-S-j" . crux-top-join-line
)))
1404 :bind
(("C-a" . mwim-beginning-of-code-or-line
)
1405 ("C-e" . mwim-end-of-code-or-line
)
1406 ("<home>" . mwim-beginning-of-line-or-code
)
1407 ("<end>" . mwim-end-of-line-or-code
)))
1409 (use-package projectile
1411 :bind-keymap
("C-c P" . projectile-command-map
)
1413 (make-directory (b/var
"projectile/") t
)
1416 (defun b/projectile-mode-line-fun
()
1417 "Report project name and type in the modeline."
1418 (let ((project-name (projectile-project-name))
1419 (project-type (projectile-project-type)))
1421 projectile-mode-line-prefix
1423 (format ":%s" project-type
)
1425 (setq projectile-mode-line-function
'b
/projectile-mode-line-fun
)
1427 (defun my-projectile-invalidate-cache (&rest _args
)
1428 ;; ignore the args to `magit-checkout'
1429 (projectile-invalidate-cache nil
))
1431 (eval-after-load 'magit-branch
1433 (advice-add 'magit-checkout
1434 :after
#'my-projectile-invalidate-cache
)
1435 (advice-add 'magit-branch-and-checkout
1436 :after
#'my-projectile-invalidate-cache
)))
1438 (projectile-cache-file (b/var
"projectile/cache.el"))
1439 (projectile-completion-system 'ivy
)
1440 (projectile-known-projects-file (b/var
"projectile/known-projects.el"))
1441 (projectile-mode-line-prefix " proj"))
1443 (use-package helpful
1446 (("C-S-h c" . helpful-command
)
1447 ("C-S-h f" . helpful-callable
) ; helpful-function
1448 ("C-S-h v" . helpful-variable
)
1449 ("C-S-h k" . helpful-key
)
1450 ("C-S-h p" . helpful-at-point
)))
1452 (use-package unkillable-scratch
1455 (unkillable-scratch 1)
1457 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1460 ;; | make pretty boxed quotes like this
1462 (use-package boxquote
1465 (:prefix-map b
/boxquote-prefix-map
1467 ("b" . boxquote-buffer
)
1468 ("B" . boxquote-insert-buffer
)
1469 ("d" . boxquote-defun
)
1470 ("F" . boxquote-insert-file
)
1471 ("hf" . boxquote-describe-function
)
1472 ("hk" . boxquote-describe-key
)
1473 ("hv" . boxquote-describe-variable
)
1474 ("hw" . boxquote-where-is
)
1475 ("k" . boxquote-kill
)
1476 ("p" . boxquote-paragraph
)
1477 ("q" . boxquote-boxquote
)
1478 ("r" . boxquote-region
)
1479 ("s" . boxquote-shell-command
)
1480 ("t" . boxquote-text
)
1481 ("T" . boxquote-title
)
1482 ("u" . boxquote-unbox
)
1483 ("U" . boxquote-unbox-region
)
1484 ("y" . boxquote-yank
)
1485 ("M-q" . boxquote-fill-paragraph
)
1486 ("M-w" . boxquote-kill-ring-save
)))
1488 (use-package orgalist
1489 ;; http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00007.html
1492 :hook
(message-mode . orgalist-mode
))
1494 ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
1499 (typo-global-mode 1)
1500 :hook
(((text-mode erc-mode
) . typo-mode
)
1501 (tex-mode .
(lambda ()(typo-mode -
1)))))
1503 ;; highlight TODOs in buffers
1504 (use-package hl-todo
1507 (global-hl-todo-mode))
1509 (use-package shrink-path
1513 (defvar user-
@-host
(concat (user-login-name) "@" (system-name) " "))
1514 (defun +eshell
/prompt
()
1515 (let ((base/dir
(shrink-path-prompt default-directory
)))
1516 (concat (propertize user-
@-host
'face
'default
)
1517 (propertize (car base
/dir
)
1518 'face
'font-lock-comment-face
)
1519 (propertize (cdr base
/dir
)
1520 'face
'font-lock-constant-face
)
1521 (propertize "> " 'face
'default
))))
1522 (setq eshell-prompt-regexp
(concat user-
@-host
".*> ")
1523 eshell-prompt-function
#'+eshell
/prompt
))
1525 (use-package eshell-up
1527 :commands eshell-up
)
1529 (use-package multi-term
1531 :bind
(("C-c a s m m" . multi-term
)
1532 ("C-c a s m d" . multi-term-dedicated-toggle
)
1533 ("C-c a s m p" . multi-term-prev
)
1534 ("C-c a s m n" . multi-term-next
)
1536 ("C-c C-j" . term-char-mode
))
1538 (setq multi-term-program
"screen"
1539 multi-term-program-switches
(concat "-c"
1540 (getenv "XDG_CONFIG_HOME")
1542 ;; TODO: add separate bindings for connecting to existing
1543 ;; session vs. always creating a new one
1544 multi-term-dedicated-select-after-open-p t
1545 multi-term-dedicated-window-height
20
1546 multi-term-dedicated-max-window-height
30
1548 '(("C-c C-c" . term-interrupt-subjob
)
1549 ("C-c C-e" . term-send-esc
)
1550 ("C-c C-j" . term-line-mode
)
1552 ;; ("C-y" . term-paste)
1553 ("C-y" . term-send-raw
)
1554 ("M-f" . term-send-forward-word
)
1555 ("M-b" . term-send-backward-word
)
1556 ("M-p" . term-send-up
)
1557 ("M-n" . term-send-down
)
1558 ("M-j" . term-send-raw-meta
)
1559 ("M-y" . term-send-raw-meta
)
1560 ("M-/" . term-send-raw-meta
)
1561 ("M-0" . term-send-raw-meta
)
1562 ("M-1" . term-send-raw-meta
)
1563 ("M-2" . term-send-raw-meta
)
1564 ("M-3" . term-send-raw-meta
)
1565 ("M-4" . term-send-raw-meta
)
1566 ("M-5" . term-send-raw-meta
)
1567 ("M-6" . term-send-raw-meta
)
1568 ("M-7" . term-send-raw-meta
)
1569 ("M-8" . term-send-raw-meta
)
1570 ("M-9" . term-send-raw-meta
)
1571 ("<C-backspace>" . term-send-backward-kill-word
)
1572 ("<M-DEL>" . term-send-backward-kill-word
)
1573 ("M-d" . term-send-delete-word
)
1574 ("M-," . term-send-raw
)
1575 ("M-." . comint-dynamic-complete
))
1576 term-unbind-key-alist
1577 '("C-z" "C-x" "C-c" "C-h"
1581 (use-package page-break-lines
1585 (page-break-lines-max-width fill-column
)
1587 (global-page-break-lines-mode))
1589 (use-package expand-region
1590 :bind
("C-=" . er
/expand-region
))
1592 (use-package multiple-cursors
1594 (("C-S-<mouse-1>" . mc
/add-cursor-on-click
)
1595 (:prefix-map b
/mc-prefix-map
1597 ("c" . mc
/edit-lines
)
1598 ("n" . mc
/mark-next-like-this
)
1599 ("p" . mc
/mark-previous-like-this
)
1600 ("a" . mc
/mark-all-like-this
)))
1602 (setq mc
/list-file
(b/var
"mc-list.el")))
1610 (use-package yasnippet
1613 (defconst yas-verbosity-cur yas-verbosity
)
1614 (setq yas-verbosity
2)
1615 (setq yas-snippet-dirs
(list (b/etc
"yasnippet/snippets/")))
1616 (add-to-list 'yas-snippet-dirs
"~/src/git/guix/etc/snippets" t
)
1618 (setq yas-verbosity yas-verbosity-cur
)
1620 (defun b/yas--maybe-expand-key-filter
(cmd)
1621 (when (and (yas--maybe-expand-key-filter cmd
)
1622 (not (bound-and-true-p git-commit-mode
)))
1624 (defconst b
/yas-maybe-expand
1625 '(menu-item "" yas-expand
:filter b
/yas--maybe-expand-key-filter
))
1626 (define-key yas-minor-mode-map
1627 (kbd "SPC") b
/yas-maybe-expand
)
1631 (use-package debbugs
1634 :repo
"emacs-straight/debbugs"
1635 :files
(:defaults
"Debbugs.wsdl")))
1637 (use-package org-ref
1639 (b/setq-every
'("~/usr/org/references.bib")
1640 reftex-default-bibliography
1641 org-ref-default-bibliography
)
1643 org-ref-bibliography-notes
"~/usr/org/notes.org"
1644 org-ref-pdf-directory
"~/usr/org/bibtex-pdfs/"))
1648 :init
(setq alert-default-style
'notifications
))
1650 ;; (use-package fill-column-indicator)
1652 (use-package emojify
1654 (make-directory (b/var
"emojify/") t
)
1655 (setq emojify-emojis-dir
(b/var
"emojify/"))
1656 :hook
(erc-mode . emojify-mode
))
1660 (("C-c w <right>" . split-window-right
)
1661 ("C-c w <down>" . split-window-below
)
1662 ("C-c w s l" . split-window-right
)
1663 ("C-c w s j" . split-window-below
)
1664 ("C-c w q" . quit-window
))
1666 (split-width-threshold 150))
1668 (use-feature windmove
1671 (("C-c w h" . windmove-left
)
1672 ("C-c w j" . windmove-down
)
1673 ("C-c w k" . windmove-up
)
1674 ("C-c w l" . windmove-right
)
1675 ("C-c w H" . windmove-swap-states-left
)
1676 ("C-c w J" . windmove-swap-states-down
)
1677 ("C-c w K" . windmove-swap-states-up
)
1678 ("C-c w L" . windmove-swap-states-right
)))
1682 :bind
("C-c a p" . pass
)
1683 :hook
(pass-mode . View-exit
))
1685 (use-package pdf-tools
1687 :bind
(:map pdf-view-mode-map
1688 ("<XF86Back>" . pdf-history-backward
)
1689 ("<XF86Forward>" . pdf-history-forward
)
1690 ("M-RET" . image-previous-line
))
1691 :config
(pdf-tools-install nil t
)
1692 :custom
(pdf-view-resize-factor 1.05))
1694 (use-package biblio
)
1697 :hook
(latex-mode . reftex-mode
))
1699 (use-feature reftex-cite
1701 :disabled
; enable to disable
1702 ; reftex-cite's default choice
1705 (defun reftex-get-bibkey-default ()
1706 "If the cursor is in a citation macro, return the word before the macro."
1707 (let* ((macro (reftex-what-macro 1)))
1709 (when (and macro
(string-match "cite" (car macro
)))
1710 (goto-char (cdr macro
)))
1711 (reftex-this-word)))))
1714 ;;; Email (with Gnus)
1716 (defvar b
/maildir
(expand-file-name "~/mail/"))
1717 (with-eval-after-load 'recentf
1718 (add-to-list 'recentf-exclude b
/maildir
))
1721 b
/gnus-init-file
(b/etc
"gnus")
1722 mail-user-agent
'gnus-user-agent
1723 read-mail-command
'gnus
)
1726 :bind
(("s-m" . gnus
)
1727 ("s-M" . gnus-unplugged
)
1729 ("C-c a M" . gnus-unplugged
))
1732 gnus-select-method
'(nnnil "")
1733 gnus-secondary-select-methods
1734 '((nnimap "shemshak"
1735 (nnimap-stream plain
)
1736 (nnimap-address "127.0.0.1")
1737 (nnimap-server-port 143)
1738 (nnimap-authenticator plain
)
1739 (nnimap-user "amin@shemshak.local"))
1741 (nnimap-stream plain
)
1742 (nnimap-address "127.0.0.1")
1743 (nnimap-server-port 143)
1744 (nnimap-authenticator plain
)
1745 (nnimap-user "bandali@gnu.local")
1746 (nnimap-inbox "INBOX")
1747 (nnimap-split-methods 'nnimap-split-fancy
)
1748 (nnimap-split-fancy (|
1749 ;; (: gnus-registry-split-fancy-with-parent)
1750 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1752 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1753 ;; *@lists.sr.ht, omitting one dot if present
1754 ;; add more \\.?\\([^.@]*\\) if needed
1755 (list ".*<~\\(.*\\)/\\([^.@]*\\)\\.?\\([^.@]*\\)@lists.sr.ht>.*" "l.~\\1.\\2\\3")
1757 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1759 (list ".*atreus.freelists.org" "l.atreus")
1760 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1761 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1762 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1763 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1764 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1765 ;; ----------------------------------
1766 ;; legend: (u)nsubscribed | (d)ead
1767 ;; ----------------------------------
1768 ;; otherwise, leave mail in INBOX
1771 (nnimap-stream plain
)
1772 (nnimap-address "127.0.0.1")
1773 (nnimap-server-port 143)
1774 (nnimap-authenticator plain
)
1775 (nnimap-user "abandali@uw.local")
1776 (nnimap-inbox "INBOX")
1777 (nnimap-split-methods 'nnimap-split-fancy
)
1778 (nnimap-split-fancy (|
1779 ;; (: gnus-registry-split-fancy-with-parent)
1781 ("subject" "SE\\s-?212" "course.se212-f19")
1782 (from "SE\\s-?212" "course.se212-f19")
1786 (nnimap-stream plain
)
1787 (nnimap-address "127.0.0.1")
1788 (nnimap-server-port 143)
1789 (nnimap-authenticator plain
)
1790 (nnimap-user "abandali@csc.uw.local")))
1791 gnus-message-archive-group
"nnimap+shemshak:Sent"
1794 (to-address .
"atreus@freelists.org")
1795 (to-list .
"atreus@freelists.org"))
1797 (to-address .
"deepspec@lists.cs.princeton.edu")
1798 (to-list .
"deepspec@lists.cs.princeton.edu")
1799 (list-identifier .
"\\[deepspec\\]"))
1801 (to-address .
"emacs-devel@gnu.org")
1802 (to-list .
"emacs-devel@gnu.org"))
1803 ("l\\.help-gnu-emacs"
1804 (to-address .
"help-gnu-emacs@gnu.org")
1805 (to-list .
"help-gnu-emacs@gnu.org"))
1806 ("l\\.info-gnu-emacs"
1807 (to-address .
"info-gnu-emacs@gnu.org")
1808 (to-list .
"info-gnu-emacs@gnu.org"))
1809 ("l\\.emacs-orgmode"
1810 (to-address .
"emacs-orgmode@gnu.org")
1811 (to-list .
"emacs-orgmode@gnu.org")
1812 (list-identifier .
"\\[O\\]"))
1813 ("l\\.emacs-tangents"
1814 (to-address .
"emacs-tangents@gnu.org")
1815 (to-list .
"emacs-tangents@gnu.org"))
1816 ("l\\.emacsconf-discuss"
1817 (to-address .
"emacsconf-discuss@gnu.org")
1818 (to-list .
"emacsconf-discuss@gnu.org"))
1819 ("l\\.emacsconf-register"
1820 (to-address .
"emacsconf-register@gnu.org")
1821 (to-list .
"emacsconf-register@gnu.org"))
1822 ("l\\.emacsconf-submit"
1823 (to-address .
"emacsconf-submit@gnu.org")
1824 (to-list .
"emacsconf-submit@gnu.org"))
1825 ("l\\.fencepost-users"
1826 (to-address .
"fencepost-users@gnu.org")
1827 (to-list .
"fencepost-users@gnu.org")
1828 (list-identifier .
"\\[Fencepost-users\\]"))
1829 ("l\\.gnewsense-art"
1830 (to-address .
"gnewsense-art@nongnu.org")
1831 (to-list .
"gnewsense-art@nongnu.org")
1832 (list-identifier .
"\\[gNewSense-art\\]"))
1833 ("l\\.gnewsense-dev"
1834 (to-address .
"gnewsense-dev@nongnu.org")
1835 (to-list .
"gnewsense-dev@nongnu.org")
1836 (list-identifier .
"\\[Gnewsense-dev\\]"))
1837 ("l\\.gnewsense-users"
1838 (to-address .
"gnewsense-users@nongnu.org")
1839 (to-list .
"gnewsense-users@nongnu.org")
1840 (list-identifier .
"\\[gNewSense-users\\]"))
1841 ("l\\.gnunet-developers"
1842 (to-address .
"gnunet-developers@gnu.org")
1843 (to-list .
"gnunet-developers@gnu.org")
1844 (list-identifier .
"\\[GNUnet-developers\\]"))
1846 (to-address .
"help-gnunet@gnu.org")
1847 (to-list .
"help-gnunet@gnu.org")
1848 (list-identifier .
"\\[Help-gnunet\\]"))
1850 (to-address .
"bug-gnuzilla@gnu.org")
1851 (to-list .
"bug-gnuzilla@gnu.org")
1852 (list-identifier .
"\\[Bug-gnuzilla\\]"))
1854 (to-address .
"gnuzilla-dev@gnu.org")
1855 (to-list .
"gnuzilla-dev@gnu.org")
1856 (list-identifier .
"\\[Gnuzilla-dev\\]"))
1858 (to-address .
"guile-devel@gnu.org")
1859 (to-list .
"guile-devel@gnu.org"))
1861 (to-address .
"guile-user@gnu.org")
1862 (to-list .
"guile-user@gnu.org"))
1864 (to-address .
"guix-devel@gnu.org")
1865 (to-list .
"guix-devel@gnu.org"))
1867 (to-address .
"help-guix@gnu.org")
1868 (to-list .
"help-guix@gnu.org"))
1870 (to-address .
"info-guix@gnu.org")
1871 (to-list .
"info-guix@gnu.org"))
1872 ("l\\.savannah-hackers-public"
1873 (to-address .
"savannah-hackers-public@gnu.org")
1874 (to-list .
"savannah-hackers-public@gnu.org"))
1875 ("l\\.savannah-users"
1876 (to-address .
"savannah-users@gnu.org")
1877 (to-list .
"savannah-users@gnu.org"))
1879 (to-address .
"www-commits@gnu.org")
1880 (to-list .
"www-commits@gnu.org"))
1882 (to-address .
"www-discuss@gnu.org")
1883 (to-list .
"www-discuss@gnu.org"))
1885 (to-address .
"haskell-art@we.lurk.org")
1886 (to-list .
"haskell-art@we.lurk.org")
1887 (list-identifier .
"\\[haskell-art\\]"))
1889 (to-address .
"haskell-cafe@haskell.org")
1890 (to-list .
"haskell-cafe@haskell.org")
1891 (list-identifier .
"\\[Haskell-cafe\\]"))
1893 (to-address .
"notmuch@notmuchmail.org")
1894 (to-list .
"notmuch@notmuchmail.org"))
1896 (to-address .
"dev@lists.parabola.nu")
1897 (to-list .
"dev@lists.parabola.nu")
1898 (list-identifier .
"\\[Dev\\]"))
1899 ("l\\.~bandali\\.public-inbox"
1900 (to-address .
"~bandali/public-inbox@lists.sr.ht")
1901 (to-list .
"~bandali/public-inbox@lists.sr.ht"))
1902 ("l\\.~sircmpwn\\.free-writers-club"
1903 (to-address .
"~sircmpwn/free-writers-club@lists.sr.ht")
1904 (to-list .
"~sircmpwn/free-writers-club@lists.sr.ht"))
1905 ("l\\.~sircmpwn\\.srht-admins"
1906 (to-address .
"~sircmpwn/sr.ht-admins@lists.sr.ht")
1907 (to-list .
"~sircmpwn/sr.ht-admins@lists.sr.ht"))
1908 ("l\\.~sircmpwn\\.srht-announce"
1909 (to-address .
"~sircmpwn/sr.ht-announce@lists.sr.ht")
1910 (to-list .
"~sircmpwn/sr.ht-announce@lists.sr.ht"))
1911 ("l\\.~sircmpwn\\.srht-dev"
1912 (to-address .
"~sircmpwn/sr.ht-dev@lists.sr.ht")
1913 (to-list .
"~sircmpwn/sr.ht-dev@lists.sr.ht"))
1914 ("l\\.~sircmpwn\\.srht-discuss"
1915 (to-address .
"~sircmpwn/sr.ht-discuss@lists.sr.ht")
1916 (to-list .
"~sircmpwn/sr.ht-discuss@lists.sr.ht"))
1918 (to-address .
"webmasters@gnu.org")
1919 (to-list .
"webmasters@gnu.org"))
1926 gnus-large-newsgroup
50
1927 gnus-home-directory
(b/var
"gnus/")
1928 gnus-directory
(concat gnus-home-directory
"news/")
1929 message-directory
(concat gnus-home-directory
"mail/")
1930 nndraft-directory
(concat gnus-home-directory
"drafts/")
1931 gnus-save-newsrc-file nil
1932 gnus-read-newsrc-file nil
1933 gnus-interactive-exit nil
1934 gnus-gcc-mark-as-read t
)
1938 (require 'ebdb-gnus
)
1940 (when (version< emacs-version
"27")
1942 'nnmail-split-abbrev-alist
1943 '(list .
"list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
1946 ;; (gnus-registry-initialize)
1948 (with-eval-after-load 'recentf
1949 (add-to-list 'recentf-exclude gnus-home-directory
)))
1951 (use-feature gnus-art
1954 gnus-buttonized-mime-types
'("multipart/\\(signed\\|encrypted\\)")
1955 gnus-visible-headers
1956 (concat gnus-visible-headers
"\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
1957 gnus-sorted-header-list
1958 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
1959 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
1960 "^Newsgroups:" "List-Id:" "^Organization:"
1961 "^User-Agent:" "^Date:")
1962 ;; local-lapsed article dates
1963 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1964 gnus-article-date-headers
'(user-defined)
1965 gnus-article-time-format
1967 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time
))
1968 (local (article-make-date-line date
'local
))
1969 (combined-lapsed (article-make-date-line date
1972 (string-match " (.+" combined-lapsed
)
1973 (match-string 0 combined-lapsed
))))
1974 (concat local lapsed
))))
1976 :map gnus-article-mode-map
1977 ("M-L" . org-store-link
)))
1979 (use-feature gnus-sum
1980 :bind
(:map gnus-summary-mode-map
1981 :prefix-map b
/gnus-summary-prefix-map
1983 ("r" . gnus-summary-reply
)
1984 ("w" . gnus-summary-wide-reply
)
1985 ("v" . gnus-summary-show-raw-article
))
1988 :map gnus-summary-mode-map
1989 ("M-L" . org-store-link
))
1990 :hook
(gnus-summary-mode . b
/no-mouse-autoselect-window
))
1992 (use-feature gnus-msg
1994 (defvar b
/signature
"Amin Bandali
1995 Free Software Activist | GNU Webmaster & Volunteer
1996 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
1997 https://shemshak.org/~amin")
1998 (defvar b
/gnu-signature
"Amin Bandali
1999 Free Software Activist | GNU Webmaster & Volunteer
2000 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
2001 https://bandali.eu.org")
2002 (defvar b
/uw-signature
"Amin Bandali, MMath Student
2003 Cheriton School of Computer Science
2004 University of Waterloo
2005 https://bandali.eu.org")
2006 (defvar b
/csc-signature
"Amin Bandali
2008 Computer Science Club, University of Waterloo
2009 https://csclub.uwaterloo.ca/~abandali")
2010 (setq gnus-posting-styles
2012 (address "amin@shemshak.org")
2014 (signature b
/signature
)
2015 (eval (setq b
/message-cite-say-hi t
)))
2017 (address "bandali@gnu.org")
2018 (signature b
/gnu-signature
)
2019 (eval (set (make-local-variable 'message-user-fqdn
) "fencepost.gnu.org")))
2020 ((header "subject" "ThankCRM")
2021 (to "webmasters-comment@gnu.org")
2023 (eval (setq b
/message-cite-say-hi nil
)))
2025 (address "abandali@uwaterloo.ca")
2026 (signature b
/uw-signature
))
2027 ("nnimap\\+uw:INBOX"
2028 (gcc "\"nnimap+uw:Sent Items\""))
2030 (address "abandali@csclub.uwaterloo.ca")
2031 (signature b
/csc-signature
)
2032 (gcc "nnimap+csc:Sent")))))
2034 (use-feature gnus-topic
2035 :hook
(gnus-group-mode . gnus-topic-mode
)
2036 :config
(setq gnus-topic-line-format
"%i[ %A: %(%{%n%}%) ]%v\n"))
2038 (use-feature gnus-agent
2040 (setq gnus-agent-synchronize-flags
'ask
)
2041 :hook
(gnus-group-mode . gnus-agent-mode
))
2043 (use-feature gnus-group
2045 (setq gnus-permanently-visible-groups
"\\(:INBOX$\\|:gnu$\\)"))
2048 ;; problematic with ebdb's popup, *EBDB-Gnus*
2049 (use-feature gnus-win
2051 (setq gnus-use-full-window nil
)))
2053 (use-feature gnus-dired
2054 :commands gnus-dired-mode
2056 (add-hook 'dired-mode-hook
'gnus-dired-mode
))
2058 (use-feature mm-decode
2060 (setq mm-discouraged-alternatives
'("text/html" "text/richtext")
2061 mm-decrypt-option
'known
2062 mm-verify-option
'known
))
2064 (use-feature sendmail
2066 (setq sendmail-program
(executable-find "msmtp")
2067 ;; message-sendmail-extra-arguments '("-v" "-d")
2068 mail-specify-envelope-from t
2069 mail-envelope-from
'header
))
2071 (use-feature message
2073 ;; redefine for a simplified In-Reply-To header
2074 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2075 (defun message-make-in-reply-to ()
2076 "Return the In-Reply-To header for this message."
2077 (when message-reply-headers
2078 (let ((from (mail-header-from message-reply-headers
))
2079 (msg-id (mail-header-id message-reply-headers
)))
2083 (defconst b
/message-cite-style-format
"On %Y-%m-%d %l:%M %p, %N wrote:")
2084 (defconst message-cite-style-bandali
2085 '((message-cite-function 'message-cite-original
)
2086 (message-citation-line-function 'message-insert-formatted-citation-line
)
2087 (message-cite-reply-position 'traditional
)
2088 (message-yank-prefix "> ")
2089 (message-yank-cited-prefix ">")
2090 (message-yank-empty-prefix ">")
2091 (message-citation-line-format
2092 (if b
/message-cite-say-hi
2093 (concat "Hi %F,\n\n" b
/message-cite-style-format
)
2094 b
/message-cite-style-format
)))
2095 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2096 (setq ;; message-cite-style 'message-cite-style-bandali
2097 message-kill-buffer-on-exit t
2098 message-send-mail-function
'message-send-mail-with-sendmail
2099 message-sendmail-envelope-from
'header
2100 message-subscribed-address-functions
2101 '(gnus-find-subscribed-addresses)
2102 message-dont-reply-to-names
2103 "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(amin@bndl\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)")
2104 (require 'company-ebdb
)
2105 :hook
(;; (message-setup . mml-secure-message-sign-pgpmime)
2106 (message-mode . flyspell-mode
)
2107 (message-mode .
(lambda ()
2108 ;; (setq fill-column 65
2109 ;; message-fill-column 65)
2110 (make-local-variable 'company-idle-delay
)
2111 (setq company-idle-delay
0.2))))
2113 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2114 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2115 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2121 (use-feature mml-sec
2123 (mml-secure-openpgp-encrypt-to-self t
)
2124 (mml-secure-openpgp-sign-with-sender t
))
2126 (use-feature footnote
2129 ;; (setq footnote-start-tag ""
2130 ;; footnote-end-tag ""
2131 ;; footnote-style 'unicode)
2133 (:map message-mode-map
2134 :prefix-map b
/footnote-prefix-map
2136 ("a" . footnote-add-footnote
)
2137 ("b" . footnote-back-to-message
)
2138 ("c" . footnote-cycle-style
)
2139 ("d" . footnote-delete-footnote
)
2140 ("g" . footnote-goto-footnote
)
2141 ("r" . footnote-renumber-footnotes
)
2142 ("s" . footnote-set-style
)))
2146 :bind
(:map gnus-group-mode-map
("e" . ebdb
))
2148 (setq ebdb-sources
(b/var
"ebdb"))
2149 (with-eval-after-load 'swiper
2150 (add-to-list 'swiper-font-lock-exclude
'ebdb-mode t
)))
2152 (use-feature ebdb-com
2155 ;; (use-package ebdb-complete
2158 ;; (ebdb-complete-enable))
2160 (use-package company-ebdb
2162 (defun company-ebdb--post-complete (_) nil
))
2164 (use-feature ebdb-gnus
2167 (ebdb-gnus-window-configuration
2170 (summary 0.25 point
)
2173 (ebdb-gnus 0.3))))))
2175 (use-feature ebdb-mua
2177 ;; :custom (ebdb-mua-pop-up nil)
2180 ;; (use-package ebdb-message
2183 ;; (use-package ebdb-vcard
2186 (use-package message-x
)
2189 (use-package message-x
2191 (message-x-completion-alist
2193 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address
)
2196 (quote message-newgroups-header-regexp
))
2197 message-newgroups-header-regexp message-newsgroups-header-regexp
)
2198 . message-expand-group
))))))
2201 (use-package gnus-harvest
2202 :commands gnus-harvest-install
2205 (if (featurep 'message-x
)
2206 (gnus-harvest-install 'message-x
)
2207 (gnus-harvest-install))))
2210 ;;; IRC (with ERC and ZNC)
2213 :bind
(("C-c b e" . erc-switch-to-buffer
)
2215 ("M-a" . erc-track-switch-buffer
))
2217 (erc-join-buffer 'bury
)
2218 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2219 (erc-nick "bandali")
2221 (erc-rename-buffers t
)
2222 (erc-server-reconnect-attempts 5)
2223 (erc-server-reconnect-timeout 3)
2225 (defun erc-cmd-OPME ()
2226 "Request chanserv to op me."
2227 (erc-message "PRIVMSG"
2228 (format "chanserv op %s %s"
2229 (erc-default-target)
2230 (erc-current-nick)) nil
))
2231 (defun erc-cmd-DEOPME ()
2232 "Deop myself from current channel."
2233 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2234 (add-to-list 'erc-modules
'keep-place
)
2235 (add-to-list 'erc-modules
'notifications
)
2236 (add-to-list 'erc-modules
'spelling
)
2237 (add-to-list 'erc-modules
'scrolltoplace
)
2238 (erc-update-modules)
2240 (when (and (version<= "24.4" emacs-version
)
2241 (version< emacs-version
"27"))
2242 ;; fix erc-lurker bug
2243 ;; patch submitted: https://bugs.gnu.org/36843#10
2244 ;; TODO: remove when patch is merged and emacs 27 is released
2245 (defvar erc-message-parsed
)
2246 (defun erc-display-message (parsed type buffer msg
&rest args
)
2247 "Display MSG in BUFFER.
2249 ARGS, PARSED, and TYPE are used to format MSG sensibly.
2251 See also `erc-format-message' and `erc-display-line'."
2252 (let ((string (if (symbolp msg
)
2253 (apply #'erc-format-message msg args
)
2255 (erc-message-parsed parsed
))
2261 (mapc (lambda (type)
2263 (erc-display-message-highlight type string
)))
2267 (erc-display-message-highlight type string
))))
2269 (if (not (erc-response-p parsed
))
2270 (erc-display-line string buffer
)
2271 (unless (erc-hide-current-message-p parsed
)
2272 (erc-put-text-property 0 (length string
) 'erc-parsed parsed string
)
2273 (erc-put-text-property 0 (length string
) 'rear-sticky t string
)
2274 (when (erc-response.tags parsed
)
2275 (erc-put-text-property 0 (length string
) 'tags
(erc-response.tags parsed
)
2277 (erc-display-line string buffer
)))))
2279 (defun erc-lurker-update-status (_message)
2280 "Update `erc-lurker-state' if necessary.
2282 This function is called from `erc-insert-pre-hook'. If the
2283 current message is a PRIVMSG, update `erc-lurker-state' to
2284 reflect the fact that its sender has issued a PRIVMSG at the
2285 current time. Otherwise, take no action.
2287 This function depends on the fact that `erc-display-message'
2288 lexically binds `erc-message-parsed', which is used to check if
2289 the current message is a PRIVMSG and to determine its sender.
2290 See also `erc-lurker-trim-nicks' and `erc-lurker-ignore-chars'.
2292 In order to limit memory consumption, this function also calls
2293 `erc-lurker-cleanup' once every `erc-lurker-cleanup-interval'
2294 updates of `erc-lurker-state'."
2295 (when (and (boundp 'erc-message-parsed
)
2296 (erc-response-p erc-message-parsed
))
2297 (let* ((command (erc-response.command erc-message-parsed
))
2299 (erc-lurker-maybe-trim
2300 (car (erc-parse-user (erc-response.sender erc-message-parsed
)))))
2302 (erc-canonicalize-server-name erc-server-announced-name
)))
2303 (when (equal command
"PRIVMSG")
2304 (when (>= (cl-incf erc-lurker-cleanup-count
)
2305 erc-lurker-cleanup-interval
)
2306 (setq erc-lurker-cleanup-count
0)
2307 (erc-lurker-cleanup))
2308 (unless (gethash server erc-lurker-state
)
2309 (puthash server
(make-hash-table :test
'equal
) erc-lurker-state
))
2310 (puthash sender
(current-time)
2311 (gethash server erc-lurker-state
))))))))
2313 (use-feature erc-fill
2316 (erc-fill-column 77)
2317 (erc-fill-function 'erc-fill-static
)
2318 (erc-fill-static-center 18))
2320 (use-feature erc-pcomplete
2323 (erc-pcomplete-nick-postfix ","))
2325 (use-feature erc-track
2327 :bind
(("C-c a e t d" . erc-track-disable
)
2328 ("C-c a e t e" . erc-track-enable
))
2330 (erc-track-enable-keybindings nil
)
2331 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2332 "324" "329" "332" "333" "353" "477"))
2333 (erc-track-priority-faces-only 'all
)
2334 (erc-track-shorten-function nil
))
2336 (use-package erc-hl-nicks
2339 (use-package erc-scrolltoplace
2343 :straight
(:host nil
:repo
"https://git.shemshak.org/amin/znc.el")
2344 :bind
(("C-c a e e" . znc-erc
)
2345 ("C-c a e a" . znc-all
))
2347 (let ((pwd (let ((auth (auth-source-search :host
"znca")))
2349 ((null auth
) (error "Couldn't find znca's authinfo"))
2350 (t (funcall (plist-get (car auth
) :secret
)))))))
2352 `(("znc.shemshak.org" 1337 t
2353 ((freenode "amin/freenode" ,pwd
)))
2354 ("znc.shemshak.org" 1337 t
2355 ((moznet "amin/moznet" ,pwd
)))
2356 ("znc.shemshak.org" 1337 t
2357 ((oftc "amin/oftc" ,pwd
)))))))
2360 ;;; Post initialization
2362 (message "Loading %s...done (%.3fs)" user-init-file
2363 (float-time (time-subtract (current-time)
2364 b
/before-user-init-time
)))
2366 ;;; init.el ends here