home | section main page | rss feed


Emacs Configuration

Table of Contents

1. Introduction

This is my Vanilla Emacs configuration, made to work with my NixOS configuration. For that reason, you will not see :ensure t inside any use-package declaration, for emacs packages are all compiled natively and reproducibly on the NixOS side. This configuration uses the emacs-lisp language only to configure variables for said packages, for the most part.

2. Initialization

This must be the very first line in the tangled file to enable lexical binding.

;; -*- lexical-binding: t; -*-

2.1. State

This is my imperative state. Note that a lot of the state is just in the form of various macros that I use in order to write in declarative syntax elsewhere. Generally, however, these are all unordered and not dependent on each other loading first.

;; pure, well okay it prints but whatever
(defmacro try (expr)
  `(condition-case err
       ,expr
     (error
      (princ (format "BLOCK FAILED: %s\n" (error-message-string err))))))
     
;; pure
(defmacro declare-irc-server (name server port)
  `(defun ,name ()
     (interactive)
     (erc-tls :server ,server
              :port ,port)))
             
;; pure, well imperative when evaluated but they're all just bindings that don't depend on each other
(defmacro create-irc-servers (&rest server-list)
  `(progn
     ,@(mapcar (lambda (n) `(declare-irc-server ,@n)) server-list)))
     
