From dcf35e8352e72926fb0867a42aefda6de7915694 Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Thu, 27 Dec 2018 18:49:54 -0500 Subject: Initial commit. --- .gitignore | 4 + init.el | 33 ++ jakob.org | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1037 insertions(+) create mode 100644 .gitignore create mode 100644 init.el create mode 100644 jakob.org diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fa406e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +elpa/ +custom.el +gnus.el +Notes.org diff --git a/init.el b/init.el new file mode 100644 index 0000000..adbc988 --- /dev/null +++ b/init.el @@ -0,0 +1,33 @@ +;; This file is but bootstrapping. My real configuration file is +;; located at "jakob.org". + +(defun eval-document (path) + "Tangles and evaluates all Emacs lisp code in the org file +located at PATH." + (let* ((body-list ()) + (src-block-regexp (concat + ;; (1) indentation (2) lang + "^\\([ \t]*\\)#\\+begin_src[ \t]+\\([^ \f\t\n\r\v]+\\)[ \t]*" + ;; (3) switches + "\\([^\":\n]*\"[^\"\n*]*\"[^\":\n]*\\|[^\":\n]*\\)" + ;; (4) header arguments + "\\([^\n]*\\)\n" + ;; (5) body + "\\([^\000]*?\n\\)??[ \t]*#\\+end_src"))) + (with-temp-buffer + (insert-file-contents path) + (goto-char (point-min)) + (while (re-search-forward src-block-regexp nil t) + (let ((lang (match-string 2)) + (args (match-string 4)) + (body (match-string 5))) + (when (and (or (string= lang "emacs-lisp") (string= lang "elisp")) + (not (string-match-p ":tangle\\s-+no" args))) + (add-to-list 'body-list body))))) + (let ((buffer (generate-new-buffer "*jakob-tangle-temporary*"))) + (set-buffer buffer) + (apply 'insert (reverse body-list)) + (eval-buffer) + (kill-buffer)))) + +(eval-document "~/.emacs.d/jakob.org") diff --git a/jakob.org b/jakob.org new file mode 100644 index 0000000..71d2da8 --- /dev/null +++ b/jakob.org @@ -0,0 +1,1000 @@ +This file contains my personal Emacs configuration, done in the style of +literate programming. Of course, being myself, I have a natural tendency to go +against the grain and do everything /my/ way; rather than using the +functionality provided by =org-babel=, I've adapted a reimplementation of +=org-babel-tangle= to =eval-document= (see =init.el=), which "tangles" all of +the source blocks into a temporary buffer and proceed to evaluate that temporary +buffer. This doesn't have any noticeable implications, but it is worth noting +that there won't be a =jakob.el= in the Emacs configuration directory. + +Custom elisp functions defined by me aren't prefixed with anything, with the +exception of functions that reimplement the functionality of existing functions. +These are prefixed with =my-= rather than replacing the original symbol, because +I imagine messing with built-in functionality in such a careless way would break +many things down the line. + +* Vanilla Functionality + +** Startup + +Having Emacs open to =*scratch*= feels as if it's inviting me to punch out some +Lisp forms and evaluate them. I like to pretend that my computers are Lisp +machines. + +#+BEGIN_SRC elisp +(setq inhibit-startup-message t + inhibit-startup-buffer-menu t + initial-scratch-message nil + initial-buffer-choice nil) +#+END_SRC + +** Filesystem + +A recurring theme in this configuration file is reconfiguring where Emacs +packages drop their various state files. =no-littering.el= is a package that +handles this fairly well through the management of =~/.emacs.d/var/= and +=~/.emacs.d/etc/= directories, but it lacks defaults for enough packages that +I've decided to jut forego it and do things my way, placing things in =~/.cache= +and =~/.local/share=. + +Save backup files to one directory instead of making a mess of the filesystem. + +#+BEGIN_SRC elisp +(setq backup-directory-alist `(("." . "~/.cache/emacs"))) +#+END_SRC + +=auto-save=, in addition to the actual files it saves, maintains another file +listing the files it's currently taking care of. + +#+BEGIN_SRC elisp +(setq auto-save-list-file-prefix "~/.cache/emacs/auto-save-list/.saves-") +#+END_SRC + +Disables the creation of locking symlinks in the current directory. This is a +very opinionated choice, and might not be a good idea for the average user. + +#+BEGIN_SRC elisp +(setq create-lockfiles nil) +#+END_SRC + +Although I personally prefer writing elisp to =custom.el=, a few packages +(specifically =package.el=) do make use of it. This snippet ensures that a +massacre is not made of my =init.el=. + +#+BEGIN_SRC elisp +(setq custom-file "~/.emacs.d/custom.el") +(when (file-exists-p custom-file) + (load custom-file)) +#+END_SRC + +** Packages + +For package archives, I currently use [[http://melpa.org/][MELPA]] and [[https://orgmode.org/elpa.html][Org's elpa]], the latter of which +is only enabled because Gentoo's Emacs package lacks =org-contribdir=. + +#+BEGIN_SRC elisp +(require 'package) +(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/")) +(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) +(package-initialize) +#+END_SRC + +Bootstrapping for =use-package=, which is how I prefer to declare and configure +third-party packages. + +#+BEGIN_SRC elisp +(unless (package-installed-p 'use-package) + (progn + (package-refresh-contents) + (package-install 'use-package))) + +(require 'use-package) +#+END_SRC + +Ensure that packages are installed by default. This can be overridden in with +=:ensure nil=. The automatic installation functionality of =use-package= is the +main reason I use it, so why not enable it by default? + +#+BEGIN_SRC elisp +(setq use-package-always-ensure t) +#+END_SRC + +Require =bind-key= early on for =:bind= declarations. + +#+BEGIN_SRC elisp +(use-package bind-key :defer t) +#+END_SRC + +** Lisp Interaction + +Don't omit information when lists nest too deep. + +#+BEGIN_SRC elisp +(setq eval-expression-print-level nil) +#+END_SRC + +** Quality of Life + +Use a consistent confirmation dialog of "y or n". + +#+BEGIN_SRC elisp +(fset 'yes-or-no-p 'y-or-n-p) +#+END_SRC + +Automatically revert buffers and dired listings when something on disk changes. + +#+BEGIN_SRC elisp +(use-package autorevert + :config + (global-auto-revert-mode 1) + (setq global-auto-revert-non-file-buffers t + auto-revert-verbose nil)) +#+END_SRC + +I got sick of seeing "Command attempted to use minibuffer while in minibuffer". + +#+BEGIN_SRC elisp +(setq enable-recursive-minibuffers t) +#+END_SRC + +Use soft wrapping instead of "scrolling" when overflowing the width of a frame. + +#+BEGIN_SRC elisp +(global-visual-line-mode t) +#+END_SRC + +Actually select help windows when I pop them so that I can kill them with . + +#+BEGIN_SRC elisp +(setq help-window-select t) +#+END_SRC + +Most *NIX tools work best when files are terminated with a newline. + +#+BEGIN_SRC emacs-lisp +(setq require-final-newline t) +#+END_SRC + +Sentences should be separated by a single space, so treat two sentences as two +when filling. + +#+BEGIN_SRC elisp +(setq sentence-end-double-space nil) +#+END_SRC + +I like using the tab key, but prefer spaces to tabstops, and the width I prefer +to use is 4 characters. + +#+BEGIN_SRC elisp +(setq-default indent-tabs-mode nil tab-width 4) +#+END_SRC + +Modern conventions state that 80 characters is the standard width. + +#+BEGIN_SRC elisp +(setq-default fill-column 80) +#+END_SRC + +When killing, add whatever's in the system clipboard if it isn't there already, +so I can get it back with . + +#+BEGIN_SRC elisp +(setq save-interprogram-paste-before-kill t) +#+END_SRC + +Enable the default-disabled functions that I use. + +#+BEGIN_SRC elisp +(put 'downcase-region 'disabled nil) +(put 'upcase-region 'disabled nil) +#+END_SRC + +#+BEGIN_SRC elisp +(show-paren-mode t) +(column-number-mode t) +#+END_SRC + +* Appearance + +** Windowing + +This feature doesn't see frequent use, but I prefer three proportionally-sized +windows to two really tiny ones over a really big one. + +#+BEGIN_SRC elisp +(setq window-combination-resize t) +#+END_SRC + +** Scrolling + +Don't do jerky jumps when the cursor reaches the end of the window. Instead, +just scroll by one line. + +#+BEGIN_SRC elisp +(setq scroll-conservatively most-positive-fixnum) +#+END_SRC + +** Chrome + +The menu bar can be accessed with =M-`= if I really need it, so I don't see the +point in having it take up the space at the top. The rest of these rarely see +use from me, and I'd prefer to disable them and have access to the extra screen +real estate. + +#+BEGIN_SRC elisp +(menu-bar-mode -1) +(scroll-bar-mode -1) +(tool-bar-mode -1) +(fringe-mode -1) +#+END_SRC + +Hacking is a lot more serene when visual stimulus is kept to a minimum. + +#+BEGIN_SRC elisp +(blink-cursor-mode 0) +#+END_SRC + +** Theme + +This is my custom theme, the code for which is very loosely adapted from +[[https://github.com/kuanyui/moe-theme.el][moe-theme.el]], but most of the palette has been altered to emulate the appearance +of my old setup of Emacs in a terminal emulator. + +#+BEGIN_SRC elisp +(deftheme chayote + "Inspired by the appearance of Emacs in my terminal emulator.") +#+END_SRC + +The colors have been extracted into a variable, =palette=, and a macro, +=with-palette=, to provide access to the theme's color definitions without +significantly polluting the global namespace. + +#+BEGIN_SRC elisp +(defvar palette + '((yellow-1 "#ffd787") (yellow-2 "#ffd700") (yellow-3 "#c4a000") + (yellow-3-5 "#aaaa11") (yellow-4 "#875f00") + + (orange-1 "#ffaf87") (orange-2 "#ff8700") (orange-3 "#ff5d17") + (orange-4 "#d75f00") (orange-5 "#af5f00") + + (magenta-1 "#ff7bbb") (magenta-2 "#ff4ea3") (magenta-3 "#ff1f8b") + + (green-1 "#87ff87") (green-2 "#a1db00") (green-3 "#5faf00") + (green-4 "#008700") (green-5 "#005f00") + + (cyan-1 "#afd7d7") (cyan-2 "#87ffd7") (cyan-3 "#00d7af") + (cyan-4 "#00ac8a") (cyan-5 "#5faf87") (cyan-6 "#005f5f") + (cyan-7 "#236f73") + + (blue-1 "#1fb6d3") (blue-2 "#1f5bff") (blue-3 "#005f87") + (blue-4 "#5f7ab1") (blue-5 "#0000af") (blue-6 "#00005f") + + (purple-1 "#d18aff") (purple-2 "#af5fff") (purple-3 "#9a08ff") + (purple-4 "#6c0099") + + (red-1 "#ef2929") (red-2 "#dd0000") (red-3 "#a40000") + (red-4 "#5f0000") + + (white-1 "#f0e9dc") (white-2 "#c6c6c6") (white-3 "#b2b2b2") + + (black-1 "#a8a8a8") (black-2 "#8a8a8a") (black-2-5 "#6c6c6c") + (black-3 "#4e4e4e") (black-4 "#3a3a3a") (black-5 "#303539") + (black-6 "#000000") + + (LIGHT_BG "#fdfde7") (white-0 "#eeeeee") + + (green-02 "#5fd700") (green-01 "#d7ff00") (green-0 "#d7ff5f") + (green-00 "#d7ff87") + + (cyan-0 "#d7ffd7") + + (blue-01 "#c3c9f8") (blue-0 "#afd7ff") (blue-00 "#d7d7ff") + + (yellow-0 "#ffff87") (yellow-00 "#ffffaf") + + (purple-0 "#af87ff") (purple-00 "#e6a8df") + + (red-0 "#ff4b4b") (red-00 "#ffafaf") + + (magenta-0 "#ffafd7") (magenta-00 "#ffd7ff") + + (orange-0 "#ffaf87") (orange-00 "#ffd787") (orange-000 "#ffd7af") + + (linum-dark "#87875f") (linum-light "#d7d7af")) + "The palette of colors in use with my 'chayote' theme.") + +(defmacro with-palette (&rest form) + "Evaluate `FORM' in a lexical environment with access to the +individual colors making up the theme's palette." + `(let ((class '((class color) (min-colors 89))) + ,@palette) + ,@form)) +#+END_SRC + +To help me in modifying the theme, I've defined a function similar to +=list-colors-display=, but for showing the colors in the palette I've defined. + +#+BEGIN_SRC elisp +(defun display-palette () + "Display names of colors defined in `PALETTE', and show what +they look like." + (interactive) + (with-help-window "*Chayote Colors*" + (with-current-buffer standard-output + (erase-buffer) + (dolist (color palette) + (let* ((name (symbol-name (first color))) + (value (second color))) + (put-text-property 0 (length name) + 'font-lock-face `(:foreground ,value) + name) + (insert name) + (insert (propertize " " 'display '(space :align-to (- right 9)))) + (insert " ") + (put-text-property 0 (length value) + 'font-lock-face `(:background ,value) + value) + (insert value) + (terpri))) + (set-buffer-modified-p nil) + (setq truncate-lines t)))) +#+END_SRC + +#+BEGIN_SRC elisp +(with-palette + (custom-theme-set-faces + 'chayote + `(default ((,class (:foreground ,white-1 :background ,black-5 :family "Terminus" :height 90)))) + `(cursor ((,class (:background ,white-0)))) + + `(link ((,class (:foreground ,blue-1 :underline t)))) + + ;; Highlighting faces + `(highlight ((,class (:background ,black-3)))) + `(hl-line ((,class (:background ,black-4)))) + `(highlight-symbol-face ((,class (:background ,green-5)))) + `(region ((,class (:background ,blue-4)))) + `(secondary-selection ((,class (:background ,blue-3 :foreground ,white-0)))) + `(isearch ((,class (:foreground ,white-1 :background ,orange-3)))) + `(lazy-highlight ((,class (:background ,magenta-3 :foreground ,white-1)))) + `(trailing-whitespace ((,class (:background ,red-3)))) + `(show-paren-match ((,class (:background ,blue-3 :foreground nil)))) + `(header-line ((,class (:background ,blue-3 :foreground ,white-0)))) + `(help-argument-name ((,class (:foreground ,magenta-1 :italic t)))) + `(eldoc-highlight-function-argument ((,class (:foreground ,green-01 :bold t :underline t :background ,green-5)))) + + ;; Mode line & frames' faces + `(mode-line ((,class (:box nil :background ,white-1 :foreground ,black-5)))) + `(mode-line-inactive ((,class (:background ,white-3 :foreground ,black-5)))) + `(mode-line-buffer-id ((,class (:box nil :foreground ,black-5 :background nil)))) + `(vertical-border ((,class (:foreground ,black-3 :background ,black-3)))) + + ;; Escape and prompt faces + `(minibuffer-prompt ((,class (:foreground ,blue-1)))) + `(escape-glyph ((,class (:foreground ,yellow-3)))) + `(error ((,class (:foreground ,red-0)))) + `(warning ((,class (:foreground ,orange-1)))) + `(success ((,class (:foreground ,green-1)))) + + ;; Font lock faces + `(font-lock-builtin-face ((,class (:foreground ,cyan-1)))) + `(font-lock-comment-delimiter-face ((,class (:inherit font-lock-comment-face)))) + `(font-lock-comment-face ((,class (:foreground ,orange-2)))) + `(font-lock-constant-face ((,class (:foreground ,cyan-2)))) + `(font-lock-doc-face ((,class (:inherit font-lock-string-face)))) + `(font-lock-doc-string-face ((,class (:inherit font-lock-string-face)))) + `(font-lock-function-name-face ((,class (:foreground ,blue-0)))) + `(font-lock-keyword-face ((,class (:foreground ,blue-1)))) + `(font-lock-negation-char-face ((,class (:foreground ,red-0)))) + `(font-lock-preprocessor-face ((,class (:inherit font-lock-builtin-face)))) + `(font-lock-regexp-grouping-backslash ((,class (:foreground ,yellow-1)))) + `(font-lock-regexp-grouping-construct ((,class (:foreground ,purple-1)))) + `(font-lock-string-face ((,class (:foreground ,orange-1)))) + `(font-lock-type-face ((,class (:foreground ,green-1)))) + `(font-lock-variable-name-face ((,class (:foreground ,yellow-1)))) + `(font-lock-warning-face ((,class (:weight bold :foreground ,red-2)))) + + ;; org-mode + `(org-block ((,class (:foreground ,white-1 :background ,black-4)))) + `(org-verbatim ((,class (:foreground ,blue-1 :background ,black-4)))) + `(org-link ((,class (:inherit link)))) + `(org-warning ((,class (:foreground ,white-0 :background ,red-4))))) + + (custom-theme-set-variables + 'chayote + `(ansi-color-names-vector [,black-5 ,red-0 ,green-0 ,yellow-1 + ,blue-1 ,purple-1 ,blue-0 ,white-1]))) +#+END_SRC + +** Modeline + +This is the vanilla modeline without the handful of components that I consider +unimportant. + +#+BEGIN_SRC elisp +(setq-default mode-line-format + '("%e" + mode-line-front-space + mode-line-client + mode-line-modified + " " + mode-line-directory + mode-line-buffer-identification + " " + mode-line-position + " " + mode-line-modes + mode-line-misc-info + mode-line-end-spaces)) +#+END_SRC + +To make things a little easier on my eyes, I've chosen to add visual separation +between my additions to the modeline. + +#+BEGIN_SRC elisp +(defconst mode-line-separator " | " + "A separator to place between components of the modeline.") +#+END_SRC + +A function to simplify the addition of new =:eval= forms to the end of +=mode-line-format=. + +#+BEGIN_SRC elisp +(defun add-to-mode-line (widget) + "Appends a `MODE-LINE-SEPARATOR' and `WIDGET' onto the end of +`MODE-LINE-FORMAT'." + (let ((eval-form `(:eval (funcall ,widget)))) + (setq-default mode-line-format + (append mode-line-format + (list mode-line-separator eval-form))))) +#+END_SRC + +My implementation of a clock for the modeline. The modeline is refreshed by a +timer to ensure that it doesn't go too stale, as it could theoretically go +several minutes without being updated. + +#+BEGIN_SRC elisp +(add-to-mode-line + (lambda () (format-time-string "%Y-%m-%d %H:%M"))) + +(let ((timer (run-at-time t 60.0 #'ignore))) + (timer-set-function timer + (lambda () + (force-mode-line-update)))) +#+END_SRC + +My implementation of a battery monitor for the modeline. Because strings in +=mode-line-format= can contain control sequences, the percent symbol has to be +escaped twice -- once for =battery-format=, and once for =mode-line-format=. + +#+BEGIN_SRC elisp +(use-package battery + :ensure t + :config + (add-to-mode-line + (lambda () + (let* ((status (battery-linux-sysfs)) + (fullness (string-to-number (cdr (assoc 112 status)))) + (text (battery-format "%L: %t, %p%%%%" status)) + (low-battery-face '(:foreground "white" + :background "red"))) + (when (< fullness 10.0) + (put-text-property 0 (length text) + 'font-lock-face low-battery-face + text)) + text)))) +#+END_SRC + +* EXWM + +Yes, I use Emacs as my window manager. You should try it out some time! + +#+BEGIN_SRC elisp +(use-package exwm + :ensure t + :config + (require 'exwm-config) + (exwm-enable) +#+END_SRC + +I find that four workspaces is enough to start out with, and I like being able +to use my X windows across workspaces. + +#+BEGIN_SRC elisp + :init + (setq exwm-workspace-number 4 + exwm-workspace-show-all-buffers t + exwm-layout-show-all-buffers t) +#+END_SRC + +"Global key bindings" in EXWM work essentially anywhere, including buffers that +are currently in char mode. The bindings below should be fairly straightforward. +I've taken this as an opportunity to incorporate windmove to my workflow, now +that I have ?\s at my disposal. The choice of keys for that was inspired by the +WASD movement typical of first-person shooter games. + +#+BEGIN_SRC elisp + :init + (setq exwm-input-global-keys + `(([?\s-r] . exwm-reset) + ([?\s-w] . windmove-up) + ([?\s-a] . windmove-left) + ([?\s-s] . windmove-down) + ([?\s-d] . windmove-right) + ([?\s-p] . (lambda (command) + (interactive (list (read-shell-command "$ "))) + (start-process-shell-command command nil command))) + ([?\s-X] . (lambda () + (interactive) + (start-process "" nil "/usr/bin/slock"))) + + ;; Keys are offset such that corresponds to the 0th workspace. + ,@(mapcar (lambda (i) + `(,(kbd (format "s-%d" i)) . + (lambda () + (interactive) + (exwm-workspace-switch-create ,(- i 1))))) + (number-sequence 1 9)))) +#+END_SRC + +Ah, yes. Simulation keys, the real reason I decided to install EXWM. + +#+BEGIN_SRC elisp + :init + (setq exwm-input-simulation-keys + '(([?\C-b] . [left]) + ([?\M-b] . [C-left]) + ([?\C-f] . [right]) + ([?\M-f] . [C-right]) + ([?\C-p] . [up]) + ([?\C-n] . [down]) + ([?\C-a] . [home]) + ([?\C-e] . [end]) + ([?\M-v] . [prior]) + ([?\C-v] . [next]) + ([?\C-d] . [delete]) + ([?\C-k] . [S-end delete]) + + ([?\C-w] . [?\C-x]) + ([?\M-w] . [?\C-c]) + ([?\C-y] . [?\C-v]) + + ([?\C-s] . [?\C-f]))) +#+END_SRC + +EXWM's buffers are named =*EXWM*= upon creation, which makes switching between +windows a pain. This snippet renames buffers when their class or title changes. + +#+BEGIN_SRC elisp + :hook + (exwm-update-class . (lambda () + (exwm-workspace-rename-buffer exwm-class-name))) + (exwm-update-title . (lambda () + (when (not exwm-instance-name) + (exwm-workspace-rename-buffer exwm-title))))) +#+END_SRC + +Start the Emacs daemon so that =emacsclient= can be used from the command line +to pop a new buffer for editing. + +#+BEGIN_SRC elisp +(server-start) +#+END_SRC + +EXWM has issues popping any sort of pinentry window, so we'll just let Emacs do +pinentry's job. + +#+BEGIN_SRC elisp +(use-package epa + :config + (setq epa-pinentry-mode 'loopback)) +#+END_SRC + +* ido + +Originally, I was going to try out ivy and see if it was any snappier than ido, +but it turns out that a properly-configured vanilla ido is faster than I'm used +to. It also plays nicely with EXWM/ERC. + +#+BEGIN_SRC elisp +(use-package ido + :ensure t + :config + (ido-mode 1) +#+END_SRC + +Fix =ido-buffer-window-other-frame= to play nicely with EXWM. + +#+BEGIN_SRC elisp + (exwm-config-ido) +#+END_SRC + +Cap the number of candidates to make it even snappier, and for the same reason, +don't use the annoying built-in ffap functionality. + +#+BEGIN_SRC elisp + :init + (setq ido-max-prospects 10) + (setq ido-use-filename-at-point nil) +#+END_SRC + +This is a preference of hygene. Stores the ido state in the same directory as +auto-save state and Emacs's backup files. + +#+BEGIN_SRC elisp + (setq ido-save-directory-list-file "~/.cache/emacs/ido.last")) +#+END_SRC + +* Org + +Some general hygene -- place generated images in the same directory as backup +files. + +#+BEGIN_SRC elisp +(use-package org + :init + (setq org-latex-preview-ltxpng-directory "~/.cache/emacs/ltximg/") + (setq org-preview-latex-image-directory "~/.cache/emacs/ltximg/") +#+END_SRC + +Only load the =org-contrib= modules that I actually use. + +#+BEGIN_SRC elisp + (setq org-modules '(org-drill)) +#+END_SRC + +Some general configurations for quality-of-life and appearance. + +#+BEGIN_SRC elisp + (setq org-return-follows-link 't) + (setq org-startup-folded 'nil) + (setq org-tags-column 100) +#+END_SRC + +Don't indent text following a headline. + +#+BEGIN_SRC elisp + (setq org-adapt-indentation nil) +#+END_SRC + +Fix =org-src= blocks such that indents according to the mode's indentation +rules, and so that there is no implicit indentation of the source code ([[https://stackoverflow.com/questions/15773354/indent-code-in-org-babel-src-blocks][1]], [[https://emacs.stackexchange.com/questions/9472/org-mode-source-block-doesnt-respect-parent-buffer-indentation][2]]). + +#+BEGIN_SRC elisp +(setq org-src-tab-acts-natively t) +(setq org-edit-src-content-indentation 0) +#+END_SRC + +Scale up embedded LaTeX so that I can actually read it. + +#+BEGIN_SRC elisp + (setq org-format-latex-options + (plist-put org-format-latex-options :scale 1.5)) +#+END_SRC + +** Workflow + +Automatically open a buffer named =*Mind Dump*= to, well, save all of my +thoughts. They're dated and saved in a directory so I can =ag= them. This is the +closest thing I will ever have to an =ag= inside my brain. + +#+BEGIN_SRC elisp +(defvar mind-dump-directory "~/Notes/Mind Dumps" + "Where to store dated 'mind dump' files.") + +(let* ((filename (concatenate 'string + (file-name-as-directory mind-dump-directory) + (format-time-string "%Y-%m-%d") + ".org")) + (buffer (find-file-noselect filename))) + (set-buffer buffer) + (rename-buffer "*Mind Dump*")) +#+END_SRC + +** Agenda + +Rather convoluted agenda setup to show me: +- The tasks I've marked as needing to be done today. +- The inbox items I need to process. +- My daily habits (implemented as recurring Org TODO's). +- A view of deadlines and scheduled items for the week ahead. + +#+BEGIN_SRC elisp +(setq org-agenda-files '("~/Notes/GTD/Habits.org" + "~/Notes/GTD/Inbox.org" + "~/Notes/GTD/Actionable.org")) + +(let ((entry-done + '(lambda () (org-agenda-skip-entry-if 'todo 'done))) + + (subtree-is-habit + '(lambda () + (let ((subtree-end (save-excursion (org-end-of-subtree t)))) + (if (string= (org-entry-get nil "STYLE") "habit") + subtree-end + nil)))) + + (subtree-is-not-habit + '(lambda () + (let ((subtree-end (save-excursion (org-end-of-subtree t)))) + (if (not (string= (org-entry-get nil "STYLE") "habit")) + subtree-end + nil)))) + + (subtree-is-not-inbox + '(lambda () + (let ((subtree-end (save-excursion (org-end-of-subtree t)))) + (if (not (search "Inbox.org" (buffer-name))) + subtree-end + nil))))) + + (setq org-agenda-custom-commands + `(("d" "Daily" + ((tags "PRIORITY=\"A\"" + ((org-agenda-skip-function ,entry-done) + (org-agenda-overriding-header "Tasks for Today:"))) + (alltodo "" + ((org-agenda-skip-function ,subtree-is-not-inbox) + (org-agenda-overriding-header "Inbox:"))) + (agenda "" + ((org-agenda-span 'day) + (org-agenda-skip-function ,subtree-is-not-habit) + (org-deadline-warning-days 0) + (org-agenda-overriding-header "Habits:"))) + (agenda "" + ((org-agenda-span 'week) + (org-agenda-skip-function ,subtree-is-habit) + (org-agenda-overriding-header "Week Ahead:")))) + ((org-agenda-compact-blocks t)))))) +#+END_SRC + +** Drill + +Scan the directory of the current buffer's file for other items -- this is so +that I can spread my cards across multiple files and still be tested on all of +them when I run =org-drill=. + +#+BEGIN_SRC elisp +(setq org-drill-scope 'directory) +#+END_SRC + +Shut up the nagging "are you studying enough!?" message if I don't get enough +items right on the first try. It's unhelpful and really just annoying. + +#+BEGIN_SRC elisp +(setq org-drill-forgetting-index 100) +#+END_SRC + +* Dired + +Hide the targets of symbolic links in dired listings. This is just a visual +preference of mine. + +#+BEGIN_SRC elisp +(use-package dired + :ensure nil + :init + (setq-default dired-listing-switches "-alL")) +#+END_SRC + +* TODO Gnus + +#+BEGIN_SRC elisp +(setq gnus-init-file "~/.emacs.d/gnus" + gnus-startup-file "~/.newsrc" + gnus-directory "~/.local/share/gnus/News/" + gnus-article-save-directory "~/.local/share/gnus/News/" + gnus-kill-files-directory "~/.local/share/gnus/News/" + gnus-uu-default-dir "~/.local/share/gnus/News/" + gnus-agent-directory "~/.local/share/gnus/News/agent/" + gnus-x-face-directory "~/.local/share/gnus/News/x-faces" + nndiary-directory "~/.local/share/gnus/News/diary/" + nndraft-directory "~/.local/share/gnus/News/drafts/" + gnus-duplicate-file "~/.local/share/gnus/News/suppression" + gnus-cache-active-file "~/.local/share/gnus/News/cache/active" + gnus-cache-directory "~/.local/share/gnus/News/cache/" + nnfolder-newsgroups-file "~/.local/share/gnus/Mail/newsgroups" + gnus-home-directory "~/.local/share/gnus" + mail-source-directory "~/.local/share/gnus/Mail/" + message-directory "~/.local/share/gnus/Mail/" + smime-certificate-directory "~/.local/share/gnus/Mail/certs/" + smtpmail-queue-dir "~/.local/share/gnus/Mail/queued-mail/" + nsm-settings-file "~/.cache/emacs/network-security.data") + +(setq gnus-thread-sort-functions 'gnus-thread-sort-by-most-recent-number) +#+END_SRC + +* Elfeed + +I don't like =.elfeed= in my home directory, so I'll give it the [[Gnus]] treatment. + +#+BEGIN_SRC elisp +(setq elfeed-db-directory "~/.local/share/elfeed") +#+END_SRC + +All of the feeds I'm subscribed to. A reduced fat version of this list is +available [[http://jakob.space/links/][on my website]] with links to the sites instead of RSS feed URLs. + +#+BEGIN_SRC elisp +(setq elfeed-feeds + '(("https://www.phoronix.com/rss.php" news) + ("https://paleotronic.com/feed/" news) + ("https://lobste.rs/newest.rss" news) + ("https://tilde.news/newest.rss" news) + ("https://this-week-in-rust.org/atom.xml" news) + ("https://readrust.net/all/feed.rss" news) + ("http://planet.lisp.org/rss20.xml" news) + + ("https://xkcd.com/rss.xml" webcomic) + ("https://www.foxtrot.com/feed/" webcomic) + ("http://pbfcomics.com/feed/" webcomic) + ("http://www.smbc-comics.com/comic/rss" webcomic) + ("http://interglacial.com/rss/bob_the_angry_flower.rss" webcomic) + + ("https://eev.ee/feeds/blog.atom.xml" blog) + ("http://fabiensanglard.net/rss.xml" blog) + ("https://drewdevault.com/feed.xml" blog) + ("http://feeds.feedburner.com/GynvaelColdwindEN?format=xml" blog) + ("http://nullprogram.com/feed/" blog) + ("https://aixxe.net/rss" blog) + ("https://blog.soykaf.com/post/index.xml" blog) + ("https://bernsteinbear.com/feed" blog) + ("https://www.nayuki.io/rss20.xml" blog) + ("https://travisgoodspeed.blogspot.com/feeds/posts/default" blog) + ("http://emacshorrors.com/feed.atom" blog) + ("http://dsasmblr.com/feed/" blog) + ("https://0x90r00t.com/feed/" blog) + ("https://outflux.net/blog/feed/" blog) + ("https://blog.krnl386.com/index.php?feed/atom" blog) + ("http://shell-storm.org/rss.xml" blog) + ("http://sh3llc0d3r.com/feed/" blog) + ("https://www.soldierx.com/rss.xml" blog) + ("http://technomancy.us/feed/atom.xml" blog) + ("https://rufflewind.com/feed.xml" blog) + ("http://j00ru.vexillium.org/?feed=rss2" blog) + ("https://dev.krzaq.cc/feed/" blog) + ("http://asawicki.info/news_rss.php5" blog) + ("https://www.filfre.net/feed/" blog) + ("http://radare.today/index.xml" blog) + ("https://lukesmith.xyz/rss.xml" blog) + ("https://nickcano.com/rss/" blog) + ("https://infinityplusonemath.wordpress.com/feed/" blog) + ("https://www.rtl-sdr.com/feed/" blog) + ("https://retro.moe/feed/" blog) + ("https://objective-see.com/rss.xml" blog) + ("http://meh.schizofreni.co/rss" blog) + ("http://feeds.feedburner.com/michaelnielsen/wmna" blog) + ("https://wargio.github.io/feed.xml" blog) + ("http://emacsninja.com/feed.atom" blog) + ("https://blog.baturin.org/feeds/atom.xml" blog) + ("https://bluishcoder.co.nz/rss.xml" blog) + ("https://leotindall.com/index.xml" blog) + ("https://blog.separateconcerns.com/feed.atom" blog) + ("https://deftly.net/rss.xml" blog) + ("https://eligrey.com/feed/" blog) + ("https://nerderati.com/" blog) + ("https://zayenz.se/index.xml" blog) + ("http://charliethe.ninja/feed.xml" blog) + ("http://www.charlesetc.com/index.xml" blog) + ("https://ramsdenj.com/feed.xml" blog) + ("https://nick.zoic.org/feed.rss" blog) + ("https://gpfault.net/rss.xml" blog) + ("https://blog.demofox.org/feed/" blog) + ("https://floooh.github.io/feed.xml" blog) + ("https://erkaman.github.io/rss.xml" blog) + ("http://samskivert.com/blog/index.xml" blog) + ("https://marioslab.io/posts/rss.xml" blog) + ("https://blog.burntsushi.net/index.xml" blog) + ("https://frederik-braun.com/feeds/all.rss.xml" blog) + ("http://www.wezm.net/feed/" blog) + ("https://theta.eu.org/feed.xml" blog) + ("https://lemire.me/blog/feed/" blog) + ("https://arp242.net/feed.xml" blog) + ("https://jamchamb.github.io/feed.xml" blog) + ("https://muto.ca/feed.xml" blog) + ("https://rocx.rocks/rss.xml" blog) + ("https://norasandler.com/feed.xml" blog) + ("http://faehnri.ch/feed.xml" blog) + ("https://pwnaccelerator.github.io/feed.xml" blog) + ("https://www.cambus.net/atom.xml" blog) + ("https://twobithistory.org/feed.xml" blog) + ("https://darksi.de/rss.xml" blog) + ("https://hackaday.com/blog/feed/" blog) + ("http://rkallos.com/feeds/all.rss.xml" blog) + ("https://pharr.org/matt/blog/feed.xml" blog) + ("https://chriszheng.science/atom.xml" blog) + ("http://bitcannon.net/index.xml" blog) + ("https://vfoley.xyz/rss.xml" blog) + ("https://blog.kingcons.io/rss.xml" blog) + ("http://blog.macrolet.net/rss.xml" blog) + ("http://www.stylewarning.com/blog/rss.xml" blog) + ("http://feeds.feedburner.com/stevelosh?format=xml" blog) + ("https://phoenhex.re/feed.xml" blog) + ("http://lambda-the-ultimate.org/rss.xml" blog) + ("https://rakhim.org/index.xml" blog) + ("http://www.evanmiller.org/news.xml" blog) + ("http://lispblog.xach.com/rss" blog) + ("https://medium.com/feed/@alexgolec" blog) + ("https://wbenny.github.io/feed.xml" blog) + ("http://vihart.com/feed/" blog) + ("https://cryogenix.net/rss.xml" blog) + ("http://www.codersnotes.com/notes/feed" blog) + ("https://ambrevar.xyz/rss.xml" blog) + ("https://hardmath123.github.io/feed.xml" blog) + ("https://wingolog.org/feed/atom" blog) + ("https://blog.0day.rocks/feed" blog) + ("https://tymoon.eu/api/reader/atom" blog) + ("https://wolf480pl.github.io/feed.xml" blog) + ("https://yingtongli.me/blog/feed.xml" blog) + ("https://text.causal.agency/feed.atom" blog) + ("https://programmingisterrible.com/rss" blog) + ("https://dehora.net/journal?format=RSS" blog))) +#+END_SRC + +* Pretty Symbols + +Enable =prettify-symbols= globally. + +#+BEGIN_SRC elisp +(use-package pretty-symbols + :ensure nil + :config + (global-prettify-symbols-mode t)) +#+END_SRC + +This is snippet was taken verbatim from [[https://emacs.stackexchange.com/questions/17283/is-it-possible-to-get-prettified-symbols-in-org-mode-source-blocks][Emacs StackExchange]] to enable +=prettify-symbols= in Org source code blocks. Sadly, I can't think of a way to +implement this as advice. + +#+BEGIN_SRC elisp +;; TODO: Can this be implemented as Elisp advice? +(defun org-src-font-lock-fontify-block (lang start end) + "Fontify code block. +This function is called by emacs automatic fontification, as long +as `org-src-fontify-natively' is non-nil." + (let ((lang-mode (org-src--get-lang-mode lang))) + (when (fboundp lang-mode) + (let ((string (buffer-substring-no-properties start end)) + (modified (buffer-modified-p)) + (org-buffer (current-buffer)) pos next) + (remove-text-properties start end '(face nil)) + (with-current-buffer + (get-buffer-create + (concat " org-src-fontification:" (symbol-name lang-mode))) + (delete-region (point-min) (point-max)) + (insert string " ") ;; so there's a final property change + (unless (eq major-mode lang-mode) (funcall lang-mode)) + ;; Avoid `font-lock-ensure', which does not display fonts in + ;; source block. + (font-lock-fontify-buffer) + (setq pos (point-min)) + (while (setq next (next-single-property-change pos 'face)) + (put-text-property + (+ start (1- pos)) (1- (+ start next)) 'face + (get-text-property pos 'face) org-buffer) + (setq pos next)) + ;; Addition: also copy 'composition info for prettified symbols + (setq pos (point-min)) + (while (setq next (next-single-property-change pos 'composition)) + (put-text-property + (+ start (1- pos)) (1- (+ start next)) 'composition + (get-text-property pos 'composition) org-buffer) + (setq pos next)) + ;; End addition + ) + (add-text-properties + start end + '(font-lock-fontified t fontified t font-lock-multiline t)) + (set-buffer-modified-p modified))))) +#+END_SRC + +* Savehist + +I don't really care about persisting minibuffer history between sessions. + +#+BEGIN_SRC elisp +(use-package savehist + :ensure nil + :config + (savehist-mode -1)) +#+END_SRC -- cgit v1.3