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 and functional
110 ;; THIS FILE IS AUTO-GENERATED FROM `init.org'.
113 ** Naming conventions
115 The conventions below were inspired by [[https://github.com/hlissner/doom-emacs][Doom]]'s, found [[https://github.com/hlissner/doom-emacs/blob/5dacbb7cb1c6ac246a9ccd15e6c4290def67757c/core/core.el#L3-L17][here]].
117 #+begin_src emacs-lisp :comments none
118 ;; Naming conventions:
120 ;; amin-... public variables or non-interactive functions
121 ;; amin--... private anything (non-interactive), not safe for direct use
122 ;; amin/... an interactive function; safe for M-x or keybinding
123 ;; amin|... a hook function
124 ;; amin*... an advising function
125 ;; amin@... a hydra command
131 :CUSTOM_ID: initial-setup
134 ** Emacs initialization
136 I'd like to do a couple of measurements of Emacs' startup time. First,
137 let's see how long Emacs takes to start up, before even loading
138 =init.el=, i.e. =user-init-file=:
140 #+begin_src emacs-lisp
141 (defvar amin--before-user-init-time (current-time)
142 "Value of `current-time' when Emacs begins loading `user-init-file'.")
143 (message "Loading Emacs...done (%.3fs)"
144 (float-time (time-subtract amin--before-user-init-time
148 Also, temporarily increase ~gc-cons-threshhold~ and
149 ~gc-cons-percentage~ during startup to reduce garbage collection
150 frequency. Clearing the ~file-name-handler-alist~ seems to help reduce
151 startup time as well.
153 #+begin_src emacs-lisp
154 (defvar amin--gc-cons-threshold gc-cons-threshold)
155 (defvar amin--gc-cons-percentage gc-cons-percentage)
156 (defvar amin--file-name-handler-alist file-name-handler-alist)
157 (setq gc-cons-threshold (* 400 1024 1024) ; 400 MiB
158 gc-cons-percentage 0.6
159 file-name-handler-alist nil
160 ;; sidesteps a bug when profiling with esup
161 esup-child-profile-require-level 0)
164 Of course, we'd like to set them back to their defaults once we're
167 #+begin_src emacs-lisp
171 (setq gc-cons-threshold amin--gc-cons-threshold
172 gc-cons-percentage amin--gc-cons-percentage
173 file-name-handler-alist amin--file-name-handler-alist)))
176 Increase the number of lines kept in message logs (the =*Messages*=
179 #+begin_src emacs-lisp
180 (setq message-log-max 20000)
183 Optionally, we could suppress some byte compiler warnings like below,
184 but for now I've decided to keep them enabled. See documentation for
185 ~byte-compile-warnings~ for more details.
187 #+begin_src emacs-lisp
188 ;; (setq byte-compile-warnings
189 ;; '(not free-vars unresolved noruntime lexical make-local))
194 #+begin_src emacs-lisp
195 (setq user-full-name "Amin Bandali"
196 user-mail-address "amin@aminb.org")
199 ** Package management
203 I can do all my package management things with Borg, and don't need
204 Emacs' built-in =package.el=. Emacs 27 lets us disable =package.el= in
205 the =early-init-file= (see [[https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b][here]]).
207 #+begin_src emacs-lisp :tangle early-init.el
208 (setq package-enable-at-startup nil)
211 But since Emacs 27 isn't out yet (Emacs 26 is just around the corner
212 right now), and even when released it'll be long before most distros
213 ship in their repos, I'll still put the old workaround with the
214 commented call to ~package-initialize~ here anyway.
216 #+begin_src emacs-lisp
217 (setq package-enable-at-startup nil)
218 ;; (package-initialize)
224 Assimilate Emacs packages as Git submodules
227 [[https://github.com/emacscollective/borg][Borg]] is at the heart of package management of my Emacs setup. In
228 short, it creates a git submodule in =lib/= for each package, which
229 can then be managed with the help of Magit or other tools.
231 #+begin_src emacs-lisp
232 (setq user-init-file (or load-file-name buffer-file-name)
233 user-emacs-directory (file-name-directory user-init-file))
234 (add-to-list 'load-path
235 (expand-file-name "lib/borg" user-emacs-directory))
239 ;; (require 'borg-nix-shell)
240 ;; (setq borg-build-shell-command 'borg-nix-shell-build-command)
242 (with-eval-after-load 'bind-key
245 ("C-c b A" . borg-activate)
246 ("C-c b a" . borg-assimilate)
247 ("C-c b b" . borg-build)
248 ("C-c b c" . borg-clone)
249 ("C-c b r" . borg-remove)))
255 A use-package declaration for simplifying your .emacs
258 [[https://github.com/jwiegley/use-package][use-package]] is an awesome utility for managing and configuring
259 packages (in our case especially the latter) in a neatly organized way
260 and without compromising on performance.
262 #+begin_src emacs-lisp
263 (require 'use-package)
264 (if nil ; set to t when need to debug init
265 (setq use-package-verbose t
266 use-package-expand-minimally nil
267 use-package-compute-statistics t
269 (setq use-package-verbose nil
270 use-package-expand-minimally t))
276 Browse the Emacsmirror package database
279 Epkg provides access to a local copy of the [[https://emacsmirror.net][Emacsmirror]] package
280 database, low-level functions for querying the database, and a
281 =package.el=-like user interface for browsing the available packages.
283 #+begin_src emacs-lisp
287 (("C-c b d" . epkg-describe-package)
288 ("C-c b p" . epkg-list-packages)
289 ("C-c b u" . epkg-update)))
292 ** No littering in =~/.emacs.d=
295 Help keeping ~/.emacs.d clean
298 By default, even for Emacs' built-in packages, the configuration files
299 and persistent data are all over the place. Use =no-littering= to help
302 #+begin_src emacs-lisp
303 (use-package no-littering
307 (add-to-list 'savehist-additional-variables 'kill-ring)
309 (setq auto-save-file-name-transforms
310 `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))))
313 ** Custom file (=custom.el=)
315 I'm not planning on using the custom file much, but even so, I
316 definitely don't want it mixing with =init.el=. So, here; let's give
317 it it's own file. While at it, treat themes as safe.
319 #+begin_src emacs-lisp
323 (setq custom-file (no-littering-expand-etc-file-name "custom.el"))
324 (when (file-exists-p custom-file)
326 (setf custom-safe-themes t))
331 Load the secrets file if it exists, otherwise show a warning.
333 #+begin_src emacs-lisp
335 (load (no-littering-expand-etc-file-name "secrets")))
338 ** Better =$PATH= handling
340 Let's use [[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]] to make Emacs use the =$PATH= as set up
343 #+begin_src emacs-lisp
344 (use-package exec-path-from-shell
347 (setq exec-path-from-shell-check-startup-files nil)
349 (exec-path-from-shell-initialize)
350 ;; while we're at it, let's fix access to our running ssh-agent
351 (exec-path-from-shell-copy-env "SSH_AGENT_PID")
352 (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
355 ** COMMENT Only one custom theme at a time
357 #+begin_src emacs-lisp
358 (defadvice load-theme (before clear-previous-themes activate)
359 "Clear existing theme settings instead of layering them"
360 (mapc #'disable-theme custom-enabled-themes))
365 Start server if not already running. Alternatively, can be done by
366 issuing =emacs --daemon= in the terminal, which can be automated with
367 a systemd service or using =brew services start emacs= on macOS. I use
368 Emacs as my window manager (via EXWM), so I always start Emacs on
369 login; so starting the server from inside Emacs is good enough for me.
371 See [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server][Using Emacs as a Server]].
373 #+begin_src emacs-lisp
376 :config (or (server-running-p) (server-mode)))
379 ** COMMENT Unicode support
381 Font stack with better unicode support, around =Ubuntu Mono= and
384 #+begin_src emacs-lisp
385 (dolist (ft (fontset-list))
389 (font-spec :name "Source Code Pro" :size 14))
393 (font-spec :name "DejaVu Sans Mono")
400 ;; :name "Symbola monospacified for DejaVu Sans Mono")
406 ;; (font-spec :name "DejaVu Sans Mono")
412 (font-spec :name "DejaVu Sans Mono" :size 14)
417 ** Gentler font resizing
419 #+begin_src emacs-lisp
420 (setq text-scale-mode-step 1.05)
423 ** Focus follows mouse
425 I’d like focus to follow the mouse when I move the cursor from one
428 #+begin_src emacs-lisp
429 (setq mouse-autoselect-window t)
432 Let’s define a function to conveniently disable this for certain
433 buffers and/or modes.
435 #+begin_src emacs-lisp
436 (defun amin--no-mouse-autoselect-window ()
437 (make-local-variable 'mouse-autoselect-window)
438 (setq mouse-autoselect-window nil))
443 #+begin_src emacs-lisp
450 Convenience macro for =setq='ing multiple variables to the same value:
452 #+begin_src emacs-lisp
453 (defmacro setq-every! (value &rest vars)
454 "Set all the variables from VARS to value VALUE."
455 (declare (indent defun) (debug t))
456 `(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars)))
466 *** Time and battery in mode-line
468 Enable displaying time and battery in the mode-line, since I'm not
469 using the Xfce panel anymore. Also, I don't need to see the load
470 average on a regular basis, so disable that.
472 Note: using =i3status= on sway at the moment, so disabling this.
474 #+begin_src emacs-lisp :tangle no
477 (setq display-time-default-load-average nil)
483 (display-battery-mode))
488 Might want to set the fringe to a smaller value, especially if using
489 EXWM. I'm fine with the default for now.
491 #+begin_src emacs-lisp
492 ;; (fringe-mode '(3 . 1))
496 *** Disable disabled commands
498 Emacs disables some commands by default that could persumably be
499 confusing for novice users. Let's disable that.
501 #+begin_src emacs-lisp
502 (setq disabled-command-function nil)
507 Save what I copy into clipboard from other applications into Emacs'
508 kill-ring, which would allow me to still be able to easily access it
509 in case I kill (cut or copy) something else inside Emacs before
510 yanking (pasting) what I'd originally intended to.
512 #+begin_src emacs-lisp
513 (setq save-interprogram-paste-before-kill t)
518 #+begin_src emacs-lisp
519 (setq enable-recursive-minibuffers t
520 resize-mini-windows t)
523 *** Lazy-person-friendly yes/no prompts
525 Lazy people would prefer to type fewer keystrokes, especially for yes
526 or no questions. I'm lazy.
528 #+begin_src emacs-lisp
529 (defalias 'yes-or-no-p #'y-or-n-p)
532 *** Startup screen and =*scratch*=
534 Firstly, let Emacs know that I'd like to have =*scratch*= as my
537 #+begin_src emacs-lisp
538 (setq initial-buffer-choice t)
541 Now let's customize the =*scratch*= buffer a bit. First off, I don't
542 need the default hint.
544 #+begin_src emacs-lisp
545 (setq initial-scratch-message nil)
548 Also, let's use Text mode as the major mode, in case I want to
549 customize it (=*scratch*='s default major mode, Fundamental mode,
550 can't really be customized).
552 #+begin_src emacs-lisp
553 (setq initial-major-mode 'text-mode)
556 Inhibit the buffer list when more than 2 files are loaded.
558 #+begin_src emacs-lisp
559 (setq inhibit-startup-buffer-menu t)
562 I don't really need to see the startup screen or echo area message
565 #+begin_src emacs-lisp
566 (advice-add #'display-startup-echo-area-message :override #'ignore)
567 (setq inhibit-startup-screen t
568 inhibit-startup-echo-area-message user-login-name)
571 *** More useful frame titles
573 Show either the file name or the buffer name (in case the buffer isn't
574 visiting a file). Borrowed from Emacs Prelude.
576 #+begin_src emacs-lisp
577 (setq frame-title-format
578 '("" invocation-name " - "
579 (:eval (if (buffer-file-name)
580 (abbreviate-file-name (buffer-file-name))
586 Emacs' default backup settings aren't that great. Let's use more
587 sensible options. See documentation for the ~make-backup-file~
590 #+begin_src emacs-lisp
591 (setq backup-by-copying t
593 delete-old-versions t)
598 Enable automatic reloading of changed buffers and files.
600 #+begin_src emacs-lisp
601 (global-auto-revert-mode 1)
602 (setq auto-revert-verbose nil
603 global-auto-revert-non-file-buffers nil)
606 *** Always use space for indentation
608 #+begin_src emacs-lisp
611 require-final-newline t
617 Enable =winner-mode=.
619 #+begin_src emacs-lisp
623 *** Don’t display =*compilation*= on success
625 Based on https://stackoverflow.com/a/17788551, with changes to use
626 =cl-letf= instead of the now obsolete =flet=.
628 #+begin_src emacs-lisp
629 (with-eval-after-load 'compile
630 (defun amin--compilation-finish-function (buffer outstr)
631 (unless (string-match "finished" outstr)
632 (switch-to-buffer-other-window buffer))
635 (setq compilation-finish-functions #'amin--compilation-finish-function)
639 (defadvice compilation-start
640 (around inhibit-display
641 (command &optional mode name-function highlight-regexp))
642 (if (not (string-match "^\\(find\\|grep\\)" command))
643 (cl-letf (((symbol-function 'display-buffer) #'ignore))
644 (save-window-excursion ad-do-it))
646 (ad-activate 'compilation-start))
649 *** Search for non-ASCII characters
651 I’d like non-ASCII characters such as ‘’“”«»‹›áⓐ𝒶 to be selected when
652 I search for their ASCII counterpart. Shoutout to [[http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html][endlessparentheses]]
655 #+begin_src emacs-lisp
656 (setq search-default-mode #'char-fold-to-regexp)
658 ;; uncomment to extend this behaviour to query-replace
659 ;; (setq replace-char-fold t)
664 #+begin_src emacs-lisp
665 (setq-default cursor-type 'bar)
670 #+begin_src emacs-lisp
674 ("C-c e b" . eval-buffer)
675 ("C-c e r" . eval-region)
677 ("C-c F m" . make-frame-command)
678 ("C-c F d" . delete-frame)
679 ("C-c F D" . delete-other-frames)
681 ("C-c o" . other-window)
683 ("C-c Q" . save-buffers-kill-terminal)
685 ("C-S-h C" . describe-char)
686 ("C-S-h F" . describe-face)
688 ("C-x K" . kill-this-buffer)
690 ("s-p" . beginning-of-buffer)
691 ("s-n" . end-of-buffer))
696 The packages in this section are absolutely essential to my everyday
697 workflow, and they play key roles in how I do my computing. They
698 immensely enhance the Emacs experience for me; both using Emacs, and
701 *** [[https://github.com/emacscollective/auto-compile][auto-compile]]
703 #+begin_src emacs-lisp
704 (use-package auto-compile
707 (auto-compile-on-load-mode)
708 (auto-compile-on-save-mode)
709 (setq auto-compile-display-buffer nil
710 auto-compile-mode-line-counter t
711 auto-compile-source-recreate-deletes-dest t
712 auto-compile-toggle-deletes-nonlib-dest t
713 auto-compile-update-autoloads t)
714 (add-hook 'auto-compile-inhibit-compile-hook
715 'auto-compile-inhibit-compile-detached-git-head))
718 *** [[https://orgmode.org/][Org mode]]
721 Org mode is for keeping notes, maintaining TODO lists, planning
722 projects, and authoring documents with a fast and effective plain-text
726 In short, my favourite way of life.
728 #+begin_src emacs-lisp
732 (setq org-src-tab-acts-natively t
733 org-src-preserve-indentation nil
734 org-edit-src-content-indentation 0
735 org-email-link-description-format "Email %c: %s" ; %.30s
736 org-highlight-latex-and-related '(entities)
737 org-use-speed-commands t
738 org-startup-folded 'content
739 org-catch-invisible-edits 'show-and-error
741 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
742 (font-lock-add-keywords
744 '(("[ \t]*\\(#\\+\\(BEGIN\\|END\\|begin\\|end\\)_\\(\\S-+\\)\\)[ \t]*\\([^\n:]*\\)"
745 (1 '(:foreground "#5a5b5a" :background "#292b2b") t) ; directive
746 (3 '(:foreground "#81a2be" :background "#292b2b") t) ; kind
747 (4 '(:foreground "#c5c8c6") t))) ; title
749 :bind (:map org-mode-map ("M-L" . org-insert-last-stored-link))
750 :hook ((org-mode . org-indent-mode)
751 (org-mode . auto-fill-mode)
752 (org-mode . flyspell-mode))
754 (org-latex-packages-alist '(("" "listings") ("" "color")))
756 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
757 '(org-block ((t (:background "#1d1f21"))))
758 '(org-latex-and-related ((t (:foreground "#b294bb")))))
760 (use-package ox-latex
763 (setq org-latex-listings 'listings
764 ;; org-latex-prefer-user-labels t
766 (add-to-list 'org-latex-packages-alist '("" "listings"))
767 (add-to-list 'org-latex-packages-alist '("" "color"))
768 (add-to-list 'org-latex-classes
769 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
770 ("\\section{%s}" . "\\section*{%s}")
771 ("\\subsection{%s}" . "\\subsection*{%s}")
772 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
773 ("\\paragraph{%s}" . "\\paragraph*{%s}")
774 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
777 (use-package ox-beamer
780 (use-package orgalist
782 :hook (message-mode . orgalist-mode))
785 **** asynchronous tangle
787 =amin/async-babel-tangle= is a function closely inspired by [[https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles][dieggsy's
788 d/async-babel-tangle]] which uses [[https://github.com/jwiegley/emacs-async][async]] to asynchronously tangle an org
791 #+begin_src emacs-lisp
792 (with-eval-after-load 'org
793 (defvar amin-show-async-tangle-results nil
794 "Keep *emacs* async buffers around for later inspection.")
796 (defvar amin-show-async-tangle-time nil
797 "Show the time spent tangling the file.")
799 (defvar amin-async-tangle-post-compile "make ti"
800 "If non-nil, pass to `compile' after successful tangle.")
802 (defun amin/async-babel-tangle ()
803 "Tangle org file asynchronously."
805 (let* ((file-tangle-start-time (current-time))
806 (file (buffer-file-name))
807 (file-nodir (file-name-nondirectory file))
808 ;; (async-quiet-switch "-q")
813 (org-babel-tangle-file ,file))
814 (unless amin-show-async-tangle-results
818 (message "Tangled %s%s"
820 (if amin-show-async-tangle-time
822 (float-time (time-subtract (current-time)
823 ',file-tangle-start-time)))
825 (when amin-async-tangle-post-compile
826 (compile amin-async-tangle-post-compile)))
827 (message "Tangling %s failed" ,file-nodir))))))))
830 'safe-local-variable-values
831 '(eval add-hook 'after-save-hook #'amin/async-babel-tangle 'append 'local))
834 *** [[https://magit.vc/][Magit]]
837 It's Magit! A Git porcelain inside Emacs.
840 Not just how I do git, but /the/ way to do git.
842 #+begin_src emacs-lisp
845 :bind (("C-x g" . magit-status)
846 ("s-g s" . magit-status)
847 ("s-g l" . magit-log-buffer-file))
849 (magit-add-section-hook 'magit-status-sections-hook
850 'magit-insert-modules
851 'magit-insert-stashes
854 magit-repository-directories '(("~/.emacs.d/" . 0)
856 (nconc magit-section-initial-visibility-alist
857 '(([unpulled status] . show)
858 ([unpushed status] . show)))
859 :custom-face (magit-diff-file-heading ((t (:weight normal)))))
862 *** [[https://github.com/abo-abo/swiper][Ivy]] (and friends)
865 Ivy - a generic completion frontend for Emacs, Swiper - isearch with
866 an overview, and more. Oh, man!
869 There's no way I could top that, so I won't attempt to.
873 #+begin_src emacs-lisp
877 (:map ivy-minibuffer-map
878 ([escape] . keyboard-escape-quit)
879 ([S-up] . ivy-previous-history-element)
880 ([S-down] . ivy-next-history-element)
881 ("DEL" . ivy-backward-delete-char))
886 ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
887 ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
888 ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
894 #+begin_src emacs-lisp
896 :bind (("C-s" . swiper)
898 ("C-S-s" . isearch-forward)))
903 #+begin_src emacs-lisp
906 :bind (([remap execute-extended-command] . counsel-M-x)
907 ([remap find-file] . counsel-find-file)
908 ("s-r" . counsel-recentf)
909 ("C-c x" . counsel-M-x)
910 ("C-c f ." . counsel-find-file)
911 :map minibuffer-local-map
912 ("C-r" . counsel-minibuffer-history))
915 (defalias 'locate #'counsel-locate))
920 #+begin_src emacs-lisp
924 :bind ("C-c a s e" . eshell)
926 (eval-when-compile (defvar eshell-prompt-regexp))
927 (defun amin/eshell-quit-or-delete-char (arg)
929 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
930 (eshell-life-is-too-much)
933 (defun amin/eshell-clear ()
935 (let ((inhibit-read-only t))
939 (defun amin|eshell-setup ()
940 (make-local-variable 'company-idle-delay)
941 (defvar company-idle-delay nil)
942 (bind-keys :map eshell-mode-map
943 ("C-d" . amin/eshell-quit-or-delete-char)
944 ("C-S-l" . amin/eshell-clear)
945 ("M-r" . counsel-esh-history)
946 ([tab] . company-complete)))
948 :hook (eshell-mode . amin|eshell-setup)
950 (eshell-hist-ignoredups t)
951 (eshell-input-filter 'eshell-input-filter-initial-space))
956 #+begin_src emacs-lisp
960 (("C-x C-b" . ibuffer-other-window)
961 :map ibuffer-mode-map
962 ("P" . ibuffer-backward-filter-group)
963 ("N" . ibuffer-forward-filter-group)
964 ("M-p" . ibuffer-do-print)
965 ("M-n" . ibuffer-do-shell-command-pipe-replace))
967 ;; Use human readable Size column instead of original one
968 (define-ibuffer-column size-h
969 (:name "Size" :inline t)
971 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
972 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
973 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
974 (t (format "%8d" (buffer-size)))))
976 (ibuffer-saved-filter-groups
978 ("dired" (mode . dired-mode))
979 ("org" (mode . org-mode))
982 (mode . gnus-group-mode)
983 (mode . gnus-summary-mode)
984 (mode . gnus-article-mode)
985 ;; not really, but...
986 (mode . message-mode)))
1000 (mode . python-mode)
1003 (mode . emacs-lisp-mode)
1004 (mode . scheme-mode)
1005 (mode . haskell-mode)
1006 (mode . lean-mode)))
1009 (name . "^\\*scratch\\*$")
1010 (name . "^\\*Messages\\*$"))))))
1012 '((mark modified read-only locked " "
1013 (name 18 18 :left :elide)
1015 (size-h 9 -1 :right)
1017 (mode 16 16 :left :elide)
1018 " " filename-and-process)
1022 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
1027 #+begin_src emacs-lisp
1028 (use-package outline
1030 :hook (prog-mode . outline-minor-mode)
1033 outline-minor-mode-map
1034 ("<s-tab>" . outline-toggle-children)
1035 ("M-p" . outline-previous-visible-heading)
1036 ("M-n" . outline-next-visible-heading)
1037 :prefix-map amin--outline-prefix-map
1039 ("TAB" . outline-toggle-children)
1040 ("a" . outline-hide-body)
1041 ("H" . outline-hide-body)
1042 ("S" . outline-show-all)
1043 ("h" . outline-hide-subtree)
1044 ("s" . outline-show-subtree)))
1047 * Borg's =layer/essentials=
1049 :CUSTOM_ID: borg-essentials
1052 TODO: break this giant source block down into individual org sections.
1054 #+begin_src emacs-lisp
1056 :config (dash-enable-font-lock))
1058 (use-package diff-hl
1060 (setq diff-hl-draw-borders nil)
1061 (global-diff-hl-mode)
1062 (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh t))
1066 :config (setq dired-listing-switches "-alh"))
1069 :when (version< "25" emacs-version)
1070 :config (global-eldoc-mode))
1075 (temp-buffer-resize-mode)
1076 (setq help-window-select t))
1079 (setq isearch-allow-scroll t))
1081 (use-package lisp-mode
1083 (add-hook 'emacs-lisp-mode-hook 'outline-minor-mode)
1084 (add-hook 'emacs-lisp-mode-hook 'reveal-mode)
1085 (defun indent-spaces-mode ()
1086 (setq indent-tabs-mode nil))
1087 (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
1091 :config (setq Man-width 80))
1094 :config (show-paren-mode))
1096 (use-package prog-mode
1097 :config (global-prettify-symbols-mode)
1098 (defun indicate-buffer-boundaries-left ()
1099 (setq indicate-buffer-boundaries 'left))
1100 (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left))
1102 (use-package recentf
1105 (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
1106 (setq recentf-max-saved-items 40))
1108 (use-package savehist
1109 :config (savehist-mode))
1111 (use-package saveplace
1112 :when (version< "25" emacs-version)
1113 :config (save-place-mode))
1116 :config (column-number-mode))
1118 (progn ; `text-mode'
1119 (add-hook 'text-mode-hook #'indicate-buffer-boundaries-left)
1120 (add-hook 'text-mode-hook #'abbrev-mode))
1125 (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
1126 (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
1127 (add-to-list 'tramp-default-proxies-alist
1128 (list (regexp-quote (system-name)) nil nil)))
1139 #+begin_src emacs-lisp
1140 (use-package company
1143 (:map company-active-map
1144 ([tab] . company-complete-common-or-cycle)
1145 ([escape] . company-abort))
1147 (company-minimum-prefix-length 1)
1148 (company-selection-wrap-around t)
1149 (company-dabbrev-char-regexp "\\sw\\|\\s_\\|[-_]")
1150 (company-dabbrev-downcase nil)
1151 (company-dabbrev-ignore-case nil)
1153 (global-company-mode t))
1156 * Syntax and spell checking
1158 :CUSTOM_ID: syntax-spell-checking
1161 #+begin_src emacs-lisp
1162 (use-package flycheck
1164 :hook (prog-mode . flycheck-mode)
1166 (:map flycheck-mode-map
1167 ("M-P" . flycheck-previous-error)
1168 ("M-N" . flycheck-next-error))
1170 ;; Use the load-path from running Emacs when checking elisp files
1171 (setq flycheck-emacs-lisp-load-path 'inherit)
1173 ;; Only flycheck when I actually save the buffer
1174 (setq flycheck-check-syntax-automatically '(mode-enabled save)))
1176 ;; http://endlessparentheses.com/ispell-and-apostrophes.html
1180 ;; ’ can be part of a word
1181 (setq ispell-local-dictionary-alist
1182 `((nil "[[:alpha:]]" "[^[:alpha:]]"
1183 "['\x2019]" nil ("-B") nil utf-8)))
1184 ;; don't send ’ to the subprocess
1185 (defun endless/replace-apostrophe (args)
1186 (cons (replace-regexp-in-string
1189 (advice-add #'ispell-send-string :filter-args
1190 #'endless/replace-apostrophe)
1192 ;; convert ' back to ’ from the subprocess
1193 (defun endless/replace-quote (args)
1194 (if (not (derived-mode-p 'org-mode))
1196 (cons (replace-regexp-in-string
1199 (advice-add #'ispell-parse-output :filter-args
1200 #'endless/replace-quote))
1205 :CUSTOM_ID: programming-modes
1208 ** [[http://alloytools.org][Alloy]] (with [[https://github.com/dwwmmn/alloy-mode][alloy-mode]])
1210 #+begin_src emacs-lisp
1211 (use-package alloy-mode
1213 :config (setq alloy-basic-offset 2))
1216 ** [[https://coq.inria.fr][Coq]] (with [[https://github.com/ProofGeneral/PG][Proof General]])
1218 #+begin_src emacs-lisp
1219 (use-package proof-site ; Proof General
1221 :load-path "lib/proof-site/generic/")
1224 ** [[https://leanprover.github.io][Lean]] (with [[https://github.com/leanprover/lean-mode][lean-mode]])
1226 #+begin_src emacs-lisp
1227 (eval-when-compile (defvar lean-mode-map))
1228 (use-package lean-mode
1230 :bind (:map lean-mode-map
1231 ("S-SPC" . company-complete))
1233 (require 'lean-input)
1234 (setq default-input-method "Lean"
1235 lean-input-tweak-all '(lean-input-compose
1236 (lean-input-prepend "/")
1237 (lean-input-nonempty))
1238 lean-input-user-translations '(("/" "/")))
1244 *** [[https://github.com/haskell/haskell-mode][haskell-mode]]
1246 #+begin_src emacs-lisp
1247 (use-package haskell-mode
1250 (setq haskell-indentation-layout-offset 4
1251 haskell-indentation-left-offset 4
1252 flycheck-checker 'haskell-hlint
1253 flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc)))
1256 *** [[https://github.com/jyp/dante][dante]]
1258 #+begin_src emacs-lisp
1261 :commands dante-mode
1262 :hook (haskell-mode . dante-mode))
1265 *** [[https://github.com/mpickering/hlint-refactor-mode][hlint-refactor]]
1267 Emacs bindings for [[https://github.com/ndmitchell/hlint][hlint]]'s refactor option. This requires the refact
1268 executable from [[https://github.com/mpickering/apply-refact][apply-refact]].
1270 #+begin_src emacs-lisp
1271 (use-package hlint-refactor
1273 :bind (:map hlint-refactor-mode-map
1274 ("C-c l b" . hlint-refactor-refactor-buffer)
1275 ("C-c l r" . hlint-refactor-refactor-at-point))
1276 :hook (haskell-mode . hlint-refactor-mode))
1279 *** [[https://github.com/flycheck/flycheck-haskell][flycheck-haskell]]
1281 #+begin_src emacs-lisp
1282 (use-package flycheck-haskell
1283 :after haskell-mode)
1286 *** [[https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el][hs-lint.el]]
1288 :header-args+: :tangle lisp/hs-lint.el :mkdirp yes
1291 Currently using =flycheck-haskell= with the =haskell-hlint= checker
1294 #+begin_src emacs-lisp :tangle no
1295 ;;; hs-lint.el --- minor mode for HLint code checking
1297 ;; Copyright 2009 (C) Alex Ott
1299 ;; Author: Alex Ott <alexott@gmail.com>
1300 ;; Keywords: haskell, lint, HLint
1302 ;; Status: distributed under terms of GPL2 or above
1304 ;; Typical message from HLint looks like:
1306 ;; /Users/ott/projects/lang-exp/haskell/test.hs:52:1: Eta reduce
1308 ;; count1 p l = length (filter p l)
1310 ;; count1 p = length . filter p
1315 (defgroup hs-lint nil
1316 "Run HLint as inferior of Emacs, parse error messages."
1320 (defcustom hs-lint-command "hlint"
1321 "The default hs-lint command for \\[hlint]."
1325 (defcustom hs-lint-save-files t
1326 "Save modified files when run HLint or no (ask user)"
1330 (defcustom hs-lint-replace-with-suggestions nil
1331 "Replace user's code with suggested replacements"
1335 (defcustom hs-lint-replace-without-ask nil
1336 "Replace user's code with suggested replacements automatically"
1340 (defun hs-lint-process-setup ()
1341 "Setup compilation variables and buffer for `hlint'."
1342 (run-hooks 'hs-lint-setup-hook))
1344 ;; regex for replace suggestions
1346 ;; ^\(.*?\):\([0-9]+\):\([0-9]+\): .*
1352 (defvar hs-lint-regex
1353 "^\\(.*?\\):\\([0-9]+\\):\\([0-9]+\\): .*[\n\C-m]Found:[\n\C-m]\\s +\\(.*\\)[\n\C-m]Why not:[\n\C-m]\\s +\\(.*\\)[\n\C-m]"
1354 "Regex for HLint messages")
1356 (defun make-short-string (str maxlen)
1357 (if (< (length str) maxlen)
1359 (concat (substring str 0 (- maxlen 3)) "...")))
1361 (defun hs-lint-replace-suggestions ()
1362 "Perform actual replacement of suggestions"
1363 (goto-char (point-min))
1364 (while (re-search-forward hs-lint-regex nil t)
1365 (let* ((fname (match-string 1))
1366 (fline (string-to-number (match-string 2)))
1367 (old-code (match-string 4))
1368 (new-code (match-string 5))
1369 (msg (concat "Replace '" (make-short-string old-code 30)
1370 "' with '" (make-short-string new-code 30) "'"))
1376 (switch-to-buffer (get-file-buffer fname))
1377 (goto-char (point-min))
1378 (forward-line (1- fline))
1380 (setf bline (point))
1381 (when (or hs-lint-replace-without-ask
1384 (setf eline (point))
1386 (setf old-code (regexp-quote old-code))
1387 (while (string-match "\\\\ " old-code spos)
1388 (setf new-old-code (concat new-old-code
1389 (substring old-code spos (match-beginning 0))
1391 (setf spos (match-end 0)))
1392 (setf new-old-code (concat new-old-code (substring old-code spos)))
1393 (remove-text-properties bline eline '(composition nil))
1394 (when (re-search-forward new-old-code eline t)
1395 (replace-match new-code nil t)))))))
1397 (defun hs-lint-finish-hook (buf msg)
1398 "Function, that is executed at the end of HLint execution"
1399 (if hs-lint-replace-with-suggestions
1400 (hs-lint-replace-suggestions)
1403 (define-compilation-mode hs-lint-mode "HLint"
1404 "Mode for check Haskell source code."
1405 (set (make-local-variable 'compilation-process-setup-function)
1406 'hs-lint-process-setup)
1407 (set (make-local-variable 'compilation-disable-input) t)
1408 (set (make-local-variable 'compilation-scroll-output) nil)
1409 (set (make-local-variable 'compilation-finish-functions)
1410 (list 'hs-lint-finish-hook))
1414 "Run HLint for current buffer with haskell source"
1416 (save-some-buffers hs-lint-save-files)
1417 (compilation-start (concat hs-lint-command " \"" buffer-file-name "\"")
1421 ;;; hs-lint.el ends here
1424 #+begin_src emacs-lisp :tangle no
1425 (use-package hs-lint
1427 :bind (:map haskell-mode-map
1428 ("C-c l l" . hs-lint)))
1435 #+begin_src emacs-lisp
1436 (use-package sgml-mode
1439 (setq sgml-basic-offset 2))
1444 #+begin_src emacs-lisp
1445 (use-package css-mode
1448 (setq css-indent-offset 2))
1453 #+begin_src emacs-lisp
1454 (use-package web-mode
1459 web-mode-code-indent-offset
1460 web-mode-css-indent-offset
1461 web-mode-markup-indent-offset))
1466 #+begin_src emacs-lisp
1467 (use-package emmet-mode
1468 :after (:any web-mode css-mode sgml-mode)
1469 :bind* (("C-)" . emmet-next-edit-point)
1470 ("C-(" . emmet-prev-edit-point))
1472 (unbind-key "C-j" emmet-mode-keymap)
1473 (setq emmet-move-cursor-between-quotes t)
1474 :hook (web-mode css-mode html-mode sgml-mode))
1481 #+begin_src emacs-lisp
1482 (use-package meghanada
1484 (:map meghanada-mode-map
1485 (("C-M-o" . meghanada-optimize-import)
1486 ("C-M-t" . meghanada-import-all)))
1487 :hook (java-mode . meghanada-mode))
1508 #+begin_src emacs-lisp
1509 (use-package treemacs
1510 :config (setq treemacs-never-persist t))
1512 (use-package yasnippet
1514 ;; (yas-global-mode)
1517 (use-package lsp-mode
1518 :init (setq lsp-eldoc-render-all nil
1519 lsp-highlight-symbol-at-point nil)
1524 (use-package company-lsp
1527 (setq company-lsp-cache-candidates t
1528 company-lsp-async t))
1532 (setq lsp-ui-sideline-update-mode 'point))
1534 (use-package lsp-java
1536 (add-hook 'java-mode-hook
1538 (setq-local company-backends (list 'company-lsp))))
1540 (add-hook 'java-mode-hook 'lsp-java-enable)
1541 (add-hook 'java-mode-hook 'flycheck-mode)
1542 (add-hook 'java-mode-hook 'company-mode)
1543 (add-hook 'java-mode-hook 'lsp-ui-mode))
1545 (use-package dap-mode
1551 (use-package dap-java
1554 (use-package lsp-java-treemacs
1560 #+begin_src emacs-lisp
1561 (use-package geiser)
1563 (use-package geiser-guile
1565 (setq geiser-guile-load-path "~/src/git/guix"))
1570 #+begin_src emacs-lisp
1572 :load-path "lib/guix/elisp")
1575 * Emacs enhancements
1577 :CUSTOM_ID: emacs-enhancements
1580 ** [[https://github.com/justbur/emacs-which-key][which-key]]
1583 Emacs package that displays available keybindings in popup
1586 #+begin_src emacs-lisp
1587 (use-package which-key
1589 :config (which-key-mode))
1594 #+begin_src emacs-lisp
1595 (add-to-list 'custom-theme-load-path "~/.emacs.d/lisp")
1596 (load-theme 'tangomod t)
1601 #+begin_src emacs-lisp
1602 (use-package smart-mode-line
1609 #+begin_src emacs-lisp
1610 (use-package doom-themes)
1613 ** theme helper functions
1615 #+begin_src emacs-lisp
1616 (defun amin/lights-on ()
1617 "Enable my favourite light theme."
1619 (mapc #'disable-theme custom-enabled-themes)
1620 (load-theme 'tangomod t)
1621 (sml/apply-theme 'automatic))
1623 (defun amin/lights-off ()
1626 (mapc #'disable-theme custom-enabled-themes)
1627 (load-theme 'doom-tomorrow-night t)
1628 (sml/apply-theme 'automatic))
1631 ("s-t d" . amin/lights-off)
1632 ("s-t l" . amin/lights-on))
1635 ** [[https://github.com/bbatsov/crux][crux]]
1637 #+begin_src emacs-lisp
1640 :bind (("C-c b k" . crux-kill-other-buffers)
1641 ("C-c d" . crux-duplicate-current-line-or-region)
1642 ("C-c D" . crux-duplicate-and-comment-current-line-or-region)
1643 ("C-c f c" . crux-copy-file-preserve-attributes)
1644 ("C-c f d" . crux-delete-file-and-buffer)
1645 ("C-c f r" . crux-rename-file-and-buffer)
1646 ("C-c j" . crux-top-join-line)
1647 ("C-S-j" . crux-top-join-line)))
1650 ** [[https://github.com/alezost/mwim.el][mwim]]
1652 #+begin_src emacs-lisp
1654 :bind (("C-a" . mwim-beginning-of-code-or-line)
1655 ("C-e" . mwim-end-of-code-or-line)
1656 ("<home>" . mwim-beginning-of-line-or-code)
1657 ("<end>" . mwim-end-of-line-or-code)))
1662 #+begin_src emacs-lisp
1663 (use-package projectile
1665 :bind-keymap ("C-c p" . projectile-command-map)
1669 (defun my-projectile-invalidate-cache (&rest _args)
1670 ;; ignore the args to `magit-checkout'
1671 (projectile-invalidate-cache nil))
1673 (eval-after-load 'magit-branch
1675 (advice-add 'magit-checkout
1676 :after #'my-projectile-invalidate-cache)
1677 (advice-add 'magit-branch-and-checkout
1678 :after #'my-projectile-invalidate-cache)))
1679 :custom (projectile-completion-system 'ivy))
1682 ** [[https://github.com/Wilfred/helpful][helpful]]
1684 #+begin_src emacs-lisp
1685 (use-package helpful
1688 (("C-S-h c" . helpful-command)
1689 ("C-S-h f" . helpful-callable) ; helpful-function
1690 ("C-S-h v" . helpful-variable)
1691 ("C-S-h k" . helpful-key)
1692 ("C-S-h p" . helpful-at-point)))
1695 ** [[https://github.com/EricCrosson/unkillable-scratch][unkillable-scratch]]
1697 Make =*scratch*= and =*Messages*= unkillable.
1699 #+begin_src emacs-lisp
1700 (use-package unkillable-scratch
1703 (unkillable-scratch 1)
1705 (unkillable-scratch-behavior 'do-nothing)
1706 (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
1709 ** [[https://github.com/davep/boxquote.el][boxquote.el]]
1713 | make pretty boxed quotes like this
1717 #+begin_src emacs-lisp
1718 (use-package boxquote
1721 (:prefix-map amin--boxquote-prefix-map
1723 ("b" . boxquote-buffer)
1724 ("B" . boxquote-insert-buffer)
1725 ("d" . boxquote-defun)
1726 ("F" . boxquote-insert-file)
1727 ("hf" . boxquote-describe-function)
1728 ("hk" . boxquote-describe-key)
1729 ("hv" . boxquote-describe-variable)
1730 ("hw" . boxquote-where-is)
1731 ("k" . boxquote-kill)
1732 ("p" . boxquote-paragraph)
1733 ("q" . boxquote-boxquote)
1734 ("r" . boxquote-region)
1735 ("s" . boxquote-shell-command)
1736 ("t" . boxquote-text)
1737 ("T" . boxquote-title)
1738 ("u" . boxquote-unbox)
1739 ("U" . boxquote-unbox-region)
1740 ("y" . boxquote-yank)
1741 ("M-q" . boxquote-fill-paragraph)
1742 ("M-w" . boxquote-kill-ring-save)))
1745 Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
1749 #+begin_src emacs-lisp
1753 (typo-global-mode 1)
1754 :hook (text-mode . typo-mode))
1759 #+begin_src emacs-lisp
1760 (use-package hl-todo
1763 (global-hl-todo-mode))
1768 #+begin_src emacs-lisp
1769 (use-package shrink-path
1772 (setq eshell-prompt-regexp "\\(.*\n\\)*λ "
1773 eshell-prompt-function #'+eshell/prompt)
1775 (defun +eshell/prompt ()
1776 (let ((base/dir (shrink-path-prompt default-directory)))
1777 (concat (propertize (car base/dir)
1778 'face 'font-lock-comment-face)
1779 (propertize (cdr base/dir)
1780 'face 'font-lock-constant-face)
1781 (propertize (+eshell--current-git-branch)
1782 'face 'font-lock-function-name-face)
1784 (propertize "λ" 'face 'eshell-prompt-face)
1785 ;; needed for the input text to not have prompt face
1786 (propertize " " 'face 'default))))
1788 (defun +eshell--current-git-branch ()
1789 (let ((branch (car (loop for match in (split-string (shell-command-to-string "git branch") "\n")
1790 when (string-match "^\*" match)
1792 (if (not (eq branch nil))
1793 (concat " " (substring branch 2))
1797 ** [[https://github.com/peterwvj/eshell-up][eshell-up]]
1799 #+begin_src emacs-lisp
1800 (use-package eshell-up
1806 #+begin_src emacs-lisp
1807 (use-package multi-term
1809 :bind (("C-c a s m m" . multi-term)
1810 ("C-c a s m p" . multi-term-dedicated-toggle)
1812 ("C-c C-j" . term-char-mode)
1814 ("C-c C-j" . term-line-mode))
1816 (setq multi-term-program "/bin/screen"
1817 ;; TODO: add separate bindings for connecting to existing
1818 ;; session vs. always creating a new one
1819 multi-term-dedicated-select-after-open-p t
1820 multi-term-dedicated-window-height 20
1821 multi-term-dedicated-max-window-height 30
1823 '(("C-c C-c" . term-interrupt-subjob)
1824 ("C-c C-e" . term-send-esc)
1826 ("C-y" . term-paste)
1827 ("M-f" . term-send-forward-word)
1828 ("M-b" . term-send-backward-word)
1829 ("M-p" . term-send-up)
1830 ("M-n" . term-send-down)
1831 ("<C-backspace>" . term-send-backward-kill-word)
1832 ("<M-DEL>" . term-send-backward-kill-word)
1833 ("M-d" . term-send-delete-word)
1834 ("M-," . term-send-raw)
1835 ("M-." . comint-dynamic-complete))
1836 term-unbind-key-alist
1837 '("C-z" "C-x" "C-c" "C-h" "C-y" "<ESC>")))
1842 #+begin_src emacs-lisp
1843 (use-package page-break-lines
1845 (global-page-break-lines-mode))
1850 #+begin_src emacs-lisp
1851 (use-package expand-region
1852 :bind ("C-=" . er/expand-region))
1860 #+begin_src emacs-lisp
1861 (defvar amin-maildir (expand-file-name "~/mail/"))
1862 (with-eval-after-load 'recentf
1863 (add-to-list 'recentf-exclude amin-maildir))
1868 #+begin_src emacs-lisp
1870 amin-gnus-init-file (no-littering-expand-etc-file-name "gnus")
1871 mail-user-agent 'gnus-user-agent
1872 read-mail-command 'gnus)
1875 :bind (("C-c m" . gnus)
1876 ("C-c M" . gnus-unplugged)
1878 ("s-M" . gnus-unplugged))
1881 gnus-select-method '(nnnil "")
1882 gnus-secondary-select-methods
1884 (nnimap-stream plain)
1885 (nnimap-address "127.0.0.1")
1886 (nnimap-server-port 143)
1887 (nnimap-authenticator plain)
1888 (nnimap-user "amin@aminb.org"))
1890 (nnimap-stream plain)
1891 (nnimap-address "127.0.0.1")
1892 (nnimap-server-port 143)
1893 (nnimap-authenticator plain)
1894 (nnimap-user "abandali@uwaterloo.ca")))
1895 gnus-message-archive-group "nnimap+amin:Sent"
1899 gnus-large-newsgroup 50
1900 gnus-home-directory (no-littering-expand-var-file-name "gnus/")
1901 gnus-directory (concat gnus-home-directory "news/")
1902 message-directory (concat gnus-home-directory "mail/")
1903 nndraft-directory (concat gnus-home-directory "drafts/")
1904 gnus-save-newsrc-file nil
1905 gnus-read-newsrc-file nil
1906 gnus-interactive-exit nil
1907 gnus-gcc-mark-as-read t))
1909 (use-package gnus-art
1912 gnus-visible-headers
1913 (concat gnus-visible-headers "\\|^List-Id:\\|^X-RT-Originator:\\|^User-Agent:")
1914 gnus-sorted-header-list
1915 '("^From:" "^Subject:" "^Summary:" "^Keywords:"
1916 "^Followup-To:" "^To:" "^Cc:" "X-RT-Originator"
1917 "^Newsgroups:" "List-Id:" "^Organization:"
1918 "^User-Agent:" "^Date:")
1919 ;; local-lapsed article dates
1920 ;; from https://www.emacswiki.org/emacs/GnusFormatting#toc11
1921 gnus-article-date-headers '(user-defined)
1922 gnus-article-time-format
1924 (let* ((date (format-time-string "%a, %d %b %Y %T %z" time))
1925 (local (article-make-date-line date 'local))
1926 (combined-lapsed (article-make-date-line date
1929 (string-match " (.+" combined-lapsed)
1930 (match-string 0 combined-lapsed))))
1931 (concat local lapsed))))
1933 :map gnus-article-mode-map
1934 ("r" . gnus-article-reply-with-original)
1935 ("R" . gnus-article-wide-reply-with-original)
1936 ("M-L" . org-store-link)))
1938 (use-package gnus-sum
1939 :bind (:map gnus-summary-mode-map
1940 :prefix-map amin--gnus-summary-prefix-map
1942 ("r" . gnus-summary-reply)
1943 ("w" . gnus-summary-wide-reply)
1944 ("v" . gnus-summary-show-raw-article))
1947 :map gnus-summary-mode-map
1948 ("r" . gnus-summary-reply-with-original)
1949 ("R" . gnus-summary-wide-reply-with-original)
1950 ("M-L" . org-store-link))
1951 :hook (gnus-summary-mode . amin--no-mouse-autoselect-window))
1953 (use-package gnus-msg
1955 (setq gnus-posting-styles
1957 (address "amin@aminb.org")
1958 (body "\nBest,\namin\n")
1959 (eval (setq amin--message-cite-say-hi t)))
1961 (address "bandali@gnu.org"))
1962 ((header "subject" "ThankCRM")
1963 (to "webmasters-comment@gnu.org")
1964 (body "\nAdded to 2018supporters.html.\n\nMoving to campaigns.\n\n-amin\n")
1965 (eval (setq amin--message-cite-say-hi nil)))
1966 ("nnimap\\+uwaterloo:.*"
1967 (address "abandali@uwaterloo.ca")
1968 (gcc "\"nnimap+uwaterloo:Sent Items\"")))))
1970 (use-package gnus-topic
1971 :hook (gnus-group-mode . gnus-topic-mode))
1973 (use-package gnus-agent
1975 (setq gnus-agent-synchronize-flags 'ask)
1976 :hook (gnus-group-mode . gnus-agent-mode))
1978 (use-package gnus-group
1980 (setq gnus-permanently-visible-groups "\\((INBOX\\|gnu$\\)"))
1982 (use-package mm-decode
1984 (setq mm-discouraged-alternatives '("text/html" "text/richtext")))
1989 #+begin_src emacs-lisp
1990 (use-package sendmail
1992 (setq sendmail-program "/usr/bin/msmtp"
1993 ;; message-sendmail-extra-arguments '("-v" "-d")
1994 mail-specify-envelope-from t
1995 mail-envelope-from 'header))
2000 #+begin_src emacs-lisp
2001 (use-package message
2003 (defconst amin--message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
2004 (defconst message-cite-style-bandali
2005 '((message-cite-function 'message-cite-original)
2006 (message-citation-line-function 'message-insert-formatted-citation-line)
2007 (message-cite-reply-position 'traditional)
2008 (message-yank-prefix "> ")
2009 (message-yank-cited-prefix ">")
2010 (message-yank-empty-prefix ">")
2011 (message-citation-line-format
2012 (if amin--message-cite-say-hi
2013 (concat "Hi %F,\n\n" amin--message-cite-style-format)
2014 amin--message-cite-style-format)))
2015 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
2016 (setq message-cite-style 'message-cite-style-bandali
2017 message-kill-buffer-on-exit t
2018 message-send-mail-function 'message-send-mail-with-sendmail
2019 message-sendmail-envelope-from 'header
2020 message-dont-reply-to-names
2021 "\\(\\(.*@aminb\\.org\\)\\|\\(amin@bandali\\.me\\)\\|\\(\\(aminb?\\|mab\\|bandali\\)@gnu\\.org\\)\\|\\(\\(m\\|a\\(min\\.\\)?\\)bandali@uwaterloo\\.ca\\)\\)"
2022 message-user-fqdn "aminb.org")
2023 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
2024 (message-mode . flyspell-mode)
2025 (message-mode . (lambda ()
2026 ;; (setq fill-column 65
2027 ;; message-fill-column 65)
2028 (make-local-variable 'company-idle-delay)
2029 (setq company-idle-delay 0.2))))
2031 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
2032 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
2033 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
2036 (with-eval-after-load 'mml-sec
2037 (setq mml-secure-openpgp-encrypt-to-self t
2038 mml-secure-openpgp-sign-with-sender t))
2043 Convenient footnotes in =message-mode=.
2045 #+begin_src emacs-lisp
2046 (use-package footnote
2049 (:map message-mode-map
2050 :prefix-map amin--footnote-prefix-map
2052 ("a" . footnote-add-footnote)
2053 ("b" . footnote-back-to-message)
2054 ("c" . footnote-cycle-style)
2055 ("d" . footnote-delete-footnote)
2056 ("g" . footnote-goto-footnote)
2057 ("r" . footnote-renumber-footnotes)
2058 ("s" . footnote-set-style))
2060 (setq footnote-start-tag ""
2062 footnote-style 'unicode))
2067 #+begin_src emacs-lisp
2070 :bind (:map gnus-group-mode-map ("e" . ebdb))
2072 (setq ebdb-sources (no-littering-expand-var-file-name "ebdb"))
2073 (with-eval-after-load 'swiper
2074 (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
2076 (use-package ebdb-com
2079 ;; (use-package ebdb-complete
2082 ;; (ebdb-complete-enable))
2084 (use-package company-ebdb
2085 :after (:all company message)
2087 (defun company-ebdb--post-complete (_) nil)
2089 (message-mode . (lambda ()
2090 (add-to-list (make-local-variable 'company-backends)
2093 (use-package ebdb-gnus
2096 (ebdb-gnus-window-configuration
2099 (summary 0.25 point)
2102 (ebdb-gnus 0.3))))))
2104 (use-package ebdb-mua
2106 ;; :custom (ebdb-mua-pop-up nil)
2109 ;; (use-package ebdb-message
2113 ;; (use-package ebdb-vcard
2117 ** COMMENT message-x
2119 #+begin_src emacs-lisp
2120 (use-package message-x
2122 (message-x-completion-alist
2124 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
2127 (quote message-newgroups-header-regexp))
2128 message-newgroups-header-regexp message-newsgroups-header-regexp)
2129 . message-expand-group)))))
2132 ** COMMENT gnus-harvest
2134 #+begin_src emacs-lisp
2135 (use-package gnus-harvest
2136 :commands gnus-harvest-install
2139 (if (featurep 'message-x)
2140 (gnus-harvest-install 'message-x)
2141 (gnus-harvest-install)))
2146 :CUSTOM_ID: blogging
2149 ** [[https://ox-hugo.scripter.co][ox-hugo]]
2151 #+begin_src emacs-lisp
2152 (use-package ox-hugo
2155 (use-package ox-hugo-auto-export
2156 :load-path "lib/ox-hugo")
2159 * Post initialization
2161 :CUSTOM_ID: post-initialization
2164 Display how long it took to load the init file.
2166 #+begin_src emacs-lisp
2167 (message "Loading %s...done (%.3fs)" user-init-file
2168 (float-time (time-subtract (current-time)
2169 amin--before-user-init-time)))
2177 #+begin_src emacs-lisp :comments none
2178 ;;; init.el ends here
2181 * COMMENT Local Variables :ARCHIVE:
2183 # eval: (add-hook 'after-save-hook #'amin/async-babel-tangle 'append 'local)
2184 # eval: (typo-mode -1)