emsenn's Emacs Stuff

Table of Contents


Emacs is the text-editor I use to interact with most documents when on a computer, and I use it for accomplishing a few other tasks as well. This document outlines my configuration.

Most of the time, I'm using Emacs to work with Org-mode - even when I'm writing in other languages, I use literate programming, so write essays (like this one) that include code blocks that can be tangled out to the usable code.

This document is unfinished, and I have no plans to finish it.

This document was written by me, emsenn, and is released for the benefit of the public under the terms included in the "License" supplement. It was made possible with financial contributions from humans like you. Please direct comments to my public inbox or, if necessary, my personal email.

This document was written when the events it discusses were contemporary. Information in it may now be incorrect, and opinions presented may be out of date.


The init.el file, kept under ~/.emacs.d/, is where I keep all my Emacs configuration. I'm sure at some point I'll want to divide it up, but I haven't had a need to, yet.

Package Manager Initialization

Set Up use-package

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
  (add-to-list 'load-path "~/.emacs.d/elpa")
  (add-to-list 'load-path "~/.emacs.d/git")
  (require 'use-package))

I use John Wiegley's use-package package to manage my packages. (It's amazing how gibberish some sentences about computers sound, isn't it?)

I'm pretty sure for this to work, you have to manually install use-package yourself, but I'm not sure.

Oh, this also adds MELPA and Org-mode's repositories as package sources - as well as the local elpa/ and git/ folders, under the ~/.emacs.d/ directory.

Configure Auto-Update

(use-package auto-package-update
             :ensure t
             (setq auto-package-update-delete-old-versions t)
             (setq auto-package-update-hide-results t)

TBH I copied this from somewhere and I don't recall where, nor what it does.

Save & Backup Configuration

(setq auto-save-mode nil)
(setq backup-directory-alist
      `(("." . ,(concat user-emacs-directory "backups"))))

Basic Client Configuration

(setq inhibit-startup-message t)  ; make startup quieter...
(setq initial-scratch-message nil)
(setq initial-major-mode 'org-mode) ; ... and org-mode
(setq ring-bell-function 'ignore)   ; no system bell
(set-face-attribute 'default nil :height 148) ; "focus mode"
(menu-bar-mode -1)   ; more "focus mode" - no menu bars, even in GUI
(tool-bar-mode -1)
(setq show-paren-delay 0)  ; why delay matching parens? ew
(show-paren-mode 1)        ; also, always show them
(setq echo-keystrokes 0.1) ; show keystrokes in the minibuffer quick
(setq fill-column 68)  ; i like short lines
(setq mouse-wheel-scroll-amount '(1 ((shift) .1))) ; and short scrolling?
(setq line-number-mode t)  ; show line...
(setq column-number-mode t)      ; ...and column number in the statusbar
(setq-default truncate-lines t)  ;
(setq sentence-end-double-space nil) ; noooooo
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(setenv "PATH" (concat (getenv "PATH") ":~/.local/bin")) ; make sure my .local/bin is in the path

GUI Configuration

Theme Configuration

(defadvice load-theme (before theme-dont-propagate activate)
  (mapc #'disable-theme custom-enabled-themes))
(use-package base16-theme
           :ensure t
           (load-theme 'base16-tomorrow-night t))



htmlize.el is "a package for exporting the contents of an Emacs buffer as HTML while respecting display properties such as colors, fonts, underlining, invisibility, etc."

It's used by several parts of Org.

(use-package htmlize
             :ensure t)


(use-package magit
             :ensure t)


(use-package org
  :mode (("\\.org$" . org-mode) ("\\.inc$" . org-mode))
  :ensure org-plus-contrib
  :bind (("C-c l" . org-store-link)
         ("C-c c" . org-capture)
         ("C-c a" . org-agenda)
         ("C-c b" . org-iswitchb)
         ("C-c C-w" . org-refile)
         ("C-c j" . org-clock-goto)
         ("C-c C-x C-o" . org-clock-out))
    (setq org-log-done t)
    (setq org-image-actual-width nil)
    (setq org-agenda-custom-commands
          '(("A" "Agenda and TODO"
             ((agenda "" )
              (alltodo "" )))))
    (setq org-agenda-todo-ignore-scheduled 'all)
    (setq org-export-allow-bind-keywords t)
    (setq org-todo-keywords
    '((sequence "DRAFT" "EDIT" "|" "DONE")
      (sequence "|" "CANCELED")))
    (setq org-capture-templates
          '(("s" "New Source File" plain (file "~/org/triage/source-capture.org")
             "#+SETUPFILE: ~/org/templates/setupfile0.org\n#+TITLE: %^{TITLE}\n#+EXPORT_FILE_NAME: ../pub/%^{SLUG}\n* Introduction\n%?\n#+INCLUDE: \"./eli.org::#draft\"\n#+INCLUDE: \"./eli.org::#eli\"\n* %\\1\n  :PROPERTIES:\n  :CUSTOM_ID: contents\n  :END:\n* Supplements\n#+INCLUDE: \"./mit-license.org::#license\"")))))


   (ledger . t)
   (shell . t)))


(require 'ox-publish)
(setq org-publish-project-alist
         :base-directory "~/org/src/"
         :base-extension "org"
         :publishing-directory "~/org/pub/"
         :recursive t
         :auto-sitemap t
         :sitemap-title ""
         :makeindex t
         :publishing-function org-html-publish-to-html
         :auto-preamble t
         :base-directory "~/org/src/teraum/"
         :base-extension "org"
         :publishing-directory "~/org/pub/teraum/"
         :recursive t
         :auto-sitemap t
         :sitemap-title ""
         :makeindex t
         :publishing-function org-html-publish-to-html
         :auto-preamble t
        ("personal-website" :components ("teraum" "personal-website-docs"))


(use-package webpaste
  :ensure t
  :bind (("C-c C-p C-b" . webpaste-paste-buffer)
         ("C-c C-p C-r" . webpaste-paste-region))
    (setq webpaste-provider-priority '("ptpb.pw"))))

Elisp Functions

Make New Project

(defun ems-make-new (slug)
  "Create a new project and fill it with the relevant boilerplate."
  (mkdir (concat "~/org/projects/" slug) :parents)
  (setq ems-project-boilerplate '("README.org" "LICENSE"))
  (while ems-project-boilerplate
    (if (not (file-exists-p (concat "~/org/projects/" slug "/" (car ems-project-boilerplate))))
        (copy-file (concat "~/org/templates/" (car ems-project-boilerplate))
                   (concat "~/org/projects/" slug "/" (car ems-project-boilerplate)))
      (setq ems-project-boilerplate (cdr ems-project-boilerplate)))))

Load Elisp in Dir

(defun ems-load-elisp-in-dir (dir)
  "`load' all elisp libraries in directory DIR which are not already loaded."
  (interactive "D")
  (let ((libraries-loaded (mapcar #'file-name-sans-extension
                                  (delq nil (mapcar #'car load-history)))))
    (dolist (file (directory-files dir t ".+\\.elc?$"))
      (let ((library (file-name-sans-extension file)))
        (unless (member library libraries-loaded)
          (load library nil t)
          (push library libraries-loaded))))))



This document was made possible with contributions from humans like you. Thank you! I currently accept contributions through the following platforms:

If there is another service through which you'd like to contribute, please send an email. Please note that in accordance with my personal directives #003 and #018, I release all useful information I create for free, so financial contributions do not entitle you to access to any "exclusive content."


Copyright 2019 emsenn

Permission is hereby granted, free of charge, to any person obtaining a copy of this document and associated media files (the "Document"), to deal in the Doftware without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Doftware, and to permit persons to whom the Doftware is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The Document is provided "as is," without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, or noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort, or otherwise, arising from, out of or in connection with the Document or the use or other dealings in the Document.

Author: emsenn

Created: 2019-05-03 Fri 21:31