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
185 (convert-standard-filename "etc/") user-emacs-directory
)
186 "The directory where packages place their configuration files.")
190 (convert-standard-filename "var/") user-emacs-directory
)
191 "The directory where packages place their persistent data files.")
194 "Expand filename FILE relative to `b/etc-dir'."
195 (expand-file-name (convert-standard-filename file
) b
/etc-dir
))
198 "Expand filename FILE relative to `b/var-dir'."
199 (expand-file-name (convert-standard-filename file
) b
/var-dir
))
202 auto-save-list-file-prefix
(b/var
"auto-save/sessions/")
203 nsm-settings-file
(b/var
"nsm-settings.el"))
205 ;; separate custom file (don't want it mixing with init.el)
209 (setq custom-file
(b/etc
"custom.el"))
210 (when (file-exists-p custom-file
)
212 ;; while at it, treat themes as safe
213 (setf custom-safe-themes t
))
215 ;; load the secrets file if it exists, otherwise show a warning
218 (load (b/etc
"secrets"))))
220 ;; better $PATH (and other environment variable) handling
221 (use-package exec-path-from-shell
224 (setq exec-path-from-shell-arguments nil
225 exec-path-from-shell-check-startup-files nil
)
227 (exec-path-from-shell-initialize)
228 ;; while we're at it, let's fix access to our running ssh-agent
229 (exec-path-from-shell-copy-env "SSH_AGENT_PID")
230 (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
232 ;; only one custom theme at a time
234 (defadvice load-theme
(before clear-previous-themes activate
)
235 "Clear existing theme settings instead of layering them"
236 (mapc #'disable-theme custom-enabled-themes
)))
238 ;; start up emacs server. see
239 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
242 :config
(or (server-running-p) (server-mode)))
246 (dolist (ft (fontset-list))
250 (font-spec :name
"Source Code Pro" :size
14))
254 (font-spec :name
"DejaVu Sans Mono")
261 ;; :name "Symbola monospacified for DejaVu Sans Mono")
267 ;; (font-spec :name "DejaVu Sans Mono")
273 (font-spec :name
"DejaVu Sans Mono" :size
14)
277 ;; gentler font resizing
278 (setq text-scale-mode-step
1.05)
280 ;; focus follows mouse
281 (setq mouse-autoselect-window t
)
283 (defun b/no-mouse-autoselect-window
()
284 "Conveniently disable `focus-follows-mouse'.
285 For disabling the behaviour for certain buffers and/or modes."
286 (make-local-variable 'mouse-autoselect-window
)
287 (setq mouse-autoselect-window nil
))
290 (setq ;; scroll-margin 1
291 ;; scroll-conservatively 10000
293 scroll-conservatively
10
294 scroll-preserve-screen-position
1)
299 (setq mouse-wheel-scroll-amount
'(1 ((shift) .
1)) ; one line at a time
300 mouse-wheel-progressive-speed nil
; don't accelerate scrolling
301 mouse-wheel-follow-mouse t
)) ; scroll window under mouse
303 (use-feature pixel-scroll
305 :config
(pixel-scroll-mode 1))
307 ;; ask for GPG passphrase in minibuffer
310 ; this will fail if gpg>=2.1 is not available
311 (epa-pinentry-mode 'loopback
))
313 (use-feature epg-config
316 ((epg-gpg-program (executable-find "gpg"))
317 (epg-pinentry-mode 'loopback
)))
322 (use-package pinentry
324 :after
(epa epg server
)
326 (setq pinentry--socket-dir server-socket-dir
)
336 (defmacro b
/setq-every
(value &rest vars
)
337 "Set all the variables from VARS to value VALUE."
338 (declare (indent defun
) (debug t
))
339 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
341 (defun b/start-process
(program &rest args
)
342 "Same as `start-process', but doesn't bother about name and buffer."
343 (let ((process-name (concat program
"_process"))
344 (buffer-name (generate-new-buffer-name
345 (concat program
"_output"))))
346 (apply #'start-process
347 process-name buffer-name program args
)))
349 (defun b/dired-start-process
(program &optional args
)
350 "Open current file with a PROGRAM."
351 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
352 ;; be nil, so remove it).
353 (apply #'b
/start-process
355 (remove nil
(list args
(dired-get-file-for-visit)))))
357 (defun b/add-elisp-section
()
361 (insert "\n\f\n;;; "))
366 ;; time and battery in mode-line
370 (setq display-time-default-load-average nil
)
376 (display-battery-mode)))
379 ;; (fringe-mode '(3 . 1))
382 ;; disable disabled commands
383 (setq disabled-command-function nil
)
385 ;; Save what I copy into clipboard from other applications into Emacs'
386 ;; kill-ring, which would allow me to still be able to easily access
387 ;; it in case I kill (cut or copy) something else inside Emacs before
388 ;; yanking (pasting) what I'd originally intended to.
389 (setq save-interprogram-paste-before-kill t
)
392 (setq enable-recursive-minibuffers t
393 resize-mini-windows t
)
395 ;; lazy-person-friendly yes/no prompts
396 (defalias 'yes-or-no-p
#'y-or-n-p
)
398 ;; i want *scratch* as my startup buffer
399 (setq initial-buffer-choice t
)
401 ;; i don't need the default hint
402 (setq initial-scratch-message nil
)
404 ;; use customizable text-mode as major mode for *scratch*
405 (setq initial-major-mode
'text-mode
)
407 ;; inhibit buffer list when more than 2 files are loaded
408 (setq inhibit-startup-buffer-menu t
)
410 ;; don't need to see the startup screen or the echo area message
411 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
412 (setq inhibit-startup-screen t
413 inhibit-startup-echo-area-message user-login-name
)
415 ;; more useful frame titles
416 (setq frame-title-format
417 '("" invocation-name
" - "
418 (:eval
(if (buffer-file-name)
419 (abbreviate-file-name (buffer-file-name))
422 ;; backups (C-h v make-backup-files RET)
423 (setq backup-by-copying t
424 backup-directory-alist
(list (cons "." (b/var
"backup/")))
426 delete-old-versions t
)
428 ;; enable automatic reloading of changed buffers and files
429 (global-auto-revert-mode 1)
430 (setq auto-revert-verbose nil
431 global-auto-revert-non-file-buffers nil
)
433 ;; always use space for indentation
436 require-final-newline t
439 ;; enable winner-mode (C-h f winner-mode RET)
442 ;; don't display *compilation* buffer on success. based on
443 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
444 ;; instead of the now obsolete `flet'.
445 (with-eval-after-load 'compile
446 (defun b/compilation-finish-function
(buffer outstr
)
447 (unless (string-match "finished" outstr
)
448 (switch-to-buffer-other-window buffer
))
451 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
455 (defadvice compilation-start
456 (around inhibit-display
457 (command &optional mode name-function highlight-regexp
))
458 (if (not (string-match "^\\(find\\|grep\\)" command
))
459 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
460 (save-window-excursion ad-do-it
))
462 (ad-activate 'compilation-start
))
464 ;; search for non-ASCII characters: i’d like non-ASCII characters such
465 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
466 ;; counterpart. shoutout to
467 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
468 (setq search-default-mode
#'char-fold-to-regexp
)
469 ;; uncomment to extend this behaviour to query-replace
470 ;; (setq replace-char-fold t)
473 (setq-default cursor-type
'bar
)
475 ;; allow scrolling in Isearch
476 (setq isearch-allow-scroll t
)
478 ;; open read-only file buffers in view-mode
479 ;; (enables niceties like `q' for quit)
480 (setq view-read-only t
)
483 :bind
("C-x v C-=" . vc-ediff
))
486 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
487 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
488 (ediff-split-window-function 'split-window-horizontally
)))
490 ;; i don't feel like jumping out of my chair every now and again; so
491 ;; don't BEEP! at me, emacs
492 (setq ring-bell-function
'ignore
)
500 ("C-c e b" . eval-buffer
)
501 ("C-c e e" . eval-last-sexp
)
502 ("C-c e r" . eval-region
)
504 ("C-c e i" . emacs-init-time
)
505 ("C-c e u" . emacs-uptime
)
506 ("C-c e v" . emacs-version
)
508 ("C-c F m" . make-frame-command
)
509 ("C-c F d" . delete-frame
)
510 ("C-c F D" . server-edit
)
512 ("C-S-h C" . describe-char
)
513 ("C-S-h F" . describe-face
)
515 ("C-x k" . kill-this-buffer
)
516 ("C-x K" . kill-buffer
)
517 ("C-x s" . save-buffer
)
518 ("C-x S" . save-some-buffers
)
520 :map emacs-lisp-mode-map
521 ("<C-return>" . b
/add-elisp-section
))
523 (when (display-graphic-p)
524 (unbind-key "C-z" global-map
))
527 ;; for back and forward mouse keys
528 ("<mouse-8>" . previous-buffer
)
529 ("<drag-mouse-8>" . previous-buffer
)
530 ("<mouse-9>" . next-buffer
)
531 ("<drag-mouse-9>" . next-buffer
)
532 ("<drag-mouse-2>" . kill-this-buffer
)
533 ("<drag-mouse-3>" . ivy-switch-buffer
))
536 :prefix-map mab
/straight-prefix-map
538 ("u" . straight-use-package
)
539 ("f" . straight-freeze-versions
)
540 ("t" . straight-thaw-versions
)
541 ("P" . straight-prune-build
)
542 ("g" . straight-get-recipe
)
543 ("r" . mab
/reload-init
)
544 ;; M-x ^straight-.*-all$
545 ("a c" . straight-check-all
)
546 ("a f" . straight-fetch-all
)
547 ("a m" . straight-merge-all
)
548 ("a n" . straight-normalize-all
)
549 ("a F" . straight-pull-all
)
550 ("a P" . straight-push-all
)
551 ("a r" . straight-rebuild-all
)
552 ;; M-x ^straight-.*-package$
553 ("p c" . straight-check-package
)
554 ("p f" . straight-fetch-package
)
555 ("p m" . straight-merge-package
)
556 ("p n" . straight-normalize-package
)
557 ("p F" . straight-pull-package
)
558 ("p P" . straight-push-package
)
559 ("p r" . straight-rebuild-package
))
562 ;;; Essential packages
564 ;; use the org-plus-contrib package to get the whole deal
565 (use-package org-plus-contrib
)
570 (setq org-src-tab-acts-natively t
571 org-src-preserve-indentation nil
572 org-edit-src-content-indentation
0
573 org-link-email-description-format
"Email %c: %s" ; %.30s
574 org-highlight-latex-and-related
'(entities)
575 org-use-speed-commands t
576 org-startup-folded
'content
577 org-catch-invisible-edits
'show-and-error
579 (when (version< org-version
"9.3")
580 (setq org-email-link-description-format
581 org-link-email-description-format
))
582 (add-to-list 'org-structure-template-alist
'("L" .
"src emacs-lisp") t
)
583 (add-to-list 'org-modules
'org-habit
)
585 (("C-c a o a" . org-agenda
)
587 ("M-L" . org-insert-last-stored-link
)
588 ("M-O" . org-toggle-link-display
))
589 :hook
((org-mode . org-indent-mode
)
590 (org-mode . auto-fill-mode
)
591 (org-mode . flyspell-mode
))
593 (org-pretty-entities t
)
594 (org-agenda-files '("~/usr/org/todos/personal.org"
595 "~/usr/org/todos/habits.org"
596 "~/src/git/masters-thesis/todo.org"))
597 (org-agenda-start-on-weekday 0)
598 (org-agenda-time-leading-zero t
)
599 (org-habit-graph-column 44)
600 (org-latex-packages-alist '(("" "listings") ("" "color")))
602 '(org-block-begin-line ((t (:foreground
"#5a5b5a" :background
"#1d1f21"))))
603 '(org-block ((t (:background
"#1d1f21"))))
604 '(org-latex-and-related ((t (:foreground
"#b294bb")))))
606 (use-feature ox-latex
609 (setq org-latex-listings
'listings
610 ;; org-latex-prefer-user-labels t
612 (add-to-list 'org-latex-classes
613 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
614 ("\\section{%s}" .
"\\section*{%s}")
615 ("\\subsection{%s}" .
"\\subsection*{%s}")
616 ("\\subsubsection{%s}" .
"\\subsubsection*{%s}")
617 ("\\paragraph{%s}" .
"\\paragraph*{%s}")
618 ("\\subparagraph{%s}" .
"\\subparagraph*{%s}"))
620 (require 'ox-beamer
))
622 (use-feature ox-extra
624 (ox-extras-activate '(latex-header-blocks ignore-headlines
)))
626 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
627 ;; org file. closely inspired by
628 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
629 (with-eval-after-load 'org
630 (defvar b
/show-async-tangle-results nil
631 "Keep *emacs* async buffers around for later inspection.")
633 (defvar b
/show-async-tangle-time nil
634 "Show the time spent tangling the file.")
636 (defun b/async-babel-tangle
()
637 "Tangle org file asynchronously."
639 (let* ((file-tangle-start-time (current-time))
640 (file (buffer-file-name))
641 (file-nodir (file-name-nondirectory file
))
642 ;; (async-quiet-switch "-q")
643 (file-noext (file-name-sans-extension file
)))
647 (org-babel-tangle-file ,file
))
648 (unless b
/show-async-tangle-results
651 (message "Tangled %s%s"
653 (if b
/show-async-tangle-time
655 (float-time (time-subtract (current-time)
656 ',file-tangle-start-time
)))
658 (message "Tangling %s failed" ,file-nodir
))))))))
661 'safe-local-variable-values
662 '(eval add-hook
'after-save-hook
#'b
/async-babel-tangle
'append
'local
))
664 ;; *the* right way to do git
667 :bind
(("C-x g" . magit-status
)
668 ("C-c g g" . magit-status
)
669 ("C-c g b" . magit-blame-addition
)
670 ("C-c g l" . magit-log-buffer-file
))
672 (magit-add-section-hook 'magit-status-sections-hook
673 'magit-insert-modules
674 'magit-insert-stashes
676 ;; (magit-add-section-hook 'magit-status-sections-hook
677 ;; 'magit-insert-ignored-files
678 ;; 'magit-insert-untracked-files
680 (setq magit-repository-directories
'(("~/" .
0)
682 (nconc magit-section-initial-visibility-alist
683 '(([unpulled status
] . show
)
684 ([unpushed status
] . show
)))
685 (setq transient-history-file
(b/var
"transient/history.el")
686 transient-levels-file
(b/etc
"transient/levels.el")
687 transient-values-file
(b/etc
"transient/values.el"))
688 :custom
(magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1
)
689 :custom-face
(magit-diff-file-heading ((t (:weight normal
)))))
691 ;; recently opened files
695 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
697 (recentf-max-saved-items 2000)
698 (recentf-save-file (b/var
"recentf-save.el")))
700 ;; smart M-x enhancement (needed by counsel for history)
703 (setq smex-save-file
(b/var
"smex-save.el")))
709 (:map ivy-minibuffer-map
710 ([escape] . keyboard-escape-quit)
711 ([S-up] . ivy-previous-history-element)
712 ([S-down] . ivy-next-history-element)
713 ("DEL" . ivy-backward-delete-char))
717 ivy-use-virtual-buffers t
718 ivy-virtual-abbreviate 'abbreviate
719 ivy-count-format "%d/%d ")
721 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
722 (defun b/ivy-ignore-buffer-p (str)
723 "Return non-nil if str names a buffer with a major mode
724 derived from one of `b/ivy-ignore-buffer-modes'.
726 This function is intended for use with `ivy-ignore-buffers'."
727 (let* ((buf (get-buffer str))
728 (mode (and buf (buffer-local-value 'major-mode buf))))
730 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
731 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
735 ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
736 ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
737 ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
742 :bind (("C-s" . swiper-isearch)
744 ("C-S-s" . isearch-forward)))
749 :bind (([remap execute-extended-command] . counsel-M-x)
750 ([remap find-file] . counsel-find-file)
751 ("C-c b b" . ivy-switch-buffer)
752 ("C-c f ." . counsel-find-file)
753 ("C-c f l" . counsel-find-library)
754 ("C-c f r" . counsel-recentf)
755 ("C-c x" . counsel-M-x)
756 :map minibuffer-local-map
757 ("C-r" . counsel-minibuffer-history))
760 (defalias 'locate #'counsel-locate))
764 :commands (helm-M-x helm-mini helm-resume)
765 :bind (("M-x" . helm-M-x)
766 ("M-y" . helm-show-kill-ring)
767 ("C-x b" . helm-mini)
768 ("C-x C-b" . helm-buffers-list)
769 ("C-x C-f" . helm-find-files)
770 ("C-h r" . helm-info-emacs)
771 ("C-s-r" . helm-resume)
773 ("<tab>" . helm-execute-persistent-action)
774 ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals
775 ("C-z" . helm-select-action)) ; List actions
776 :config (helm-mode 1)))
781 :bind ("C-c a s e" . eshell)
783 (eval-when-compile (defvar eshell-prompt-regexp))
784 (defun b/eshell-quit-or-delete-char (arg)
786 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
787 (eshell-life-is-too-much)
790 (defun b/eshell-clear ()
792 (let ((inhibit-read-only t))
796 (defun b/eshell-setup ()
797 (make-local-variable 'company-idle-delay)
798 (defvar company-idle-delay)
799 (setq company-idle-delay nil)
800 (bind-keys :map eshell-mode-map
801 ("C-d" . b/eshell-quit-or-delete-char)
802 ("C-S-l" . b/eshell-clear)
803 ("M-r" . counsel-esh-history)
804 ([tab] . company-complete)))
806 :hook (eshell-mode . b/eshell-setup)
808 (eshell-directory-name (b/var "eshell/"))
809 (eshell-hist-ignoredups t)
810 (eshell-input-filter 'eshell-input-filter-initial-space))
814 (("C-x C-b" . ibuffer)
815 :map ibuffer-mode-map
816 ("P" . ibuffer-backward-filter-group)
817 ("N" . ibuffer-forward-filter-group)
818 ("M-p" . ibuffer-do-print)
819 ("M-n" . ibuffer-do-shell-command-pipe-replace))
821 ;; Use human readable Size column instead of original one
822 (define-ibuffer-column size-h
823 (:name "Size" :inline t)
825 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
826 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
827 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
828 (t (format "%8d" (buffer-size)))))
830 (ibuffer-saved-filter-groups
832 ("dired" (mode . dired-mode))
833 ("org" (mode . org-mode))
836 (mode . gnus-group-mode)
837 (mode . gnus-summary-mode)
838 (mode . gnus-article-mode)
839 ;; not really, but...
840 (mode . message-mode)))
858 (mode . emacs-lisp-mode)
860 (mode . haskell-mode)
863 (mode . alloy-mode)))
867 (mode . latex-mode)))
870 (name . "^\\*scratch\\*$")
871 (name . "^\\*Messages\\*$")))
872 ("erc" (mode . erc-mode)))))
874 '((mark modified read-only locked " "
875 (name 18 18 :left :elide)
879 (mode 16 16 :left :elide)
880 " " filename-and-process)
884 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
888 :hook (prog-mode . outline-minor-mode)
889 :delight (outline-minor-mode " outl")
892 outline-minor-mode-map
893 ("<s-tab>" . outline-toggle-children)
894 ("M-p" . outline-previous-visible-heading)
895 ("M-n" . outline-next-visible-heading)
896 :prefix-map b/outline-prefix-map
898 ("TAB" . outline-toggle-children)
899 ("a" . outline-hide-body)
900 ("H" . outline-hide-body)
901 ("S" . outline-show-all)
902 ("h" . outline-hide-subtree)
903 ("s" . outline-show-subtree)))
906 :custom (ls-lisp-dirs-first t))
910 (setq dired-listing-switches "-alh"
911 ls-lisp-use-insert-directory-program nil)
913 ;; easily diff 2 marked files
914 ;; https://oremacs.com/2017/03/18/dired-ediff/
915 (defun dired-ediff-files ()
918 (defvar ediff-after-quit-hook-internal)
919 (let ((files (dired-get-marked-files))
920 (wnd (current-window-configuration)))
921 (if (<= (length files) 2)
922 (let ((file1 (car files))
923 (file2 (if (cdr files)
927 (dired-dwim-target-directory)))))
928 (if (file-newer-than-file-p file1 file2)
929 (ediff-files file2 file1)
930 (ediff-files file1 file2))
931 (add-hook 'ediff-after-quit-hook-internal
933 (setq ediff-after-quit-hook-internal nil)
934 (set-window-configuration wnd))))
935 (error "no more than 2 files should be marked"))))
938 (setq dired-guess-shell-alist-user
939 '(("\\.pdf\\'" "evince" "zathura" "okular")
940 ("\\.doc\\'" "libreoffice")
941 ("\\.docx\\'" "libreoffice")
942 ("\\.ppt\\'" "libreoffice")
943 ("\\.pptx\\'" "libreoffice")
944 ("\\.xls\\'" "libreoffice")
945 ("\\.xlsx\\'" "libreoffice")
946 ("\\.flac\\'" "mpv")))
947 :bind (:map dired-mode-map
948 ("b" . dired-up-directory)
949 ("e" . dired-ediff-files)
950 ("E" . dired-toggle-read-only)
951 ("\\" . dired-hide-details-mode)
954 (b/dired-start-process "zathura"))))
955 :hook (dired-mode . dired-hide-details-mode))
959 (temp-buffer-resize-mode)
960 (setq help-window-select t))
964 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
965 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
966 (add-to-list 'tramp-default-proxies-alist
967 (list (regexp-quote (system-name)) nil nil)))
970 :config (dash-enable-font-lock))
972 (use-feature doc-view
973 :bind (:map doc-view-mode-map
974 ("M-RET" . image-previous-line)))
979 ;; highlight uncommitted changes in the left fringe
983 (setq diff-hl-draw-borders nil)
984 (global-diff-hl-mode)
985 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
987 ;; display Lisp objects at point in the echo area
989 :when (version< "25" emacs-version)
991 :config (global-eldoc-mode))
993 ;; highlight matching parens
996 :config (show-paren-mode))
998 (use-feature elec-pair
1000 :config (electric-pair-mode))
1003 :delight (auto-fill-function " fill")
1004 :config (column-number-mode))
1006 ;; save minibuffer history
1007 (use-feature savehist
1011 (savehist-file (b/var "savehist.el")))
1013 ;; automatically save place in files
1014 (use-feature saveplace
1015 :when (version< "25" emacs-version)
1016 :config (save-place-mode)
1018 (save-place-file (b/var "save-place.el")))
1020 (use-feature prog-mode
1021 :config (global-prettify-symbols-mode)
1022 (defun indicate-buffer-boundaries-left ()
1023 (setq indicate-buffer-boundaries 'left))
1024 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1026 (use-feature text-mode
1027 :hook (text-mode . indicate-buffer-boundaries-left))
1029 (use-feature conf-mode
1032 (use-feature sh-mode
1035 (use-package company
1039 (:map company-active-map
1040 ([tab] . company-complete-common-or-cycle)
1041 ([escape] . company-abort
))
1043 (company-minimum-prefix-length 1)
1044 (company-selection-wrap-around t
)
1045 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1046 (company-dabbrev-downcase nil
)
1047 (company-dabbrev-ignore-case nil
)
1049 (global-company-mode t
))
1051 (use-package flycheck
1053 :hook
(prog-mode . flycheck-mode
)
1055 (:map flycheck-mode-map
1056 ("M-P" . flycheck-previous-error
)
1057 ("M-N" . flycheck-next-error
))
1059 ;; Use the load-path from running Emacs when checking elisp files
1060 (setq flycheck-emacs-lisp-load-path
'inherit
)
1062 ;; Only flycheck when I actually save the buffer
1063 (setq flycheck-check-syntax-automatically
'(mode-enabled save
))
1064 :custom
(flycheck-mode-line-prefix "flyc"))
1066 (use-feature flyspell
1069 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1073 ;; ’ can be part of a word
1074 (setq ispell-local-dictionary-alist
1075 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1076 "['\x2019]" nil
("-B") nil utf-8
))
1077 ispell-program-name
(executable-find "hunspell"))
1078 ;; don't send ’ to the subprocess
1079 (defun endless/replace-apostrophe
(args)
1080 (cons (replace-regexp-in-string
1083 (advice-add #'ispell-send-string
:filter-args
1084 #'endless
/replace-apostrophe
)
1086 ;; convert ' back to ’ from the subprocess
1087 (defun endless/replace-quote
(args)
1088 (if (not (derived-mode-p 'org-mode
))
1090 (cons (replace-regexp-in-string
1093 (advice-add #'ispell-parse-output
:filter-args
1094 #'endless
/replace-quote
))
1098 :hook
(text-mode . abbrev-mode
)
1100 (abbrev-file-name (b/var
"abbrev.el")))
1103 ;;; Programming modes
1105 (use-feature lisp-mode
1107 (defun indent-spaces-mode ()
1108 (setq indent-tabs-mode nil
))
1109 (add-hook 'lisp-interaction-mode-hook
#'indent-spaces-mode
))
1112 :delight
(reveal-mode " reveal")
1113 :hook
(emacs-lisp-mode . reveal-mode
))
1115 (use-feature elisp-mode
1116 :delight
(emacs-lisp-mode "Elisp" :major
))
1119 (use-package alloy-mode
1120 :straight
(:host github
:repo
"dwwmmn/alloy-mode")
1122 :config
(setq alloy-basic-offset
2))
1124 (eval-when-compile (defvar lean-mode-map
))
1125 (use-package lean-mode
1126 :straight
(:host github
:repo
"leanprover/lean-mode"
1127 :fork
(:repo
"notbandali/lean-mode" :branch
"remove-cl"))
1129 :bind
(:map lean-mode-map
1130 ("S-SPC" . company-complete
))
1132 (require 'lean-input
)
1133 (setq default-input-method
"Lean"
1134 lean-input-tweak-all
'(lean-input-compose
1135 (lean-input-prepend "/")
1136 (lean-input-nonempty))
1137 lean-input-user-translations
'(("/" "/")))
1141 (use-package proof-site
; for Coq
1142 :straight proof-general
)
1144 (use-package haskell-mode
1146 (setq haskell-indentation-layout-offset
4
1147 haskell-indentation-left-offset
4
1148 flycheck-checker
'haskell-hlint
1149 flycheck-disabled-checkers
'(haskell-stack-ghc haskell-ghc
)))
1153 :commands dante-mode
1154 :hook
(haskell-mode . dante-mode
))
1156 (use-package hlint-refactor
1158 :bind
(:map hlint-refactor-mode-map
1159 ("C-c l b" . hlint-refactor-refactor-buffer
)
1160 ("C-c l r" . hlint-refactor-refactor-at-point
))
1161 :hook
(haskell-mode . hlint-refactor-mode
))
1163 (use-package flycheck-haskell
1164 :after haskell-mode
)
1165 ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el
1168 (use-feature sgml-mode
1170 (setq sgml-basic-offset
2))
1172 (use-feature css-mode
1174 (setq css-indent-offset
2))
1176 (use-package web-mode
1180 web-mode-code-indent-offset
1181 web-mode-css-indent-offset
1182 web-mode-markup-indent-offset
))
1184 (use-package emmet-mode
1185 :after
(:any web-mode css-mode sgml-mode
)
1186 :bind
* (("C-)" . emmet-next-edit-point
)
1187 ("C-(" . emmet-prev-edit-point
))
1189 (unbind-key "C-j" emmet-mode-keymap
)
1190 (setq emmet-move-cursor-between-quotes t
)
1191 :hook
(web-mode css-mode html-mode sgml-mode
))
1194 (use-package meghanada
1196 (:map meghanada-mode-map
1197 (("C-M-o" . meghanada-optimize-import
)
1198 ("C-M-t" . meghanada-import-all
)))
1199 :hook
(java-mode . meghanada-mode
)))
1202 (use-package treemacs
1203 :config
(setq treemacs-never-persist t
))
1205 (use-package yasnippet
1207 ;; (yas-global-mode)
1210 (use-package lsp-mode
1211 :init
(setq lsp-eldoc-render-all nil
1212 lsp-highlight-symbol-at-point nil
)
1217 (use-package company-lsp
1220 (setq company-lsp-cache-candidates t
1221 company-lsp-async t
))
1225 (setq lsp-ui-sideline-update-mode
'point
))
1227 (use-package lsp-java
1229 (add-hook 'java-mode-hook
1231 (setq-local company-backends
(list 'company-lsp
))))
1233 (add-hook 'java-mode-hook
'lsp-java-enable
)
1234 (add-hook 'java-mode-hook
'flycheck-mode
)
1235 (add-hook 'java-mode-hook
'company-mode
)
1236 (add-hook 'java-mode-hook
'lsp-ui-mode
))
1238 (use-package dap-mode
1244 (use-package dap-java
1247 (use-package lsp-java-treemacs
1252 :bind
(:map eclim-mode-map
("S-SPC" . company-complete
))
1253 :hook
((java-mode . eclim-mode
)
1254 (eclim-mode .
(lambda ()
1255 (make-local-variable 'company-idle-delay
)
1256 (defvar company-idle-delay
)
1257 ;; (setq company-idle-delay 0.7)
1258 (setq company-idle-delay nil
))))
1260 (eclim-auto-save nil
)
1261 ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp")
1262 (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim")
1263 (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse"))))
1267 (make-directory (b/var
"geiser/") t
)
1268 (setq geiser-repl-history-filename
(b/var
"geiser/repl-history")))
1270 (use-feature geiser-guile
1272 (setq geiser-guile-load-path
"~/src/git/guix"))
1279 (font-latex-fontify-sectioning 'color
)))
1281 (use-package go-mode
)
1283 (use-package po-mode
1285 (po-mode .
(lambda () (run-with-timer 0.1 nil
'View-exit
))))
1287 (use-feature tex-mode
1290 (lambda (p) (string-match "^---?" (car p
)))
1291 tex--prettify-symbols-alist
)
1292 :hook
((tex-mode . auto-fill-mode
)
1293 (tex-mode . flyspell-mode
)
1294 (tex-mode .
(lambda () (electric-indent-local-mode -
1)))))
1299 (add-to-list 'custom-theme-load-path
1301 (convert-standard-filename "lisp") user-emacs-directory
))
1302 (load-theme 'tangomod t
)
1304 (use-package smart-mode-line
1305 :commands
(sml/apply-theme
)
1309 (smart-mode-line-enable))
1311 (use-package doom-themes
)
1313 (defvar b
/org-mode-font-lock-keywords
1314 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1315 (1 '(:foreground
"#5a5b5a" :background
"#292b2b") t
) ; directive
1316 (3 '(:foreground
"#81a2be" :background
"#292b2b") t
) ; kind
1317 (4 '(:foreground
"#c5c8c6") t
)))) ; title
1319 (defun b/lights-on
()
1320 "Enable my favourite light theme."
1322 (mapc #'disable-theme custom-enabled-themes
)
1323 (load-theme 'tangomod t
)
1324 (sml/apply-theme
'automatic
)
1325 (font-lock-remove-keywords
1326 'org-mode b
/org-mode-font-lock-keywords
))
1328 (defun b/lights-off
()
1331 (mapc #'disable-theme custom-enabled-themes
)
1332 ;; (load-theme 'doom-tomorrow-night t)
1333 (sml/apply-theme
'automatic
)
1334 (font-lock-add-keywords
1335 'org-mode b
/org-mode-font-lock-keywords t
))
1338 ("C-c t d" . b
/lights-off
)
1339 ("C-c t l" . b
/lights-on
))
1342 ;;; Emacs enhancements & auxiliary packages
1345 :config
(setq Man-width
80))
1347 (use-package which-key
1351 (which-key-add-key-based-replacements
1352 ;; prefixes for global prefixes and minor modes
1356 "C-c 8 -" "typo/dashes"
1357 "C-c 8 <" "typo/left-brackets"
1358 "C-c 8 >" "typo/right-brackets"
1360 "C-x a" "abbrev/expand"
1361 "C-x r" "rectangle/register/bookmark"
1362 "C-x v" "version control"
1363 ;; prefixes for my personal bindings
1364 "C-c a" "applications"
1369 "C-c c" "compile-and-comments"
1375 "C-c m" "multiple-cursors"
1376 "C-c P" "projectile"
1377 "C-c P s" "projectile/search"
1378 "C-c P x" "projectile/execute"
1379 "C-c P 4" "projectile/other-window"
1385 ;; prefixes for major modes
1386 (which-key-add-major-mode-key-based-replacements 'message-mode
1388 (which-key-add-major-mode-key-based-replacements 'org-mode
1389 "C-c C-v" "org-babel")
1390 (which-key-add-major-mode-key-based-replacements 'web-mode
1391 "C-c C-a" "web/attributes"
1392 "C-c C-b" "web/blocks"
1394 "C-c C-e" "web/element"
1395 "C-c C-t" "web/tags")
1399 (which-key-add-column-padding 5)
1400 (which-key-max-description-length 32))
1402 (use-package crux
; results in Waiting for git... [2 times]
1404 :bind
(("C-c d" . crux-duplicate-current-line-or-region
)
1405 ("C-c D" . crux-duplicate-and-comment-current-line-or-region
)
1406 ("C-c f c" . crux-copy-file-preserve-attributes
)
1407 ("C-c f d" . crux-delete-file-and-buffer
)
1408 ("C-c f r" . crux-rename-file-and-buffer
)
1409 ("C-c j" . crux-top-join-line
)
1410 ("C-S-j" . crux-top-join-line
)))
1413 :bind
(("C-a" . mwim-beginning-of-code-or-line
)
1414 ("C-e" . mwim-end-of-code-or-line
)
1415 ("<home>" . mwim-beginning-of-line-or-code
)
1416 ("<end>" . mwim-end-of-line-or-code
)))
1418 (use-package projectile
1420 :bind-keymap
("C-c P" . projectile-command-map
)
1422 (make-directory (b/var
"projectile/") t
)
1425 (defun b/projectile-mode-line-fun
()
1426 "Report project name and type in the modeline."
1427 (let ((project-name (projectile-project-name))
1428 (project-type (projectile-project-type)))
1430 projectile-mode-line-prefix
1432 (format ":%s" project-type
)
1434 (setq projectile-mode-line-function
'b
/projectile-mode-line-fun
)
1436 (defun my-projectile-invalidate-cache (&rest _args
)
1437 ;; ignore the args to `magit-checkout'
1438 (projectile-invalidate-cache nil
))
1440 (eval-after-load 'magit-branch
1442 (advice-add 'magit-checkout
1443 :after
#'my-projectile-invalidate-cache
)
1444 (advice-add 'magit-branch-and-checkout
1445 :after
#'my-projectile-invalidate-cache
)))
1447 (projectile-cache-file (b/var
"projectile/cache.el"))
1448 (projectile-completion-system 'ivy
)
1449 (projectile-known-projects-file (b/var
"projectile/known-projects.el"))
1450 (projectile-mode-line-prefix " proj"))
1452 (use-package helpful
1455 (("C-S-h c" . helpful-command
)
1456 ("C-S-h f" . helpful-callable
) ; helpful-function
1457 ("C-S-h v" . helpful-variable
)
1458 ("C-S-h k" . helpful-key
)
1459 ("C-S-h p" . helpful-at-point
)))
1461 (use-package unkillable-scratch
1464 (unkillable-scratch 1)
1466 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1469 ;; | make pretty boxed quotes like this
1471 (use-package boxquote
1474 (:prefix-map b
/boxquote-prefix-map
1476 ("b" . boxquote-buffer
)
1477 ("B" . boxquote-insert-buffer
)
1478 ("d" . boxquote-defun
)
1479 ("F" . boxquote-insert-file
)
1480 ("hf" . boxquote-describe-function
)
1481 ("hk" . boxquote-describe-key
)
1482 ("hv" . boxquote-describe-variable
)
1483 ("hw" . boxquote-where-is
)
1484 ("k" . boxquote-kill
)
1485 ("p" . boxquote-paragraph
)
1486 ("q" . boxquote-boxquote
)
1487 ("r" . boxquote-region
)
1488 ("s" . boxquote-shell-command
)
1489 ("t" . boxquote-text
)
1490 ("T" . boxquote-title
)
1491 ("u" . boxquote-unbox
)
1492 ("U" . boxquote-unbox-region
)
1493 ("y" . boxquote-yank
)
1494 ("M-q" . boxquote-fill-paragraph
)
1495 ("M-w" . boxquote-kill-ring-save
)))
1497 (use-package orgalist
1498 ;; http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00007.html
1501 :hook
(message-mode . orgalist-mode
))
1503 ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
1508 (typo-global-mode 1)
1509 :hook
(((text-mode erc-mode
) . typo-mode
)
1510 (tex-mode .
(lambda ()(typo-mode -
1)))))
1512 ;; highlight TODOs in buffers
1513 (use-package hl-todo
1516 (global-hl-todo-mode))
1518 (use-package shrink-path
1522 (defvar user-
@-host
(concat (user-login-name) "@" (system-name) " "))
1523 (defun +eshell
/prompt
()
1524 (let ((base/dir
(shrink-path-prompt default-directory
)))
1525 (concat (propertize user-
@-host
'face
'default
)
1526 (propertize (car base
/dir
)
1527 'face
'font-lock-comment-face
)
1528 (propertize (cdr base
/dir
)
1529 'face
'font-lock-constant-face
)
1530 (propertize "> " 'face
'default
))))
1531 (setq eshell-prompt-regexp
(concat user-
@-host
".*> ")
1532 eshell-prompt-function
#'+eshell
/prompt
))
1534 (use-package eshell-up
1536 :commands eshell-up
)
1538 (use-package multi-term
1540 :bind
(("C-c a s m m" . multi-term
)
1541 ("C-c a s m d" . multi-term-dedicated-toggle
)
1542 ("C-c a s m p" . multi-term-prev
)
1543 ("C-c a s m n" . multi-term-next
)
1545 ("C-c C-j" . term-char-mode
))
1547 (setq multi-term-program
"screen"
1548 multi-term-program-switches
(concat "-c"
1549 (getenv "XDG_CONFIG_HOME")
1551 ;; TODO: add separate bindings for connecting to existing
1552 ;; session vs. always creating a new one
1553 multi-term-dedicated-select-after-open-p t
1554 multi-term-dedicated-window-height
20
1555 multi-term-dedicated-max-window-height
30
1557 '(("C-c C-c" . term-interrupt-subjob
)
1558 ("C-c C-e" . term-send-esc
)
1559 ("C-c C-j" . term-line-mode
)
1561 ;; ("C-y" . term-paste)
1562 ("C-y" . term-send-raw
)
1563 ("M-f" . term-send-forward-word
)
1564 ("M-b" . term-send-backward-word
)
1565 ("M-p" . term-send-up
)
1566 ("M-n" . term-send-down
)
1567 ("M-j" . term-send-raw-meta
)
1568 ("M-y" . term-send-raw-meta
)
1569 ("M-/" . term-send-raw-meta
)
1570 ("M-0" . term-send-raw-meta
)
1571 ("M-1" . term-send-raw-meta
)
1572 ("M-2" . term-send-raw-meta
)
1573 ("M-3" . term-send-raw-meta
)
1574 ("M-4" . term-send-raw-meta
)
1575 ("M-5" . term-send-raw-meta
)
1576 ("M-6" . term-send-raw-meta
)
1577 ("M-7" . term-send-raw-meta
)
1578 ("M-8" . term-send-raw-meta
)
1579 ("M-9" . term-send-raw-meta
)
1580 ("<C-backspace>" . term-send-backward-kill-word
)
1581 ("<M-DEL>" . term-send-backward-kill-word
)
1582 ("M-d" . term-send-delete-word
)
1583 ("M-," . term-send-raw
)
1584 ("M-." . comint-dynamic-complete
))
1585 term-unbind-key-alist
1586 '("C-z" "C-x" "C-c" "C-h"
1590 (use-package page-break-lines
1594 (page-break-lines-max-width fill-column
)
1596 (global-page-break-lines-mode))
1598 (use-package expand-region
1599 :bind
("C-=" . er
/expand-region
))
1601 (use-package multiple-cursors
1603 (("C-S-<mouse-1>" . mc
/add-cursor-on-click
)
1604 (:prefix-map b
/mc-prefix-map
1606 ("c" . mc
/edit-lines
)
1607 ("n" . mc
/mark-next-like-this
)
1608 ("p" . mc
/mark-previous-like-this
)
1609 ("a" . mc
/mark-all-like-this
)))
1611 (setq mc
/list-file
(b/var
"mc-list.el")))
1619 (use-package yasnippet
1622 (defconst yas-verbosity-cur yas-verbosity
)
1623 (setq yas-verbosity
2)
1624 (setq yas-snippet-dirs
(list (b/etc
"yasnippet/snippets/")))
1625 (add-to-list 'yas-snippet-dirs
"~/src/git/guix/etc/snippets" t
)
1627 (setq yas-verbosity yas-verbosity-cur
)
1629 (defun b/yas--maybe-expand-key-filter
(cmd)
1630 (when (and (yas--maybe-expand-key-filter cmd
)
1631 (not (bound-and-true-p git-commit-mode
)))
1633 (defconst b
/yas-maybe-expand
1634 '(menu-item "" yas-expand
:filter b
/yas--maybe-expand-key-filter
))
1635 (define-key yas-minor-mode-map
1636 (kbd "SPC") b
/yas-maybe-expand
)
1640 (use-package debbugs
1643 :repo
"emacs-straight/debbugs"
1644 :files
(:defaults
"Debbugs.wsdl")))
1646 (use-package org-ref
1648 (b/setq-every
'("~/usr/org/references.bib")
1649 reftex-default-bibliography
1650 org-ref-default-bibliography
)
1652 org-ref-bibliography-notes
"~/usr/org/notes.org"
1653 org-ref-pdf-directory
"~/usr/org/bibtex-pdfs/"))
1657 :init
(setq alert-default-style
'notifications
))
1659 ;; (use-package fill-column-indicator)
1661 (use-package emojify
1663 (make-directory (b/var
"emojify/") t
)
1664 (setq emojify-emojis-dir
(b/var
"emojify/"))
1665 :hook
(erc-mode . emojify-mode
))
1669 (("C-c w <right>" . split-window-right
)
1670 ("C-c w <down>" . split-window-below
)
1671 ("C-c w s l" . split-window-right
)
1672 ("C-c w s j" . split-window-below
)
1673 ("C-c w q" . quit-window
))
1675 (split-width-threshold 150))
1677 (use-feature windmove
1680 (("C-c w h" . windmove-left
)
1681 ("C-c w j" . windmove-down
)
1682 ("C-c w k" . windmove-up
)
1683 ("C-c w l" . windmove-right
)
1684 ("C-c w H" . windmove-swap-states-left
)
1685 ("C-c w J" . windmove-swap-states-down
)
1686 ("C-c w K" . windmove-swap-states-up
)
1687 ("C-c w L" . windmove-swap-states-right
)))
1691 :bind
("C-c a p" . pass
)
1692 :hook
(pass-mode . View-exit
))
1694 (use-package pdf-tools
1696 :bind
(:map pdf-view-mode-map
1697 ("<XF86Back>" . pdf-history-backward
)
1698 ("<XF86Forward>" . pdf-history-forward
)
1699 ("M-RET" . image-previous-line
))
1700 :config
(pdf-tools-install nil t
)
1701 :custom
(pdf-view-resize-factor 1.05))
1703 (use-package biblio
)
1706 :hook
(latex-mode . reftex-mode
))
1708 (use-feature reftex-cite
1710 :disabled
; enable to disable
1711 ; reftex-cite's default choice
1714 (defun reftex-get-bibkey-default ()
1715 "If the cursor is in a citation macro, return the word before the macro."
1716 (let* ((macro (reftex-what-macro 1)))
1718 (when (and macro
(string-match "cite" (car macro
)))
1719 (goto-char (cdr macro
)))
1720 (reftex-this-word)))))
1723 ;;; Email (with Gnus)
1725 (defvar b
/maildir
(expand-file-name "~/mail/"))
1726 (with-eval-after-load 'recentf
1727 (add-to-list 'recentf-exclude b
/maildir
))
1730 b
/gnus-init-file
(b/etc
"gnus")
1731 mail-user-agent
'gnus-user-agent
1732 read-mail-command
'gnus
)
1735 :bind
(("s-m" . gnus
)
1736 ("s-M" . gnus-unplugged
)
1738 ("C-c a M" . gnus-unplugged
))
1741 gnus-select-method
'(nnnil "")
1742 gnus-secondary-select-methods
1743 '((nnimap "shemshak"
1744 (nnimap-stream plain
)
1745 (nnimap-address "127.0.0.1")
1746 (nnimap-server-port 143)
1747 (nnimap-authenticator plain
)
1748 (nnimap-user "amin@shemshak.local"))
1750 (nnimap-stream plain
)
1751 (nnimap-address "127.0.0.1")
1752 (nnimap-server-port 143)
1753 (nnimap-authenticator plain
)
1754 (nnimap-user "bandali@gnu.local")
1755 (nnimap-inbox "INBOX")
1756 (nnimap-split-methods 'nnimap-split-fancy
)
1757 (nnimap-split-fancy (|
1758 ;; (: gnus-registry-split-fancy-with-parent)
1759 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1761 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1762 ;; *@lists.sr.ht, omitting one dot if present
1763 ;; add more \\.?\\([^.@]*\\) if needed
1764 (list ".*<~\\(.*\\)/\\([^.@]*\\)\\.?\\([^.@]*\\)@lists.sr.ht>.*" "l.~\\1.\\2\\3")
1766 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1768 (list ".*atreus.freelists.org" "l.atreus")
1769 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1770 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1771 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1772 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1773 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1774 ;; ----------------------------------
1775 ;; legend: (u)nsubscribed | (d)ead
1776 ;; ----------------------------------
1777 ;; otherwise, leave mail in INBOX
1780 (nnimap-stream plain
)
1781 (nnimap-address "127.0.0.1")
1782 (nnimap-server-port 143)
1783 (nnimap-authenticator plain
)
1784 (nnimap-user "abandali@uw.local")
1785 (nnimap-inbox "INBOX")
1786 (nnimap-split-methods 'nnimap-split-fancy
)
1787 (nnimap-split-fancy (|
1788 ;; (: gnus-registry-split-fancy-with-parent)
1790 ("subject" "SE\\s-?212" "course.se212-f19")
1791 (from "SE\\s-?212" "course.se212-f19")
1795 (nnimap-stream plain
)
1796 (nnimap-address "127.0.0.1")
1797 (nnimap-server-port 143)
1798 (nnimap-authenticator plain
)
1799 (nnimap-user "abandali@csc.uw.local")))
1800 gnus-message-archive-group
"nnimap+shemshak:Sent"
1803 (to-address .
"atreus@freelists.org")
1804 (to-list .
"atreus@freelists.org"))
1806 (to-address .
"deepspec@lists.cs.princeton.edu")
1807 (to-list .
"deepspec@lists.cs.princeton.edu")
1808 (list-identifier .
"\\[deepspec\\]"))
1810 (to-address .
"emacs-devel@gnu.org")
1811 (to-list .
"emacs-devel@gnu.org"))
1812 ("l\\.help-gnu-emacs"
1813 (to-address .
"help-gnu-emacs@gnu.org")
1814 (to-list .
"help-gnu-emacs@gnu.org"))
1815 ("l\\.info-gnu-emacs"
1816 (to-address .
"info-gnu-emacs@gnu.org")
1817 (to-list .
"info-gnu-emacs@gnu.org"))
1818 ("l\\.emacs-orgmode"
1819 (to-address .
"emacs-orgmode@gnu.org")
1820 (to-list .
"emacs-orgmode@gnu.org")
1821 (list-identifier .
"\\[O\\]"))
1822 ("l\\.emacs-tangents"
1823 (to-address .
"emacs-tangents@gnu.org")
1824 (to-list .
"emacs-tangents@gnu.org"))
1825 ("l\\.emacsconf-discuss"
1826 (to-address .
"emacsconf-discuss@gnu.org")
1827 (to-list .
"emacsconf-discuss@gnu.org"))
1828 ("l\\.emacsconf-register"
1829 (to-address .
"emacsconf-register@gnu.org")
1830 (to-list .
"emacsconf-register@gnu.org"))
1831 ("l\\.emacsconf-submit"
1832 (to-address .
"emacsconf-submit@gnu.org")
1833 (to-list .
"emacsconf-submit@gnu.org"))
1834 ("l\\.fencepost-users"
1835 (to-address .
"fencepost-users@gnu.org")
1836 (to-list .
"fencepost-users@gnu.org")
1837 (list-identifier .
"\\[Fencepost-users\\]"))
1838 ("l\\.gnewsense-art"
1839 (to-address .
"gnewsense-art@nongnu.org")
1840 (to-list .
"gnewsense-art@nongnu.org")
1841 (list-identifier .
"\\[gNewSense-art\\]"))
1842 ("l\\.gnewsense-dev"
1843 (to-address .
"gnewsense-dev@nongnu.org")
1844 (to-list .
"gnewsense-dev@nongnu.org")
1845 (list-identifier .
"\\[Gnewsense-dev\\]"))
1846 ("l\\.gnewsense-users"
1847 (to-address .
"gnewsense-users@nongnu.org")
1848 (to-list .
"gnewsense-users@nongnu.org")
1849 (list-identifier .
"\\[gNewSense-users\\]"))
1850 ("l\\.gnunet-developers"
1851 (to-address .
"gnunet-developers@gnu.org")
1852 (to-list .
"gnunet-developers@gnu.org")
1853 (list-identifier .
"\\[GNUnet-developers\\]"))
1855 (to-address .
"help-gnunet@gnu.org")
1856 (to-list .
"help-gnunet@gnu.org")
1857 (list-identifier .
"\\[Help-gnunet\\]"))
1859 (to-address .
"bug-gnuzilla@gnu.org")
1860 (to-list .
"bug-gnuzilla@gnu.org")
1861 (list-identifier .
"\\[Bug-gnuzilla\\]"))
1863 (to-address .
"gnuzilla-dev@gnu.org")
1864 (to-list .
"gnuzilla-dev@gnu.org")
1865 (list-identifier .
"\\[Gnuzilla-dev\\]"))
1867 (to-address .
"guile-devel@gnu.org")
1868 (to-list .
"guile-devel@gnu.org"))
1870 (to-address .
"guile-user@gnu.org")
1871 (to-list .
"guile-user@gnu.org"))
1873 (to-address .
"guix-devel@gnu.org")
1874 (to-list .
"guix-devel@gnu.org"))
1876 (to-address .
"help-guix@gnu.org")
1877 (to-list .
"help-guix@gnu.org"))
1879 (to-address .
"info-guix@gnu.org")
1880 (to-list .
"info-guix@gnu.org"))
1881 ("l\\.savannah-hackers-public"
1882 (to-address .
"savannah-hackers-public@gnu.org")
1883 (to-list .
"savannah-hackers-public@gnu.org"))
1884 ("l\\.savannah-users"
1885 (to-address .
"savannah-users@gnu.org")
1886 (to-list .
"savannah-users@gnu.org"))
1888 (to-address .
"www-commits@gnu.org")
1889 (to-list .
"www-commits@gnu.org"))
1891 (to-address .
"www-discuss@gnu.org")
1892 (to-list .
"www-discuss@gnu.org"))
1894 (to-address .
"haskell-art@we.lurk.org")
1895 (to-list .
"haskell-art@we.lurk.org")
1896 (list-identifier .
"\\[haskell-art\\]"))
1898 (to-address .
"haskell-cafe@haskell.org")
1899 (to-list .
"haskell-cafe@haskell.org")
1900 (list-identifier .
"\\[Haskell-cafe\\]"))
1902 (to-address .
"notmuch@notmuchmail.org")
1903 (to-list .
"notmuch@notmuchmail.org"))
1905 (to-address .
"dev@lists.parabola.nu")
1906 (to-list .
"dev@lists.parabola.nu")
1907 (list-identifier .
"\\[Dev\\]"))
1908 ("l\\.~bandali\\.public-inbox"
1909 (to-address .
"~bandali/public-inbox@lists.sr.ht")
1910 (to-list .
"~bandali/public-inbox@lists.sr.ht"))
1911 ("l\\.~sircmpwn\\.free-writers-club"
1912 (to-address .
"~sircmpwn/free-writers-club@lists.sr.ht")
1913 (to-list .
"~sircmpwn/free-writers-club@lists.sr.ht"))
1914 ("l\\.~sircmpwn\\.srht-admins"
1915 (to-address .
"~sircmpwn/sr.ht-admins@lists.sr.ht")
1916 (to-list .
"~sircmpwn/sr.ht-admins@lists.sr.ht"))
1917 ("l\\.~sircmpwn\\.srht-announce"
1918 (to-address .
"~sircmpwn/sr.ht-announce@lists.sr.ht")
1919 (to-list .
"~sircmpwn/sr.ht-announce@lists.sr.ht"))
1920 ("l\\.~sircmpwn\\.srht-dev"
1921 (to-address .
"~sircmpwn/sr.ht-dev@lists.sr.ht")
1922 (to-list .
"~sircmpwn/sr.ht-dev@lists.sr.ht"))
1923 ("l\\.~sircmpwn\\.srht-discuss"
1924 (to-address .
"~sircmpwn/sr.ht-discuss@lists.sr.ht")
1925 (to-list .
"~sircmpwn/sr.ht-discuss@lists.sr.ht"))
1927 (to-address .
"webmasters@gnu.org")
1928 (to-list .
"webmasters@gnu.org"))
1935 gnus-large-newsgroup
50
1936 gnus-home-directory
(b/var
"gnus/")
1937 gnus-directory
(concat gnus-home-directory
"news/")
1938 message-directory
(concat gnus-home-directory
"mail/")
1939 nndraft-directory
(concat gnus-home-directory
"drafts/")
1940 gnus-save-newsrc-file nil
1941 gnus-read-newsrc-file nil
1942 gnus-interactive-exit nil
1943 gnus-gcc-mark-as-read t
)
1947 (require 'ebdb-gnus
)
1949 (when (version< emacs-version
"27")
1951 'nnmail-split-abbrev-alist
1952 '(list .
"list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
1955 ;; (gnus-registry-initialize)
1957 (with-eval-after-load 'recentf
1958 (add-to-list 'recentf-exclude gnus-home-directory
)))
1960 (use-feature gnus-art
1963 gnus-buttonized-mime-types
'("multipart/\\(signed\\|encrypted\\)")
1964 gnus-visible-headers
1965 (concat gnus-visible-headers
"\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
1966 gnus-sorted-header-list
1967 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
1968 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
1969 "^Newsgroups:" "List-Id:" "^Organization:"
1970 "^User-Agent:" "^Date:")
1971 ;; local-lapsed article dates
1972 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1973 gnus-article-date-headers
'(user-defined)
1974 gnus-article-time-format
1976 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time
))
1977 (local (article-make-date-line date
'local
))
1978 (combined-lapsed (article-make-date-line date
1981 (string-match " (.+" combined-lapsed
)
1982 (match-string 0 combined-lapsed
))))
1983 (concat local lapsed
))))
1985 :map gnus-article-mode-map
1986 ("M-L" . org-store-link
)))
1988 (use-feature gnus-sum
1989 :bind
(:map gnus-summary-mode-map
1990 :prefix-map b
/gnus-summary-prefix-map
1992 ("r" . gnus-summary-reply
)
1993 ("w" . gnus-summary-wide-reply
)
1994 ("v" . gnus-summary-show-raw-article
))
1997 :map gnus-summary-mode-map
1998 ("M-L" . org-store-link
))
1999 :hook
(gnus-summary-mode . b
/no-mouse-autoselect-window
))
2001 (use-feature gnus-msg
2003 (defvar b
/signature
"Amin Bandali
2004 Free Software Activist | GNU Webmaster & Volunteer
2005 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
2006 https://shemshak.org/~amin")
2007 (defvar b
/gnu-signature
"Amin Bandali
2008 Free Software Activist | GNU Webmaster & Volunteer
2009 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
2010 https://bandali.eu.org")
2011 (defvar b
/uw-signature
"Amin Bandali, MMath Student
2012 Cheriton School of Computer Science
2013 University of Waterloo
2014 https://bandali.eu.org")
2015 (defvar b
/csc-signature
"Amin Bandali
2017 Computer Science Club, University of Waterloo
2018 https://csclub.uwaterloo.ca/~abandali")
2019 (setq gnus-posting-styles
2021 (address "amin@shemshak.org")
2023 (signature b
/signature
)
2024 (eval (setq b
/message-cite-say-hi t
)))
2026 (address "bandali@gnu.org")
2027 (signature b
/gnu-signature
)
2028 (eval (set (make-local-variable 'message-user-fqdn
) "fencepost.gnu.org")))
2029 ((header "subject" "ThankCRM")
2030 (to "webmasters-comment@gnu.org")
2032 (eval (setq b
/message-cite-say-hi nil
)))
2034 (address "abandali@uwaterloo.ca")
2035 (signature b
/uw-signature
))
2036 ("nnimap\\+uw:INBOX"
2037 (gcc "\"nnimap+uw:Sent Items\""))
2039 (address "abandali@csclub.uwaterloo.ca")
2040 (signature b
/csc-signature
)
2041 (gcc "nnimap+csc:Sent")))))
2043 (use-feature gnus-topic
2044 :hook
(gnus-group-mode . gnus-topic-mode
)
2045 :config
(setq gnus-topic-line-format
"%i[ %A: %(%{%n%}%) ]%v\n"))
2047 (use-feature gnus-agent
2049 (setq gnus-agent-synchronize-flags
'ask
)
2050 :hook
(gnus-group-mode . gnus-agent-mode
))
2052 (use-feature gnus-group
2054 (setq gnus-permanently-visible-groups
"\\(:INBOX$\\|:gnu$\\)"))
2057 ;; problematic with ebdb's popup, *EBDB-Gnus*
2058 (use-feature gnus-win
2060 (setq gnus-use-full-window nil
)))
2062 (use-feature gnus-dired
2063 :commands gnus-dired-mode
2065 (add-hook 'dired-mode-hook
'gnus-dired-mode
))
2067 (use-feature mm-decode
2069 (setq mm-discouraged-alternatives
'("text/html" "text/richtext")
2070 mm-decrypt-option
'known
2071 mm-verify-option
'known
))
2073 (use-feature sendmail
2075 (setq sendmail-program
(executable-find "msmtp")
2076 ;; message-sendmail-extra-arguments '("-v" "-d")
2077 mail-specify-envelope-from t
2078 mail-envelope-from
'header
))
2080 (use-feature message
2082 ;; redefine for a simplified In-Reply-To header
2083 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2084 (defun message-make-in-reply-to ()
2085 "Return the In-Reply-To header for this message."
2086 (when message-reply-headers
2087 (let ((from (mail-header-from message-reply-headers
))
2088 (msg-id (mail-header-id message-reply-headers
)))
2092 (defconst b
/message-cite-style-format
"On %Y-%m-%d %l:%M %p, %N wrote:")
2093 (defconst message-cite-style-bandali
2094 '((message-cite-function 'message-cite-original
)
2095 (message-citation-line-function 'message-insert-formatted-citation-line
)
2096 (message-cite-reply-position 'traditional
)
2097 (message-yank-prefix "> ")
2098 (message-yank-cited-prefix ">")
2099 (message-yank-empty-prefix ">")
2100 (message-citation-line-format
2101 (if b
/message-cite-say-hi
2102 (concat "Hi %F,\n\n" b
/message-cite-style-format
)
2103 b
/message-cite-style-format
)))
2104 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2105 (setq ;; message-cite-style 'message-cite-style-bandali
2106 message-kill-buffer-on-exit t
2107 message-send-mail-function
'message-send-mail-with-sendmail
2108 message-sendmail-envelope-from
'header
2109 message-subscribed-address-functions
2110 '(gnus-find-subscribed-addresses)
2111 message-dont-reply-to-names
2112 "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(amin@bndl\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)")
2113 (require 'company-ebdb
)
2114 :hook
(;; (message-setup . mml-secure-message-sign-pgpmime)
2115 (message-mode . flyspell-mode
)
2116 (message-mode .
(lambda ()
2117 ;; (setq fill-column 65
2118 ;; message-fill-column 65)
2119 (make-local-variable 'company-idle-delay
)
2120 (setq company-idle-delay
0.2))))
2122 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2123 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2124 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2130 (use-feature mml-sec
2132 (mml-secure-openpgp-encrypt-to-self t
)
2133 (mml-secure-openpgp-sign-with-sender t
))
2135 (use-feature footnote
2138 ;; (setq footnote-start-tag ""
2139 ;; footnote-end-tag ""
2140 ;; footnote-style 'unicode)
2142 (:map message-mode-map
2143 :prefix-map b
/footnote-prefix-map
2145 ("a" . footnote-add-footnote
)
2146 ("b" . footnote-back-to-message
)
2147 ("c" . footnote-cycle-style
)
2148 ("d" . footnote-delete-footnote
)
2149 ("g" . footnote-goto-footnote
)
2150 ("r" . footnote-renumber-footnotes
)
2151 ("s" . footnote-set-style
)))
2155 :bind
(:map gnus-group-mode-map
("e" . ebdb
))
2157 (setq ebdb-sources
(b/var
"ebdb"))
2158 (with-eval-after-load 'swiper
2159 (add-to-list 'swiper-font-lock-exclude
'ebdb-mode t
)))
2161 (use-feature ebdb-com
2164 ;; (use-package ebdb-complete
2167 ;; (ebdb-complete-enable))
2169 (use-package company-ebdb
2171 (defun company-ebdb--post-complete (_) nil
))
2173 (use-feature ebdb-gnus
2176 (ebdb-gnus-window-configuration
2179 (summary 0.25 point
)
2182 (ebdb-gnus 0.3))))))
2184 (use-feature ebdb-mua
2186 ;; :custom (ebdb-mua-pop-up nil)
2189 ;; (use-package ebdb-message
2192 ;; (use-package ebdb-vcard
2195 (use-package message-x
)
2198 (use-package message-x
2200 (message-x-completion-alist
2202 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address
)
2205 (quote message-newgroups-header-regexp
))
2206 message-newgroups-header-regexp message-newsgroups-header-regexp
)
2207 . message-expand-group
))))))
2210 (use-package gnus-harvest
2211 :commands gnus-harvest-install
2214 (if (featurep 'message-x
)
2215 (gnus-harvest-install 'message-x
)
2216 (gnus-harvest-install))))
2219 ;;; IRC (with ERC and ZNC)
2222 :bind
(("C-c b e" . erc-switch-to-buffer
)
2224 ("M-a" . erc-track-switch-buffer
))
2226 (erc-join-buffer 'bury
)
2227 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2228 (erc-nick "bandali")
2230 (erc-rename-buffers t
)
2231 (erc-server-reconnect-attempts 5)
2232 (erc-server-reconnect-timeout 3)
2234 (defun erc-cmd-OPME ()
2235 "Request chanserv to op me."
2236 (erc-message "PRIVMSG"
2237 (format "chanserv op %s %s"
2238 (erc-default-target)
2239 (erc-current-nick)) nil
))
2240 (defun erc-cmd-DEOPME ()
2241 "Deop myself from current channel."
2242 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2243 (add-to-list 'erc-modules
'keep-place
)
2244 (add-to-list 'erc-modules
'notifications
)
2245 (add-to-list 'erc-modules
'spelling
)
2246 (add-to-list 'erc-modules
'scrolltoplace
)
2247 (erc-update-modules)
2249 (when (and (version<= "24.4" emacs-version
)
2250 (version< emacs-version
"27"))
2251 ;; fix erc-lurker bug
2252 ;; patch submitted: https://bugs.gnu.org/36843#10
2253 ;; TODO: remove when patch is merged and emacs 27 is released
2254 (defvar erc-message-parsed
)
2255 (defun erc-display-message (parsed type buffer msg
&rest args
)
2256 "Display MSG in BUFFER.
2258 ARGS, PARSED, and TYPE are used to format MSG sensibly.
2260 See also `erc-format-message' and `erc-display-line'."
2261 (let ((string (if (symbolp msg
)
2262 (apply #'erc-format-message msg args
)
2264 (erc-message-parsed parsed
))
2270 (mapc (lambda (type)
2272 (erc-display-message-highlight type string
)))
2276 (erc-display-message-highlight type string
))))
2278 (if (not (erc-response-p parsed
))
2279 (erc-display-line string buffer
)
2280 (unless (erc-hide-current-message-p parsed
)
2281 (erc-put-text-property 0 (length string
) 'erc-parsed parsed string
)
2282 (erc-put-text-property 0 (length string
) 'rear-sticky t string
)
2283 (when (erc-response.tags parsed
)
2284 (erc-put-text-property 0 (length string
) 'tags
(erc-response.tags parsed
)
2286 (erc-display-line string buffer
)))))
2288 (defun erc-lurker-update-status (_message)
2289 "Update `erc-lurker-state' if necessary.
2291 This function is called from `erc-insert-pre-hook'. If the
2292 current message is a PRIVMSG, update `erc-lurker-state' to
2293 reflect the fact that its sender has issued a PRIVMSG at the
2294 current time. Otherwise, take no action.
2296 This function depends on the fact that `erc-display-message'
2297 lexically binds `erc-message-parsed', which is used to check if
2298 the current message is a PRIVMSG and to determine its sender.
2299 See also `erc-lurker-trim-nicks' and `erc-lurker-ignore-chars'.
2301 In order to limit memory consumption, this function also calls
2302 `erc-lurker-cleanup' once every `erc-lurker-cleanup-interval'
2303 updates of `erc-lurker-state'."
2304 (when (and (boundp 'erc-message-parsed
)
2305 (erc-response-p erc-message-parsed
))
2306 (let* ((command (erc-response.command erc-message-parsed
))
2308 (erc-lurker-maybe-trim
2309 (car (erc-parse-user (erc-response.sender erc-message-parsed
)))))
2311 (erc-canonicalize-server-name erc-server-announced-name
)))
2312 (when (equal command
"PRIVMSG")
2313 (when (>= (cl-incf erc-lurker-cleanup-count
)
2314 erc-lurker-cleanup-interval
)
2315 (setq erc-lurker-cleanup-count
0)
2316 (erc-lurker-cleanup))
2317 (unless (gethash server erc-lurker-state
)
2318 (puthash server
(make-hash-table :test
'equal
) erc-lurker-state
))
2319 (puthash sender
(current-time)
2320 (gethash server erc-lurker-state
))))))))
2322 (use-feature erc-fill
2325 (erc-fill-column 77)
2326 (erc-fill-function 'erc-fill-static
)
2327 (erc-fill-static-center 18))
2329 (use-feature erc-pcomplete
2332 (erc-pcomplete-nick-postfix ","))
2334 (use-feature erc-track
2336 :bind
(("C-c a e t d" . erc-track-disable
)
2337 ("C-c a e t e" . erc-track-enable
))
2339 (erc-track-enable-keybindings nil
)
2340 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2341 "324" "329" "332" "333" "353" "477"))
2342 (erc-track-priority-faces-only 'all
)
2343 (erc-track-shorten-function nil
))
2345 (use-package erc-hl-nicks
2348 (use-package erc-scrolltoplace
2352 :straight
(:host nil
:repo
"https://git.shemshak.org/amin/znc.el")
2353 :bind
(("C-c a e e" . znc-erc
)
2354 ("C-c a e a" . znc-all
))
2356 (let ((pwd (let ((auth (auth-source-search :host
"znca")))
2358 ((null auth
) (error "Couldn't find znca's authinfo"))
2359 (t (funcall (plist-get (car auth
) :secret
)))))))
2361 `(("znc.shemshak.org" 1337 t
2362 ((freenode "amin/freenode" ,pwd
)))
2363 ("znc.shemshak.org" 1337 t
2364 ((moznet "amin/moznet" ,pwd
)))
2365 ("znc.shemshak.org" 1337 t
2366 ((oftc "amin/oftc" ,pwd
)))))))
2369 ;;; Post initialization
2371 (message "Loading %s...done (%.3fs)" user-init-file
2372 (float-time (time-subtract (current-time)
2373 b
/before-user-init-time
)))
2375 ;;; init.el ends here