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 (use-feature epg-config
309 ((epg-gpg-program (executable-find "gpg"))))
318 (defmacro b
/setq-every
(value &rest vars
)
319 "Set all the variables from VARS to value VALUE."
320 (declare (indent defun
) (debug t
))
321 `(progn ,@(mapcar (lambda (x) (list 'setq x value
)) vars
)))
323 (defun b/start-process
(program &rest args
)
324 "Same as `start-process', but doesn't bother about name and buffer."
325 (let ((process-name (concat program
"_process"))
326 (buffer-name (generate-new-buffer-name
327 (concat program
"_output"))))
328 (apply #'start-process
329 process-name buffer-name program args
)))
331 (defun b/dired-start-process
(program &optional args
)
332 "Open current file with a PROGRAM."
333 ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can
334 ;; be nil, so remove it).
335 (apply #'b
/start-process
337 (remove nil
(list args
(dired-get-file-for-visit)))))
339 (defun b/add-elisp-section
()
343 (insert "\n\f\n;;; "))
348 ;; time and battery in mode-line
352 (setq display-time-default-load-average nil
)
358 (display-battery-mode)))
361 ;; (fringe-mode '(3 . 1))
364 ;; disable disabled commands
365 (setq disabled-command-function nil
)
367 ;; Save what I copy into clipboard from other applications into Emacs'
368 ;; kill-ring, which would allow me to still be able to easily access
369 ;; it in case I kill (cut or copy) something else inside Emacs before
370 ;; yanking (pasting) what I'd originally intended to.
371 (setq save-interprogram-paste-before-kill t
)
374 (setq enable-recursive-minibuffers t
375 resize-mini-windows t
)
377 ;; lazy-person-friendly yes/no prompts
378 (defalias 'yes-or-no-p
#'y-or-n-p
)
380 ;; i want *scratch* as my startup buffer
381 (setq initial-buffer-choice t
)
383 ;; i don't need the default hint
384 (setq initial-scratch-message nil
)
386 ;; use customizable text-mode as major mode for *scratch*
387 (setq initial-major-mode
'text-mode
)
389 ;; inhibit buffer list when more than 2 files are loaded
390 (setq inhibit-startup-buffer-menu t
)
392 ;; don't need to see the startup screen or the echo area message
393 (advice-add #'display-startup-echo-area-message
:override
#'ignore
)
394 (setq inhibit-startup-screen t
395 inhibit-startup-echo-area-message user-login-name
)
397 ;; more useful frame titles
398 (setq frame-title-format
399 '("" invocation-name
" - "
400 (:eval
(if (buffer-file-name)
401 (abbreviate-file-name (buffer-file-name))
404 ;; backups (C-h v make-backup-files RET)
405 (setq backup-by-copying t
406 backup-directory-alist
(list (cons "." (b/var
"backup/")))
408 delete-old-versions t
)
410 ;; enable automatic reloading of changed buffers and files
411 (global-auto-revert-mode 1)
412 (setq auto-revert-verbose nil
413 global-auto-revert-non-file-buffers nil
)
415 ;; always use space for indentation
418 require-final-newline t
421 ;; enable winner-mode (C-h f winner-mode RET)
424 ;; don't display *compilation* buffer on success. based on
425 ;; https://stackoverflow.com/a/17788551, with changes to use `cl-letf'
426 ;; instead of the now obsolete `flet'.
427 (with-eval-after-load 'compile
428 (defun b/compilation-finish-function
(buffer outstr
)
429 (unless (string-match "finished" outstr
)
430 (switch-to-buffer-other-window buffer
))
433 (setq compilation-finish-functions
#'b
/compilation-finish-function
)
437 (defadvice compilation-start
438 (around inhibit-display
439 (command &optional mode name-function highlight-regexp
))
440 (if (not (string-match "^\\(find\\|grep\\)" command
))
441 (cl-letf (((symbol-function 'display-buffer
) #'ignore
))
442 (save-window-excursion ad-do-it
))
444 (ad-activate 'compilation-start
))
446 ;; search for non-ASCII characters: i’d like non-ASCII characters such
447 ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII
448 ;; counterpart. shoutout to
449 ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html
450 (setq search-default-mode
#'char-fold-to-regexp
)
451 ;; uncomment to extend this behaviour to query-replace
452 ;; (setq replace-char-fold t)
455 (setq-default cursor-type
'bar
)
457 ;; allow scrolling in Isearch
458 (setq isearch-allow-scroll t
)
460 ;; open read-only file buffers in view-mode
461 ;; (enables niceties like `q' for quit)
462 (setq view-read-only t
)
465 :bind
("C-x v C-=" . vc-ediff
))
468 :config
(add-hook 'ediff-after-quit-hook-internal
'winner-undo
)
469 :custom
((ediff-window-setup-function 'ediff-setup-windows-plain
)
470 (ediff-split-window-function 'split-window-horizontally
)))
472 ;; i don't feel like jumping out of my chair every now and again; so
473 ;; don't BEEP! at me, emacs
474 (setq ring-bell-function
'ignore
)
482 ("C-c e b" . eval-buffer
)
483 ("C-c e e" . eval-last-sexp
)
484 ("C-c e r" . eval-region
)
486 ("C-c e i" . emacs-init-time
)
487 ("C-c e u" . emacs-uptime
)
488 ("C-c e v" . emacs-version
)
490 ("C-c F m" . make-frame-command
)
491 ("C-c F d" . delete-frame
)
492 ("C-c F D" . server-edit
)
494 ("C-S-h C" . describe-char
)
495 ("C-S-h F" . describe-face
)
497 ("C-x k" . kill-this-buffer
)
498 ("C-x K" . kill-buffer
)
499 ("C-x s" . save-buffer
)
500 ("C-x S" . save-some-buffers
)
502 :map emacs-lisp-mode-map
503 ("<C-return>" . b
/add-elisp-section
))
505 (when (display-graphic-p)
506 (unbind-key "C-z" global-map
))
509 ;; for back and forward mouse keys
510 ("<mouse-8>" . previous-buffer
)
511 ("<drag-mouse-8>" . previous-buffer
)
512 ("<mouse-9>" . next-buffer
)
513 ("<drag-mouse-9>" . next-buffer
)
514 ("<drag-mouse-2>" . kill-this-buffer
)
515 ("<drag-mouse-3>" . ivy-switch-buffer
))
518 :prefix-map mab
/straight-prefix-map
520 ("u" . straight-use-package
)
521 ("f" . straight-freeze-versions
)
522 ("t" . straight-thaw-versions
)
523 ("P" . straight-prune-build
)
524 ("g" . straight-get-recipe
)
525 ("r" . mab
/reload-init
)
526 ;; M-x ^straight-.*-all$
527 ("a c" . straight-check-all
)
528 ("a f" . straight-fetch-all
)
529 ("a m" . straight-merge-all
)
530 ("a n" . straight-normalize-all
)
531 ("a F" . straight-pull-all
)
532 ("a P" . straight-push-all
)
533 ("a r" . straight-rebuild-all
)
534 ;; M-x ^straight-.*-package$
535 ("p c" . straight-check-package
)
536 ("p f" . straight-fetch-package
)
537 ("p m" . straight-merge-package
)
538 ("p n" . straight-normalize-package
)
539 ("p F" . straight-pull-package
)
540 ("p P" . straight-push-package
)
541 ("p r" . straight-rebuild-package
))
544 ;;; Essential packages
546 ;; use the org-plus-contrib package to get the whole deal
547 (use-package org-plus-contrib
)
552 (setq org-src-tab-acts-natively t
553 org-src-preserve-indentation nil
554 org-edit-src-content-indentation
0
555 org-link-email-description-format
"Email %c: %s" ; %.30s
556 org-highlight-latex-and-related
'(entities)
557 org-use-speed-commands t
558 org-startup-folded
'content
559 org-catch-invisible-edits
'show-and-error
561 (when (version< org-version
"9.3")
562 (setq org-email-link-description-format
563 org-link-email-description-format
))
564 (add-to-list 'org-structure-template-alist
'("L" .
"src emacs-lisp") t
)
565 (add-to-list 'org-modules
'org-habit
)
567 (("C-c a o a" . org-agenda
)
569 ("M-L" . org-insert-last-stored-link
)
570 ("M-O" . org-toggle-link-display
))
571 :hook
((org-mode . org-indent-mode
)
572 (org-mode . auto-fill-mode
)
573 (org-mode . flyspell-mode
))
575 (org-pretty-entities t
)
576 (org-agenda-files '("~/usr/org/todos/personal.org"
577 "~/usr/org/todos/habits.org"
578 "~/src/git/masters-thesis/todo.org"))
579 (org-agenda-start-on-weekday 0)
580 (org-agenda-time-leading-zero t
)
581 (org-habit-graph-column 44)
582 (org-latex-packages-alist '(("" "listings") ("" "color")))
584 '(org-block-begin-line ((t (:foreground
"#5a5b5a" :background
"#1d1f21"))))
585 '(org-block ((t (:background
"#1d1f21"))))
586 '(org-latex-and-related ((t (:foreground
"#b294bb")))))
588 (use-feature ox-latex
591 (setq org-latex-listings
'listings
592 ;; org-latex-prefer-user-labels t
594 (add-to-list 'org-latex-classes
595 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
596 ("\\section{%s}" .
"\\section*{%s}")
597 ("\\subsection{%s}" .
"\\subsection*{%s}")
598 ("\\subsubsection{%s}" .
"\\subsubsection*{%s}")
599 ("\\paragraph{%s}" .
"\\paragraph*{%s}")
600 ("\\subparagraph{%s}" .
"\\subparagraph*{%s}"))
602 (require 'ox-beamer
))
604 (use-feature ox-extra
606 (ox-extras-activate '(latex-header-blocks ignore-headlines
)))
608 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
609 ;; org file. closely inspired by
610 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
611 (with-eval-after-load 'org
612 (defvar b
/show-async-tangle-results nil
613 "Keep *emacs* async buffers around for later inspection.")
615 (defvar b
/show-async-tangle-time nil
616 "Show the time spent tangling the file.")
618 (defun b/async-babel-tangle
()
619 "Tangle org file asynchronously."
621 (let* ((file-tangle-start-time (current-time))
622 (file (buffer-file-name))
623 (file-nodir (file-name-nondirectory file
))
624 ;; (async-quiet-switch "-q")
625 (file-noext (file-name-sans-extension file
)))
629 (org-babel-tangle-file ,file
))
630 (unless b
/show-async-tangle-results
633 (message "Tangled %s%s"
635 (if b
/show-async-tangle-time
637 (float-time (time-subtract (current-time)
638 ',file-tangle-start-time
)))
640 (message "Tangling %s failed" ,file-nodir
))))))))
643 'safe-local-variable-values
644 '(eval add-hook
'after-save-hook
#'b
/async-babel-tangle
'append
'local
))
646 ;; *the* right way to do git
649 :bind
(("C-x g" . magit-status
)
650 ("C-c g g" . magit-status
)
651 ("C-c g b" . magit-blame-addition
)
652 ("C-c g l" . magit-log-buffer-file
))
654 (magit-add-section-hook 'magit-status-sections-hook
655 'magit-insert-modules
656 'magit-insert-stashes
658 ;; (magit-add-section-hook 'magit-status-sections-hook
659 ;; 'magit-insert-ignored-files
660 ;; 'magit-insert-untracked-files
662 (setq magit-repository-directories
'(("~/" .
0)
664 (nconc magit-section-initial-visibility-alist
665 '(([unpulled status
] . show
)
666 ([unpushed status
] . show
)))
667 (setq transient-history-file
(b/var
"transient/history.el")
668 transient-levels-file
(b/etc
"transient/levels.el")
669 transient-values-file
(b/etc
"transient/values.el"))
670 :custom
(magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1
)
671 :custom-face
(magit-diff-file-heading ((t (:weight normal
)))))
673 ;; recently opened files
677 ;; (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
679 (recentf-max-saved-items 2000)
680 (recentf-save-file (b/var
"recentf-save.el")))
682 ;; smart M-x enhancement (needed by counsel for history)
685 (setq smex-save-file
(b/var
"smex-save.el")))
691 (:map ivy-minibuffer-map
692 ([escape] . keyboard-escape-quit)
693 ([S-up] . ivy-previous-history-element)
694 ([S-down] . ivy-next-history-element)
695 ("DEL" . ivy-backward-delete-char))
699 ivy-use-virtual-buffers t
700 ivy-virtual-abbreviate 'abbreviate
701 ivy-count-format "%d/%d ")
703 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
704 (defun b/ivy-ignore-buffer-p (str)
705 "Return non-nil if str names a buffer with a major mode
706 derived from one of `b/ivy-ignore-buffer-modes'.
708 This function is intended for use with `ivy-ignore-buffers'."
709 (let* ((buf (get-buffer str))
710 (mode (and buf (buffer-local-value 'major-mode buf))))
712 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
713 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
717 ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
718 ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
719 ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
724 :bind (("C-s" . swiper-isearch)
726 ("C-S-s" . isearch-forward)))
731 :bind (([remap execute-extended-command] . counsel-M-x)
732 ([remap find-file] . counsel-find-file)
733 ("C-c b b" . ivy-switch-buffer)
734 ("C-c f ." . counsel-find-file)
735 ("C-c f l" . counsel-find-library)
736 ("C-c f r" . counsel-recentf)
737 ("C-c x" . counsel-M-x)
738 :map minibuffer-local-map
739 ("C-r" . counsel-minibuffer-history))
742 (defalias 'locate #'counsel-locate))
746 :commands (helm-M-x helm-mini helm-resume)
747 :bind (("M-x" . helm-M-x)
748 ("M-y" . helm-show-kill-ring)
749 ("C-x b" . helm-mini)
750 ("C-x C-b" . helm-buffers-list)
751 ("C-x C-f" . helm-find-files)
752 ("C-h r" . helm-info-emacs)
753 ("C-s-r" . helm-resume)
755 ("<tab>" . helm-execute-persistent-action)
756 ("C-i" . helm-execute-persistent-action) ; Make TAB work in terminals
757 ("C-z" . helm-select-action)) ; List actions
758 :config (helm-mode 1)))
763 :bind ("C-c a s e" . eshell)
765 (eval-when-compile (defvar eshell-prompt-regexp))
766 (defun b/eshell-quit-or-delete-char (arg)
768 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
769 (eshell-life-is-too-much)
772 (defun b/eshell-clear ()
774 (let ((inhibit-read-only t))
778 (defun b/eshell-setup ()
779 (make-local-variable 'company-idle-delay)
780 (defvar company-idle-delay)
781 (setq company-idle-delay nil)
782 (bind-keys :map eshell-mode-map
783 ("C-d" . b/eshell-quit-or-delete-char)
784 ("C-S-l" . b/eshell-clear)
785 ("M-r" . counsel-esh-history)
786 ([tab] . company-complete)))
788 :hook (eshell-mode . b/eshell-setup)
790 (eshell-directory-name (b/var "eshell/"))
791 (eshell-hist-ignoredups t)
792 (eshell-input-filter 'eshell-input-filter-initial-space))
796 (("C-x C-b" . ibuffer)
797 :map ibuffer-mode-map
798 ("P" . ibuffer-backward-filter-group)
799 ("N" . ibuffer-forward-filter-group)
800 ("M-p" . ibuffer-do-print)
801 ("M-n" . ibuffer-do-shell-command-pipe-replace))
803 ;; Use human readable Size column instead of original one
804 (define-ibuffer-column size-h
805 (:name "Size" :inline t)
807 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
808 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
809 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
810 (t (format "%8d" (buffer-size)))))
812 (ibuffer-saved-filter-groups
814 ("dired" (mode . dired-mode))
815 ("org" (mode . org-mode))
818 (mode . gnus-group-mode)
819 (mode . gnus-summary-mode)
820 (mode . gnus-article-mode)
821 ;; not really, but...
822 (mode . message-mode)))
840 (mode . emacs-lisp-mode)
842 (mode . haskell-mode)
845 (mode . alloy-mode)))
849 (mode . latex-mode)))
852 (name . "^\\*scratch\\*$")
853 (name . "^\\*Messages\\*$")))
854 ("erc" (mode . erc-mode)))))
856 '((mark modified read-only locked " "
857 (name 18 18 :left :elide)
861 (mode 16 16 :left :elide)
862 " " filename-and-process)
866 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
870 :hook (prog-mode . outline-minor-mode)
871 :delight (outline-minor-mode " outl")
874 outline-minor-mode-map
875 ("<s-tab>" . outline-toggle-children)
876 ("M-p" . outline-previous-visible-heading)
877 ("M-n" . outline-next-visible-heading)
878 :prefix-map b/outline-prefix-map
880 ("TAB" . outline-toggle-children)
881 ("a" . outline-hide-body)
882 ("H" . outline-hide-body)
883 ("S" . outline-show-all)
884 ("h" . outline-hide-subtree)
885 ("s" . outline-show-subtree)))
888 :custom (ls-lisp-dirs-first t))
892 (setq dired-listing-switches "-alh"
893 ls-lisp-use-insert-directory-program nil)
895 ;; easily diff 2 marked files
896 ;; https://oremacs.com/2017/03/18/dired-ediff/
897 (defun dired-ediff-files ()
900 (defvar ediff-after-quit-hook-internal)
901 (let ((files (dired-get-marked-files))
902 (wnd (current-window-configuration)))
903 (if (<= (length files) 2)
904 (let ((file1 (car files))
905 (file2 (if (cdr files)
909 (dired-dwim-target-directory)))))
910 (if (file-newer-than-file-p file1 file2)
911 (ediff-files file2 file1)
912 (ediff-files file1 file2))
913 (add-hook 'ediff-after-quit-hook-internal
915 (setq ediff-after-quit-hook-internal nil)
916 (set-window-configuration wnd))))
917 (error "no more than 2 files should be marked"))))
920 (setq dired-guess-shell-alist-user
921 '(("\\.pdf\\'" "evince" "zathura" "okular")
922 ("\\.doc\\'" "libreoffice")
923 ("\\.docx\\'" "libreoffice")
924 ("\\.ppt\\'" "libreoffice")
925 ("\\.pptx\\'" "libreoffice")
926 ("\\.xls\\'" "libreoffice")
927 ("\\.xlsx\\'" "libreoffice")
928 ("\\.flac\\'" "mpv")))
929 :bind (:map dired-mode-map
930 ("b" . dired-up-directory)
931 ("e" . dired-ediff-files)
932 ("E" . dired-toggle-read-only)
933 ("\\" . dired-hide-details-mode)
936 (b/dired-start-process "zathura"))))
937 :hook (dired-mode . dired-hide-details-mode))
941 (temp-buffer-resize-mode)
942 (setq help-window-select t))
946 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
947 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
948 (add-to-list 'tramp-default-proxies-alist
949 (list (regexp-quote (system-name)) nil nil)))
952 :config (dash-enable-font-lock))
954 (use-feature doc-view
955 :bind (:map doc-view-mode-map
956 ("M-RET" . image-previous-line)))
961 ;; highlight uncommitted changes in the left fringe
965 (setq diff-hl-draw-borders nil)
966 (global-diff-hl-mode)
967 :hook (magit-post-refresh . diff-hl-magit-post-refresh))
969 ;; display Lisp objects at point in the echo area
971 :when (version< "25" emacs-version)
973 :config (global-eldoc-mode))
975 ;; highlight matching parens
978 :config (show-paren-mode))
980 (use-feature elec-pair
982 :config (electric-pair-mode))
985 :delight (auto-fill-function " fill")
986 :config (column-number-mode))
988 ;; save minibuffer history
989 (use-feature savehist
993 (savehist-file (b/var "savehist.el")))
995 ;; automatically save place in files
996 (use-feature saveplace
997 :when (version< "25" emacs-version)
998 :config (save-place-mode)
1000 (save-place-file (b/var "save-place.el")))
1002 (use-feature prog-mode
1003 :config (global-prettify-symbols-mode)
1004 (defun indicate-buffer-boundaries-left ()
1005 (setq indicate-buffer-boundaries 'left))
1006 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1008 (use-feature text-mode
1009 :hook (text-mode . indicate-buffer-boundaries-left))
1011 (use-feature conf-mode
1014 (use-feature sh-mode
1017 (use-package company
1021 (:map company-active-map
1022 ([tab] . company-complete-common-or-cycle)
1023 ([escape] . company-abort
))
1025 (company-minimum-prefix-length 1)
1026 (company-selection-wrap-around t
)
1027 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1028 (company-dabbrev-downcase nil
)
1029 (company-dabbrev-ignore-case nil
)
1031 (global-company-mode t
))
1033 (use-package flycheck
1035 :hook
(prog-mode . flycheck-mode
)
1037 (:map flycheck-mode-map
1038 ("M-P" . flycheck-previous-error
)
1039 ("M-N" . flycheck-next-error
))
1041 ;; Use the load-path from running Emacs when checking elisp files
1042 (setq flycheck-emacs-lisp-load-path
'inherit
)
1044 ;; Only flycheck when I actually save the buffer
1045 (setq flycheck-check-syntax-automatically
'(mode-enabled save
))
1046 :custom
(flycheck-mode-line-prefix "flyc"))
1048 (use-feature flyspell
1051 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1055 ;; ’ can be part of a word
1056 (setq ispell-local-dictionary-alist
1057 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1058 "['\x2019]" nil
("-B") nil utf-8
))
1059 ispell-program-name
(executable-find "hunspell"))
1060 ;; don't send ’ to the subprocess
1061 (defun endless/replace-apostrophe
(args)
1062 (cons (replace-regexp-in-string
1065 (advice-add #'ispell-send-string
:filter-args
1066 #'endless
/replace-apostrophe
)
1068 ;; convert ' back to ’ from the subprocess
1069 (defun endless/replace-quote
(args)
1070 (if (not (derived-mode-p 'org-mode
))
1072 (cons (replace-regexp-in-string
1075 (advice-add #'ispell-parse-output
:filter-args
1076 #'endless
/replace-quote
))
1080 :hook
(text-mode . abbrev-mode
)
1082 (abbrev-file-name (b/var
"abbrev.el")))
1085 ;;; Programming modes
1087 (use-feature lisp-mode
1089 (defun indent-spaces-mode ()
1090 (setq indent-tabs-mode nil
))
1091 (add-hook 'lisp-interaction-mode-hook
#'indent-spaces-mode
))
1094 :delight
(reveal-mode " reveal")
1095 :hook
(emacs-lisp-mode . reveal-mode
))
1097 (use-feature elisp-mode
1098 :delight
(emacs-lisp-mode "Elisp" :major
))
1101 (use-package alloy-mode
1102 :straight
(:host github
:repo
"dwwmmn/alloy-mode")
1104 :config
(setq alloy-basic-offset
2))
1106 (eval-when-compile (defvar lean-mode-map
))
1107 (use-package lean-mode
1108 :straight
(:host github
:repo
"leanprover/lean-mode"
1109 :fork
(:repo
"notbandali/lean-mode" :branch
"remove-cl"))
1111 :bind
(:map lean-mode-map
1112 ("S-SPC" . company-complete
))
1114 (require 'lean-input
)
1115 (setq default-input-method
"Lean"
1116 lean-input-tweak-all
'(lean-input-compose
1117 (lean-input-prepend "/")
1118 (lean-input-nonempty))
1119 lean-input-user-translations
'(("/" "/")))
1123 (use-package proof-site
; for Coq
1124 :straight proof-general
)
1126 (use-package haskell-mode
1128 (setq haskell-indentation-layout-offset
4
1129 haskell-indentation-left-offset
4
1130 flycheck-checker
'haskell-hlint
1131 flycheck-disabled-checkers
'(haskell-stack-ghc haskell-ghc
)))
1135 :commands dante-mode
1136 :hook
(haskell-mode . dante-mode
))
1138 (use-package hlint-refactor
1140 :bind
(:map hlint-refactor-mode-map
1141 ("C-c l b" . hlint-refactor-refactor-buffer
)
1142 ("C-c l r" . hlint-refactor-refactor-at-point
))
1143 :hook
(haskell-mode . hlint-refactor-mode
))
1145 (use-package flycheck-haskell
1146 :after haskell-mode
)
1147 ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el
1150 (use-feature sgml-mode
1152 (setq sgml-basic-offset
2))
1154 (use-feature css-mode
1156 (setq css-indent-offset
2))
1158 (use-package web-mode
1162 web-mode-code-indent-offset
1163 web-mode-css-indent-offset
1164 web-mode-markup-indent-offset
))
1166 (use-package emmet-mode
1167 :after
(:any web-mode css-mode sgml-mode
)
1168 :bind
* (("C-)" . emmet-next-edit-point
)
1169 ("C-(" . emmet-prev-edit-point
))
1171 (unbind-key "C-j" emmet-mode-keymap
)
1172 (setq emmet-move-cursor-between-quotes t
)
1173 :hook
(web-mode css-mode html-mode sgml-mode
))
1176 (use-package meghanada
1178 (:map meghanada-mode-map
1179 (("C-M-o" . meghanada-optimize-import
)
1180 ("C-M-t" . meghanada-import-all
)))
1181 :hook
(java-mode . meghanada-mode
)))
1184 (use-package treemacs
1185 :config
(setq treemacs-never-persist t
))
1187 (use-package yasnippet
1189 ;; (yas-global-mode)
1192 (use-package lsp-mode
1193 :init
(setq lsp-eldoc-render-all nil
1194 lsp-highlight-symbol-at-point nil
)
1199 (use-package company-lsp
1202 (setq company-lsp-cache-candidates t
1203 company-lsp-async t
))
1207 (setq lsp-ui-sideline-update-mode
'point
))
1209 (use-package lsp-java
1211 (add-hook 'java-mode-hook
1213 (setq-local company-backends
(list 'company-lsp
))))
1215 (add-hook 'java-mode-hook
'lsp-java-enable
)
1216 (add-hook 'java-mode-hook
'flycheck-mode
)
1217 (add-hook 'java-mode-hook
'company-mode
)
1218 (add-hook 'java-mode-hook
'lsp-ui-mode
))
1220 (use-package dap-mode
1226 (use-package dap-java
1229 (use-package lsp-java-treemacs
1234 :bind
(:map eclim-mode-map
("S-SPC" . company-complete
))
1235 :hook
((java-mode . eclim-mode
)
1236 (eclim-mode .
(lambda ()
1237 (make-local-variable 'company-idle-delay
)
1238 (defvar company-idle-delay
)
1239 ;; (setq company-idle-delay 0.7)
1240 (setq company-idle-delay nil
))))
1242 (eclim-auto-save nil
)
1243 ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp")
1244 (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim")
1245 (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse"))))
1249 (make-directory (b/var
"geiser/") t
)
1250 (setq geiser-repl-history-filename
(b/var
"geiser/repl-history")))
1252 (use-feature geiser-guile
1254 (setq geiser-guile-load-path
"~/src/git/guix"))
1261 (font-latex-fontify-sectioning 'color
)))
1263 (use-package go-mode
)
1265 (use-package po-mode
1267 (po-mode .
(lambda () (run-with-timer 0.1 nil
'View-exit
))))
1269 (use-feature tex-mode
1272 (lambda (p) (string-match "^---?" (car p
)))
1273 tex--prettify-symbols-alist
)
1274 :hook
((tex-mode . auto-fill-mode
)
1275 (tex-mode . flyspell-mode
)
1276 (tex-mode .
(lambda () (electric-indent-local-mode -
1)))))
1281 (add-to-list 'custom-theme-load-path
1283 (convert-standard-filename "lisp") user-emacs-directory
))
1284 (load-theme 'tangomod t
)
1286 (use-package smart-mode-line
1287 :commands
(sml/apply-theme
)
1291 (smart-mode-line-enable))
1293 (use-package doom-themes
)
1295 (defvar b
/org-mode-font-lock-keywords
1296 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
1297 (1 '(:foreground
"#5a5b5a" :background
"#292b2b") t
) ; directive
1298 (3 '(:foreground
"#81a2be" :background
"#292b2b") t
) ; kind
1299 (4 '(:foreground
"#c5c8c6") t
)))) ; title
1301 (defun b/lights-on
()
1302 "Enable my favourite light theme."
1304 (mapc #'disable-theme custom-enabled-themes
)
1305 (load-theme 'tangomod t
)
1306 (sml/apply-theme
'automatic
)
1307 (font-lock-remove-keywords
1308 'org-mode b
/org-mode-font-lock-keywords
))
1310 (defun b/lights-off
()
1313 (mapc #'disable-theme custom-enabled-themes
)
1314 ;; (load-theme 'doom-tomorrow-night t)
1315 (sml/apply-theme
'automatic
)
1316 (font-lock-add-keywords
1317 'org-mode b
/org-mode-font-lock-keywords t
))
1320 ("C-c t d" . b
/lights-off
)
1321 ("C-c t l" . b
/lights-on
))
1324 ;;; Emacs enhancements & auxiliary packages
1327 :config
(setq Man-width
80))
1329 (use-package which-key
1333 (which-key-add-key-based-replacements
1334 ;; prefixes for global prefixes and minor modes
1338 "C-c 8 -" "typo/dashes"
1339 "C-c 8 <" "typo/left-brackets"
1340 "C-c 8 >" "typo/right-brackets"
1342 "C-x a" "abbrev/expand"
1343 "C-x r" "rectangle/register/bookmark"
1344 "C-x v" "version control"
1345 ;; prefixes for my personal bindings
1346 "C-c a" "applications"
1351 "C-c c" "compile-and-comments"
1357 "C-c m" "multiple-cursors"
1358 "C-c P" "projectile"
1359 "C-c P s" "projectile/search"
1360 "C-c P x" "projectile/execute"
1361 "C-c P 4" "projectile/other-window"
1367 ;; prefixes for major modes
1368 (which-key-add-major-mode-key-based-replacements 'message-mode
1370 (which-key-add-major-mode-key-based-replacements 'org-mode
1371 "C-c C-v" "org-babel")
1372 (which-key-add-major-mode-key-based-replacements 'web-mode
1373 "C-c C-a" "web/attributes"
1374 "C-c C-b" "web/blocks"
1376 "C-c C-e" "web/element"
1377 "C-c C-t" "web/tags")
1381 (which-key-add-column-padding 5)
1382 (which-key-max-description-length 32))
1384 (use-package crux
; results in Waiting for git... [2 times]
1386 :bind
(("C-c d" . crux-duplicate-current-line-or-region
)
1387 ("C-c D" . crux-duplicate-and-comment-current-line-or-region
)
1388 ("C-c f c" . crux-copy-file-preserve-attributes
)
1389 ("C-c f d" . crux-delete-file-and-buffer
)
1390 ("C-c f r" . crux-rename-file-and-buffer
)
1391 ("C-c j" . crux-top-join-line
)
1392 ("C-S-j" . crux-top-join-line
)))
1395 :bind
(("C-a" . mwim-beginning-of-code-or-line
)
1396 ("C-e" . mwim-end-of-code-or-line
)
1397 ("<home>" . mwim-beginning-of-line-or-code
)
1398 ("<end>" . mwim-end-of-line-or-code
)))
1400 (use-package projectile
1402 :bind-keymap
("C-c P" . projectile-command-map
)
1404 (make-directory (b/var
"projectile/") t
)
1407 (defun b/projectile-mode-line-fun
()
1408 "Report project name and type in the modeline."
1409 (let ((project-name (projectile-project-name))
1410 (project-type (projectile-project-type)))
1412 projectile-mode-line-prefix
1414 (format ":%s" project-type
)
1416 (setq projectile-mode-line-function
'b
/projectile-mode-line-fun
)
1418 (defun my-projectile-invalidate-cache (&rest _args
)
1419 ;; ignore the args to `magit-checkout'
1420 (projectile-invalidate-cache nil
))
1422 (eval-after-load 'magit-branch
1424 (advice-add 'magit-checkout
1425 :after
#'my-projectile-invalidate-cache
)
1426 (advice-add 'magit-branch-and-checkout
1427 :after
#'my-projectile-invalidate-cache
)))
1429 (projectile-cache-file (b/var
"projectile/cache.el"))
1430 (projectile-completion-system 'ivy
)
1431 (projectile-known-projects-file (b/var
"projectile/known-projects.el"))
1432 (projectile-mode-line-prefix " proj"))
1434 (use-package helpful
1437 (("C-S-h c" . helpful-command
)
1438 ("C-S-h f" . helpful-callable
) ; helpful-function
1439 ("C-S-h v" . helpful-variable
)
1440 ("C-S-h k" . helpful-key
)
1441 ("C-S-h p" . helpful-at-point
)))
1443 (use-package unkillable-scratch
1446 (unkillable-scratch 1)
1448 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1451 ;; | make pretty boxed quotes like this
1453 (use-package boxquote
1456 (:prefix-map b
/boxquote-prefix-map
1458 ("b" . boxquote-buffer
)
1459 ("B" . boxquote-insert-buffer
)
1460 ("d" . boxquote-defun
)
1461 ("F" . boxquote-insert-file
)
1462 ("hf" . boxquote-describe-function
)
1463 ("hk" . boxquote-describe-key
)
1464 ("hv" . boxquote-describe-variable
)
1465 ("hw" . boxquote-where-is
)
1466 ("k" . boxquote-kill
)
1467 ("p" . boxquote-paragraph
)
1468 ("q" . boxquote-boxquote
)
1469 ("r" . boxquote-region
)
1470 ("s" . boxquote-shell-command
)
1471 ("t" . boxquote-text
)
1472 ("T" . boxquote-title
)
1473 ("u" . boxquote-unbox
)
1474 ("U" . boxquote-unbox-region
)
1475 ("y" . boxquote-yank
)
1476 ("M-q" . boxquote-fill-paragraph
)
1477 ("M-w" . boxquote-kill-ring-save
)))
1479 (use-package orgalist
1480 ;; http://lists.gnu.org/archive/html/emacs-orgmode/2019-04/msg00007.html
1483 :hook
(message-mode . orgalist-mode
))
1485 ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
1490 (typo-global-mode 1)
1491 :hook
(((text-mode erc-mode
) . typo-mode
)
1492 (tex-mode .
(lambda ()(typo-mode -
1)))))
1494 ;; highlight TODOs in buffers
1495 (use-package hl-todo
1498 (global-hl-todo-mode))
1500 (use-package shrink-path
1504 (defvar user-
@-host
(concat (user-login-name) "@" (system-name) " "))
1505 (defun +eshell
/prompt
()
1506 (let ((base/dir
(shrink-path-prompt default-directory
)))
1507 (concat (propertize user-
@-host
'face
'default
)
1508 (propertize (car base
/dir
)
1509 'face
'font-lock-comment-face
)
1510 (propertize (cdr base
/dir
)
1511 'face
'font-lock-constant-face
)
1512 (propertize "> " 'face
'default
))))
1513 (setq eshell-prompt-regexp
(concat user-
@-host
".*> ")
1514 eshell-prompt-function
#'+eshell
/prompt
))
1516 (use-package eshell-up
1518 :commands eshell-up
)
1520 (use-package multi-term
1522 :bind
(("C-c a s m m" . multi-term
)
1523 ("C-c a s m d" . multi-term-dedicated-toggle
)
1524 ("C-c a s m p" . multi-term-prev
)
1525 ("C-c a s m n" . multi-term-next
)
1527 ("C-c C-j" . term-char-mode
))
1529 (setq multi-term-program
"screen"
1530 multi-term-program-switches
(concat "-c"
1531 (getenv "XDG_CONFIG_HOME")
1533 ;; TODO: add separate bindings for connecting to existing
1534 ;; session vs. always creating a new one
1535 multi-term-dedicated-select-after-open-p t
1536 multi-term-dedicated-window-height
20
1537 multi-term-dedicated-max-window-height
30
1539 '(("C-c C-c" . term-interrupt-subjob
)
1540 ("C-c C-e" . term-send-esc
)
1541 ("C-c C-j" . term-line-mode
)
1543 ;; ("C-y" . term-paste)
1544 ("C-y" . term-send-raw
)
1545 ("M-f" . term-send-forward-word
)
1546 ("M-b" . term-send-backward-word
)
1547 ("M-p" . term-send-up
)
1548 ("M-n" . term-send-down
)
1549 ("M-j" . term-send-raw-meta
)
1550 ("M-y" . term-send-raw-meta
)
1551 ("M-/" . term-send-raw-meta
)
1552 ("M-0" . term-send-raw-meta
)
1553 ("M-1" . term-send-raw-meta
)
1554 ("M-2" . term-send-raw-meta
)
1555 ("M-3" . term-send-raw-meta
)
1556 ("M-4" . term-send-raw-meta
)
1557 ("M-5" . term-send-raw-meta
)
1558 ("M-6" . term-send-raw-meta
)
1559 ("M-7" . term-send-raw-meta
)
1560 ("M-8" . term-send-raw-meta
)
1561 ("M-9" . term-send-raw-meta
)
1562 ("<C-backspace>" . term-send-backward-kill-word
)
1563 ("<M-DEL>" . term-send-backward-kill-word
)
1564 ("M-d" . term-send-delete-word
)
1565 ("M-," . term-send-raw
)
1566 ("M-." . comint-dynamic-complete
))
1567 term-unbind-key-alist
1568 '("C-z" "C-x" "C-c" "C-h"
1572 (use-package page-break-lines
1576 (page-break-lines-max-width fill-column
)
1578 (global-page-break-lines-mode))
1580 (use-package expand-region
1581 :bind
("C-=" . er
/expand-region
))
1583 (use-package multiple-cursors
1585 (("C-S-<mouse-1>" . mc
/add-cursor-on-click
)
1586 (:prefix-map b
/mc-prefix-map
1588 ("c" . mc
/edit-lines
)
1589 ("n" . mc
/mark-next-like-this
)
1590 ("p" . mc
/mark-previous-like-this
)
1591 ("a" . mc
/mark-all-like-this
)))
1593 (setq mc
/list-file
(b/var
"mc-list.el")))
1601 (use-package yasnippet
1604 (defconst yas-verbosity-cur yas-verbosity
)
1605 (setq yas-verbosity
2)
1606 (setq yas-snippet-dirs
(list (b/etc
"yasnippet/snippets/")))
1607 (add-to-list 'yas-snippet-dirs
"~/src/git/guix/etc/snippets" t
)
1609 (setq yas-verbosity yas-verbosity-cur
)
1611 (defun b/yas--maybe-expand-key-filter
(cmd)
1612 (when (and (yas--maybe-expand-key-filter cmd
)
1613 (not (bound-and-true-p git-commit-mode
)))
1615 (defconst b
/yas-maybe-expand
1616 '(menu-item "" yas-expand
:filter b
/yas--maybe-expand-key-filter
))
1617 (define-key yas-minor-mode-map
1618 (kbd "SPC") b
/yas-maybe-expand
)
1622 (use-package debbugs
1625 :repo
"emacs-straight/debbugs"
1626 :files
(:defaults
"Debbugs.wsdl")))
1628 (use-package org-ref
1630 (b/setq-every
'("~/usr/org/references.bib")
1631 reftex-default-bibliography
1632 org-ref-default-bibliography
)
1634 org-ref-bibliography-notes
"~/usr/org/notes.org"
1635 org-ref-pdf-directory
"~/usr/org/bibtex-pdfs/"))
1639 :init
(setq alert-default-style
'notifications
))
1641 ;; (use-package fill-column-indicator)
1643 (use-package emojify
1645 (make-directory (b/var
"emojify/") t
)
1646 (setq emojify-emojis-dir
(b/var
"emojify/"))
1647 :hook
(erc-mode . emojify-mode
))
1651 (("C-c w <right>" . split-window-right
)
1652 ("C-c w <down>" . split-window-below
)
1653 ("C-c w s l" . split-window-right
)
1654 ("C-c w s j" . split-window-below
)
1655 ("C-c w q" . quit-window
))
1657 (split-width-threshold 150))
1659 (use-feature windmove
1662 (("C-c w h" . windmove-left
)
1663 ("C-c w j" . windmove-down
)
1664 ("C-c w k" . windmove-up
)
1665 ("C-c w l" . windmove-right
)
1666 ("C-c w H" . windmove-swap-states-left
)
1667 ("C-c w J" . windmove-swap-states-down
)
1668 ("C-c w K" . windmove-swap-states-up
)
1669 ("C-c w L" . windmove-swap-states-right
)))
1673 :bind
("C-c a p" . pass
)
1674 :hook
(pass-mode . View-exit
))
1676 (use-package pdf-tools
1678 :bind
(:map pdf-view-mode-map
1679 ("<XF86Back>" . pdf-history-backward
)
1680 ("<XF86Forward>" . pdf-history-forward
)
1681 ("M-RET" . image-previous-line
))
1682 :config
(pdf-tools-install nil t
)
1683 :custom
(pdf-view-resize-factor 1.05))
1685 (use-package biblio
)
1688 :hook
(latex-mode . reftex-mode
))
1690 (use-feature reftex-cite
1692 :disabled
; enable to disable
1693 ; reftex-cite's default choice
1696 (defun reftex-get-bibkey-default ()
1697 "If the cursor is in a citation macro, return the word before the macro."
1698 (let* ((macro (reftex-what-macro 1)))
1700 (when (and macro
(string-match "cite" (car macro
)))
1701 (goto-char (cdr macro
)))
1702 (reftex-this-word)))))
1705 ;;; Email (with Gnus)
1707 (defvar b
/maildir
(expand-file-name "~/mail/"))
1708 (with-eval-after-load 'recentf
1709 (add-to-list 'recentf-exclude b
/maildir
))
1712 b
/gnus-init-file
(b/etc
"gnus")
1713 mail-user-agent
'gnus-user-agent
1714 read-mail-command
'gnus
)
1717 :bind
(("s-m" . gnus
)
1718 ("s-M" . gnus-unplugged
)
1720 ("C-c a M" . gnus-unplugged
))
1723 gnus-select-method
'(nnnil "")
1724 gnus-secondary-select-methods
1725 '((nnimap "shemshak"
1726 (nnimap-stream plain
)
1727 (nnimap-address "127.0.0.1")
1728 (nnimap-server-port 143)
1729 (nnimap-authenticator plain
)
1730 (nnimap-user "amin@shemshak.local"))
1732 (nnimap-stream plain
)
1733 (nnimap-address "127.0.0.1")
1734 (nnimap-server-port 143)
1735 (nnimap-authenticator plain
)
1736 (nnimap-user "bandali@gnu.local")
1737 (nnimap-inbox "INBOX")
1738 (nnimap-split-methods 'nnimap-split-fancy
)
1739 (nnimap-split-fancy (|
1740 ;; (: gnus-registry-split-fancy-with-parent)
1741 ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
1743 (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
1744 ;; *@lists.sr.ht, omitting one dot if present
1745 ;; add more \\.?\\([^.@]*\\) if needed
1746 (list ".*<~\\(.*\\)/\\([^.@]*\\)\\.?\\([^.@]*\\)@lists.sr.ht>.*" "l.~\\1.\\2\\3")
1748 (from "webmasters\\(-comment\\)?@gnu\\.org" "webmasters")
1750 (list ".*atreus.freelists.org" "l.atreus")
1751 (list ".*deepspec.lists.cs.princeton.edu" "l.deepspec")
1752 ;; (list ".*haskell-art.we.lurk.org" "l.haskell.art") ;d
1753 (list ".*haskell-cafe.haskell.org" "l.haskell-cafe")
1754 ;; (list ".*notmuch.notmuchmail.org" "l.notmuch") ;u
1755 ;; (list ".*dev.lists.parabola.nu" "l.parabola-dev") ;u
1756 ;; ----------------------------------
1757 ;; legend: (u)nsubscribed | (d)ead
1758 ;; ----------------------------------
1759 ;; otherwise, leave mail in INBOX
1762 (nnimap-stream plain
)
1763 (nnimap-address "127.0.0.1")
1764 (nnimap-server-port 143)
1765 (nnimap-authenticator plain
)
1766 (nnimap-user "abandali@uw.local")
1767 (nnimap-inbox "INBOX")
1768 (nnimap-split-methods 'nnimap-split-fancy
)
1769 (nnimap-split-fancy (|
1770 ;; (: gnus-registry-split-fancy-with-parent)
1772 ("subject" "SE\\s-?212" "course.se212-f19")
1773 (from "SE\\s-?212" "course.se212-f19")
1777 (nnimap-stream plain
)
1778 (nnimap-address "127.0.0.1")
1779 (nnimap-server-port 143)
1780 (nnimap-authenticator plain
)
1781 (nnimap-user "abandali@csc.uw.local")))
1782 gnus-message-archive-group
"nnimap+shemshak:Sent"
1785 (to-address .
"atreus@freelists.org")
1786 (to-list .
"atreus@freelists.org"))
1788 (to-address .
"deepspec@lists.cs.princeton.edu")
1789 (to-list .
"deepspec@lists.cs.princeton.edu")
1790 (list-identifier .
"\\[deepspec\\]"))
1792 (to-address .
"emacs-devel@gnu.org")
1793 (to-list .
"emacs-devel@gnu.org"))
1794 ("l\\.help-gnu-emacs"
1795 (to-address .
"help-gnu-emacs@gnu.org")
1796 (to-list .
"help-gnu-emacs@gnu.org"))
1797 ("l\\.info-gnu-emacs"
1798 (to-address .
"info-gnu-emacs@gnu.org")
1799 (to-list .
"info-gnu-emacs@gnu.org"))
1800 ("l\\.emacs-orgmode"
1801 (to-address .
"emacs-orgmode@gnu.org")
1802 (to-list .
"emacs-orgmode@gnu.org")
1803 (list-identifier .
"\\[O\\]"))
1804 ("l\\.emacs-tangents"
1805 (to-address .
"emacs-tangents@gnu.org")
1806 (to-list .
"emacs-tangents@gnu.org"))
1807 ("l\\.emacsconf-discuss"
1808 (to-address .
"emacsconf-discuss@gnu.org")
1809 (to-list .
"emacsconf-discuss@gnu.org"))
1810 ("l\\.emacsconf-register"
1811 (to-address .
"emacsconf-register@gnu.org")
1812 (to-list .
"emacsconf-register@gnu.org"))
1813 ("l\\.emacsconf-submit"
1814 (to-address .
"emacsconf-submit@gnu.org")
1815 (to-list .
"emacsconf-submit@gnu.org"))
1816 ("l\\.fencepost-users"
1817 (to-address .
"fencepost-users@gnu.org")
1818 (to-list .
"fencepost-users@gnu.org")
1819 (list-identifier .
"\\[Fencepost-users\\]"))
1820 ("l\\.gnewsense-art"
1821 (to-address .
"gnewsense-art@nongnu.org")
1822 (to-list .
"gnewsense-art@nongnu.org")
1823 (list-identifier .
"\\[gNewSense-art\\]"))
1824 ("l\\.gnewsense-dev"
1825 (to-address .
"gnewsense-dev@nongnu.org")
1826 (to-list .
"gnewsense-dev@nongnu.org")
1827 (list-identifier .
"\\[Gnewsense-dev\\]"))
1828 ("l\\.gnewsense-users"
1829 (to-address .
"gnewsense-users@nongnu.org")
1830 (to-list .
"gnewsense-users@nongnu.org")
1831 (list-identifier .
"\\[gNewSense-users\\]"))
1832 ("l\\.gnunet-developers"
1833 (to-address .
"gnunet-developers@gnu.org")
1834 (to-list .
"gnunet-developers@gnu.org")
1835 (list-identifier .
"\\[GNUnet-developers\\]"))
1837 (to-address .
"help-gnunet@gnu.org")
1838 (to-list .
"help-gnunet@gnu.org")
1839 (list-identifier .
"\\[Help-gnunet\\]"))
1841 (to-address .
"bug-gnuzilla@gnu.org")
1842 (to-list .
"bug-gnuzilla@gnu.org")
1843 (list-identifier .
"\\[Bug-gnuzilla\\]"))
1845 (to-address .
"gnuzilla-dev@gnu.org")
1846 (to-list .
"gnuzilla-dev@gnu.org")
1847 (list-identifier .
"\\[Gnuzilla-dev\\]"))
1849 (to-address .
"guile-devel@gnu.org")
1850 (to-list .
"guile-devel@gnu.org"))
1852 (to-address .
"guile-user@gnu.org")
1853 (to-list .
"guile-user@gnu.org"))
1855 (to-address .
"guix-devel@gnu.org")
1856 (to-list .
"guix-devel@gnu.org"))
1858 (to-address .
"help-guix@gnu.org")
1859 (to-list .
"help-guix@gnu.org"))
1861 (to-address .
"info-guix@gnu.org")
1862 (to-list .
"info-guix@gnu.org"))
1863 ("l\\.savannah-hackers-public"
1864 (to-address .
"savannah-hackers-public@gnu.org")
1865 (to-list .
"savannah-hackers-public@gnu.org"))
1866 ("l\\.savannah-users"
1867 (to-address .
"savannah-users@gnu.org")
1868 (to-list .
"savannah-users@gnu.org"))
1870 (to-address .
"www-commits@gnu.org")
1871 (to-list .
"www-commits@gnu.org"))
1873 (to-address .
"www-discuss@gnu.org")
1874 (to-list .
"www-discuss@gnu.org"))
1876 (to-address .
"haskell-art@we.lurk.org")
1877 (to-list .
"haskell-art@we.lurk.org")
1878 (list-identifier .
"\\[haskell-art\\]"))
1880 (to-address .
"haskell-cafe@haskell.org")
1881 (to-list .
"haskell-cafe@haskell.org")
1882 (list-identifier .
"\\[Haskell-cafe\\]"))
1884 (to-address .
"notmuch@notmuchmail.org")
1885 (to-list .
"notmuch@notmuchmail.org"))
1887 (to-address .
"dev@lists.parabola.nu")
1888 (to-list .
"dev@lists.parabola.nu")
1889 (list-identifier .
"\\[Dev\\]"))
1890 ("l\\.~bandali\\.public-inbox"
1891 (to-address .
"~bandali/public-inbox@lists.sr.ht")
1892 (to-list .
"~bandali/public-inbox@lists.sr.ht"))
1893 ("l\\.~sircmpwn\\.free-writers-club"
1894 (to-address .
"~sircmpwn/free-writers-club@lists.sr.ht")
1895 (to-list .
"~sircmpwn/free-writers-club@lists.sr.ht"))
1896 ("l\\.~sircmpwn\\.srht-admins"
1897 (to-address .
"~sircmpwn/sr.ht-admins@lists.sr.ht")
1898 (to-list .
"~sircmpwn/sr.ht-admins@lists.sr.ht"))
1899 ("l\\.~sircmpwn\\.srht-announce"
1900 (to-address .
"~sircmpwn/sr.ht-announce@lists.sr.ht")
1901 (to-list .
"~sircmpwn/sr.ht-announce@lists.sr.ht"))
1902 ("l\\.~sircmpwn\\.srht-dev"
1903 (to-address .
"~sircmpwn/sr.ht-dev@lists.sr.ht")
1904 (to-list .
"~sircmpwn/sr.ht-dev@lists.sr.ht"))
1905 ("l\\.~sircmpwn\\.srht-discuss"
1906 (to-address .
"~sircmpwn/sr.ht-discuss@lists.sr.ht")
1907 (to-list .
"~sircmpwn/sr.ht-discuss@lists.sr.ht"))
1909 (to-address .
"webmasters@gnu.org")
1910 (to-list .
"webmasters@gnu.org"))
1917 gnus-large-newsgroup
50
1918 gnus-home-directory
(b/var
"gnus/")
1919 gnus-directory
(concat gnus-home-directory
"news/")
1920 message-directory
(concat gnus-home-directory
"mail/")
1921 nndraft-directory
(concat gnus-home-directory
"drafts/")
1922 gnus-save-newsrc-file nil
1923 gnus-read-newsrc-file nil
1924 gnus-interactive-exit nil
1925 gnus-gcc-mark-as-read t
)
1929 (require 'ebdb-gnus
)
1931 (when (version< emacs-version
"27")
1933 'nnmail-split-abbrev-alist
1934 '(list .
"list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop")
1937 ;; (gnus-registry-initialize)
1939 (with-eval-after-load 'recentf
1940 (add-to-list 'recentf-exclude gnus-home-directory
)))
1942 (use-feature gnus-art
1945 gnus-buttonized-mime-types
'("multipart/\\(signed\\|encrypted\\)")
1946 gnus-visible-headers
1947 (concat gnus-visible-headers
"\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
1948 gnus-sorted-header-list
1949 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
1950 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
1951 "^Newsgroups:" "List-Id:" "^Organization:"
1952 "^User-Agent:" "^Date:")
1953 ;; local-lapsed article dates
1954 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1955 gnus-article-date-headers
'(user-defined)
1956 gnus-article-time-format
1958 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time
))
1959 (local (article-make-date-line date
'local
))
1960 (combined-lapsed (article-make-date-line date
1963 (string-match " (.+" combined-lapsed
)
1964 (match-string 0 combined-lapsed
))))
1965 (concat local lapsed
))))
1967 :map gnus-article-mode-map
1968 ("M-L" . org-store-link
)))
1970 (use-feature gnus-sum
1971 :bind
(:map gnus-summary-mode-map
1972 :prefix-map b
/gnus-summary-prefix-map
1974 ("r" . gnus-summary-reply
)
1975 ("w" . gnus-summary-wide-reply
)
1976 ("v" . gnus-summary-show-raw-article
))
1979 :map gnus-summary-mode-map
1980 ("M-L" . org-store-link
))
1981 :hook
(gnus-summary-mode . b
/no-mouse-autoselect-window
))
1983 (use-feature gnus-msg
1985 (defvar b
/signature
"Amin Bandali
1986 Free Software Activist | GNU Webmaster & Volunteer
1987 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
1988 https://shemshak.org/~amin")
1989 (defvar b
/gnu-signature
"Amin Bandali
1990 Free Software Activist | GNU Webmaster & Volunteer
1991 GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103
1992 https://bandali.eu.org")
1993 (defvar b
/uw-signature
"Amin Bandali, MMath Student
1994 Cheriton School of Computer Science
1995 University of Waterloo
1996 https://bandali.eu.org")
1997 (defvar b
/csc-signature
"Amin Bandali
1999 Computer Science Club, University of Waterloo
2000 https://csclub.uwaterloo.ca/~abandali")
2001 (setq gnus-posting-styles
2003 (address "amin@shemshak.org")
2005 (signature b
/signature
)
2006 (eval (setq b
/message-cite-say-hi t
)))
2008 (address "bandali@gnu.org")
2009 (signature b
/gnu-signature
)
2010 (eval (set (make-local-variable 'message-user-fqdn
) "fencepost.gnu.org")))
2011 ((header "subject" "ThankCRM")
2012 (to "webmasters-comment@gnu.org")
2014 (eval (setq b
/message-cite-say-hi nil
)))
2016 (address "abandali@uwaterloo.ca")
2017 (signature b
/uw-signature
))
2018 ("nnimap\\+uw:INBOX"
2019 (gcc "\"nnimap+uw:Sent Items\""))
2021 (address "abandali@csclub.uwaterloo.ca")
2022 (signature b
/csc-signature
)
2023 (gcc "nnimap+csc:Sent")))))
2025 (use-feature gnus-topic
2026 :hook
(gnus-group-mode . gnus-topic-mode
)
2027 :config
(setq gnus-topic-line-format
"%i[ %A: %(%{%n%}%) ]%v\n"))
2029 (use-feature gnus-agent
2031 (setq gnus-agent-synchronize-flags
'ask
)
2032 :hook
(gnus-group-mode . gnus-agent-mode
))
2034 (use-feature gnus-group
2036 (setq gnus-permanently-visible-groups
"\\(:INBOX$\\|:gnu$\\)"))
2039 ;; problematic with ebdb's popup, *EBDB-Gnus*
2040 (use-feature gnus-win
2042 (setq gnus-use-full-window nil
)))
2044 (use-feature gnus-dired
2045 :commands gnus-dired-mode
2047 (add-hook 'dired-mode-hook
'gnus-dired-mode
))
2049 (use-feature mm-decode
2051 (setq mm-discouraged-alternatives
'("text/html" "text/richtext")
2052 mm-decrypt-option
'known
2053 mm-verify-option
'known
))
2055 (use-feature sendmail
2057 (setq sendmail-program
(executable-find "msmtp")
2058 ;; message-sendmail-extra-arguments '("-v" "-d")
2059 mail-specify-envelope-from t
2060 mail-envelope-from
'header
))
2062 (use-feature message
2064 ;; redefine for a simplified In-Reply-To header
2065 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
2066 (defun message-make-in-reply-to ()
2067 "Return the In-Reply-To header for this message."
2068 (when message-reply-headers
2069 (let ((from (mail-header-from message-reply-headers
))
2070 (msg-id (mail-header-id message-reply-headers
)))
2074 (defconst b
/message-cite-style-format
"On %Y-%m-%d %l:%M %p, %N wrote:")
2075 (defconst message-cite-style-bandali
2076 '((message-cite-function 'message-cite-original
)
2077 (message-citation-line-function 'message-insert-formatted-citation-line
)
2078 (message-cite-reply-position 'traditional
)
2079 (message-yank-prefix "> ")
2080 (message-yank-cited-prefix ">")
2081 (message-yank-empty-prefix ">")
2082 (message-citation-line-format
2083 (if b
/message-cite-say-hi
2084 (concat "Hi %F,\n\n" b
/message-cite-style-format
)
2085 b
/message-cite-style-format
)))
2086 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2087 (setq ;; message-cite-style 'message-cite-style-bandali
2088 message-kill-buffer-on-exit t
2089 message-send-mail-function
'message-send-mail-with-sendmail
2090 message-sendmail-envelope-from
'header
2091 message-subscribed-address-functions
2092 '(gnus-find-subscribed-addresses)
2093 message-dont-reply-to-names
2094 "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(amin@bndl\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a\\(min\\.\\)?bandali@uwaterloo\\.ca\\)\\|\\(abandali@csclub\\.uwaterloo\\.ca\\)\\)")
2095 (require 'company-ebdb
)
2096 :hook
(;; (message-setup . mml-secure-message-sign-pgpmime)
2097 (message-mode . flyspell-mode
)
2098 (message-mode .
(lambda ()
2099 ;; (setq fill-column 65
2100 ;; message-fill-column 65)
2101 (make-local-variable 'company-idle-delay
)
2102 (setq company-idle-delay
0.2))))
2104 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2105 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2106 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2112 (use-feature mml-sec
2114 (mml-secure-openpgp-encrypt-to-self t
)
2115 (mml-secure-openpgp-sign-with-sender t
))
2117 (use-feature footnote
2120 ;; (setq footnote-start-tag ""
2121 ;; footnote-end-tag ""
2122 ;; footnote-style 'unicode)
2124 (:map message-mode-map
2125 :prefix-map b
/footnote-prefix-map
2127 ("a" . footnote-add-footnote
)
2128 ("b" . footnote-back-to-message
)
2129 ("c" . footnote-cycle-style
)
2130 ("d" . footnote-delete-footnote
)
2131 ("g" . footnote-goto-footnote
)
2132 ("r" . footnote-renumber-footnotes
)
2133 ("s" . footnote-set-style
)))
2137 :bind
(:map gnus-group-mode-map
("e" . ebdb
))
2139 (setq ebdb-sources
(b/var
"ebdb"))
2140 (with-eval-after-load 'swiper
2141 (add-to-list 'swiper-font-lock-exclude
'ebdb-mode t
)))
2143 (use-feature ebdb-com
2146 ;; (use-package ebdb-complete
2149 ;; (ebdb-complete-enable))
2151 (use-package company-ebdb
2153 (defun company-ebdb--post-complete (_) nil
))
2155 (use-feature ebdb-gnus
2158 (ebdb-gnus-window-configuration
2161 (summary 0.25 point
)
2164 (ebdb-gnus 0.3))))))
2166 (use-feature ebdb-mua
2168 ;; :custom (ebdb-mua-pop-up nil)
2171 ;; (use-package ebdb-message
2174 ;; (use-package ebdb-vcard
2177 (use-package message-x
)
2180 (use-package message-x
2182 (message-x-completion-alist
2184 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address
)
2187 (quote message-newgroups-header-regexp
))
2188 message-newgroups-header-regexp message-newsgroups-header-regexp
)
2189 . message-expand-group
))))))
2192 (use-package gnus-harvest
2193 :commands gnus-harvest-install
2196 (if (featurep 'message-x
)
2197 (gnus-harvest-install 'message-x
)
2198 (gnus-harvest-install))))
2201 ;;; IRC (with ERC and ZNC)
2204 :bind
(("C-c b e" . erc-switch-to-buffer
)
2206 ("M-a" . erc-track-switch-buffer
))
2208 (erc-join-buffer 'bury
)
2209 (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
2210 (erc-nick "bandali")
2212 (erc-rename-buffers t
)
2213 (erc-server-reconnect-attempts 5)
2214 (erc-server-reconnect-timeout 3)
2216 (defun erc-cmd-OPME ()
2217 "Request chanserv to op me."
2218 (erc-message "PRIVMSG"
2219 (format "chanserv op %s %s"
2220 (erc-default-target)
2221 (erc-current-nick)) nil
))
2222 (defun erc-cmd-DEOPME ()
2223 "Deop myself from current channel."
2224 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
2225 (add-to-list 'erc-modules
'keep-place
)
2226 (add-to-list 'erc-modules
'notifications
)
2227 (add-to-list 'erc-modules
'spelling
)
2228 (add-to-list 'erc-modules
'scrolltoplace
)
2229 (erc-update-modules)
2231 (when (and (version<= "24.4" emacs-version
)
2232 (version< emacs-version
"27"))
2233 ;; fix erc-lurker bug
2234 ;; patch submitted: https://bugs.gnu.org/36843#10
2235 ;; TODO: remove when patch is merged and emacs 27 is released
2236 (defvar erc-message-parsed
)
2237 (defun erc-display-message (parsed type buffer msg
&rest args
)
2238 "Display MSG in BUFFER.
2240 ARGS, PARSED, and TYPE are used to format MSG sensibly.
2242 See also `erc-format-message' and `erc-display-line'."
2243 (let ((string (if (symbolp msg
)
2244 (apply #'erc-format-message msg args
)
2246 (erc-message-parsed parsed
))
2252 (mapc (lambda (type)
2254 (erc-display-message-highlight type string
)))
2258 (erc-display-message-highlight type string
))))
2260 (if (not (erc-response-p parsed
))
2261 (erc-display-line string buffer
)
2262 (unless (erc-hide-current-message-p parsed
)
2263 (erc-put-text-property 0 (length string
) 'erc-parsed parsed string
)
2264 (erc-put-text-property 0 (length string
) 'rear-sticky t string
)
2265 (when (erc-response.tags parsed
)
2266 (erc-put-text-property 0 (length string
) 'tags
(erc-response.tags parsed
)
2268 (erc-display-line string buffer
)))))
2270 (defun erc-lurker-update-status (_message)
2271 "Update `erc-lurker-state' if necessary.
2273 This function is called from `erc-insert-pre-hook'. If the
2274 current message is a PRIVMSG, update `erc-lurker-state' to
2275 reflect the fact that its sender has issued a PRIVMSG at the
2276 current time. Otherwise, take no action.
2278 This function depends on the fact that `erc-display-message'
2279 lexically binds `erc-message-parsed', which is used to check if
2280 the current message is a PRIVMSG and to determine its sender.
2281 See also `erc-lurker-trim-nicks' and `erc-lurker-ignore-chars'.
2283 In order to limit memory consumption, this function also calls
2284 `erc-lurker-cleanup' once every `erc-lurker-cleanup-interval'
2285 updates of `erc-lurker-state'."
2286 (when (and (boundp 'erc-message-parsed
)
2287 (erc-response-p erc-message-parsed
))
2288 (let* ((command (erc-response.command erc-message-parsed
))
2290 (erc-lurker-maybe-trim
2291 (car (erc-parse-user (erc-response.sender erc-message-parsed
)))))
2293 (erc-canonicalize-server-name erc-server-announced-name
)))
2294 (when (equal command
"PRIVMSG")
2295 (when (>= (cl-incf erc-lurker-cleanup-count
)
2296 erc-lurker-cleanup-interval
)
2297 (setq erc-lurker-cleanup-count
0)
2298 (erc-lurker-cleanup))
2299 (unless (gethash server erc-lurker-state
)
2300 (puthash server
(make-hash-table :test
'equal
) erc-lurker-state
))
2301 (puthash sender
(current-time)
2302 (gethash server erc-lurker-state
))))))))
2304 (use-feature erc-fill
2307 (erc-fill-column 77)
2308 (erc-fill-function 'erc-fill-static
)
2309 (erc-fill-static-center 18))
2311 (use-feature erc-pcomplete
2314 (erc-pcomplete-nick-postfix ","))
2316 (use-feature erc-track
2318 :bind
(("C-c a e t d" . erc-track-disable
)
2319 ("C-c a e t e" . erc-track-enable
))
2321 (erc-track-enable-keybindings nil
)
2322 (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
2323 "324" "329" "332" "333" "353" "477"))
2324 (erc-track-priority-faces-only 'all
)
2325 (erc-track-shorten-function nil
))
2327 (use-package erc-hl-nicks
2330 (use-package erc-scrolltoplace
2334 :straight
(:host nil
:repo
"https://git.shemshak.org/amin/znc.el")
2335 :bind
(("C-c a e e" . znc-erc
)
2336 ("C-c a e a" . znc-all
))
2338 (let ((pwd (let ((auth (auth-source-search :host
"znca")))
2340 ((null auth
) (error "Couldn't find znca's authinfo"))
2341 (t (funcall (plist-get (car auth
) :secret
)))))))
2343 `(("znc.shemshak.org" 1337 t
2344 ((freenode "amin/freenode" ,pwd
)))
2345 ("znc.shemshak.org" 1337 t
2346 ((moznet "amin/moznet" ,pwd
)))
2347 ("znc.shemshak.org" 1337 t
2348 ((oftc "amin/oftc" ,pwd
)))))))
2351 ;;; Post initialization
2353 (message "Loading %s...done (%.3fs)" user-init-file
2354 (float-time (time-subtract (current-time)
2355 b
/before-user-init-time
)))
2357 ;;; init.el ends here