1 #+title: =aminb='s Literate Emacs Configuration
4 #+property: header-args :tangle yes
11 This org file is my literate configuration for GNU Emacs, and is
12 tangled to [[./init.el][init.el]]. Packages are installed and managed using
13 [[https://github.com/emacscollective/borg][Borg]]. Over the years, I've taken inspiration from configurations of
14 many different people. Some of the configurations that I can remember
15 off the top of my head are:
17 - [[https://github.com/dieggsy/dotfiles][dieggsy/dotfiles]]: literate Emacs and dotfiles configuration, uses
18 straight.el for managing packages
19 - [[https://github.com/dakra/dmacs][dakra/dmacs]]: literate Emacs configuration, using Borg for managing
21 - [[http://pages.sachachua.com/.emacs.d/Sacha.html][Sacha Chua's literate Emacs configuration]]
22 - [[https://github.com/dakrone/eos][dakrone/eos]]
23 - Ryan Rix's [[http://doc.rix.si/cce/cce.html][Complete Computing Environment]] ([[http://doc.rix.si/projects/fsem.html][about cce]])
24 - [[https://github.com/jwiegley/dot-emacs][jwiegley/dot-emacs]]: nix-based configuration
25 - [[https://github.com/wasamasa/dotemacs][wasamasa/dotemacs]]
26 - [[https://github.com/hlissner/doom-emacs][Doom Emacs]]
28 I'd like to have a fully reproducible Emacs setup (part of the reason
29 why I store my configuration in this repository) but unfortunately out
30 of the box, that's not achievable with =package.el=, not currently
31 anyway. So, I've opted to use Borg. For what it's worth, I briefly
32 experimented with [[https://github.com/raxod502/straight.el][straight.el]], but found that it added about 2 seconds
33 to my init time; which is unacceptable for me: I use Emacs as my
34 window manager (via EXWM) and coming from bspwm, I'm too used to
35 having fast startup times.
39 To use this config for your Emacs, first you need to clone this repo,
40 then bootstrap Borg, tell Borg to retrieve package submodules, and
41 byte-compiled the packages. Something along these lines should work:
43 #+begin_src sh :tangle no
44 git clone https://github.com/aminb/dotfiles ~/.emacs.d
51 * Contents :toc_1:noexport:
55 - [[#initial-setup][Initial setup]]
57 - [[#borg-essentials][Borg's =layer/essentials=]]
58 - [[#editing][Editing]]
59 - [[#syntax-spell-checking][Syntax and spell checking]]
60 - [[#programming-modes][Programming modes]]
61 - [[#emacs-enhancements][Emacs enhancements]]
63 - [[#blogging][Blogging]]
64 - [[#post-initialization][Post initialization]]
74 #+begin_src emacs-lisp :comments none
75 ;;; init.el --- Amin Bandali's Emacs config -*- lexical-binding: t; eval: (view-mode 1) -*-
78 Enable =view-mode=, which both makes the file read-only (as a reminder
79 that =init.el= is an auto-generated file, not supposed to be edited),
80 and provides some convenient key bindings for browsing through the
85 #+begin_src emacs-lisp :comments none
86 ;; Copyright (C) 2018 Amin Bandali <bandali@gnu.org>
88 ;; This program is free software: you can redistribute it and/or modify
89 ;; it under the terms of the GNU General Public License as published by
90 ;; the Free Software Foundation, either version 3 of the License, or
91 ;; (at your option) any later version.
93 ;; This program is distributed in the hope that it will be useful,
94 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
95 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96 ;; GNU General Public License for more details.
98 ;; You should have received a copy of the GNU General Public License
99 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
104 #+begin_src emacs-lisp :comments none
107 ;; Emacs configuration of Amin Bandali, computer scientist, functional
108 ;; programmer, and free software advocate.
110 ;; THIS FILE IS AUTO-GENERATED FROM `init.org'.
115 :CUSTOM_ID: initial-setup
118 ** Emacs initialization
120 I'd like to do a couple of measurements of Emacs' startup time. First,
121 let's see how long Emacs takes to start up, before even loading
122 =init.el=, i.e. =user-init-file=:
124 #+begin_src emacs-lisp
125 (defvar a/before-user-init-time (current-time)
126 "Value of `current-time' when Emacs begins loading `user-init-file'.")
127 (message "Loading Emacs...done (%.3fs)"
128 (float-time (time-subtract a/before-user-init-time
132 Also, temporarily increase ~gc-cons-threshhold~ and
133 ~gc-cons-percentage~ during startup to reduce garbage collection
134 frequency. Clearing the ~file-name-handler-alist~ seems to help reduce
135 startup time as well.
137 #+begin_src emacs-lisp
138 (defvar a/gc-cons-threshold gc-cons-threshold)
139 (defvar a/gc-cons-percentage gc-cons-percentage)
140 (defvar a/file-name-handler-alist file-name-handler-alist)
141 (setq gc-cons-threshold (* 400 1024 1024) ; 400 MiB
142 gc-cons-percentage 0.6
143 file-name-handler-alist nil
144 ;; sidesteps a bug when profiling with esup
145 esup-child-profile-require-level 0)
148 Of course, we'd like to set them back to their defaults once we're
151 #+begin_src emacs-lisp
155 (setq gc-cons-threshold a/gc-cons-threshold
156 gc-cons-percentage a/gc-cons-percentage
157 file-name-handler-alist a/file-name-handler-alist)))
160 Increase the number of lines kept in message logs (the =*Messages*=
163 #+begin_src emacs-lisp
164 (setq message-log-max 20000)
167 Optionally, we could suppress some byte compiler warnings like below,
168 but for now I've decided to keep them enabled. See documentation for
169 ~byte-compile-warnings~ for more details.
171 #+begin_src emacs-lisp
172 ;; (setq byte-compile-warnings
173 ;; '(not free-vars unresolved noruntime lexical make-local))
178 #+begin_src emacs-lisp
179 (setq user-full-name "Amin Bandali"
180 user-mail-address "amin@aminb.org")
183 ** Package management
187 I can do all my package management things with Borg, and don't need
188 Emacs' built-in =package.el=. Emacs 27 lets us disable =package.el= in
189 the =early-init-file= (see [[https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b][here]]).
191 #+begin_src emacs-lisp :tangle early-init.el
192 (setq package-enable-at-startup nil)
195 But since Emacs 27 isn't out yet (Emacs 26 is just around the corner
196 right now), and even when released it'll be long before most distros
197 ship in their repos, I'll still put the old workaround with the
198 commented call to ~package-initialize~ here anyway.
200 #+begin_src emacs-lisp
201 (setq package-enable-at-startup nil)
202 ;; (package-initialize)
208 Assimilate Emacs packages as Git submodules
211 [[https://github.com/emacscollective/borg][Borg]] is at the heart of package management of my Emacs setup. In
212 short, it creates a git submodule in =lib/= for each package, which
213 can then be managed with the help of Magit or other tools.
215 #+begin_src emacs-lisp
216 (setq user-init-file (or load-file-name buffer-file-name)
217 user-emacs-directory (file-name-directory user-init-file))
218 (add-to-list 'load-path
219 (expand-file-name "lib/borg" user-emacs-directory))
223 ;; (require 'borg-nix-shell)
224 ;; (setq borg-build-shell-command 'borg-nix-shell-build-command)
226 (with-eval-after-load 'bind-key
229 ("C-c b A" . borg-activate)
230 ("C-c b a" . borg-assimilate)
231 ("C-c b b" . borg-build)
232 ("C-c b c" . borg-clone)
233 ("C-c b r" . borg-remove)))
239 A use-package declaration for simplifying your .emacs
242 [[https://github.com/jwiegley/use-package][use-package]] is an awesome utility for managing and configuring
243 packages (in our case especially the latter) in a neatly organized way
244 and without compromising on performance.
246 #+begin_src emacs-lisp
247 (require 'use-package)
248 (if nil ; set to t when need to debug init
249 (setq use-package-verbose t
250 use-package-expand-minimally nil
251 use-package-compute-statistics t
253 (setq use-package-verbose nil
254 use-package-expand-minimally t))
260 Browse the Emacsmirror package database
263 Epkg provides access to a local copy of the [[https://emacsmirror.net][Emacsmirror]] package
264 database, low-level functions for querying the database, and a
265 =package.el=-like user interface for browsing the available packages.
267 #+begin_src emacs-lisp
271 (("C-c b d" . epkg-describe-package)
272 ("C-c b p" . epkg-list-packages)
273 ("C-c b u" . epkg-update)))
276 ** No littering in =~/.emacs.d=
279 Help keeping ~/.emacs.d clean
282 By default, even for Emacs' built-in packages, the configuration files
283 and persistent data are all over the place. Use =no-littering= to help
286 #+begin_src emacs-lisp
287 (use-package no-littering
291 (add-to-list 'savehist-additional-variables 'kill-ring)
293 (setq auto-save-file-name-transforms
294 `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))))
297 ** Custom file (=custom.el=)
299 I'm not planning on using the custom file much, but even so, I
300 definitely don't want it mixing with =init.el=. So, here; let's give
301 it it's own file. While at it, treat themes as safe.
303 #+begin_src emacs-lisp
307 (setq custom-file (no-littering-expand-etc-file-name "custom.el"))
308 (when (file-exists-p custom-file)
310 (setf custom-safe-themes t))
315 Load the secrets file if it exists, otherwise show a warning.
317 #+begin_src emacs-lisp
319 (load (no-littering-expand-etc-file-name "secrets")))
322 ** Better =$PATH= handling
324 Let's use [[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]] to make Emacs use the =$PATH= as set up
327 #+begin_src emacs-lisp
328 (use-package exec-path-from-shell
331 (setq exec-path-from-shell-check-startup-files nil)
333 (exec-path-from-shell-initialize)
334 ;; while we're at it, let's fix access to our running ssh-agent
335 (exec-path-from-shell-copy-env "SSH_AGENT_PID")
336 (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
339 ** COMMENT Only one custom theme at a time
341 #+begin_src emacs-lisp
342 (defadvice load-theme (before clear-previous-themes activate)
343 "Clear existing theme settings instead of layering them"
344 (mapc #'disable-theme custom-enabled-themes))
349 Start server if not already running. Alternatively, can be done by
350 issuing =emacs --daemon= in the terminal, which can be automated with
351 a systemd service or using =brew services start emacs= on macOS. I use
352 Emacs as my window manager (via EXWM), so I always start Emacs on
353 login; so starting the server from inside Emacs is good enough for me.
355 See [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server][Using Emacs as a Server]].
357 #+begin_src emacs-lisp
360 :config (or (server-running-p) (server-mode)))
363 ** COMMENT Unicode support
365 Font stack with better unicode support, around =Ubuntu Mono= and
368 #+begin_src emacs-lisp
369 (dolist (ft (fontset-list))
373 (font-spec :name "Source Code Pro" :size 14))
377 (font-spec :name "DejaVu Sans Mono")
384 ;; :name "Symbola monospacified for DejaVu Sans Mono")
390 ;; (font-spec :name "DejaVu Sans Mono")
396 (font-spec :name "DejaVu Sans Mono" :size 14)
401 ** Gentler font resizing
403 #+begin_src emacs-lisp
404 (setq text-scale-mode-step 1.05)
407 ** Focus follows mouse
409 I’d like focus to follow the mouse when I move the cursor from one
412 #+begin_src emacs-lisp
413 (setq mouse-autoselect-window t)
416 Let’s define a function to conveniently disable this for certain
417 buffers and/or modes.
419 #+begin_src emacs-lisp
420 (defun a/no-mouse-autoselect-window ()
421 (make-local-variable 'mouse-autoselect-window)
422 (setq mouse-autoselect-window nil))
427 #+begin_src emacs-lisp
434 Convenience macro for =setq='ing multiple variables to the same value:
436 #+begin_src emacs-lisp
437 (defmacro a/setq-every (value &rest vars)
438 "Set all the variables from VARS to value VALUE."
439 (declare (indent defun) (debug t))
440 `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars)))
450 *** Time and battery in mode-line
452 Enable displaying time and battery in the mode-line, since I'm not
453 using the Xfce panel anymore. Also, I don't need to see the load
454 average on a regular basis, so disable that.
456 Note: using =i3status= on sway at the moment, so disabling this.
458 #+begin_src emacs-lisp :tangle no
461 (setq display-time-default-load-average nil)
467 (display-battery-mode))
472 Might want to set the fringe to a smaller value, especially if using
473 EXWM. I'm fine with the default for now.
475 #+begin_src emacs-lisp
476 ;; (fringe-mode '(3 . 1))
480 *** Disable disabled commands
482 Emacs disables some commands by default that could persumably be
483 confusing for novice users. Let's disable that.
485 #+begin_src emacs-lisp
486 (setq disabled-command-function nil)
491 Save what I copy into clipboard from other applications into Emacs'
492 kill-ring, which would allow me to still be able to easily access it
493 in case I kill (cut or copy) something else inside Emacs before
494 yanking (pasting) what I'd originally intended to.
496 #+begin_src emacs-lisp
497 (setq save-interprogram-paste-before-kill t)
502 #+begin_src emacs-lisp
503 (setq enable-recursive-minibuffers t
504 resize-mini-windows t)
507 *** Lazy-person-friendly yes/no prompts
509 Lazy people would prefer to type fewer keystrokes, especially for yes
510 or no questions. I'm lazy.
512 #+begin_src emacs-lisp
513 (defalias 'yes-or-no-p #'y-or-n-p)
516 *** Startup screen and =*scratch*=
518 Firstly, let Emacs know that I'd like to have =*scratch*= as my
521 #+begin_src emacs-lisp
522 (setq initial-buffer-choice t)
525 Now let's customize the =*scratch*= buffer a bit. First off, I don't
526 need the default hint.
528 #+begin_src emacs-lisp
529 (setq initial-scratch-message nil)
532 Also, let's use Text mode as the major mode, in case I want to
533 customize it (=*scratch*='s default major mode, Fundamental mode,
534 can't really be customized).
536 #+begin_src emacs-lisp
537 (setq initial-major-mode 'text-mode)
540 Inhibit the buffer list when more than 2 files are loaded.
542 #+begin_src emacs-lisp
543 (setq inhibit-startup-buffer-menu t)
546 I don't really need to see the startup screen or echo area message
549 #+begin_src emacs-lisp
550 (advice-add #'display-startup-echo-area-message :override #'ignore)
551 (setq inhibit-startup-screen t
552 inhibit-startup-echo-area-message user-login-name)
555 *** More useful frame titles
557 Show either the file name or the buffer name (in case the buffer isn't
558 visiting a file). Borrowed from Emacs Prelude.
560 #+begin_src emacs-lisp
561 (setq frame-title-format
562 '("" invocation-name " - "
563 (:eval (if (buffer-file-name)
564 (abbreviate-file-name (buffer-file-name))
570 Emacs' default backup settings aren't that great. Let's use more
571 sensible options. See documentation for the ~make-backup-file~
574 #+begin_src emacs-lisp
575 (setq backup-by-copying t
577 delete-old-versions t)
582 Enable automatic reloading of changed buffers and files.
584 #+begin_src emacs-lisp
585 (global-auto-revert-mode 1)
586 (setq auto-revert-verbose nil
587 global-auto-revert-non-file-buffers nil)
590 *** Always use space for indentation
592 #+begin_src emacs-lisp
595 require-final-newline t
601 Enable =winner-mode=.
603 #+begin_src emacs-lisp
607 *** Don’t display =*compilation*= on success
609 Based on https://stackoverflow.com/a/17788551, with changes to use
610 =cl-letf= instead of the now obsolete =flet=.
612 #+begin_src emacs-lisp
613 (with-eval-after-load 'compile
614 (defun a/compilation-finish-function (buffer outstr)
615 (unless (string-match "finished" outstr)
616 (switch-to-buffer-other-window buffer))
619 (setq compilation-finish-functions #'a/compilation-finish-function)
623 (defadvice compilation-start
624 (around inhibit-display
625 (command &optional mode name-function highlight-regexp))
626 (if (not (string-match "^\\(find\\|grep\\)" command))
627 (cl-letf (((symbol-function 'display-buffer) #'ignore))
628 (save-window-excursion ad-do-it))
630 (ad-activate 'compilation-start))
633 *** Search for non-ASCII characters
635 I’d like non-ASCII characters such as ‘’“”«»‹›áⓐ𝒶 to be selected when
636 I search for their ASCII counterpart. Shoutout to [[http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html][endlessparentheses]]
639 #+begin_src emacs-lisp
640 (setq search-default-mode #'char-fold-to-regexp)
642 ;; uncomment to extend this behaviour to query-replace
643 ;; (setq replace-char-fold t)
648 #+begin_src emacs-lisp
649 (setq-default cursor-type 'bar)
654 #+begin_src emacs-lisp
658 ("C-c e b" . eval-buffer)
659 ("C-c e r" . eval-region)
661 ("C-c F m" . make-frame-command)
662 ("C-c F d" . delete-frame)
663 ("C-c F D" . delete-other-frames)
665 ("C-c o" . other-window)
667 ("C-c Q" . save-buffers-kill-terminal)
669 ("C-S-h C" . describe-char)
670 ("C-S-h F" . describe-face)
672 ("C-x K" . kill-this-buffer)
674 ("s-p" . beginning-of-buffer)
675 ("s-n" . end-of-buffer))
680 The packages in this section are absolutely essential to my everyday
681 workflow, and they play key roles in how I do my computing. They
682 immensely enhance the Emacs experience for me; both using Emacs, and
685 *** [[https://github.com/emacscollective/auto-compile][auto-compile]]
687 #+begin_src emacs-lisp
688 (use-package auto-compile
691 (auto-compile-on-load-mode)
692 (auto-compile-on-save-mode)
693 (setq auto-compile-display-buffer nil
694 auto-compile-mode-line-counter t
695 auto-compile-source-recreate-deletes-dest t
696 auto-compile-toggle-deletes-nonlib-dest t
697 auto-compile-update-autoloads t)
698 (add-hook 'auto-compile-inhibit-compile-hook
699 'auto-compile-inhibit-compile-detached-git-head))
702 *** [[https://orgmode.org/][Org mode]]
705 Org mode is for keeping notes, maintaining TODO lists, planning
706 projects, and authoring documents with a fast and effective plain-text
710 In short, my favourite way of life.
712 #+begin_src emacs-lisp
716 (setq org-src-tab-acts-natively t
717 org-src-preserve-indentation nil
718 org-edit-src-content-indentation 0
719 org-email-link-description-format "Email %c: %s" ; %.30s
720 org-highlight-latex-and-related '(entities)
721 org-use-speed-commands t
722 org-startup-folded 'content
723 org-catch-invisible-edits 'show-and-error
725 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
726 (font-lock-add-keywords
728 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
729 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
730 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
731 (4 '(:foreground "#c5c8c6") t))) ; title
733 :bind (:map org-mode-map ("M-L" . org-insert-last-stored-link))
734 :hook ((org-mode . org-indent-mode)
735 (org-mode . auto-fill-mode)
736 (org-mode . flyspell-mode))
738 (org-latex-packages-alist '(("" "listings") ("" "color")))
740 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
741 '(org-block ((t (:background "#1d1f21"))))
742 '(org-latex-and-related ((t (:foreground "#b294bb")))))
744 (use-package ox-latex
747 (setq org-latex-listings 'listings
748 ;; org-latex-prefer-user-labels t
750 (add-to-list 'org-latex-packages-alist '("" "listings"))
751 (add-to-list 'org-latex-packages-alist '("" "color"))
752 (add-to-list 'org-latex-classes
753 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
754 ("\\section{%s}" . "\\section*{%s}")
755 ("\\subsection{%s}" . "\\subsection*{%s}")
756 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
757 ("\\paragraph{%s}" . "\\paragraph*{%s}")
758 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
761 (use-package ox-beamer
764 (use-package orgalist
766 :hook (message-mode . orgalist-mode))
769 **** asynchronous tangle
771 =a/async-babel-tangle= is a function closely inspired by [[https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles][dieggsy's
772 d/async-babel-tangle]] which uses [[https://github.com/jwiegley/emacs-async][async]] to asynchronously tangle an org
775 #+begin_src emacs-lisp
776 (with-eval-after-load 'org
777 (defvar a/show-async-tangle-results nil
778 "Keep *emacs* async buffers around for later inspection.")
780 (defvar a/show-async-tangle-time nil
781 "Show the time spent tangling the file.")
783 (defvar a/async-tangle-post-compile "make ti"
784 "If non-nil, pass to `compile' after successful tangle.")
786 (defun a/async-babel-tangle ()
787 "Tangle org file asynchronously."
789 (let* ((file-tangle-start-time (current-time))
790 (file (buffer-file-name))
791 (file-nodir (file-name-nondirectory file))
792 ;; (async-quiet-switch "-q")
797 (org-babel-tangle-file ,file))
798 (unless a/show-async-tangle-results
802 (message "Tangled %s%s"
804 (if a/show-async-tangle-time
806 (float-time (time-subtract (current-time)
807 ',file-tangle-start-time)))
809 (when a/async-tangle-post-compile
810 (compile a/async-tangle-post-compile)))
811 (message "Tangling %s failed" ,file-nodir))))))))
814 'safe-local-variable-values
815 '(eval add-hook 'after-save-hook #'a/async-babel-tangle 'append 'local))
818 *** [[https://magit.vc/][Magit]]
821 It's Magit! A Git porcelain inside Emacs.
824 Not just how I do git, but /the/ way to do git.
826 #+begin_src emacs-lisp
829 :bind (("C-x g" . magit-status)
830 ("s-g s" . magit-status)
831 ("s-g l" . magit-log-buffer-file))
833 (magit-add-section-hook 'magit-status-sections-hook
834 'magit-insert-modules
835 'magit-insert-stashes
838 magit-repository-directories '(("~/.emacs.d/" . 0)
840 (nconc magit-section-initial-visibility-alist
841 '(([unpulled status] . show)
842 ([unpushed status] . show)))
843 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
846 *** [[https://github.com/abo-abo/swiper][Ivy]] (and friends)
849 Ivy - a generic completion frontend for Emacs, Swiper - isearch with
850 an overview, and more. Oh, man!
853 There's no way I could top that, so I won't attempt to.
857 #+begin_src emacs-lisp
861 (:map ivy-minibuffer-map
862 ([escape] . keyboard-escape-quit)
863 ([S-up] . ivy-previous-history-element)
864 ([S-down] . ivy-next-history-element)
865 ("DEL" . ivy-backward-delete-char))
870 ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
871 ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
872 ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
878 #+begin_src emacs-lisp
880 :bind (("C-s" . swiper)
882 ("C-S-s" . isearch-forward)))
887 #+begin_src emacs-lisp
890 :bind (([remap execute-extended-command] . counsel-M-x)
891 ([remap find-file] . counsel-find-file)
892 ("s-r" . counsel-recentf)
893 ("C-c x" . counsel-M-x)
894 ("C-c f ." . counsel-find-file)
895 :map minibuffer-local-map
896 ("C-r" . counsel-minibuffer-history))
899 (defalias 'locate #'counsel-locate))
904 #+begin_src emacs-lisp
908 :bind ("C-c a s e" . eshell)
910 (eval-when-compile (defvar eshell-prompt-regexp))
911 (defun a/eshell-quit-or-delete-char (arg)
913 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
914 (eshell-life-is-too-much)
917 (defun a/eshell-clear ()
919 (let ((inhibit-read-only t))
923 (defun a/eshell-setup ()
924 (make-local-variable 'company-idle-delay)
925 (defvar company-idle-delay nil)
926 (bind-keys :map eshell-mode-map
927 ("C-d" . a/eshell-quit-or-delete-char)
928 ("C-S-l" . a/eshell-clear)
929 ("M-r" . counsel-esh-history)
930 ([tab] . company-complete)))
932 :hook (eshell-mode . a/eshell-setup)
934 (eshell-hist-ignoredups t)
935 (eshell-input-filter 'eshell-input-filter-initial-space))
940 #+begin_src emacs-lisp
944 (("C-x C-b" . ibuffer-other-window)
945 :map ibuffer-mode-map
946 ("P" . ibuffer-backward-filter-group)
947 ("N" . ibuffer-forward-filter-group)
948 ("M-p" . ibuffer-do-print)
949 ("M-n" . ibuffer-do-shell-command-pipe-replace))
951 ;; Use human readable Size column instead of original one
952 (define-ibuffer-column size-h
953 (:name "Size" :inline t)
955 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
956 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
957 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
958 (t (format "%8d" (buffer-size)))))
960 (ibuffer-saved-filter-groups
962 ("dired" (mode . dired-mode))
963 ("org" (mode . org-mode))
966 (mode . gnus-group-mode)
967 (mode . gnus-summary-mode)
968 (mode . gnus-article-mode)
969 ;; not really, but...
970 (mode . message-mode)))
987 (mode . emacs-lisp-mode)
989 (mode . haskell-mode)
993 (name . "^\\*scratch\\*$")
994 (name . "^\\*Messages\\*$"))))))
996 '((mark modified read-only locked " "
997 (name 18 18 :left :elide)
1001 (mode 16 16 :left :elide)
1002 " " filename-and-process)
1006 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
1011 #+begin_src emacs-lisp
1012 (use-package outline
1014 :hook (prog-mode . outline-minor-mode)
1017 outline-minor-mode-map
1018 ("<s-tab>" . outline-toggle-children)
1019 ("M-p" . outline-previous-visible-heading)
1020 ("M-n" . outline-next-visible-heading)
1021 :prefix-map a/outline-prefix-map
1023 ("TAB" . outline-toggle-children)
1024 ("a" . outline-hide-body)
1025 ("H" . outline-hide-body)
1026 ("S" . outline-show-all)
1027 ("h" . outline-hide-subtree)
1028 ("s" . outline-show-subtree)))
1031 * Borg's =layer/essentials=
1033 :CUSTOM_ID: borg-essentials
1036 TODO: break this giant source block down into individual org sections.
1038 #+begin_src emacs-lisp
1040 :config (dash-enable-font-lock))
1042 (use-package diff-hl
1044 (setq diff-hl-draw-borders nil)
1045 (global-diff-hl-mode)
1046 (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh t))
1050 :config (setq dired-listing-switches "-alh"))
1053 :when (version< "25" emacs-version)
1054 :config (global-eldoc-mode))
1059 (temp-buffer-resize-mode)
1060 (setq help-window-select t))
1063 (setq isearch-allow-scroll t))
1065 (use-package lisp-mode
1067 (add-hook 'emacs-lisp-mode-hook 'outline-minor-mode)
1068 (add-hook 'emacs-lisp-mode-hook 'reveal-mode)
1069 (defun indent-spaces-mode ()
1070 (setq indent-tabs-mode nil))
1071 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
1075 :config (setq Man-width 80))
1078 :config (show-paren-mode))
1080 (use-package prog-mode
1081 :config (global-prettify-symbols-mode)
1082 (defun indicate-buffer-boundaries-left ()
1083 (setq indicate-buffer-boundaries 'left))
1084 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1086 (use-package recentf
1089 (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
1090 (setq recentf-max-saved-items 40))
1092 (use-package savehist
1093 :config (savehist-mode))
1095 (use-package saveplace
1096 :when (version< "25" emacs-version)
1097 :config (save-place-mode))
1100 :config (column-number-mode))
1102 (progn ; `text-mode'
1103 (add-hook 'text-mode-hook #'indicate-buffer-boundaries-left)
1104 (add-hook 'text-mode-hook #'abbrev-mode))
1109 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
1110 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
1111 (add-to-list 'tramp-default-proxies-alist
1112 (list (regexp-quote (system-name)) nil nil)))
1123 #+begin_src emacs-lisp
1124 (use-package company
1127 (:map company-active-map
1128 ([tab] . company-complete-common-or-cycle)
1129 ([escape] . company-abort))
1131 (company-minimum-prefix-length 1)
1132 (company-selection-wrap-around t)
1133 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1134 (company-dabbrev-downcase nil)
1135 (company-dabbrev-ignore-case nil)
1137 (global-company-mode t))
1140 * Syntax and spell checking
1142 :CUSTOM_ID: syntax-spell-checking
1145 #+begin_src emacs-lisp
1146 (use-package flycheck
1148 :hook (prog-mode . flycheck-mode)
1150 (:map flycheck-mode-map
1151 ("M-P" . flycheck-previous-error)
1152 ("M-N" . flycheck-next-error))
1154 ;; Use the load-path from running Emacs when checking elisp files
1155 (setq flycheck-emacs-lisp-load-path 'inherit)
1157 ;; Only flycheck when I actually save the buffer
1158 (setq flycheck-check-syntax-automatically '(mode-enabled save)))
1160 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1164 ;; ’ can be part of a word
1165 (setq ispell-local-dictionary-alist
1166 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1167 "['\x2019]" nil ("-B") nil utf-8)))
1168 ;; don't send ’ to the subprocess
1169 (defun endless/replace-apostrophe (args)
1170 (cons (replace-regexp-in-string
1173 (advice-add #'ispell-send-string :filter-args
1174 #'endless/replace-apostrophe)
1176 ;; convert ' back to ’ from the subprocess
1177 (defun endless/replace-quote (args)
1178 (if (not (derived-mode-p 'org-mode))
1180 (cons (replace-regexp-in-string
1183 (advice-add #'ispell-parse-output :filter-args
1184 #'endless/replace-quote))
1189 :CUSTOM_ID: programming-modes
1192 ** [[http://alloytools.org][Alloy]] (with [[https://github.com/dwwmmn/alloy-mode][alloy-mode]])
1194 #+begin_src emacs-lisp
1195 (use-package alloy-mode
1197 :config (setq alloy-basic-offset 2))
1200 ** [[https://coq.inria.fr][Coq]] (with [[https://github.com/ProofGeneral/PG][Proof General]])
1202 #+begin_src emacs-lisp
1203 (use-package proof-site ; Proof General
1205 :load-path "lib/proof-site/generic/")
1208 ** [[https://leanprover.github.io][Lean]] (with [[https://github.com/leanprover/lean-mode][lean-mode]])
1210 #+begin_src emacs-lisp
1211 (eval-when-compile (defvar lean-mode-map))
1212 (use-package lean-mode
1214 :bind (:map lean-mode-map
1215 ("S-SPC" . company-complete))
1217 (require 'lean-input)
1218 (setq default-input-method "Lean"
1219 lean-input-tweak-all '(lean-input-compose
1220 (lean-input-prepend "/")
1221 (lean-input-nonempty))
1222 lean-input-user-translations '(("/" "/")))
1228 *** [[https://github.com/haskell/haskell-mode][haskell-mode]]
1230 #+begin_src emacs-lisp
1231 (use-package haskell-mode
1234 (setq haskell-indentation-layout-offset 4
1235 haskell-indentation-left-offset 4
1236 flycheck-checker 'haskell-hlint
1237 flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc)))
1240 *** [[https://github.com/jyp/dante][dante]]
1242 #+begin_src emacs-lisp
1245 :commands dante-mode
1246 :hook (haskell-mode . dante-mode))
1249 *** [[https://github.com/mpickering/hlint-refactor-mode][hlint-refactor]]
1251 Emacs bindings for [[https://github.com/ndmitchell/hlint][hlint]]'s refactor option. This requires the refact
1252 executable from [[https://github.com/mpickering/apply-refact][apply-refact]].
1254 #+begin_src emacs-lisp
1255 (use-package hlint-refactor
1257 :bind (:map hlint-refactor-mode-map
1258 ("C-c l b" . hlint-refactor-refactor-buffer)
1259 ("C-c l r" . hlint-refactor-refactor-at-point))
1260 :hook (haskell-mode . hlint-refactor-mode))
1263 *** [[https://github.com/flycheck/flycheck-haskell][flycheck-haskell]]
1265 #+begin_src emacs-lisp
1266 (use-package flycheck-haskell
1267 :after haskell-mode)
1270 *** [[https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el][hs-lint.el]]
1272 :header-args+: :tangle lisp/hs-lint.el :mkdirp yes
1275 Currently using =flycheck-haskell= with the =haskell-hlint= checker
1278 #+begin_src emacs-lisp :tangle no
1279 ;;; hs-lint.el --- minor mode for HLint code checking
1281 ;; Copyright 2009 (C) Alex Ott
1283 ;; Author: Alex Ott <alexott@gmail.com>
1284 ;; Keywords: haskell, lint, HLint
1286 ;; Status: distributed under terms of GPL2 or above
1288 ;; Typical message from HLint looks like:
1290 ;; /Users/ott/projects/lang-exp/haskell/test.hs:52:1: Eta reduce
1292 ;; count1 p l = length (filter p l)
1294 ;; count1 p = length . filter p
1299 (defgroup hs-lint nil
1300 "Run HLint as inferior of Emacs, parse error messages."
1304 (defcustom hs-lint-command "hlint"
1305 "The default hs-lint command for \\[hlint]."
1309 (defcustom hs-lint-save-files t
1310 "Save modified files when run HLint or no (ask user)"
1314 (defcustom hs-lint-replace-with-suggestions nil
1315 "Replace user's code with suggested replacements"
1319 (defcustom hs-lint-replace-without-ask nil
1320 "Replace user's code with suggested replacements automatically"
1324 (defun hs-lint-process-setup ()
1325 "Setup compilation variables and buffer for `hlint'."
1326 (run-hooks 'hs-lint-setup-hook))
1328 ;; regex for replace suggestions
1330 ;; ^\(.*?\):\([0-9]+\):\([0-9]+\): .*
1336 (defvar hs-lint-regex
1337 "^\\(.*?\\):\\([0-9]+\\):\\([0-9]+\\): .*[\n\C-m]Found:[\n\C-m]\\s +\\(.*\\)[\n\C-m]Why not:[\n\C-m]\\s +\\(.*\\)[\n\C-m]"
1338 "Regex for HLint messages")
1340 (defun make-short-string (str maxlen)
1341 (if (< (length str) maxlen)
1343 (concat (substring str 0 (- maxlen 3)) "...")))
1345 (defun hs-lint-replace-suggestions ()
1346 "Perform actual replacement of suggestions"
1347 (goto-char (point-min))
1348 (while (re-search-forward hs-lint-regex nil t)
1349 (let* ((fname (match-string 1))
1350 (fline (string-to-number (match-string 2)))
1351 (old-code (match-string 4))
1352 (new-code (match-string 5))
1353 (msg (concat "Replace '" (make-short-string old-code 30)
1354 "' with '" (make-short-string new-code 30) "'"))
1360 (switch-to-buffer (get-file-buffer fname))
1361 (goto-char (point-min))
1362 (forward-line (1- fline))
1364 (setf bline (point))
1365 (when (or hs-lint-replace-without-ask
1368 (setf eline (point))
1370 (setf old-code (regexp-quote old-code))
1371 (while (string-match "\\\\ " old-code spos)
1372 (setf new-old-code (concat new-old-code
1373 (substring old-code spos (match-beginning 0))
1375 (setf spos (match-end 0)))
1376 (setf new-old-code (concat new-old-code (substring old-code spos)))
1377 (remove-text-properties bline eline '(composition nil))
1378 (when (re-search-forward new-old-code eline t)
1379 (replace-match new-code nil t)))))))
1381 (defun hs-lint-finish-hook (buf msg)
1382 "Function, that is executed at the end of HLint execution"
1383 (if hs-lint-replace-with-suggestions
1384 (hs-lint-replace-suggestions)
1387 (define-compilation-mode hs-lint-mode "HLint"
1388 "Mode for check Haskell source code."
1389 (set (make-local-variable 'compilation-process-setup-function)
1390 'hs-lint-process-setup)
1391 (set (make-local-variable 'compilation-disable-input) t)
1392 (set (make-local-variable 'compilation-scroll-output) nil)
1393 (set (make-local-variable 'compilation-finish-functions)
1394 (list 'hs-lint-finish-hook))
1398 "Run HLint for current buffer with haskell source"
1400 (save-some-buffers hs-lint-save-files)
1401 (compilation-start (concat hs-lint-command " \"" buffer-file-name "\"")
1405 ;;; hs-lint.el ends here
1408 #+begin_src emacs-lisp :tangle no
1409 (use-package hs-lint
1411 :bind (:map haskell-mode-map
1412 ("C-c l l" . hs-lint)))
1419 #+begin_src emacs-lisp
1420 (use-package sgml-mode
1423 (setq sgml-basic-offset 2))
1428 #+begin_src emacs-lisp
1429 (use-package css-mode
1432 (setq css-indent-offset 2))
1437 #+begin_src emacs-lisp
1438 (use-package web-mode
1443 web-mode-code-indent-offset
1444 web-mode-css-indent-offset
1445 web-mode-markup-indent-offset))
1450 #+begin_src emacs-lisp
1451 (use-package emmet-mode
1452 :after (:any web-mode css-mode sgml-mode)
1453 :bind* (("C-)" . emmet-next-edit-point)
1454 ("C-(" . emmet-prev-edit-point))
1456 (unbind-key "C-j" emmet-mode-keymap)
1457 (setq emmet-move-cursor-between-quotes t)
1458 :hook (web-mode css-mode html-mode sgml-mode))
1465 #+begin_src emacs-lisp
1466 (use-package meghanada
1468 (:map meghanada-mode-map
1469 (("C-M-o" . meghanada-optimize-import)
1470 ("C-M-t" . meghanada-import-all)))
1471 :hook (java-mode . meghanada-mode))
1492 #+begin_src emacs-lisp
1493 (use-package treemacs
1494 :config (setq treemacs-never-persist t))
1496 (use-package yasnippet
1498 ;; (yas-global-mode)
1501 (use-package lsp-mode
1502 :init (setq lsp-eldoc-render-all nil
1503 lsp-highlight-symbol-at-point nil)
1508 (use-package company-lsp
1511 (setq company-lsp-cache-candidates t
1512 company-lsp-async t))
1516 (setq lsp-ui-sideline-update-mode 'point))
1518 (use-package lsp-java
1520 (add-hook 'java-mode-hook
1522 (setq-local company-backends (list 'company-lsp))))
1524 (add-hook 'java-mode-hook 'lsp-java-enable)
1525 (add-hook 'java-mode-hook 'flycheck-mode)
1526 (add-hook 'java-mode-hook 'company-mode)
1527 (add-hook 'java-mode-hook 'lsp-ui-mode))
1529 (use-package dap-mode
1535 (use-package dap-java
1538 (use-package lsp-java-treemacs
1544 #+begin_src emacs-lisp
1545 (use-package geiser)
1547 (use-package geiser-guile
1549 (setq geiser-guile-load-path "~/src/git/guix"))
1554 #+begin_src emacs-lisp
1556 :load-path "lib/guix/elisp")
1559 * Emacs enhancements
1561 :CUSTOM_ID: emacs-enhancements
1564 ** [[https://github.com/justbur/emacs-which-key][which-key]]
1567 Emacs package that displays available keybindings in popup
1570 #+begin_src emacs-lisp
1571 (use-package which-key
1573 :config (which-key-mode))
1578 #+begin_src emacs-lisp
1579 (add-to-list 'custom-theme-load-path "~/.emacs.d/lisp")
1580 (load-theme 'tangomod t)
1585 #+begin_src emacs-lisp
1586 (use-package smart-mode-line
1593 #+begin_src emacs-lisp
1594 (use-package doom-themes)
1597 ** theme helper functions
1599 #+begin_src emacs-lisp
1600 (defun a/lights-on ()
1601 "Enable my favourite light theme."
1603 (mapc #'disable-theme custom-enabled-themes)
1604 (load-theme 'tangomod t)
1605 (sml/apply-theme 'automatic))
1607 (defun a/lights-off ()
1610 (mapc #'disable-theme custom-enabled-themes)
1611 (load-theme 'doom-tomorrow-night t)
1612 (sml/apply-theme 'automatic))
1615 ("s-t d" . a/lights-off)
1616 ("s-t l" . a/lights-on))
1619 ** [[https://github.com/bbatsov/crux][crux]]
1621 #+begin_src emacs-lisp
1624 :bind (("C-c b k" . crux-kill-other-buffers)
1625 ("C-c d" . crux-duplicate-current-line-or-region)
1626 ("C-c D" . crux-duplicate-and-comment-current-line-or-region)
1627 ("C-c f c" . crux-copy-file-preserve-attributes)
1628 ("C-c f d" . crux-delete-file-and-buffer)
1629 ("C-c f r" . crux-rename-file-and-buffer)
1630 ("C-c j" . crux-top-join-line)
1631 ("C-S-j" . crux-top-join-line)))
1634 ** [[https://github.com/alezost/mwim.el][mwim]]
1636 #+begin_src emacs-lisp
1638 :bind (("C-a" . mwim-beginning-of-code-or-line)
1639 ("C-e" . mwim-end-of-code-or-line)
1640 ("<home>" . mwim-beginning-of-line-or-code)
1641 ("<end>" . mwim-end-of-line-or-code)))
1646 #+begin_src emacs-lisp
1647 (use-package projectile
1649 :bind-keymap ("C-c p" . projectile-command-map)
1653 (defun my-projectile-invalidate-cache (&rest _args)
1654 ;; ignore the args to `magit-checkout'
1655 (projectile-invalidate-cache nil))
1657 (eval-after-load 'magit-branch
1659 (advice-add 'magit-checkout
1660 :after #'my-projectile-invalidate-cache)
1661 (advice-add 'magit-branch-and-checkout
1662 :after #'my-projectile-invalidate-cache)))
1663 :custom (projectile-completion-system 'ivy))
1666 ** [[https://github.com/Wilfred/helpful][helpful]]
1668 #+begin_src emacs-lisp
1669 (use-package helpful
1672 (("C-S-h c" . helpful-command)
1673 ("C-S-h f" . helpful-callable) ; helpful-function
1674 ("C-S-h v" . helpful-variable)
1675 ("C-S-h k" . helpful-key)
1676 ("C-S-h p" . helpful-at-point)))
1679 ** [[https://github.com/EricCrosson/unkillable-scratch][unkillable-scratch]]
1681 Make =*scratch*= and =*Messages*= unkillable.
1683 #+begin_src emacs-lisp
1684 (use-package unkillable-scratch
1687 (unkillable-scratch 1)
1689 (unkillable-scratch-behavior 'do-nothing)
1690 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1693 ** [[https://github.com/davep/boxquote.el][boxquote.el]]
1697 | make pretty boxed quotes like this
1701 #+begin_src emacs-lisp
1702 (use-package boxquote
1705 (:prefix-map a/boxquote-prefix-map
1707 ("b" . boxquote-buffer)
1708 ("B" . boxquote-insert-buffer)
1709 ("d" . boxquote-defun)
1710 ("F" . boxquote-insert-file)
1711 ("hf" . boxquote-describe-function)
1712 ("hk" . boxquote-describe-key)
1713 ("hv" . boxquote-describe-variable)
1714 ("hw" . boxquote-where-is)
1715 ("k" . boxquote-kill)
1716 ("p" . boxquote-paragraph)
1717 ("q" . boxquote-boxquote)
1718 ("r" . boxquote-region)
1719 ("s" . boxquote-shell-command)
1720 ("t" . boxquote-text)
1721 ("T" . boxquote-title)
1722 ("u" . boxquote-unbox)
1723 ("U" . boxquote-unbox-region)
1724 ("y" . boxquote-yank)
1725 ("M-q" . boxquote-fill-paragraph)
1726 ("M-w" . boxquote-kill-ring-save)))
1729 Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
1733 #+begin_src emacs-lisp
1737 (typo-global-mode 1)
1738 :hook (text-mode . typo-mode))
1743 #+begin_src emacs-lisp
1744 (use-package hl-todo
1747 (global-hl-todo-mode))
1752 #+begin_src emacs-lisp
1753 (use-package shrink-path
1756 (setq eshell-prompt-regexp "\\(.*\n\\)*λ "
1757 eshell-prompt-function #'+eshell/prompt)
1759 (defun +eshell/prompt ()
1760 (let ((base/dir (shrink-path-prompt default-directory)))
1761 (concat (propertize (car base/dir)
1762 'face 'font-lock-comment-face)
1763 (propertize (cdr base/dir)
1764 'face 'font-lock-constant-face)
1765 (propertize (+eshell--current-git-branch)
1766 'face 'font-lock-function-name-face)
1768 (propertize "λ" 'face 'eshell-prompt-face)
1769 ;; needed for the input text to not have prompt face
1770 (propertize " " 'face 'default))))
1772 (defun +eshell--current-git-branch ()
1773 (let ((branch (car (loop for match in (split-string (shell-command-to-string "git branch") "\n")
1774 when (string-match "^\*" match)
1776 (if (not (eq branch nil))
1777 (concat " " (substring branch 2))
1781 ** [[https://github.com/peterwvj/eshell-up][eshell-up]]
1783 #+begin_src emacs-lisp
1784 (use-package eshell-up
1790 #+begin_src emacs-lisp
1791 (use-package multi-term
1793 :bind (("C-c a s m m" . multi-term)
1794 ("C-c a s m p" . multi-term-dedicated-toggle)
1796 ("C-c C-j" . term-char-mode)
1798 ("C-c C-j" . term-line-mode))
1800 (setq multi-term-program "/bin/screen"
1801 ;; TODO: add separate bindings for connecting to existing
1802 ;; session vs. always creating a new one
1803 multi-term-dedicated-select-after-open-p t
1804 multi-term-dedicated-window-height 20
1805 multi-term-dedicated-max-window-height 30
1807 '(("C-c C-c" . term-interrupt-subjob)
1808 ("C-c C-e" . term-send-esc)
1810 ("C-y" . term-paste)
1811 ("M-f" . term-send-forward-word)
1812 ("M-b" . term-send-backward-word)
1813 ("M-p" . term-send-up)
1814 ("M-n" . term-send-down)
1815 ("<C-backspace>" . term-send-backward-kill-word)
1816 ("<M-DEL>" . term-send-backward-kill-word)
1817 ("M-d" . term-send-delete-word)
1818 ("M-," . term-send-raw)
1819 ("M-." . comint-dynamic-complete))
1820 term-unbind-key-alist
1821 '("C-z" "C-x" "C-c" "C-h" "C-y" "<ESC>")))
1826 #+begin_src emacs-lisp
1827 (use-package page-break-lines
1829 (global-page-break-lines-mode))
1834 #+begin_src emacs-lisp
1835 (use-package expand-region
1836 :bind ("C-=" . er/expand-region))
1844 #+begin_src emacs-lisp
1845 (defvar a/maildir (expand-file-name "~/mail/"))
1846 (with-eval-after-load 'recentf
1847 (add-to-list 'recentf-exclude a/maildir))
1852 #+begin_src emacs-lisp
1854 a/gnus-init-file (no-littering-expand-etc-file-name "gnus")
1855 mail-user-agent 'gnus-user-agent
1856 read-mail-command 'gnus)
1859 :bind (("C-c m" . gnus)
1860 ("C-c M" . gnus-unplugged)
1862 ("s-M" . gnus-unplugged))
1865 gnus-select-method '(nnnil "")
1866 gnus-secondary-select-methods
1868 (nnimap-stream plain)
1869 (nnimap-address "127.0.0.1")
1870 (nnimap-server-port 143)
1871 (nnimap-authenticator plain)
1872 (nnimap-user "amin@aminb.org"))
1874 (nnimap-stream plain)
1875 (nnimap-address "127.0.0.1")
1876 (nnimap-server-port 143)
1877 (nnimap-authenticator plain)
1878 (nnimap-user "abandali@uwaterloo.ca")))
1879 gnus-message-archive-group "nnimap+amin:Sent"
1883 gnus-large-newsgroup 50
1884 gnus-home-directory (no-littering-expand-var-file-name "gnus/")
1885 gnus-directory (concat gnus-home-directory "news/")
1886 message-directory (concat gnus-home-directory "mail/")
1887 nndraft-directory (concat gnus-home-directory "drafts/")
1888 gnus-save-newsrc-file nil
1889 gnus-read-newsrc-file nil
1890 gnus-interactive-exit nil
1891 gnus-gcc-mark-as-read t))
1893 (use-package gnus-art
1896 gnus-visible-headers
1897 (concat gnus-visible-headers "\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
1898 gnus-sorted-header-list
1899 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
1900 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
1901 "^Newsgroups:" "List-Id:" "^Organization:"
1902 "^User-Agent:" "^Date:")
1903 ;; local-lapsed article dates
1904 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1905 gnus-article-date-headers '(user-defined)
1906 gnus-article-time-format
1908 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
1909 (local (article-make-date-line date 'local))
1910 (combined-lapsed (article-make-date-line date
1913 (string-match " (.+" combined-lapsed)
1914 (match-string 0 combined-lapsed))))
1915 (concat local lapsed))))
1917 :map gnus-article-mode-map
1918 ("r" . gnus-article-reply-with-original)
1919 ("R" . gnus-article-wide-reply-with-original)
1920 ("M-L" . org-store-link)))
1922 (use-package gnus-sum
1923 :bind (:map gnus-summary-mode-map
1924 :prefix-map a/gnus-summary-prefix-map
1926 ("r" . gnus-summary-reply)
1927 ("w" . gnus-summary-wide-reply)
1928 ("v" . gnus-summary-show-raw-article))
1931 :map gnus-summary-mode-map
1932 ("r" . gnus-summary-reply-with-original)
1933 ("R" . gnus-summary-wide-reply-with-original)
1934 ("M-L" . org-store-link))
1935 :hook (gnus-summary-mode . a/no-mouse-autoselect-window))
1937 (use-package gnus-msg
1939 (setq gnus-posting-styles
1941 (address "amin@aminb.org")
1942 (body "\nBest,\namin\n")
1943 (eval (setq a/message-cite-say-hi t)))
1945 (address "bandali@gnu.org"))
1946 ((header "subject" "ThankCRM")
1947 (to "webmasters-comment@gnu.org")
1948 (body "\nAdded to 2018supporters.html.\n\nMoving to campaigns.\n\n-amin\n")
1949 (eval (setq a/message-cite-say-hi nil)))
1950 ("nnimap\\+uwaterloo:.*"
1951 (address "abandali@uwaterloo.ca")
1952 (gcc "\"nnimap+uwaterloo:Sent Items\"")))))
1954 (use-package gnus-topic
1955 :hook (gnus-group-mode . gnus-topic-mode))
1957 (use-package gnus-agent
1959 (setq gnus-agent-synchronize-flags 'ask)
1960 :hook (gnus-group-mode . gnus-agent-mode))
1962 (use-package gnus-group
1964 (setq gnus-permanently-visible-groups "\\((INBOX\\|gnu$\\)"))
1966 (use-package mm-decode
1968 (setq mm-discouraged-alternatives '("text/html" "text/richtext")))
1973 #+begin_src emacs-lisp
1974 (use-package sendmail
1976 (setq sendmail-program "/usr/bin/msmtp"
1977 ;; message-sendmail-extra-arguments '("-v" "-d")
1978 mail-specify-envelope-from t
1979 mail-envelope-from 'header))
1984 #+begin_src emacs-lisp
1985 (use-package message
1987 (defconst a/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
1988 (defconst message-cite-style-bandali
1989 '((message-cite-function 'message-cite-original)
1990 (message-citation-line-function 'message-insert-formatted-citation-line)
1991 (message-cite-reply-position 'traditional)
1992 (message-yank-prefix "> ")
1993 (message-yank-cited-prefix ">")
1994 (message-yank-empty-prefix ">")
1995 (message-citation-line-format
1996 (if a/message-cite-say-hi
1997 (concat "Hi %F,\n\n" a/message-cite-style-format)
1998 a/message-cite-style-format)))
1999 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2000 (setq message-cite-style 'message-cite-style-bandali
2001 message-kill-buffer-on-exit t
2002 message-send-mail-function 'message-send-mail-with-sendmail
2003 message-sendmail-envelope-from 'header
2004 message-dont-reply-to-names
2005 "\\(\\(.*@aminb\\.org\\)\\|\\(amin@bandali\\.me\\)\\|\\(\\(aminb?\\|mab\\|bandali\\)@gnu\\.org\\)\\|\\(\\(m\\|a\\(min\\.\\)?\\)bandali@uwaterloo\\.ca\\)\\)"
2006 message-user-fqdn "aminb.org")
2007 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2008 (message-mode . flyspell-mode)
2009 (message-mode . (lambda ()
2010 ;; (setq fill-column 65
2011 ;; message-fill-column 65)
2012 (make-local-variable 'company-idle-delay)
2013 (setq company-idle-delay 0.2))))
2015 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2016 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2017 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2020 (with-eval-after-load 'mml-sec
2021 (setq mml-secure-openpgp-encrypt-to-self t
2022 mml-secure-openpgp-sign-with-sender t))
2027 Convenient footnotes in =message-mode=.
2029 #+begin_src emacs-lisp
2030 (use-package footnote
2033 (:map message-mode-map
2034 :prefix-map a/footnote-prefix-map
2036 ("a" . footnote-add-footnote)
2037 ("b" . footnote-back-to-message)
2038 ("c" . footnote-cycle-style)
2039 ("d" . footnote-delete-footnote)
2040 ("g" . footnote-goto-footnote)
2041 ("r" . footnote-renumber-footnotes)
2042 ("s" . footnote-set-style))
2044 (setq footnote-start-tag ""
2046 footnote-style 'unicode))
2051 #+begin_src emacs-lisp
2054 :bind (:map gnus-group-mode-map ("e" . ebdb))
2056 (setq ebdb-sources (no-littering-expand-var-file-name "ebdb"))
2057 (with-eval-after-load 'swiper
2058 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2060 (use-package ebdb-com
2063 ;; (use-package ebdb-complete
2066 ;; (ebdb-complete-enable))
2068 (use-package company-ebdb
2069 :after (:all company message)
2071 (defun company-ebdb--post-complete (_) nil)
2073 (message-mode . (lambda ()
2074 (add-to-list (make-local-variable 'company-backends)
2077 (use-package ebdb-gnus
2080 (ebdb-gnus-window-configuration
2083 (summary 0.25 point)
2086 (ebdb-gnus 0.3))))))
2088 (use-package ebdb-mua
2090 ;; :custom (ebdb-mua-pop-up nil)
2093 ;; (use-package ebdb-message
2097 ;; (use-package ebdb-vcard
2101 ** COMMENT message-x
2103 #+begin_src emacs-lisp
2104 (use-package message-x
2106 (message-x-completion-alist
2108 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2111 (quote message-newgroups-header-regexp))
2112 message-newgroups-header-regexp message-newsgroups-header-regexp)
2113 . message-expand-group)))))
2116 ** COMMENT gnus-harvest
2118 #+begin_src emacs-lisp
2119 (use-package gnus-harvest
2120 :commands gnus-harvest-install
2123 (if (featurep 'message-x)
2124 (gnus-harvest-install 'message-x)
2125 (gnus-harvest-install)))
2130 :CUSTOM_ID: blogging
2133 ** [[https://ox-hugo.scripter.co][ox-hugo]]
2135 #+begin_src emacs-lisp
2136 (use-package ox-hugo
2139 (use-package ox-hugo-auto-export
2140 :load-path "lib/ox-hugo")
2143 * Post initialization
2145 :CUSTOM_ID: post-initialization
2148 Display how long it took to load the init file.
2150 #+begin_src emacs-lisp
2151 (message "Loading %s...done (%.3fs)" user-init-file
2152 (float-time (time-subtract (current-time)
2153 a/before-user-init-time)))
2161 #+begin_src emacs-lisp :comments none
2162 ;;; init.el ends here
2165 * COMMENT Local Variables :ARCHIVE:
2167 # eval: (add-hook 'after-save-hook #'a/async-babel-tangle 'append 'local)
2168 # eval: (typo-mode -1)