;; pure
(defun org-html-latex-environment-pandoc-fix (orig-fun latex-environment contents info)
  "Force `ox-html' to use the convert command for LaTeX environments when set to 'html."
  (let ((processing-type (plist-get info :with-latex)))
    (if (eq processing-type 'html)
        (let* ((latex-frag (org-remove-indentation (org-element-property :value latex-environment)))
               (converted (org-format-latex-as-html latex-frag)))
          (format "<div class=\"equation-container\">\n<span class=\"equation\">\n%s\n</span>\n</div>" converted))
      (funcall orig-fun latex-environment contents info))))
     
;; imperative
(defun insert-urandom-password (&optional length)
  (interactive "P")
  (let ((length (or length 32))
        (chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{};:,.<>?"))
    (insert
     (with-temp-buffer
       (call-process "head" nil t nil "-c" (number-to-string length) "/dev/urandom")
       (let ((bytes (buffer-string)))
         (mapconcat (lambda (c)
                      (string (elt chars (mod (string-to-char (char-to-string c)) (length chars)))))
                    bytes ""))))))
                   
;; imperative
(defun create-htmlize-css ()
  (org-html-htmlize-generate-css)
  (with-current-buffer "*html*"
    (buffer-string)))
   
;; imperative
(defun minify-css (css)
  "A functional wrapper around the external 'minify' binary."
  (with-temp-buffer
    (insert css)
    (call-process-region (point-min) (point-max) "minify" t t nil "--type=css")
    (buffer-string)))
   
;; imperative
(defun emacs-config ()
  (unless noninteractive (server-start))

  ;; start with sane defaults
  (pixel-scroll-precision-mode 1)
  ;; (display-battery-mode 1)
  (display-time-mode 1)
  (menu-bar-mode -1)
  (scroll-bar-mode -1)
  (tool-bar-mode -1)
  (global-auto-revert-mode 1)

  ;; load theme, fonts, and transparency. Prettify symbols.
  (unless noninteractive (when (display-graphic-p)
    (set-face-attribute 'default nil :font "Iosevka Nerd Font" :height 130)
    (set-face-attribute 'variable-pitch nil :font "Lora" :height 1.1)
    (set-fontset-font t 'han   (font-spec :family "Noto Sans CJK SC"))
    (set-fontset-font t 'kana  (font-spec :family "Noto Sans CJK JP"))
    (set-fontset-font t 'emoji (font-spec :family "Noto Color Emoji") nil 'prepend)
    (set-fontset-font t 'symbol (font-spec :family "Noto Color Emoji") nil 'append)
    (set-fontset-font t '(#x1f300 . #x1f5ff) (font-spec :family "Noto Color Emoji") nil 'prepend)
    (set-fontset-font t '(#xe000 . #xf8ff) (font-spec :family "Symbols Nerd Font Mono") nil 'append))))
   
;; imperative
(defun evil-config ()
  (evil-mode 1)
  (evil-set-undo-system 'undo-redo)
  (evil-set-initial-state 'pdf-view-mode 'normal))

;; imperative
(defun doom-themes-config ()
  (load-theme 'doom-rouge t)
  (doom-themes-visual-bell-config)
  (doom-themes-treemacs-config)
  (doom-themes-org-config))

;; imperative
(defun org-roam-config ()
  (org-roam-db-autosync-mode)
  (org-roam-update-org-id-locations))

;; same as above
(defun org-electric-pair ()
  (setq-local electric-pair-inhibit-predicate
              (lambda (c) (if (eq c ?<) t (electric-pair-default-inhibit c)))))
             
;; same as above
(defun org-yasnippet-latex () (yas-activate-extra-mode 'latex-mode))

;; same as above
(defun remove-annoying-pairing () (remove-hook 'post-self-insert-hook #'yaml-electric-bar-and-angle t))

;; taken from blog https://writepermission.com/org-blogging-rss-feed.html
;; (defun rp/org-rss-publish-to-rss (plist filename pub-dir)
;;   "Publish RSS with PLIST, only when FILENAME is 'rss.org'.
;;   PUB-DIR is when the output will be placed."
;;   (if (equal "rss.org" (file-name-nondirectory filename))
;;       (org-rss-publish-to-rss plist filename pub-dir)))

;; (defun rp/org-rss-publish-to-rss (plist filename pub-dir)
;;   "Publish an Org file to RSS without creating Org IDs."
;;   (let* ((ext (concat "." (or (plist-get plist :rss-extension)
;;                               org-rss-extension
;;                               "xml")))
;;          (visiting (find-buffer-visiting filename))
;;          (buf (or visiting
;;                   (let ((org-inhibit-startup t))
;;                     (find-file-noselect filename)))))
;;     (unwind-protect
;;         (with-current-buffer buf
;;           (let ((org-inhibit-startup t))
;;             ;; Keep PUBDATE generation.
;;             (org-rss-add-pubdate-property)
;;             (save-buffer))
;;           (org-publish-org-to 'rss filename ext plist pub-dir))
;;       (unless visiting
;;         (kill-buffer buf)))))

(defun rp/org-rss-publish-to-rss (plist filename pub-dir)
  (org-publish-org-to
   'rss
   filename
   (concat "." (or (plist-get plist :rss-extension)
                   org-rss-extension
                   "xml"))
   plist
   pub-dir))
   
;; (defun rp/org-rss-publish-to-rss (plist filename pub-dir)
;;   "Use stock RSS publishing for normal posts, but bypass UID/PUBDATE
;; mutation for the generated rss.org sitemap."
;;   (if (string-equal (file-name-nondirectory filename) "rss.org")
;;       (org-publish-org-to
;;        'rss
;;        filename
;;        (concat "." (or (plist-get plist :rss-extension)
;;                        org-rss-extension
;;                        "xml"))
;;        plist
;;        pub-dir)
;;     (org-rss-publish-to-rss plist filename pub-dir)))

(defun format-rss-feed-entry (entry style project)
  "Format ENTRY for the RSS feed.
ENTRY is a file name.  STYLE is either 'list' or 'tree'.
PROJECT is the current project."
  (cond ((not (directory-name-p entry))
         (let* ((file (org-publish--expand-file-name entry project))
                (title (org-publish-find-title entry project))
                (date (format-time-string "%Y-%m-%d" (org-publish-find-date entry project)))
                (link (concat (file-name-sans-extension entry) ".html")))
           (with-temp-buffer
             (org-mode)
             
             (insert (format "* %s\n" title))
             (org-set-property "RSS_PERMALINK" link)
             (org-set-property "PUBDATE" date)
             (insert-file-contents file)
             (buffer-string))))
        ((eq style 'tree)
         ;; Return only last subdir.
         (file-name-nondirectory (directory-file-name entry)))
        (t entry)))
       
       
(defun format-rss-feed (title list)
  "Generate the rss.org file from the formatted list."
  (with-temp-buffer
    (org-mode) 
    (insert "#+TITLE: " title "\n\n")
    (insert (org-list-to-generic list '(:istart "" :icount "" :isep "\n")))
    (buffer-substring-no-properties (point-min) (point-max))))
   
(try (require 'url-util))

(defun org-sitemap-format-xml (title list)
  "Format the sitemap list as a standard XML file."
  (concat "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
          "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"
          (org-list-to-generic list '(:splice t :item-bullet "" :item-wrap nil))
          "\n</urlset>\n"))
         
(defun org-sitemap-format-entry-xml (entry style project)
  "Format ENTRY in PROJECT for XML sitemap."
  (let* ((file (file-name-sans-extension entry))
         (link (url-encode-url (concat "https://ret2pop.net/" file ".html")))
         (date (org-publish-find-date entry project))
         (lastmod (format-time-string "%Y-%m-%d" date)))
    (format "<url>\n  <loc>%s</loc>\n  <lastmod>%s</lastmod>\n</url>" link lastmod)))
   
(defun rp/org-sitemap-publish-function (plist filename pub-dir)
  (when (string-equal (file-name-nondirectory filename) "sitemap.xml")
    (org-publish-attachment plist filename pub-dir)))
   
(defvar my-mu4e-search-history nil)

(defun my-mu4e-search-with-ivy ()
  "Search mu4e using the native prompt wrapped in Ivy."
  (interactive)
  ;; We use mu4e's own query reader if possible, otherwise fallback
  (let ((query (completing-read "mu4e search: " 
                                my-mu4e-search-history nil nil nil 
                                'my-mu4e-search-history)))
    (unless (string-blank-p query)
      (mu4e-search query))))
     
(defun my-mu4e-narrow-with-ivy ()
  "Live-preview matches in the current buffer using Ivy, 
then append the typed input to the mu4e database query."
  (interactive)
  (let* ((current-query (or (mu4e-last-query) ""))
         ;; 1. Collect all lines in the current headers buffer for the preview
         (lines (save-excursion
                  (goto-char (point-min))
                  (let (res)
                    (while (not (eobp))
                      (push (buffer-substring-no-properties 
                             (line-beginning-position) 
                             (line-end-position)) 
                            res)
                      (forward-line 1))
                    (reverse res)))))
                   
    ;; 2. Launch Ivy with the collected lines
    (ivy-read (format "Narrow '%s' with: " current-query)
              lines
              :action (lambda (_)
                        ;; 3. IGNORE the selected line (_). 
                        ;; Instead, grab exactly what you typed into the prompt.
                        (let ((input ivy-text))
                          (if (string-blank-p input)
                              (message "No narrowing term provided. Canceled.")
                            ;; 4. Combine the old query with your new input and query Xapian
                            (mu4e-search (format "(%s) AND (%s)" current-query input))))))))
                           
(defvar my-current-weather "Fetching weather..."
  "Stores the latest fetched weather string.")

;; 2. The asynchronous fetch function
(defun my-fetch-weather-async ()
  "Fetch weather asynchronously without blocking Emacs."
  (interactive)
  (let ((buf (get-buffer-create " *wttr-output*")))
    (with-current-buffer buf (erase-buffer))
    (make-process
     :name "wttr-fetch"
     :buffer buf
     :command '("curl" "-s" "--max-time" "2" "wttr.in/?format=3")
     ;; The sentinel runs when the process finishes (success or fail)
     :sentinel (lambda (process event)
                 (when (string-match-p "finished" event)
                   (let ((output (with-current-buffer (process-buffer process)
                                   (string-trim (buffer-string)))))
                     ;; Validate output just like your old try macro did
                     (if (or (string-blank-p output)
                             (string-match-p "BLOCK FAILED\\|Unknown location\\|<html>" output))
                         (setq my-current-weather "Weather currently unavailable.")
                       (setq my-current-weather output)))
                       
                   ;; If the dashboard is visible, refresh it so the new text appears!
                   (when (get-buffer-window "*dashboard*" 'visible)
                     (with-current-buffer "*dashboard*"
                       (dashboard-refresh-buffer))))))))
                       
;; 3. Your new, simplified (and fast!) dashboard widget
(defun my-dashboard-insert-weather-clock (list-size)
  "Insert a styled clock and the pre-fetched weather variable."
  (let ((clock (format-time-string "%I:%M %p  •  %A, %B %d")))
    (insert "\n")
    (insert (propertize clock 'face '(:height 1.5 :weight bold :foreground "#51afef")))
    (insert "\n\n")
    ;; Just insert the variable. No network calls happen here.
    (insert (propertize my-current-weather 'face '(:foreground "#a9a1e1" :weight semi-bold)))
    (insert "\n\n")))
   
(defun my-refresh-dashboard-if-visible ()
  "Refresh the dashboard buffer, but only if it's currently visible in a window."
  (when (get-buffer-window "*dashboard*" 'visible)
    (with-current-buffer "*dashboard*"
      (dashboard-refresh-buffer))))
     
(defun my-setup-dashboard-timer ()
  "Start a timer to refresh the dashboard every 60 seconds."
  ;; Cancel any existing timer first to avoid creating multiple timers
  (when (timerp my-dashboard-refresh-timer)
    (cancel-timer my-dashboard-refresh-timer))
  ;; Run the refresh function every 60 seconds
  (setq my-dashboard-refresh-timer (run-with-timer 60 60 #'my-refresh-dashboard-if-visible)))

(defun my-fix-htmlize-invalid-face-bug (orig-fn face attribute &optional frame inherit)
  (if (facep face)
      (funcall orig-fn face attribute frame inherit)
      'unspecified))
     
(defun rp/vterm-cleanup-on-exit (buffer _event)
  "Close windows showing BUFFER after vterm exits, then kill BUFFER."
  (let ((buf buffer))
    (run-at-time
     0 nil
     (lambda ()
       (when (buffer-live-p buf)
         (let ((wins (get-buffer-window-list buf nil t)))
           (dolist (win wins)
             (when (window-live-p win)
               (if (one-window-p t win)
                   ;; Can't delete the last window in a frame.
                   ;; Switch it away from the vterm buffer instead.
                   (with-selected-window win
                     (switch-to-prev-buffer win 'kill))
                 (delete-window win)))))
         (when (buffer-live-p buf)
           (kill-buffer buf)))))))

2.2. Random Packages

These are packages that I require in order to write some scripts in emacs-lisp.

(use-package tex-site)
(use-package subr-x)
(use-package dash)
(use-package s)
(use-package f)
(use-package yaml-mode
  :demand t)

2.3. Emacs

These are all the options that need to be set at the start of the program. Because use-package is largely declarative, the order of many of these options should not matter. However, there is some imperative programming that must be done. Hooks are also largely declarative in this configuration as they are also defined using the use-package macros. Some of these options will have documentation strings attached, so it is easy to follow what the individual options do. Emacs is self documenting, after all!

(use-package emacs
  :custom
  ;; global defaults
  (enable-local-variables :all "don't emit local variable warnings when publishing")
  (indent-tabs-mode nil "no real tabs, only spaces")
  (tab-width 2 "tab show as 2 spaces")
  (standard-indent 2 "base indentation")
  (custom-safe-themes t "I already manage my themes with nix")
  (custom-file null-device "Don't save custom configs")
  (jit-lock-chunk-size 16384 "actually load code blocks")
  (jit-lock-stealth-time 1.25 "fontify in the background after 1.25s of idle time")
  (jit-lock-stealth-nice 0.1 "don't freeze Emacs while stealth fontifying")
  ;; ---------------------------------------------------------------------------
  ;; UTF-8 Everywhere
  ;; ---------------------------------------------------------------------------
  (set-language-environment "UTF-8")
  (set-default-coding-systems 'utf-8)
  (prefer-coding-system 'utf-8)
  (set-terminal-coding-system 'utf-8)
  (set-keyboard-coding-system 'utf-8)
  (set-selection-coding-system 'utf-8)
  (locale-coding-system 'utf-8)
  (use-default-font-for-symbols nil)

  ;; Startup errors
  (warning-minimum-level :emergency "Supress emacs warnings")
  (confirm-kill-processes nil "Don't ask to quit")
  (debug-ignored-errors (cons 'remote-file-error debug-ignored-errors) "Remove annoying error from debug errors")
  (browse-url-generic-program "qutebrowser" "set browser to librewolf")
  (browse-url-secondary-browser-function 'browse-url-generic "set browser")
  (browse-url-browser-function 'browse-url-generic "set browser")
  (default-frame-alist '((alpha-background . 100)
                         (vertical-scroll-bars)
                         (internal-border-width . 24)
                         (left-fringe . 8)
                         (right-fringe . 8)))
  ;; Mouse wheel
  (mouse-wheel-scroll-amount '(1 ((shift) . 1)) "Nicer scrolling")
  (mouse-wheel-progressive-speed nil "Make scrolling non laggy")
  (mouse-wheel-follow-mouse 't "Scroll correct window")
  (scroll-conservatively 101 "Sort of smooth scrolling")
  (scroll-step 1 "Scroll one line at a time")
  (debug-on-error nil "Don't make the annoying popups")
  (display-time-24hr-format t "Use 24 hour format to read the time")
  (display-line-numbers-type 'relative "Relative line numbers for easy vim jumping")
  (use-short-answers t "Use y instead of yes")
  (make-backup-files nil "Don't make backups")
  (line-spacing 2 "Default line spacing")
  (c-doc-comment-style '((c-mode . doxygen)
                         (c++-mode . doxygen)))
  (fill-column 150)

  :hook ((prog-mode . display-line-numbers-mode)
         (org-mode . auto-fill-mode)
         (org-mode . display-line-numbers-mode))
  :config (emacs-config))

As you can see, the config (and sometimes the init section) of most of these use-package blocks contain most of the imperative commands. In fact, most of the configurations are completely declarative without any imperative programming at all (i.e. hooks and custom options). Note that Emacs lambdas contain imperative state, unlike in NixOS where lambdas can contain function applications but they themselves are mainly declarative. Usually, however, the lambdas or functions do little to nothing and are mainly wrappers for executing two commands or for giving a variable an option. Often you will see a config section of a use-package declaration have only one or two entries, which is intentional, as I've designed this configuration to put as little in config as possible. I hardly consider most of this configuration to be imperative, but of course Emacs was not designed to be fully imperative.

2.4. Network

(use-package enwc :custom (enwc-default-backend 'nm "use networkmanager backend"))

2.5. System Monitor

(use-package proced
  :custom (proced-enable-color-flag t "use colors in proced"))

2.6. Org Mode

This is my org mode configuration, which also configures latex.

(use-package org
  :demand t
  :after (f s dash nix-mode)
  :hook
  ((org-mode . remove-annoying-pairing))
  :custom
  (org-export-allow-bind-keywords t "don't emit warnings")
  (org-confirm-babel-evaluate nil "I want to evaluate stuff when publishing")
  ;; Fix terrible indentation issues
  (org-edit-src-content-indentation 0)
  (org-src-tab-acts-natively t)
  (org-src-preserve-indentation t)
  (org-hide-drawer-startup t)
  (org-startup-folded 'showall)

  (TeX-PDF-mode t)
  (org-confirm-babel-evaluate nil "Don't ask to evaluate code block")
  (org-export-with-broken-links t "publish website even with broken links")
  (org-src-fontify-natively t "Colors!")

  ;; org-latex
  (org-format-latex-header "\\documentclass{article} \
    \\usepackage[usenames]{color} \
    [DEFAULT-PACKAGES] \
    [PACKAGES] \
    \\pagestyle{empty}             % do not remove \
    % The settings below are copied from fullpage.sty \
    \\setlength{\\textwidth}{\\paperwidth} \
    \\addtolength{\\textwidth}{-3cm} \
    \\setlength{\\oddsidemargin}{1.5cm} \
    \\addtolength{\\oddsidemargin}{-2.54cm} \
    \\setlength{\\evensidemargin}{\\oddsidemargin} \
    \\setlength{\\textheight}{\\paperheight} \
    \\addtolength{\\textheight}{-\\headheight} \
    \\addtolength{\\textheight}{-\\headsep} \
    \\addtolength{\\textheight}{-\\footskip} \
    \\addtolength{\\textheight}{-3cm} \
    \\setlength{\\topmargin}{1.5cm} \
    \\addtolength{\\topmargin}{-2.54cm} \
    \\usepackage{amsmath} \
    \\usepackage{tikz-cd} \
    ")
  (org-preview-latex-image-directory (expand-file-name "~/.cache/ltximg/") "don't use weird cache location")
  (org-latex-preview-ltxpng-directory (expand-file-name "~/.cache/ltximg/") "don't use weird cache location")
  (org-latex-to-html-convert-command "printf '%%s' %i | pandoc -f latex -t html --mathml | tr -d '\\n' | sed -e 's/^<p>//' -e 's/<\\/p>$//'" "latex to MathML with special character handling")
  (org-latex-to-mathml-convert-command "printf '%%s' %i | pandoc -f latex -t html --mathml | tr -d '\\n' | sed -e 's/^<p>//' -e 's/<\\/p>$//'" "latex to MathML with special character handling")

  (TeX-engine 'xetex "set xelatex as default engine")
  (preview-default-option-list '("displaymath" "textmath" "graphics") "preview latex")
  ;; (preview-image-type 'png "Use PNGs")
  ;; (org-preview-latex-default-process 'imagemagick)
  (org-format-latex-options
   '(:foreground default
                 :background default
                 :scale 2
                 :html-foreground "Black"
                 :html-background "Transparent"
                 :html-scale 1.5
                 :matchers ("begin" "$1" "$" "$$" "\\(" "\\[")) "space latex better")
  (org-return-follows-link t "be able to follow links without mouse")
  (org-startup-indented t "Indent the headings")
  (org-image-actual-width '(300) "Cap width") 
  (org-startup-with-inline-images t "See images on opening file")
  (org-hide-emphasis-markers t "prettify org mode")
  (org-use-sub-superscripts "{}" "Only display superscripts and subscripts when enclosed in {}")
  (org-pretty-entities t "prettify org mode")
  (org-agenda-files (list "~/monorepo/agenda.org" "~/org/notes.org" "~/org/agenda.org") "set default org files")
  (org-agenda-block-separator "")
  (org-fontify-whole-heading-line t)
  (org-fontify-done-headline t)
  (org-fontify-quote-and-verse-blocks t)
  (org-default-notes-file (concat org-directory "/notes.org") "Notes file")

  ;; ricing
  (org-auto-align-tags nil)
  (org-tags-column 0)
  (org-catch-invisible-edits 'show-and-error)
  (org-special-ctrl-a/e t)
  (org-insert-heading-respect-content t)
  (org-pretty-entities t)
  (org-agenda-tags-column 0)
  (org-ellipsis "…")
  :config
  (org-babel-do-load-languages 'org-babel-load-languages
                               '((shell . t)
                                 (python . t)
                                 (nix . t)
                                 (scheme . t)
                                 (latex . t)))
  :config
  (add-to-list 'org-preview-latex-process-alist
               '(xetex-imagemagick
                 :programs ("xelatex" "convert")
                 :description "pdf > png"
                 :message "you need to install the programs: xelatex and imagemagick."
                 :image-input-type "pdf"
                 :image-output-type "png"
                 :image-size-adjust (1.0 . 1.0)
                 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
                 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O")))
                 
  ;; Set this new process as your default
  (setq org-preview-latex-default-process 'xetex-imagemagick)
  (set-face-attribute 'org-document-title nil :height 1.5 :weight 'bold)
  (set-face-attribute 'org-level-1 nil :height 1.4 :weight 'bold)
  (set-face-attribute 'org-level-2 nil :height 1.3 :weight 'bold)
  (set-face-attribute 'org-level-3 nil :height 1.2 :weight 'semibold)
  (set-face-attribute 'org-level-4 nil :height 1.1 :weight 'normal)
  (set-face-attribute 'org-level-5 nil :height 1.0 :weight 'normal)
  (set-face-attribute 'org-level-6 nil :height 1.0 :weight 'normal))

(use-package org-tempo
  :after org)

(use-package org-habit
  :after org
  :custom
  (org-habit-preceding-days 7 "See org habit entries")
  (org-habit-following-days 35 "See org habit entries")
  (org-habit-show-habits t "See org habit entries")
  (org-habit-show-habits-only-for-today nil "See org habit entries")
  (org-habit-show-all-today t "Show org habit graph"))

(use-package htmlize
  :demand t
  :after (doom-themes yaml-mode)
  :config (advice-add 'face-attribute :around #'my-fix-htmlize-invalid-face-bug))

(use-package ox-latex
  :after (org)
  :custom
  (org-latex-compiler "xelatex" "Use latex as default")
  (org-latex-pdf-process '("xelatex -interaction=nonstopmode -output-directory=%o %f") "set xelatex as default"))

(use-package ox-html
  :demand t
  :after (org htmlize)
  :custom
  (org-html-htmlize-output-type 'css "allow styling from CSS file")
  (org-html-with-latex 'html "let my html handler handle latex")
  (org-html-mathjax-options nil "disable mathjax, use MathML")
  (org-html-mathjax-template "" "disable mathjax, use MathML")
  (org-html-head-include-default-style nil "use my own css for everything")
  (org-html-head-include-scripts nil "use my own js for everything")
  (org-html-postamble (concat "Copyright © 2024 " system-fullname) "set copyright notice on bottom of site")
  (org-html-divs '((preamble "header" "preamble")
                   (content "main" "content")
                   (postamble "footer" "postamble")) "semantic html exports")
  (org-html-viewport '((width "device-width")
                       (initial-scale "1.0")
                       (minimum-scale "1.0")) "Prevent zooming out past default size")
  :config (advice-add 'org-html-latex-environment :around #'org-html-latex-environment-pandoc-fix))

(use-package ox-rss
  :after org
  :demand t)

(use-package ox-publish
  :demand t
  :after (org f s dash ox-html ox-rss)
  :custom
  (org-publish-project-alist
   `(("website-org"
      :base-directory "~/monorepo"
      :base-extension "org"
      :exclude "nix/README\\.org\\|blog/rss\\.org\\|result/.*\\|nix/.*"
      :publishing-directory "~/website_html"
      :with-author t
      :with-date t
      :with-broken-links t
      :language en
     
      :recursive t
      :publishing-function org-html-publish-to-html
      :headline-levels 4
      :html-footnotes-section "<div id=\"footnotes\"><hr><div id=\"text-footnotes\"><span class=\"footnotes-label-hidden\">%s</span>%s</div></div>"
      :html-head ,(concat "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS Feed\" href=\"/blog/rss.xml\"><meta name=\"theme-color\" content=\"#ffffff\">\n<link rel=\"preload\" href=\"/fonts/Inconsolata-Medium.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<meta name=\"theme-color\" content=\"#ffffff\">\n<link rel=\"preload\" href=\"/fonts/Lora-Medium.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<link rel=\"preload\" href=\"/fonts/CormorantGaramond-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<link rel=\"preload\" href=\"/fonts/CormorantGaramond-Medium.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>\n<link rel=\"manifest\" href=\"/site.webmanifest\">\n<link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/favicon-16x16.png\">\n<link rel=\"mask-icon\" href=\"/safari-pinned-tab.svg\" color=\"#5bbad5\">\n<link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/favicon-32x32.png\">\n<link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"/apple-touch-icon.png\"><meta name=\"msapplication-TileColor\" content=\"#da532c\">\n"
                          "<style>"
                          (->> (create-htmlize-css)
                               (s-replace-regexp "<style[^>]*>" "")
                               (s-replace "</style>" "")
                               (s-replace "<![CDATA[/*><![CDATA[/*>\n" "")
                               (s-replace "/*]]>*/-->" "")
                               (s-trim)
                               (minify-css))
                          (f-read-text "~/monorepo/style.css" 'utf-8)
                          "</style>")
      :html-preamble t
      :html-preamble-format (("en" "<p class=\"preamble\"><a href=\"/index.html\">home</a> | <a href=\"./index.html\">section main page</a> | <a href=\"/blog/rss.xml\">rss feed</a></p><hr>"))
     
      ;; sitemap.html stuff
      :auto-sitemap t
      :sitemap-filename "sitemap.org"
      :sitemap-title "Site Index"
      :sitemap-style list
      :sitemap-sort-files anti-chronologically)
     
     ;; ("website-blog-rss"
     ;;  :base-directory "~/monorepo/blog"
     ;;  :base-extension "org"
     ;;  :recursive nil
     ;;  :exclude "rss\\.org\\|index\\.org\\|404\\.org"
     ;;  :rss-extension "xml"
     
     ;;  :publishing-directory "~/website_html/blog"
     ;;  :publishing-function rp/org-rss-publish-to-rss
     ;;  :html-link-home "https://ret2pop.net/blog/"
     ;;  :html-link-use-abs-url t
     
     ;;  ;; use custom sitemap functionality to publish rss feed
     ;;  :auto-sitemap t
     ;;  :sitemap-filename "rss.org"
     ;;  :sitemap-title "Blog Feed"
     ;;  :sitemap-style list
     ;;  :sitemap-sort-folders ignore
     ;;  :sitemap-sort-files anti-chronologically
     ;;  :sitemap-format-entry format-rss-feed-entry
     ;;  :sitemap-function format-rss-feed)
     
     ("website-blog-rss"
      :base-directory "~/monorepo/blog"
      :base-extension "org"
      :recursive nil
     
      ;; Only publish the generated feed source.
      :exclude ".*"
      :include ("rss.org")
     
      :rss-extension "xml"
      :publishing-directory "~/website_html/blog"
      :publishing-function rp/org-rss-publish-to-rss
      :html-link-home "https://ret2pop.net/blog/"
      :html-link-use-abs-url t
     
      :auto-sitemap t
      :sitemap-filename "rss.org"
      :sitemap-title "Blog Feed"
      :sitemap-style list
      :sitemap-sort-folders ignore
      :sitemap-sort-files anti-chronologically
      :sitemap-format-entry format-rss-feed-entry
      :sitemap-function format-rss-feed)
     
     ("website-sitemap-xml"
      :base-directory "~/monorepo"
      :base-extension "org"
      :recursive t
      :exclude "nix/README\\.org\\|blog/rss\\.org"
      :publishing-directory "~/website_html"
      :publishing-function rp/org-sitemap-publish-function
      :auto-sitemap t
      :sitemap-filename "sitemap.xml"
      :sitemap-format-entry org-sitemap-format-entry-xml
      :sitemap-style list
      :sitemap-function org-sitemap-format-xml)
     
     ("website-static"
      :base-directory "~/monorepo"
      :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|ico\\|asc\\|pub\\|webmanifest\\|xml\\|svg\\|txt\\|webp\\|conf"
      :publishing-directory "~/website_html/"
      :recursive t
      :publishing-function org-publish-attachment)
     
     ("website"
      :auto-sitemap t
      :components ("website-org" "website-static" "website-blog-rss" "website-sitemap-xml")))
   "functions to publish website"))

As you can see, I only have one real entry in config here (I don't count requires even though they have to be on the top)

3. All The Icons

I already pull in all-the-icons, but we need the emacs package to load it correctly.

(use-package all-the-icons
  :if (display-graphic-p))

4. Variable Pitch Font

I use this in org-mode so that I can read/write with variable pitched font. Feels like I'm reading a blog article or something.

(use-package mixed-pitch
  :hook ((org-mode . mixed-pitch-mode))
  :custom (mixed-pitch-set-height t)
  :config
  (dolist (face '(org-latex-and-related
                  org-priority
                  org-block
                  org-table
                  org-formula))
    (add-to-list 'mixed-pitch-fixed-pitch-faces face)))

5. Writeroom

(use-package writeroom-mode
  :custom (writeroom-width 150))

6. Indent Bars

I want to show indent lines in emacs so that I can line things up.

(use-package indent-bars
  :after (nix-mode)
  :hook (
         (python-ts-mode . indent-bars-mode)
         (css-ts-mode . indent-bars-mode)
         (haskell-mode . indent-bars-mode)
         (js-ts-mode . indent-bars-mode)
         (c-ts-mode . indent-bars-mode)
         (c++-ts-mode . indent-bars-mode)
         (rust-ts-mode . indent-bars-mode)
         (go-ts-mode . indent-bars-mode)
         (python-mode . indent-bars-mode)
         (yaml-ts-mode . indent-bars-mode)
         (nix-mode . indent-bars-mode)
         (emacs-lisp-mode . indent-bars-mode)))

7. Autopair

Use electric-pair to automatically complete pairs of things. We need to change what electric-pair does based on the mode.

(use-package electric-pair
  :hook ((prog-mode . electric-pair-mode)
         (org-mode . org-electric-pair)))

8. Search and Replace

wgrep is a program that allows you to do more intelligent search and replace.

(use-package wgrep
  :after grep)

9. Fragtog

This package is used to generate previews automatically when your cursor hovers over a latex snippet.

(use-package org-fragtog :hook (org-mode . org-fragtog-mode))

10. Snippets

Yasnippets are useful for macros that automatically complete to an arbitrary form.

(use-package yasnippet
  :demand t
  :hook (org-mode . org-yasnippet-latex)
  :custom (yas-snippet-dirs '("~/monorepo/yasnippet/" "~/.emacs.d/snippets"))
  :config (yas-global-mode 1))

(use-package yasnippet-snippets
  :after yasnippet)

11. Completion

Company-mode! We need this to do autocomplete stuff.

(use-package company
  :custom
  (company-backends '(company-capf company-files company-yasnippet company-ispell))
  
  (company-idle-delay 0.1)
  (company-minimum-prefix-length 1)
  (company-require-match nil)
  (company-selection-wrap-around t)
  (company-tooltip-align-annotations t)

  :bind (:map company-active-map
              ("RET" . nil)
              ("<return>" . nil)
              ("TAB" . company-complete-selection)
              ("<tab>" . company-complete-selection)
              ("C-j" . company-select-next)
              ("C-k" . company-select-previous))
             
  :hook ((after-init . global-company-mode)))

(use-package company-box
  :hook (company-mode . company-box-mode)
  :custom
  (company-box-scrollbar nil))

12. Spelling

This loads a dictionary so that I can save certain words to be not misspelled and also have this spellcheck during org mode.

(unless noninteractive (use-package ispell
                         :custom
                         (ispell-program-name "aspell" "use aspell")
                         (ispell-local-dictionary-alist
                          '(("en" "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "en") nil utf-8)))
                         (ispell-dictionary "en" "Use english dictionary")
                         (ispell-extra-args my-ispell-args "Force aspell to use normal mode instead of nroff")
                         (ispell-silently-savep t "Save changes to dict without confirmation")
                         (ispell-alternate-dictionary my-ispell-dictionary "dict location")))
                         
(unless noninteractive (use-package flyspell
                         :hook (text-mode . flyspell-mode)))

13. Packages

First, some small configurations and some evil-mode initilaization because I like vim keybindings:

  (use-package evil
    :demand t
    :custom (evil-want-keybinding nil "Don't load a whole bunch of default keybindings")
    :bind
    (:map evil-normal-state-map
          ("/" . swiper)
          ("?" . (lambda () (interactive) (swiper "--reverse"))))
    :config (evil-config))
   
  (use-package evil-collection
    :demand t
    :after (evil)
    :bind (:map evil-motion-state-map
                ("SPC" . nil)
                ("RET" . nil)
                ("TAB" . nil))
    :config (evil-collection-init))
   
  (use-package evil-commentary
    :after (evil)
    :config (evil-commentary-mode))
   
  (use-package evil-org
    :after (evil org)
    :hook (org-mode . evil-org-mode))
   
  (use-package evil-org-agenda
    :after (evil-org)
    :config (evil-org-agenda-set-keys))
   
  (use-package which-key
    :config (which-key-mode))
   
  (use-package page-break-lines
    :config (page-break-lines-mode))
   
  (use-package evil-mc
    :after evil
    :config (global-evil-mc-mode 1))
   
  (use-package evil-surround
    :after evil
    :config
    (global-evil-surround-mode 1))
   
  (use-package evil-lion
    :config
    (evil-lion-mode))
   
  (use-package evil-multiedit
    :after evil
    :config
    (evil-multiedit-default-keybinds))
   
  (use-package evil-textobj-tree-sitter
    :ensure t
    ;; Ensure Evil is loaded first so the text-object maps exist
    :after evil
    
    ;; 1. The Keybindings
    :bind ((:map evil-outer-text-objects-map
                 ("f" . my-treesit-outer-function)
                 ("c" . my-treesit-outer-class)
                 ("a" . my-treesit-outer-arg))
                 
           (:map evil-inner-text-objects-map
                 ("f" . my-treesit-inner-function)
                 ("c" . my-treesit-inner-class)
                 ("a" . my-treesit-inner-arg))
                 
           (:map evil-normal-state-map
                 ("] f" . my-treesit-goto-next-function)
                 ("[ f" . my-treesit-goto-prev-function)
                 ("] c" . my-treesit-goto-next-class)
                 ("[ c" . my-treesit-goto-prev-class)))
                 
    ;; 2. The Command Definitions
    :config
    ;; Link the custom names we bound above to the actual Tree-sitter closures
    (defalias 'my-treesit-outer-function (evil-textobj-tree-sitter-get-textobj "function.outer"))
    (defalias 'my-treesit-inner-function (evil-textobj-tree-sitter-get-textobj "function.inner"))
    
    (defalias 'my-treesit-outer-class    (evil-textobj-tree-sitter-get-textobj "class.outer"))
    (defalias 'my-treesit-inner-class    (evil-textobj-tree-sitter-get-textobj "class.inner"))
    
    ;; "a" is standard Vim terminology for "argument" (parameter)
    (defalias 'my-treesit-outer-arg      (evil-textobj-tree-sitter-get-textobj "parameter.outer"))
    (defalias 'my-treesit-inner-arg      (evil-textobj-tree-sitter-get-textobj "parameter.inner"))
   
    ;; Navigation commands are standard interactive functions, so we wrap them cleanly
    (defun my-treesit-goto-next-function ()
      (interactive)
      (evil-textobj-tree-sitter-goto-textobj "function.outer"))
      
    (defun my-treesit-goto-prev-function ()
      (interactive)
      (evil-textobj-tree-sitter-goto-textobj "function.outer" t))
     
    (defun my-treesit-goto-next-class ()
      (interactive)
      (evil-textobj-tree-sitter-goto-textobj "class.outer"))
      
    (defun my-treesit-goto-prev-class ()
      (interactive)
      (evil-textobj-tree-sitter-goto-textobj "class.outer" t)))
     
     
  (use-package general
    :after (evil evil-collection)
    :config
    (general-create-definer leader-key :prefix "SPC")
    ;; these are just bindings but the symbols are all lazily handled by general
    (create-irc-servers
     (znc "ret2pop.net" "5000")
     (prestonpan "nullring.xyz" "6697")
     (libera-chat "irc.libera.chat" "6697")
     (efnet "irc.prison.net" "6697")
     (matrix-org "matrix.org" "8448")
     (gimp-org "irc.gimp.org" "6697"))
     
    (general-define-key
     "C-=" #'text-scale-increase
     "C--" #'text-scale-decrease
     "C-0" #'text-scale-set)
     
    (leader-key 'normal
      "o c" '(org-capture :wk "Capture")
      ;; Org Mode
      "n" '(:ignore t :wk "Org mode plugins")
      "n j j" '(org-journal-new-entry :wk "Make new journal entry")
      "n r f" '(org-roam-node-find :wk "Find roam node")
      "n r i" '(org-roam-node-insert :wk "Insert roam node")
      "n r a" '(org-roam-alias-add :wk "Add alias to org roam node")
      "n r g" '(org-roam-graph :wk "Graph roam database")
      "m I" '(org-id-get-create :wk "Make org id")
     
      ;; Programming Projects
      "." '(counsel-find-file :wk "find file")
      "p a" '(projectile-add-known-project :wk "Add to project list")
      
      "N f" '(nix-flake :wk "nix flake menu")
      "f" '(:ignore t :wk "file operations")
      "f p" '(projectile-switch-project :wk "find project to switch to")
      "f f" '(counsel-fzf :wk "find file in project")
      "f s" '(counsel-rg :wk "find string in project")
     
      "y n s" '(yas-new-snippet :wk "Create new snippet")
     
      "g" '(:ignore t :wk "Magit")
      "g /" '(magit-dispatch :wk "git commands")
      "g P" '(magit-push :wk "git push")
      "g c" '(magit-commit :wk "git commit")
      "g p" '(magit-pull :wk "Pull from git")
      "g s" '(magit-status :wk "Change status of files")
      "g i" '(magit-init :wk "init new git project")
      "g r" '(magit-rebase :wk "Rebase branch")
      "g m" '(magit-merge :wk "Merge branches")
      "g b" '(magit-branch :wk "Git branch")
     
      "o p" '(treemacs :wk "Project Drawer")
      "o P" '(treemacs-projectile :wk "Import Projectile project to treemacs")
     
      "w r" '(writeroom-mode :wk "focus mode for writing")
     
      ;; Applications
      "o" '(:ignore t :wk "Open application")
      "o t" '(projectile-run-vterm-other-window :wk "Terminal")
      "o e" '(projectile-run-eshell :wk "Elisp Interpreter")
      "o m" '(mu4e :wk "Email")
      "o M" '(matrix-org :wk "Connect to matrix")
      "o r s" '(elfeed :wk "rss feed")
      "o a" '(org-agenda :wk "Open agenda")
      "o w" '(eww :wk "web browser")
      "o n" '(enwc :wk "NetworkManager Interface")
      "m m" '(emms :wk "Music player")
      "s m" '(proced :wk "System Manager")
      "l p" '(list-processes :wk "List Emacs Processes")
     
      "m P p" '(org-publish :wk "Publish website components")
      "s e" '(sudo-edit :wk "Edit file with sudo")
     
      ;; "f f" '(eglot-format :wk "Format code buffer")
      "i p c" '(prestonpan :wk "Connect to my IRC server")
      "i l c" '(liberachat :wk "Connect to libera chat server")
      "i e c" '(efnet :wk "Connect to efnet chat server")
      "i g c" '(gimp-org :wk "Connect to gimp chat server")
      "i z c" '(znc :wk "Connect to my ZNC instance")
     
      ;; Documentation
      "h" '(:ignore t :wk "Documentation")
      "h v" '(counsel-describe-variable :wk "Describe variable")
      "h f" '(counsel-describe-function :wk "Describe function")
      "h h" '(help :wk "Help")
      "h m" '(woman :wk "Manual")
      "h i" '(info :wk "Info")
     
      "s i p" '(insert-urandom-password :wk "insert random password to buffer (for sops)")
     
      "h r r" '(lambda () (interactive) (load-file (expand-file-name "~/monorepo/nix/init.el")))))

13.1. Journal

I use org-journal to journal about my life, and it's a part of my website:

(use-package org-journal
  :after (org)
  :custom
  (org-journal-dir "~/monorepo/journal/" "Set journal directory")
  (org-journal-date-format "%A, %d %B %Y" "Date format")
  (org-journal-file-format "%Y%m%d.org" "Automatic file creation format based on date")
  (org-journal-enable-agenda-integration t "All org-journal entries are org-agenda entries")
  (org-journal-file-header "#+TITLE: Daily Journal\n#+STARTUP: showeverything\n#+DESCRIPTION: My daily journal entry\n#+AUTHOR: Preston Pan\n#+date:\n#+options: broken-links:t" "set header files on new org journal entry"))

13.2. Org Super Agenda

This gives richer org agenda views.

(use-package org-super-agenda
  :after org
  :custom
  (org-super-agenda-groups
   '((:name "Overdue"
            :deadline past)
     (:name "Today"
            :time-grid t
            :scheduled today)
     (:name "Important"
            :priority "A")
     (:name "Due soon"
            :deadline future)
     (:name "Next"
            :todo "NEXT")
     (:name "Waiting"
            :todo "WAIT")
     (:name "Projects"
            :tag "project")))
           
  :config
  (org-super-agenda-mode))

13.3. Org Ql

This allows efficient querying of my org mode files.

(use-package org-ql
  :after org)

13.4. Doom Modeline

The default modeline is ugly. I replace it with the doom modeline because it's better.

(use-package doom-modeline
  :config (doom-modeline-mode 1))

13.4.1. Doom Theme

I used to use catppuccin, but the doom themes are so good that I am willing to break some theme consistency with my desktop in order to use doom themes. I mean it looks better anyways if emacs is a distinct theme.

(use-package doom-themes
  :demand t
  :custom
  (doom-themes-enable-bold t "use bold letters")
  (doom-themes-enable-italic t "use italic letters")
  (doom-themes-treemacs-theme "doom-colors" "set theme to something like catppuccin but doom")
  :config
  (unless noninteractive (doom-themes-config)))

(use-package solaire-mode
  :after doom-themes
  :config (solaire-global-mode +1))

13.5. Grammar

I want to write good! I grammar good too.

(use-package writegood-mode
  :hook (text-mode . writegood-mode))

13.6. Make Org Look Better

Org superstar adds those nice looking utf-8 bullets:

(use-package org-modern
  :after (org)
  :hook (org-mode . org-modern-mode)
  :custom
  (org-modern-block-fringe t)
  (org-modern-block-name t)
  (org-modern-star '("◉" "○" "◈" "◇"))
  (org-modern-block-name '((t . t)))
  (org-modern-keyword '((t . t)))
  :config
  (global-org-modern-mode))

13.7. Notifications

We use org-alert in order to give us notifications based on our org-agenda.

(use-package org-alert
  :after (org ox-publish)
  :custom
  (alert-default-style 'libnotify)
  (org-alert-interval 300)
  (org-alert-notify-cutoff 10)
  (org-alert-notify-after-event-cutoff 10)
  :config (org-alert-enable))

13.8. LSP

We set up eglot, the LSP manager for emacs, now built in:

(use-package python
  :after lsp-mode
  :hook (python-ts-mode . lsp-deferred))

(use-package yaml-mode
  :after lsp-mode
  :hook (yaml-ts-mode . lsp-deferred))

(use-package go-ts-mode
  :after lsp-mode
  :hook (go-ts-mode . lsp-deferred))

(use-package haskell-mode
  :after lsp-mode
  :hook (haskell-mode . lsp-deferred))

(use-package scheme-mode
  :hook (scheme-mode . lsp-deferred)
  :after lsp-mode
  :mode ("\\.sls\\'" "\\.scm\\'"))

(use-package elisp-mode
  :after lsp-mode
  :hook (emacs-lisp-mode . lsp-deferred))

(use-package cc-mode
  :after lsp-mode
  :hook ((c-mode . lsp-deferred)
         (c-ts-mode . lsp-deferred)))
         
(use-package css-mode
  :after lsp-mode
  :hook ((css-mode . lsp-deferred)
         (css-ts-mode . lsp-deferred)))
         
(use-package js
  :after lsp-mode
  :hook ((js-mode . lsp-deferred)
         (js-ts-mode . lsp-deferred)
         (tsx-ts-mode . lsp-deferred)))
         
(use-package json-mode
  :after lsp-mode
  :hook ((json-mode . lsp-deferred)
         (json-ts-mode . lsp-deferred)))
         
(use-package toml-mode
  :after lsp-mode
  :hook ((toml-ts-mode . lsp-deferred)))

(use-package nix-mode
  :demand t
  :after lsp-mode
  :hook (nix-mode . lsp-deferred)
  :mode "\\.nix\\'")

(use-package sh-script
  :after lsp-mode
  :hook (sh-mode . lsp-deferred))

(use-package poetry
  :config (poetry-tracking-mode 1))

(use-package lsp-mode
  :demand t
  :custom
  (lsp-use-plists t)
  (lsp-typescript-format-enable t)
  (lsp-typescript-indent-size 4)
  (lsp-typescript-tab-size 4)
  (lsp-typescript-indent-style "spaces")

  (lsp-auto-guess-root t)
  (lsp-restart 'auto-restart)
  (lsp-keep-workspace-alive t)

  :general
  (:states 'normal :keymaps 'lsp-mode-map
           "gI" #'lsp-find-implementation
           "gy" #'lsp-find-type-definition
           "K"  #'lsp-describe-thing-at-point))
           
(use-package lsp-ui
  :after lsp-mode
  :general
  (:states 'normal :keymaps 'lsp-mode-map
           "gd" #'lsp-ui-peek-find-definitions
           "gr" #'lsp-ui-peek-find-references)
  :hook (lsp-mode . lsp-ui-mode))

(use-package editorconfig
  :config (editorconfig-mode 1))

(use-package flycheck
  :config (global-flycheck-mode))

(use-package platformio-mode
  :hook (prog-mode . platformio-conditionally-enable))

(use-package dap-mode
  :custom
  (dap-auto-configure-features '(sessions locals controls tooltip))
  :hook (lsp-mode . dap-mode))

13.8.1. C/C++

Specific configuration for C (I also use the clangd lsp):

(use-package irony
  :hook ((c++-mode . irony-mode)
         (c-mode . irony-mode)
         (objc-mode . irony-mode)
         (irony-mode . irony-cdb-autosetup-compile-options)))
         
(use-package irony-eldoc
  :hook ((irony-mode . irony-eldoc)))

13.8.2. Solidity

For writing solidity:

(use-package solidity-mode)
(use-package solidity-flycheck
  :after flycheck
  :custom (solidity-flycheck-solc-checker-active t))

13.9. Projectile

Manages projects and shit.

(use-package projectile
  :custom
  (projectile-project-search-path '("~/org" "~/src" "~/monorepo" "~/projects") "search path for projects")
  :config (projectile-mode +1))

13.10. Dashboard

We want our emacs initialization to be pretty and display useful things.

(use-package dashboard
  :after (projectile)
  :custom
  (dashboard-banner-logo-title "Introducing: Ret2pop!" "Set title for dashboard")
  (dashboard-startup-banner logo-file)
  (dashboard-icon-type 'all-the-icons "Use nerd icons")
  (dashboard-center-content t "Center content")
  (dashboard-set-init-info t)
  (dashboard-set-heading-icons t)
  (dashboard-set-file-icons t)
  (dashboard-projects-backend 'projectile)

  (dashboard-week-agenda t "Agenda in dashboard")
  (dashboard-items '((recents   . 5)
                     (projects  . 5)
                     (agenda    . 5)) "Look at some items")
  (dashboard-startupify-list '(dashboard-insert-banner
                               dashboard-insert-newline
                               dashboard-insert-banner-title
                               dashboard-insert-newline
                               dashboard-insert-navigator
                               dashboard-insert-newline
                               dashboard-insert-init-info
                               dashboard-insert-items
                               dashboard-insert-newline
                               dashboard-insert-footer))
  :config
  (unless noninteractive (dashboard-setup-startup-hook))

  (my-fetch-weather-async)
  (defvar my-weather-timer nil)
  (when (timerp my-weather-timer)
    (cancel-timer my-weather-timer))
  (setq my-weather-timer (run-with-timer 900 900 #'my-fetch-weather-async))

  (add-to-list 'dashboard-item-generators '(weather-clock . my-dashboard-insert-weather-clock))
  (add-to-list 'dashboard-items '(weather-clock . 1)))

13.11. Ivy

Ivy is a pretty cool general program for displaying stuff:

(use-package ivy
  :demand t
  :custom
  (ivy-use-virtual-buffers t "Make searching more efficient")
  (enable-recursive-minibuffers t "Don't get soft locked when in a minibuffer")
  :bind
  ("C-j" . ivy-immediate-done)
  ("C-c C-r" . ivy-resume)
  :config
  (ivy-mode))

(use-package ivy-rich
  :config
  (ivy-rich-mode))

(use-package counsel
  :after ivy
  :bind
  ("M-x" . counsel-M-x)
  ("C-x C-f" . counsel-find-file)
  ("<f1> f" . counsel-describe-function)
  ("<f1> v" . counsel-describe-variable)
  ("<f1> o" . counsel-describe-symbol)
  ("<f1> l" . counsel-find-library)
  ("<f2> i" . counsel-info-lookup-symbol)
  ("<f2> u" . counsel-unicode-char)
  ("C-c g" . counsel-git)
  ("C-c j" . counsel-git-grep)
  ("C-c k" . counsel-ag)
  ("C-x l" . counsel-locate))

(use-package swiper
  :after ivy
  :bind ("C-s" . swiper))

(use-package ivy-posframe
  :custom
  (ivy-posframe-display-functions-alist '((t . ivy-posframe-display)))
  :config (ivy-posframe-mode 1))

(use-package all-the-icons-ivy-rich
  :after (ivy all-the-icons)
  :config (all-the-icons-ivy-rich-mode 1))

I use it for an M-x replacement and a dired replacement, among other things.

13.12. Magit

I use magit in order to do all my git management in emacs.

(use-package magit)
(use-package git-gutter
  :config
  (global-git-gutter-mode +1))

(defun ret2pop/enable-smerge-maybe ()
  (save-excursion
    (goto-char (point-min))
    (when (re-search-forward "^<<<<<<< " nil t)
      (smerge-mode 1))))
     
(use-package smerge-mode
  :hook ((find-file . ret2pop/enable-smerge-maybe))
  :general
  (:states '(normal motion)
   :keymaps 'smerge-mode-map
   "]c" #'smerge-next
   "[c" #'smerge-prev)
  (:states '(normal visual)
   :keymaps 'smerge-mode-map
   :prefix ","
   "n" #'smerge-next
   "p" #'smerge-prev
   "u" #'smerge-keep-upper
   "l" #'smerge-keep-lower
   "m" #'smerge-keep-current
   "o" #'smerge-keep-other
   "a" #'smerge-keep-all
   "b" #'smerge-keep-base
   "r" #'smerge-resolve
   "R" #'smerge-refine
   "e" #'smerge-ediff))

13.13. IRC

Configure IRC to use my username.

(use-package erc
  :hook ((erc-mode . erc-notifications-mode))
  :custom
  (erc-nick system-username "sets erc username to the one set in nix config")
  (erc-user-full-name system-fullname "sets erc fullname to the one set in nix config"))

13.14. LLM

I use LLMs in order to help me come up with ideas. I use a local LLM so that I can have a competitive LLM that doesn't cost money.

13.14.1. Minuet

Minuet does my code completion, showing the potential code completion as a ghost and automatically completing the code when my cursor is still. It is kind of like copilot but it works with local LLMs, which is better. Though, it's obviously not always the most accurate.

(use-package minuet
    :config
    (setq minuet-provider 'openai-fim-compatible)
    (setq minuet-n-completions 1)
    (setq minuet-context-window 4096)
    (plist-put minuet-openai-fim-compatible-options :end-point "http://localhost:11434/v1/completions")
    ;; an arbitrary non-null environment variable as placeholder.
    ;; For Windows users, TERM may not be present in environment variables.
    ;; Consider using APPDATA instead.
    (plist-put minuet-openai-fim-compatible-options :name "Ollama")
    (plist-put minuet-openai-fim-compatible-options :api-key "nothing")
    (plist-put minuet-openai-fim-compatible-options :model "rnj-1:latest")
   
    (minuet-set-optional-options minuet-openai-fim-compatible-options :max_tokens 100)
    :hook (prog-mode-hook . minuet-auto-suggestion-mode))

13.15. RSS Feed

I use really simple syndication (RSS) in order to read news. As a result, I use elfeed to fetch feeds found on my website:

(defun my/elfeed-export-recent-tsv (outfile days)
  (interactive "FExport recent Elfeed TSV to file: \nnDays: ")
  (require 'elfeed)
  (elfeed-db-load)
  (let ((cutoff (- (float-time) (* days 86400))))
    (with-temp-file outfile
      (insert "date\tfeed-title\tfeed-url\ttitle\turl\ttags\n")
      (maphash
       (lambda (_id entry)
         (when (>= (elfeed-entry-date entry) cutoff)
           (let* ((feed (elfeed-entry-feed entry))
                  (date (seconds-to-time (elfeed-entry-date entry)))
                  (date-str (format-time-string "%Y-%m-%d %H:%M:%S" date))
                  (feed-title (or (and feed (elfeed-feed-title feed)) ""))
                  (feed-url (or (and feed (elfeed-feed-url feed)) ""))
                  (title (or (elfeed-entry-title entry) ""))
                  (url (or (elfeed-entry-link entry) ""))
                  (tags (mapconcat #'symbol-name (elfeed-entry-tags entry) ",")))
             (insert
              (mapconcat
               #'identity
               (list date-str feed-title feed-url title url tags)
               "\t")
              "\n"))))
       elfeed-db-entries))))
       
(defvar elfeed-ai-agent-hype-regex
  '("\\b\\(?:autonomous\\|multi[-[:space:]]?\\|ai[[:space:]]+\\)agents?\\b"
    "\\bagentic[[:space:]]+\\(?:workflow\\|framework\\|ai\\|architecture\\)\\b"
    "\\bagent[[:space:]]+\\(?:swarm\\|orchestration\\|loop\\)\\b"
    "\\bfor[[:space:]]+agents?\\b"
    "\\b\\(?:optimizing\\|optimising\\|building\\|designed?\\|designing\\)\\b.*\\bfor[[:space:]]+agents?\\b"))
   
(defvar elfeed-ai-product-brand-regex
  '("\\bchatgpt\\b"
    "\\bclaude\\(?:[[:space:]]?\\(?:3\\|3\\.5\\|3\\.7\\)\\)?\\b"
    "\\bgrok\\b"
    "\\bgemini\\(?:[[:space:]]?\\(?:pro\\|flash\\|ultra\\)\\)?\\b"
    "\\bdall[-[:space:]]?e\\(?:[[:space:]]?[1-9]\\)?\\b"
    "\\b\\(?:midjourney\\|sora\\|perplexity\\)\\b"
    "\\b\\(?:llama[-[:space:]]?[1-9]?\\|mistral\\|qwen\\|deepseek\\)\\b"
    "\\b\\(?:cursor\\|windsurf\\|notebooklm\\|aider\\|cline\\|roo[-[:space:]]?code\\)\\b"
    "\\b\\(?:v0\\|bolt\\.new\\|lovable\\)\\b"
    "\\b\\w*claw\\w*\\b"))
   
(defvar elfeed-ai-model-vendor-regex
  '("\\bopenai\\b"
    "\\banthropic\\b"
    "\\bxai\\b"
    "\\b\\(?:google[[:space:]]+\\)?deepmind\\b"
    "\\bhugging[-[:space:]]?face\\b"
    "\\b\\(?:cohere\\|meta[[:space:]]+ai\\|mistral[[:space:]]+ai\\)\\b"))
   
(defvar elfeed-ai-model-family-regex
  '("\\bgpt\\(?:-?[2345]\\|-?4\\.1\\|-?4\\.5\\|[-[:space:]]?o\\(?:1\\|3\\|4\\)\\)\\b"
    "\\bgenai\\b"
    "\\b[lvs]lms?\\b"
    "\\bagi\\b"
    "\\bgenerative[[:space:]]+ai\\b"
    "\\b\\(?:foundation\\|diffusion\\|large[[:space:]]+language\\)[[:space:]]+models?\\b"
    "\\b\\(?:rag\\|lora\\|fine[-[:space:]]?tun\\(?:ing\\|ed\\)\\)\\b"
    "\\bprompt[[:space:]]+engineering\\b"))
   
(defvar elfeed-ai-wrapper-marketing-regex
  '("\\b\\(?:ai\\|llm\\|gpt\\|chatgpt\\|claude\\|grok\\|gemini\\)[-[:space:]]?powered\\b"
    "\\bai[-[:space:]]?\\(?:driven\\|native\\|first\\|generated\\|assisted\\)\\b"
    "\\b\\(?:build\\|built\\|building\\)\\b.*\\bwith[[:space:]]+\\(?:ai\\|llms?\\|gpt\\|chatgpt\\|claude\\|grok\\|gemini\\)\\b"
    "\\bchat[[:space:]]+with[[:space:]]+\\(?:your\\|any\\)[[:space:]]+\\(?:data\\|pdfs?\\|code\\|docs?\\|database\\)\\b"
    "\\bsupercharg\\(?:ed?\\|ing\\)[[:space:]]+\\(?:your\\|with\\)[[:space:]]+\\(?:ai\\|llms?\\)\\b"
    "\\b\\w+[-[:space:]]?\\(?:copilot\\|assistant\\|agent\\)\\b"))
   
(defvar elfeed-ai-rolecast-regex
  '("\\bturning[[:space:]]+\\(?:an?\\|the\\)?[[:space:]]*\\(?:llm\\|ai\\|model\\|agent\\)[[:space:]]+into[[:space:]]+\\(?:an?\\|the\\)?[[:space:]]*\\w+\\b"
    "\\b\\(?:your\\|an?\\)[[:space:]]+\\(?:ai\\|llm\\|agent\\)[[:space:]]+\\(?:teammate\\|coworker\\|coder\\|researcher\\|assistant\\|manager\\|judge\\)\\b"
    "\\b\\(?:replace\\|automate\\)[[:space:]]+your[[:space:]]+\\(?:team\\|developers?\\|engineers?\\|designers?\\)[[:space:]]+with[[:space:]]+ai\\b"
    "\\bai[[:space:]]+\\(?:software[[:space:]]+\\)?\\(?:engineer\\|developer\\)\\b"))
   
(defvar elfeed-show-hn-demo-regex
  '("\\b\\(?:show\\|ask\\|tell\\)\\W+hn"
    "\\b\\(?:launch\\|launching\\|launched\\)\\W+hn"
    "\\b\\(?:i\\|we\\)\\W+\\(?:built\\|made\\|created\\)\\W+\\(?:a\\|an\\|this\\)\\b"
    "\\b\\(?:introducing\\|announcing\\)\\W+"
    "\\b\\(?:my\\|our\\)\\W+weekend\\W+project\\b"))
   
(defvar elfeed-anti-capitalist-slop-regex
  '(;; Targets the specific "reddit-tier" anti-capitalist buzzwords, not actual economics
    "\\blate[-[:space:]]?stage[[:space:]]+capitalism\\b"
    "\\btechno[-[:space:]]?feudalism\\b"
    "\\benshittification\\b" ; Highly correlated with circlejerk tech/capitalism complaining
    "\\bcorporate[[:space:]]+greed\\b"
    "\\b(?:eat[[:space:]]+the[[:space:]]+rich|class[[:space:]]+warfare)\\b"
    "\\bruling[[:space:]]+class\\b"
    "\\bsilicon[[:space:]]+valley[[:space:]]+elites?\\b"))
   
(defvar elfeed-anti-immigrant-slop-regex
  '(;; Targets the sensationalist framing of immigration, not neutral border news
    "\\b(?:border|migrant)[[:space:]]+crisis\\b"
    "\\bmass[[:space:]]+(?:im)?migration\\b"
    "\\billegal[[:space:]]+(?:aliens?|immigrants?)\\b"
    "\\bgreat[[:space:]]+replacement\\b"
    "\\bopen[[:space:]]+borders?\\b"))
   
(defvar elfeed-ai-doomerism-regex
  '(;; Targets the moral panic/resource whining around AI, not legitimate AI benchmarks or legal updates
    "\\bplagiarism[[:space:]]+machines?\\b"
    "\\bstolen[[:space:]]+(?:art|data|content)\\b"
    "\\b(?:ai|llms?|generative)[[:space:]]+(?:theft|stealing)\\b"
    "\\bcopyright[[:space:]]+(?:theft|infringement)\\b"
    "\\b(?:boiling[[:space:]]+the[[:space:]]+oceans?|guzzling[[:space:]]+(?:water|power|electricity))\\b"
    "\\bunethic(?:al|s)[[:space:]]+(?:ai|tech)\\b"))
   
(defvar elfeed-anti-tech-circlejerk-regex
  '(;; Targets the general "tech is ruining society" populist outrage
    "\\btech[[:space:]]+bros?\\b"
    "\\bdead[[:space:]]+internet[[:space:]]+theory\\b"
    "\\bruin(?:ing|ed)?[[:space:]]+the[[:space:]]+internet\\b"
    "\\btech[[:space:]]+dystopia\\b"
    "\\btech[[:space:]]+(?:backlash|reckoning)\\b"))
   
(defvar elfeed-crypto-slop-regex
  '(;; Targets Web3 buzzwords safely without breaking system design news
    "\\bdecentrali[zs]ed[[:space:]]+(?:finance|exchange|web|autonomous|apps?|identity)\\b"
    "\\b(?:defi|dapps?|daos?)\\b"
    "\\b(?:web3|web[[:space:]]3\\.0)\\b"
    "\\bcrypto(?:currency|currencies)?\\b"
    "\\bnfts?\\b"))
   
(defvar elfeed-general-culture-war-regex
  '(;; Targets the evergreen vocabulary of online tribalism
    "\\b\\(?:virtue[[:space:]]+signal\\(?:ing\\)?\\|mind[[:space:]]+virus\\|psyop\\|grifter\\|gaslight\\(?:ing\\)?\\)\\b"
    "\\bculture[[:space:]]+war\\b"
    "\\b\\(?:left\\|right\\)[-[:space:]]?wing[[:space:]]+\\(?:mob\\|agenda\\|propaganda\\|bias\\|tears\\)\\b"
    "\\becho[[:space:]]+chamber\\b"
    "\\bpolitical[[:space:]]+theater\\b"))
   
(defvar elfeed-economic-doomerism-regex
  '(;; Targets the hyper-sensationalized financial collapse crowd
    "\\bfiat[[:space:]]+\\(?:currency\\|money\\)[[:space:]]+\\(?:collapse\\|ponzi\\)\\b"
    "\\bhyperinflation[[:space:]]+\\(?:is[[:space:]]+here\\|incoming\\)\\b"
    "\\b\\(?:great\\|massive\\)[[:space:]]+wealth[[:space:]]+transfer\\b"
    "\\bcollapse[[:space:]]+of[[:space:]]+\\(?:western\\|civilization\\|society\\)\\b"))
   
(defvar elfeed-hn-filter-list
  `(,elfeed-ai-agent-hype-regex
    ,elfeed-ai-product-brand-regex
    ,elfeed-ai-model-vendor-regex
    ,elfeed-ai-model-family-regex
    ,elfeed-ai-wrapper-marketing-regex
    ,elfeed-ai-rolecast-regex
    ,elfeed-anti-tech-circlejerk-regex
    ,elfeed-ai-doomerism-regex
    ,elfeed-anti-immigrant-slop-regex
    ,elfeed-anti-capitalist-slop-regex
    ,elfeed-crypto-slop-regex
    ,elfeed-general-culture-war-regex
    ,elfeed-economic-doomerism-regex
    ,elfeed-show-hn-demo-regex))
   
(defun elfeed-list-to-filter (filter-list)
  (mapconcat #'identity filter-list "\\|"))

(defun elfeed-final-filter (filter-lists)
  ;; Use standard non-capturing group \(?: ... \)
  (concat
   "\\(?:"
   (mapconcat #'elfeed-list-to-filter filter-lists "\\|")
   "\\)"))
   
(use-package elfeed
  :hook ((elfeed-search-mode . elfeed-update))
  :general (:states 'normal :keymaps 'elfeed-search-mode-map "r" 'elfeed-update)
  :custom
  (elfeed-search-filter (format "@1-month-ago +unread !%s" (elfeed-final-filter elfeed-hn-filter-list)) "Only display unread articles from a month ago")
  (elfeed-curl-max-connections 8 "less max connections for less lag"))

(use-package elfeed-org
  :after (elfeed org)
  :demand t
  :custom (rmh-elfeed-org-files '("~/monorepo/config/elfeed.org") "Use elfeed config in repo as default")
  :config (elfeed-org))

13.15.1. Youtube

Then we set up elfeed-tube for Youtube video RSS feeds (so I don't ever have to use the web interface and can control it from emacs):

(use-package elfeed-tube
  :after elfeed
  :demand t
  :bind (:map elfeed-show-mode-map
              ("F" . elfeed-tube-fetch)
              ([remap save-buffer] . elfeed-tube-save)
              :map elfeed-search-mode-map
              ("F" . elfeed-tube-fetch)
              ([remap save-buffer] . elfeed-tube-save))
  :config (elfeed-tube-setup))

(use-package elfeed-tube-mpv
  :after elfeed-tube
  :demand t
  :bind (:map elfeed-show-mode-map
              ("C-c C-f" . elfeed-tube-mpv-follow-mode)
              ("C-c C-c" . elfeed-tube-mpv)
              ("C-c C-w" . elfeed-tube-mpv-where)
              :map elfeed-search-mode-map
              ("M" . elfeed-tube-mpv)))

13.16. Project Drawer

I use treemacs as my sidebar for projects, so that I can easily navigate to any file in the project directory.

(use-package treemacs
  :demand t
  :after doom-themes)

(use-package treemacs-evil
  :after (treemacs evil))

(use-package treemacs-projectile
  :demand t
  :after (treemacs projectile))

(use-package treemacs-magit
  :after (treemacs magit))

(use-package treemacs-all-the-icons
  :after (treemacs all-the-icons))

13.17. Eww

Used only for the purpose of viewing RSS feed items in emacs if I can, only resorting to Chromium if I have to:

(use-package eww
  :bind (:map eww-mode-map
              ("y Y" . eww-copy-page-url))
  :custom
  (search-engines
   '((("google" "g") "https://google.com/search?q=%s")
     (("duckduckgo" "d" "ddg") "https://duckduckgo.com/?q=%s")
     (("rfc" "r") "https://www.rfc-editor.org/rfc/rfc%s.txt")
     (("rfc-kw" "rk") "https://www.rfc-editor.org/search/rfc_search_detail.php?title=%s"))
   "use this set of search engines")
  (search-engine-default "google" "Use google as default")
  (eww-search-prefix "https://google.com/search?q=" "Google prefix"))

13.18. Nix Mode

Load Nix mode so our exported website has syntax highlighting for Nix blocks.


13.19. Scheme

(use-package geiser
  :after scheme)

(use-package geiser-chez
  :after geiser
  :custom
  (geiser-active-implementations '(chez))
  (geiser-chez-binary "chez"))

13.20. Org Roam

For all my mathematics and programming notes:

(use-package org-roam
  :after (org)
  :custom
  (org-roam-db-update-on-save t "Update org-roam db")
  (org-roam-graph-viewer "qutebrowser" "Use qutebrowser to view org-roam graph")
  (org-roam-directory (file-truename "~/monorepo/mindmap") "Set org-roam directory inside monorepo")
  (org-roam-capture-templates '(("d" "default" plain "%?"
                                 :target (file+head "${title}.org"
                                                    "#+title: ${title}\n#+author: Preston Pan\n#+description:\n#+options: broken-links:t")
                                 :unnarrowed t)) "org-roam files start with this snippet by default")
  :config (org-roam-config))

(unless noninteractive (use-package org-roam-ui
                         :after org-roam
                         :hook (after-init . org-roam-ui-mode)
                         :custom
                         (org-roam-ui-sync-theme t "Use emacs theme for org-roam-ui")
                         (org-roam-ui-follow t "Have cool visual while editing org-roam")
                         (org-roam-ui-update-on-save t "This option is obvious")
                         (org-roam-ui-open-on-start t "Have cool visual open in qutebrowser when emacs loads")
                         ;; lol this is really bad but we'll let it pass because it is a race condition i probably can't fix
                         :config (run-with-timer 10 nil #'org-roam-ui-sync-theme)))

13.21. Pinentry

Set up pinentry so that I can use emacs as my pinentry frontend:

(unless noninteractive (use-package pinentry
                         :custom (epa-pinentry-mode `loopback "Set this option to match gpg-agent.conf")
                         :config (pinentry-start)))

13.22. Email

Email in emacs can be done with Mu4e.

(use-package smtpmail
  :custom
  (user-mail-address system-email "Use our email")
  (user-full-name system-fullname "Use our full name")
  (sendmail-program "msmtp" "Use msmtp in order to send emails")
  (send-mail-function 'smtpmail-send-it "This is required for this to work")
  (message-sendmail-f-is-evil t "Use evil-mode for sendmail")
  (message-sendmail-extra-arguments '("--read-envelope-from") "idk what this does")
  (message-send-mail-function 'message-send-mail-with-sendmail "Use sendmail"))

(use-package mu4e
  :after smtpmail
  :general
  (:states '(normal motion) :keymaps 'mu4e-main-mode-map
           "s" #'my-ivy-mu4e-search)
           
  (:states '(normal motion) :keymaps 'mu4e-headers-mode-map
           "s" #'my-ivy-mu4e-search
           "/" #'my-mu4e-narrow-with-ivy)
           
  (:states '(normal motion) :keymaps 'mu4e-thread-mode-map
           "s" #'my-ivy-mu4e-search
           "/" #'my-mu4e-narrow-with-ivy)
  :hook
  ((mu4e-compose-mode . mml-secure-message-sign-pgpmime))
  :custom
  (mu4e-drafts-folder "/Drafts" "Set drafts folder mu db")
  (mu4e-sent-folder   "/Sent" "Set sent folder in mu db")
  (mu4e-trash-folder  "/Trash" "Set trash folder in mu db")
  (mu4e-attachment-dir  "~/Downloads" "Set downloads folder for attachments")
  (mu4e-view-show-addresses 't "Show email addresses in main view")
  (mu4e-confirm-quit nil "Don't ask to quit")
  (message-kill-buffer-on-exit t "Kill buffer when I exit mu4e")
  (mu4e-compose-dont-reply-to-self t "Don't include self in replies")
  (mu4e-change-filenames-when-moving t)
  (mu4e-get-mail-command (concat "mbsync " system-username) "Use mbsync for imap")
  (mu4e-compose-reply-ignore-address (list "no-?reply" system-email) "ignore my own address and noreply")
  (mu4e-html2text-command "w3m -T text/html" "Use w3m to convert html to text")
  (mu4e-update-interval 300 "Update duration")
  (mu4e-completing-read-function 'ivy-completing-read)
  (mu4e-headers-auto-update t "Auto-updates feed")
  (mu4e-view-show-images t "Shows images")
  (mu4e-compose-signature-auto-include nil)
  (mml-secure-openpgp-sign-with-sender t)
  (mml-secure-openpgp-signers (list system-gpgkey))
  (mail-user-agent 'mu4e-user-agent)
  (message-mail-user-agent 'mu4e-user-agent)
  (mu4e-use-fancy-chars t "Random option to make mu4e look nicer"))

13.23. Music

Set up emms in order to play music from my music directory:

(unless noninteractive (use-package emms
                         :custom
                         (emms-source-file-default-directory (expand-file-name "~/music/") "Use directory specified in Nix")
                         (emms-player-mpd-music-directory (expand-file-name "~/music/") "Use directory specified in Nix")
                         (emms-player-mpd-server-name "localhost" "Connect to localhost")
                         (emms-player-mpd-server-port "6600" "Connect to port 6600")
                         (emms-player-list '(emms-player-mpd) "Use mpd")
                         (emms-lyrics-display-on-modeline t "Display lyrics for reading")
                         (emms-info-functions '(emms-info-mpd emms-info-native emms-info-cueinfo) "functions for displaying information about tracks")
                         :hook
                         ((emms-playlist-mode . emms-lyrics-mode)
                          (emms-player-started . emms-lyrics-lrclib-get))
                         :init (emms-all)
                         :config (emms-player-mpd-connect)))

13.24. Tabs

I use tabs because sometimes I like using the mouse (it's actually more efficient to have the option for both, trust me. Keyboards aren't all it).

(use-package centaur-tabs
  :custom
  (centaur-tabs-set-icons t "use icons for centaur-tabs")
  (centaur-tabs-set-modified-marker t "show when buffer modified")
  (centaur-tabs-icon-type 'all-the-icons "use all-the-icons for icons")
  :bind
  ("C-<prior>" . centaur-tabs-backward)
  ("C-<next>" . centaur-tabs-forward)
  :demand t
  :config (centaur-tabs-mode t))

13.25. Sops

(unless noninteractive
  (use-package sops
    :bind (("C-c C-c" . sops-save-file)
           ("C-c C-k" . sops-cancel)
           ("C-c C-d" . sops-edit-file))
    :init (global-sops-mode 1)))

13.26. Pulseaudio

(unless noninteractive
  (use-package pulseaudio-control
    :config (pulseaudio-control-default-keybindings)))

13.27. TreeSitter

(use-package treesit-auto
  :custom
  (treesit-auto-install 'prompt)
  :config
  (treesit-auto-add-to-auto-mode-alist 'all)
  (global-treesit-auto-mode))

13.28. Indentation

(use-package aggressive-indent
  :hook ((js-ts-mode . aggressive-indent-mode)
         (css-ts-mode . aggressive-indent-mode)
         (json-ts-mode . aggressive-indent-mode)
         (nix-mode . aggressive-indent-mode)
         (c-ts-mode . aggressive-indent-mode)))

13.29. Pulsar

(use-package pulsar
  :custom
  (pulsar-delay 0.055)
  (pulsar-iterations 5)
  (pulsar-face 'pulsar-green)
  (pulsar-region-face 'pulsar-yellow)
  (pulsar-highlight-face 'pulsar-magenta)
  :bind
  (:map global-map
    ("C-x l" . pulsar-pulse-line)
    ("C-x L" . pulsar-highlight-permanently-dwim))
  :config
  (pulsar-global-mode 1))

13.30. VTerm

(use-package vterm
  :custom
  (vterm-kill-buffer-on-exit nil)
  :hook (vterm-exit-functions . rp/vterm-close-window-on-exit))

14. Unpinned

14.1. Lean4

For some reason, lean4-mode is not in MELPA currently so I have to do this ugly thing:

(unless noninteractive (use-package lean4-mode
                         :commands lean4-mode
                         :vc (:url "https://github.com/leanprover-community/lean4-mode.git"
                                   :rev "76895d8939111654a472cfc617cfd43fbf5f1eb6")))

and actually pull something from the internet instead of pinning. Thankfully this reproduction issue is probably localized to lean files. Also, we're pulling a specific commit so it is still pinned. If it fails to fetch, lean4 is broken I guess.