Theresa O’Connor

Building a habitable computing environment

Copyright⟫=

Copyright © 1997–2020 Theresa O'Connor <tess@oconnor.cx>

Introduction

Hi, I'm Tess.

I've been using various flavors of Unix machines for over twenty years. Many years ago, I often found myself making related changes to multiple dotfiles. It occurred to me that it might be easier to understand my configuration if I wrote it as a literate program. I believe history has demonstrated how very wrong I was, but I'm too lazy to undo the damage at this point. All of my dotfiles are interleaved in one very long literate program, and for some reason you're reading it now. I'm sorry.

Table of Contents

Concepts

$SYSNAME

I use $SYSNAME for "whatever kind of CPU/OS combo we're on." This is similar to GNU's buildtype, but a bit simpler.

Setting SYSNAME (zsh)⟫=

# I put architecture-specific local binaries I've built in ~/$SYSNAME/bin.
machtype=`uname -m`
ostype=`uname -s`
export SYSNAME=`echo ${machtype}-${ostype} | tr '[:upper:]' '[:lower:]'`
unset machtype ostype

Because home directories are sometimes shared by machines of different architectures, I put binaries in ~/$SYSNAME/bin.

Set SYSNAME in Emacs⟫=

(defconst tess-sysname
  (format
   "%s-%s"
   (cond ((string-match "^x86_64" system-configuration) "x86_64")
         ((string-match "^i686" system-configuration) "i686")
         ((string-match "^i386" system-configuration) "i386")
         (t "unknown"))
   (cond ((string-match "apple-darwin" system-configuration) "darwin")
         ((string-match "pc-linux-gnu" system-configuration) "linux")
         ((string-match "w64-mingw32" system-configuration) "windows")
         (t "unknown")))
  "What kind of OS are we running on.")

Home sweet home

bin/ - shell scripts

This direectory should be in my shell's search path as well as Emacs'.

get function (zsh)⟫=

get () {
    if [[ -z "$1" ]]; then
        print "Must specify remote file to get." >& 2
        return 1
    fi

    REMOTE=$1
    LOCAL=`print $1 | cut -d : -f 2 | xargs basename`

    rsync -LPv $REMOTE $LOCAL
}

Setting PATH (zsh)⟫=

# Don't add duplicate $path entries
typeset -U path

# add-to-path [ DIR ... ]
# Add each DIR to $path iff it exists.
add-to-path() {
    local dir
    local -i added=1
    for dir in $*; do
        if [[ -d $dir ]]; then
            path=($dir $path)
            added=0
        fi
    done
    return added
}

# is-in-path PROGRAM
# returns true if PROGRAM is somewhere in $path
is-in-path() {
    whence $1 > /dev/null
}

Setting PATH (zsh)⟫=

add-to-path ~/bin

Ensure HOME/bin is in exec-path⟫=

(add-to-list 'exec-path (expand-file-name "~/bin/"))

bin/ip

ip simply prints the current IP address.

bin/ip⟫=

#!/bin/sh

# Echos the current IP address. If you want to see the addresses of all
# interfaces, provide an argument to this script (e.g., "ip all").

IFACE=""

if [ "x$1" = "x" ]; then
    case `uname -s` in
      Darwin)
        IFACE=`⟪Default interface name on macOS⟫`
        ;;
      FreeBSD)
        IFACE=`⟪Default interface name on FreeBSD⟫`
        ;;
      Linux)
        IFACE=`netstat -rn | grep ^0.0.0.0 | cut -c 74-`
    esac
fi

if [ "x$IFACE" != "x" ]; then
    for iface in $IFACE; do
        echo `/sbin/ifconfig $iface | grep inet | grep -v inet6 | awk '{print $2}'`
    done
    exit
fi

defun tess-ip⟫=

(defvar tess-default-network-interface
  (cond
    ((eq system-type 'darwin) "en0")
    ((eq system-type 'gnu/linux) "eth0")
    (t nil)))

(defun tess-ip (&optional interface)
  (interactive (list (completing-read
                      "Interface: "
                      (mapcar 'car (network-interface-list))
                      nil t nil nil
                      tess-default-network-interface)))
  (let ((addresses
         (mapcar (lambda (entry)
                   (let ((formatted
                          (substring (format-network-address
                                      (cdr entry))
                                     0 -2)))
                     formatted))
                 (if (not interface)
                     (network-interface-list)
                   (list (assoc interface (network-interface-list)))))))
    ;; Only return a list of addresses when there's ony one.
    (if (not (cdr addresses))
        (car addresses)
      addresses)))

(defun eshell/ip (&rest arguments)
  (let ((addresses (apply 'tess-ip arguments)))
    (if (stringp addresses)
        addresses
      (mapconcat 'identity addresses "\n"))))

bin/randomize-mac-address

Sometimes you need to change your MAC address, okay?

bin/randomize-mac-address⟫=

#!/bin/bash

function default-iface {
    ⟪Default interface name on macOS⟫
}

function lladdr {
    ifconfig $1 ether | grep ether | awk '{print $2}'
}

if [ "x$1" = "x" ]; then
    IFACE=`default-iface`
else
    IFACE=$1
fi

OLD_LLADDR=`lladdr $IFACE`
NEW_LLADDR=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`

echo "Changing the MAC address of $IFACE from $OLD_LLADDR to $NEW_LLADDR"
sudo ifconfig $IFACE lladdr $NEW_LLADDR

bin/dr

This prints the default route.

bin/dr⟫=

#!/bin/sh

case `uname -s` in
  Darwin|FreeBSD|SunOS)
    netstat -rn | grep default | grep -v utun | awk '{print $2}'
    ;;
  Linux)
    netstat -rn | grep ^0.0.0.0 | awk '{print $2}'
    ;;
  *)
    echo 'unknown'
    ;;
esac

bin/ssid

What's the SSID

bin/ssid⟫=

#!/bin/sh

case `uname -s` in
    Darwin)
        IFACE="unknown"

        IFS="
"
        PARSE_THIS_LINE=/usr/bin/false
        for line in `networksetup -listallhardwareports`; do
            if $PARSE_THIS_LINE; then
                IFACE=`echo "${line}" | cut -c 9-`
                break
            fi
            if [ "Hardware Port: Wi-Fi" == "${line}" ]; then
                PARSE_THIS_LINE=/usr/bin/true
            fi
        done
        networksetup -getairportnetwork $IFACE | cut -c 24-
        ;;
    FreeBSD)
        IFACE=`⟪Default interface name on FreeBSD⟫`
        echo `/sbin/ifconfig $IFACE | grep ssid | awk '{print $2}'`
        ;;
    *)
        echo 'unknown'
        ;;
esac

Common utilities

All of the above scripts share these implementation bits:

Default interface name on macOS⟫=

netstat -rn | grep default | grep -v utun | awk '{ print $4 }'

Default interface name on FreeBSD⟫=

netstat -rn | grep default | grep -v :: | cut -c 65-

code/ - git repositories

define tess-workspace⟫=

(defconst tess-workspace "~/code"
  "Where I check out version-controlled things.")

ninja-mode⟫=

(when (locate-library "ninja-mode")
  (autoload 'ninja-mode "ninja-mode" nil t)
  (add-to-list 'auto-mode-alist '("\\.ninja\\'" . ninja-mode)))

code/Makefile

code/Makefile⟫=

# Note that this Makefile has only been tested with GNU Make.

EMACS=emacs -q --no-site-file
CWD=~/code

⟪37emacs clone rule⟫
⟪erc clone rule⟫
⟪gnus clone rule⟫
⟪github elisp make rules⟫
⟪Generic el-to-elc Make rule⟫

37emacs clone rule⟫=

37emacs/backpack.el:
        git clone git@github.com:hober/37emacs.git

erc clone rule⟫=

erc/erc.el:
        git clone ssh://hober@git.sv.gnu.org/srv/git/erc.git

elisp/ - Emacs Lisp libraries

define tess-elisp-dirs and tess-elisp-dir⟫=

(defconst tess-elisp-dirs
  (mapcar (lambda (entry)
            (let ((name (car entry))
                  (default-dir (cdr entry)))
              (if default-dir
                  (expand-file-name name default-dir)
                nil)))
          (list (cons "emacs" (xdg-config-home))
                (cons ".emacs.d" (xdg-config-home))
                (cons "elisp" tess-mac-shared-home)
                (cons "elisp" tess-mac-data-volume)
                (cons "elisp" "~"))))

(defconst tess-elisp-dir
  (or (catch 'found
        (mapc (lambda (dir)
                (when (and (stringp dir) (file-directory-p dir))
                  (throw 'found dir)))
              tess-elisp-dirs))
      "~/elisp")
  "Where I keep local copies of elisp files, both my own and others'.")

Configure load-path⟫=

(mapc (lambda (dir)
        (when (and (stringp dir) (file-directory-p dir))
          (add-to-list 'load-path dir)
          (let ((default-directory dir))
            (load "./subdirs.el" t))))
      tess-elisp-dirs)

elisp/subdirs.el⟫=

(cond ((fboundp 'normal-top-level-add-subdirs-to-load-path)
       (normal-top-level-add-subdirs-to-load-path))
      ((fboundp 'paths-find-recursive-load-path)
       (let ((subdirs (paths-find-recursive-load-path
                       (list default-directory))))
         (setq load-path (nconc subdirs load-path)))))

elisp/Makefile

byte-compile command (zsh)⟫=

# Handy command-line tool to byte-compile elisp files.
byte-compile() {
    emacs -batch -L . -f batch-byte-compile $*
}
# Completion for byte-compile
_byte-compile() { _arguments ':file:_files -g "*.el"' }
compdef _byte-compile byte-compile

elisp/Makefile⟫=

# GNU Make rules for fetching and byte-compiling various elisp files.

EMACS=emacs -q --no-site-file

usage:
        @echo "usage: make [foo.el | foo.elc | autoloads | usage | all]"
        @echo "       make foo.el  will fetch foo.el from the Internet"
        @echo "       make foo.elc will byte-compile foo.el."
        @echo "                    (fetching foo.el first if necessary)."
        @echo "       make all will turn buil .elc for all .el in this dir."
        @echo "       make autoloads will update the autoloads file."
        @echo "       make usage displays this message."
        @echo

⟪autoloads make rule⟫

ELS = $(shell ls -1 *.el)
ELCS = $(ELS:.el=.elc)
all: $(ELCS)
        make $(ELCS)

elisp/Makefile⟫=

⟪Generic el-to-elc Make rule⟫

Generic el-to-elc Make rule⟫=

.el.elc:
        $(EMACS) -batch -L . \
                -eval "(setq max-lisp-eval-depth ⟪max-lisp-eval-depth⟫)" \
                -eval "(setq max-specpdl-size ⟪max-specpdl-size⟫)" \
                -eval "(mapc (lambda (dir) (add-to-list 'load-path dir)) \
                        (parse-colon-path (getenv \"LOAD_PATH\")))" \
                -f batch-byte-compile $*.el

elisp/Makefile⟫=

EMACSWIKI_DOWNLOAD=https://www.emacswiki.org/emacs/download/
GITHUB=https://raw.githubusercontent.com

# Where I most recently fetched various random elisp files written by
# other people.

⟪applescript-mode.el fetch rule⟫
⟪boxquote.el fetch rule⟫
⟪color-theme fetch rules⟫
⟪css-mode.el fetch rule⟫
⟪csv.el fetch rule⟫
⟪deft.el fetch rule⟫
⟪dom.el fetch rule⟫
⟪ecmascript-mode.el fetch rule⟫
⟪erc-highlight-nicknames.el fetch rule⟫
⟪erc-robot.el fetch rule⟫
⟪espresso.el fetch rule⟫
⟪eudcb-mab.el fetch rule⟫
⟪fillcode.el fetch rule⟫
⟪haskell-mode fetch fules⟫
⟪http-FOO.el fetch rules⟫
⟪http-twiddle.el fetch rule⟫
⟪install.el fetch rule⟫
⟪javascript.el fetch rule⟫
⟪mb-depth fetch rule⟫
⟪moz.el fetch rule⟫
⟪multi-region.el fetch rule⟫
⟪mwe-log-commands.el fetch rule⟫
⟪oddmuse.el fetch rule⟫
⟪paredit.el fetch rule⟫
⟪parenface.el fetch rule⟫
⟪psvn.el fetch rule⟫
⟪rpm-spec-mode.el fetch rule⟫
⟪ruby fetch rules⟫
⟪setnu.el fetch rule⟫
⟪swift major mode fetch rules⟫
⟪tc.el fetch rule⟫
⟪tidy.el fetch rule⟫
⟪tracking.el fetch rule⟫
⟪twit.el fetch rule⟫
⟪two-mode-mode.el fetch rule⟫
⟪wikipedia elisp fetch rules⟫
⟪vc-svn.el fetch rule⟫
⟪wdired.el fetch rule⟫
⟪xterm-frobs.el fetch rule⟫

$SYSNAME/bin - binaries

Setting SYSNAME (zsh)⟫=

add-to-path ~/$SYSNAME/bin ~/$SYSNAME/sbin

Add SYSNAME/bin to exec-path⟫=

(add-to-list 'exec-path
             (expand-file-name "bin"
                               (expand-file-name tess-sysname "~")))

templates/ - skeleton files of various types

templates⟫=

(when (fboundp 'auto-insert-mode)
  (auto-insert-mode 1)
  (setq auto-insert-query nil)
  (setq auto-insert-directory "~/templates/")
  ⟪atom template⟫
  ⟪css template⟫
  ⟪html template⟫
  ⟪js template⟫
  ⟪latex template⟫
  ⟪plist template⟫
  ⟪python template⟫)

tmp/ - temporary files

Local config files and XDG

I put local (machine-specific) config files in XDG Base Directory-style config directories. Only some systems come with XDG environment variables set, so I need to set them myself when they're missing.

Configure XDG (zsh)⟫=

# Set XDG variables if they're not already set.

mkdir -p ${XDG_CACHE_HOME:=~/.cache}; export XDG_CACHE_HOME
print ${XDG_CONFIG_DIRS:=/etc/xdg} > /dev/null ; export XDG_CONFIG_DIRS
print ${XDG_DATA_DIRS:='/usr/local/share/:/usr/share/'} > /dev/null ; export XDG_DATA_DIRS
mkdir -p ${XDG_DATA_HOME:=~/.local/share}; export XDG_DATA_HOME
mkdir -p ${XDG_DESKTOP_DIR:=~/Desktop}; export XDG_DESKTOP_DIR
mkdir -p ${XDG_DOCUMENTS_DIR:=~/Documents}; export XDG_DOCUMENTS_DIR
mkdir -p ${XDG_DOWNLOAD_DIR:=~/Downloads}; export XDG_DOWNLOAD_DIR
mkdir -p ${XDG_MUSIC_DIR:=~/Music}; export XDG_MUSIC_DIR
mkdir -p ${XDG_PICTURES_DIR:=~/Pictures}; export XDG_PICTURES_DIR
mkdir -p ${XDG_PUBLICSHARE_DIR:=~/Public}; export XDG_PUBLICSHARE_DIR
mkdir -p -m 0700 ${XDG_RUNTIME_DIR:=~/tmp}; export XDG_RUNTIME_DIR
mkdir -p ${XDG_TEMPLATES_DIR:=~/templates}; export XDG_TEMPLATES_DIR
mkdir -p ${XDG_VIDEOS_DIR:=~/Movies}; export XDG_VIDEOS_DIR

basic w32 fixups⟫=

(when tess-w32-flag
  (setenv "XDG_CONFIG_HOME"
          (format "C:\\Users\\%s\\AppData\\Roaming\\" user-login-name))
  ;; Fix the appearance of Emacs' window
  (setq tess-screen-height-to-type-size-ratio 70
        tess-emacs-top 10
        tess-emacs-left 10)
  ;; Fix assumptions about where things are
  (setenv "HOME" (getenv "USERPROFILE"))
  (cd "~/"))

define xdg-config-home for emacs⟫=

(unless (require 'xdg nil t)
  (defun xdg-config-home ()
    "Directory relative to which user-specific config files live."
    (or (getenv "XDG_CONFIG_HOME")
        (expand-file-name ".config" "~"))))

define data-vol and shared-home for emacs⟫=

(defconst tess-mac-data-volume
  "/Volumes/data/")

(defconst tess-mac-shared-home
  (let ((dir (expand-file-name (format "Users/%s" user-login-name)
                               tess-mac-data-volume)))
    (if (file-directory-p dir)
        dir
      "~/shared")))

Local config overrides

For my shell, I have two local config overrides: one file that gets loaded right at the start of my .zshrc, and one right afterwards.

Load pre.zsh⟫=

# We need to define $XDG_CONFIG_HOME before all the other XDG variables
# so that we can load pre.zsh as quickly as possible.

mkdir -p ${XDG_CONFIG_HOME:=~/.config}

if [[ -r $XDG_CONFIG_HOME/zsh/pre.zsh ]]; then
    . $XDG_CONFIG_HOME/zsh/pre.zsh
fi

if [[ -d $XDG_CONFIG_HOME/zsh/functions ]]; then
    fpath=($XDG_CONFIG_HOME/zsh/functions $fpath)
fi

Load post.zsh⟫=

if [[ -r $XDG_CONFIG_HOME/zsh/post.zsh ]]; then
    . $XDG_CONFIG_HOME/zsh/post.zsh
fi

For Emacs and Gnus, it's simpler. Each only has one local file, which run after .emacs and .gnus, respectively.

Custom hooks⟫=

(defvar tess-before-local-init-hook nil
  "Hook run before my local init file gets loaded.")
(defvar tess-after-local-init-hook nil
  "Hook run after my local init file gets loaded.")

Host-specific customizations⟫=

(run-hooks 'tess-before-local-init-hook)
(require 'local nil t)
(run-hooks 'tess-after-local-init-hook)

Local Gnus configuration⟫=

(require 'local-gnus nil t)

Shells and terminals

Features common to all shells

setenv TIME⟫=

setenv TIME "real\t%es\nuser\t%Us\nsys\t%Ss\n"

unset ignoreeof⟫=

unset ignoreeof

unset autologout⟫=

unset autologout

Cursors

There is nothing worse than blinking cursors.

Disable blinking cursors⟫=

(when (fboundp 'blink-cursor-mode)
  (blink-cursor-mode -1))
(setq visible-cursor nil) ; Emacs 22

Here's how to disable Emacs blinking cursors from a plist on macOS.

emacs-app cursor⟫=

<key>CursorBlinkRate</key>
<string>NO</string>
<key>CursorType</key>
<string>box</string>

And here's how to disable a blinking cursor in vi.

.exrc⟫=

set flash

cdpath

setq cd-path⟫=

(setq cd-path '("./" "~/" "~/code/"))
(setenv "CDPATH" (mapconcat 'identity cd-path path-separator))

ls

How to set your ls colors on Linux systems:

LSC1⟫=

no=00:fi=00:di=00;33:ln=00;36:pi=00;33:so=01;32:bd=00;34;46:cd=00;34;43:

LSC2⟫=

or=00;36:mi=00;36:ex=00;32:*.tar.=00;31:*.tgz=00;31:*.arj=00;31:

LSC3⟫=

*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:

LSC4⟫=

*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:

ls defaults (zsh)⟫=

# Set my preferred colors for `ls` to use. Directories should be yellow!

export LS_COLORS='⟪LSC1⟫⟪LSC2⟫⟪LSC3⟫⟪LSC4⟫'

ls in linux (zsh)⟫=

export LC_COLLATE='C'
alias ls='ls -FN --color'

LC COLLATE in Emacs⟫=

;; Fix sort order in dired, ls, etc.
(setenv "LC_COLLATE" "C")

(when (eq system-type 'darwin)
  (setq dired-use-ls-dired nil))

How to set your ls colors on FreeBSD and macOS:

ls defaults (zsh)⟫=

export LSCOLORS='dxgxCxdxcxegedabagDeBe'

ls in freebsd (zsh)⟫=

alias ls='ls -FG'

Path

Set exec-path from path_helper on macOS⟫=

(when (file-executable-p "/usr/libexec/path_helper")
  (setq exec-path
        (split-string
         (substring (tess-run-executable "/usr/libexec/path_helper" "-c")
                    13 -2)
         path-separator)))

When I have a separate data partition on Mac, make sure I set up my path appropriately.

Configure XDG (zsh)⟫=

# On macOS machines with multiple partitions, I usually have a shared
# partition for data.

add-to-path /Volumes/data/Users/`id -un`/bin || add-to-path ~/shared/bin

Config data-vol and shared-home in Emacs⟫=

(let ((shared-bin
       (expand-file-name "bin" tess-mac-shared-home)))
  (when (file-directory-p shared-bin)
    (add-to-list 'exec-path shared-bin)))

Fix exec-path under Emacs⟫=

(defun tess-score-path (path)
  "Score PATH for sorting `exec-path' entries."
  (+ (if (string-match (regexp-quote (expand-file-name "~")) path) 100 0)
     (length path)))

(defun tess-cmp-path (p1 p2)
  "Non-nil iff P1 should appear before P2 in `exec-path'."
  (> (tess-score-path p1) (tess-score-path p2)))

(defun tess-path-fixup ()
  "Update `exec-path' with my preferred ordering."
  (setq exec-path
        (sort (seq-uniq
               (mapcar (lambda (p)
                         (file-name-as-directory (expand-file-name p)))
                       exec-path)
               'string-equal)
              'tess-cmp-path))
  (setenv "PATH" (mapconcat 'identity exec-path path-separator)))

(add-hook 'tess-after-local-init-hook 'tess-path-fixup)

Fix exec-path under Windows⟫=

(defun tess-fix-w32-pathname (dir)
  "Munge DIR to be a real dir name."
  (setq dir (or dir ""))
  ;; FIXME: an example of why I do this would be nice.
  (if (string-match "^[\"]\\(.*\\)[\"]/\\'" dir)
      (file-name-as-directory (match-string 1 dir))
    dir))

(let ((path (parse-colon-path (getenv "PATH"))))
  (setenv "PATH"
          (mapconcat 'tess-fix-w32-pathname path path-separator)))

Prompts

Setting my prompt (zsh)⟫=

update-prompt() {
    PS1=$'\n'"%n%F{8}@%f%m %F{8}($*)"$'\n'"%F{3}%~%F{8}%(!.#.:)%f "
    RPS1=''
}

if is-in-path lsb_release; then
    update-prompt `lsb_release -si` `lsb_release -sr` `lsb_release -sc`
elif is-in-path sysctl; then
    update-prompt `sysctl -n hw.model` `sysctl -n kern.osversion`
fi

Setting my prompt (bash)⟫=

if [ -X lsb_release]; then
    PROMPT_SYS_INFO=" (`lsb_release -si` `lsb_release -sr` `lsb_release -sc`)"
else
    PROMPT_SYS_INFO=""
fi

PS1="\n\u@\h$PROMPT_SYS_INFO\n\w\$ "

Setting my prompt in PowerShell⟫=

function Prompt {
    "${env:USERNAME}@${env:COMPUTERNAME} (Windows " +
    [Environment]::OSVersion.Version + ")" +
    [Environment]::NewLine + (Get-Location) + ': '
}

Eshell prompt⟫=

(defconst tess-eshell-prompt-format-string
  (let ((user (or (getenv "USER") (user-login-name) "tess"))
        (host (car (split-string
                    (or (getenv "HOST") (system-name) "unknown")
                    "\\.")))
        (emacs-version-string
         (let ((version
                (mapcar 'string-to-number
                        (split-string emacs-version "\\."))))
           (setf (cadr version)
                 (+ (cadr version) 65))
           (when (and (boundp 'emacs-build-number)
                      (< (length version) 3))
             (setq version (append version (list emacs-build-number))))
           (apply 'format "%d%c%d" version)))
        (char (if (= (user-uid) 0) "#" ":")))
    (format "\n%s@%s (Emacs%s)\n%s%s " user host
            emacs-version-string
            "%s" char)))
(defun tess-eshell-prompt ()
  (format tess-eshell-prompt-format-string default-directory))

Eshell prompt⟫=

(setq eshell-prompt-function 'tess-eshell-prompt)
(setq eshell-prompt-regexp "^[^#:\n]*[#:] ")

Setting my prompt (sh)⟫=

PS1="${USER}@$(hostname -s): "

Aliases

I define shell aliases in a .alias file in my home directory, and load it from Eshell.

.alias⟫=

alias rmb rm -f \*~ .\*~

And here's how you tell Eshell to use it:

Various custom Eshell commands⟫=

(setq eshell-aliases-file "~/.alias")

I've made this a function in zsh because I don't want it to complain about no matches. There's probably a more elegant way to do this.

rmb function⟫=

rmb() {
    emulate -L zsh; set -o null_glob
    local -a files=(*~ .*~)
    if (( $#files > 0 )); then
        rm $files
        print removed $files
    fi
}

On macOS, I use oa to figure out additional aliases to set.

macOS shell aliases (zsh)⟫=

define-app-alias() {
    local shortcut=$1
    shift
    local app
    for app in $*; do
        if oa -dq $app; then
            alias $shortcut="oa '$app'"
            break
        fi
    done
}

define-app-alias amon 'Activity Monitor'
define-app-alias brave 'Brave Browser'
define-app-alias chrome 'Google Chrome'
define-app-alias dutil 'Disk Utility'
define-app-alias edge 'Microsoft Edge'
define-app-alias ff 'Firefox'
define-app-alias kca 'Keychain Access'
define-app-alias marked 'Marked 2' 'Marked'
define-app-alias otp 'OTP Auth'
define-app-alias prefs 'System Preferences'
define-app-alias store 'App Store'
define-app-alias stp 'Safari Technology Preview' 'Safari'
define-app-alias teams 'Microsoft Teams'

if is-in-path mDNSResponder; then
    alias flush-dns-cache='sudo killall -HUP mDNSResponder'
fi

Add Emacs & utilities to PATH⟫=

if is-in-path oa; then
    emacs_app=`oa -d Emacs`
    if (( $? == 0 )); then
        if [[ -x $emacs_app/Contents/MacOS/Emacs ]]; then
            alias emacs="$emacs_app/Contents/MacOS/Emacs -nw"
        fi
        add-to-path $emacs_app/Contents/MacOS/bin
    fi
fi

macOS browser aliases⟫=

if ({ oa -dq "Brave Browser" }) then
    alias brave 'set url = "\!:1*"; \\
                 if ($url == "") oa "Brave Browser"; \\
                 if ($url != "") open -a "Brave Browser" --args "$url"'
endif

if ({ oa -dq "Google Chrome" }) then
    alias chrome 'set url = "\!:1*"; \\
                  if ($url == "") oa "Google Chrome"; \\
                  if ($url != "") open -a "Google Chrome" --args "$url"'
endif

if ({ oa -dq "Microsoft Edge" }) then
    alias edge 'set url = "\!:1*"; \\
                if ($url == "") oa "Microsoft Edge"; \\
                if ($url != "") open -a "Microsoft Edge" --args "$url"'
endif

if ({ oa -dq "Firefox" }) then
    alias ff "oa Firefox"
endif

# Purple Safari is the best Safari
if ({ oa -dq "Safari Technology Preview" }) then
    alias stp "oa 'Safari Technology Preview'"
else
    alias stp "oa Safari"
endif

hostname aliases (zsh)⟫=

ssh_hosts=("${(@f)$(grep '^Host[ ][^*]' ~/.ssh/config | cut -c 6-)}")

_recvcfg () {
    _arguments ":host:($ssh_hosts[*])"
}
compdef _recvcfg recvcfg

_sendcfg () {
    _arguments ":host:($ssh_hosts[*])"
}
compdef _sendcfg sendcfg

for host in $ssh_hosts; do
    if [[ $host == `hostname -s` ]]; then
        continue
    fi
    alias $host="ssh -t $host screen -DR"
    alias x$host="ssh -t $host screen -x"
done

Shell completion

Turn on file completion.

git completion (zsh)⟫=

gitcompletion='~/code/git/contrib/completion'
if [[ -r $gitcompletion/git-completion.zsh ]]; then
    if [[ ! -e ~/.git-completion.bash ]]; then
        cp $gitcompletion/git-completion.bash ~/.git-completion.bash
    fi
    . $gitcompletion/git-completion.zsh
fi

Use case-insensitive completion in zsh⟫=

zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'

setq completion-ignore-case⟫=

(setq completion-ignore-case t)

case-insensitive filename completion⟫=

(setq read-file-name-completion-ignore-case t)

Disable SPC minibuffer completion⟫=

(define-key minibuffer-local-completion-map (kbd "SPC") nil)

ssh command completion⟫=

set ssh_hosts = `grep '^Host[ ][^*]' ~/.ssh/config | cut -c 6-`
complete ssh 'p/1/$ssh_hosts/'
complete sendfg 'p/*/$ssh_hosts/'
complete recvcfg 'p/*/$ssh_hosts/'

pcomplete⟫=

(setq pcomplete-cycle-completions nil)

Custom completion (zsh)⟫=

# Completion

autoload -Uz compinit && compinit
⟪Use case-insensitive completion in zsh⟫
⟪git completion (zsh)⟫

Some Unix systems have a group per user, and some don't. Try to configure my umask to do the right thing on either kind of Unix.

Set my umask (zsh)⟫=

# A righteous umask.

if [[ `id -un` = `id -gn` ]]; then
    umask 002
else
    umask 022
fi

Use Emacs key bindings for line editing⟫=

# Use Emacs key bindings for command line editing.
bindkey -e

zsh

I'm in the process of switching my default shell to zsh.

Warn when a zsh function should have declared a local variable⟫=

# Warn if one of my zsh functions should have declared a local variable
set -o warn_nested_var

Don't warn when a zsh function should have declared a local variable⟫=

set -o no_warn_nested_var

Interactive shell options (zsh)⟫=

# Don't complain about patterns with no match unless none of them match
set -o csh_null_glob
# Display possible completions on second TAB
set -o bash_auto_list

Prevent default.profraw files from being created⟫=

export LLVM_PROFILE_FILE=/dev/null

.zshrc⟫=

#!/bin/zsh

⟪Warn when a zsh function should have declared a local variable⟫
⟪Load pre.zsh⟫
⟪Setting PATH (zsh)⟫
⟪Configure XDG (zsh)⟫
⟪Setting SYSNAME (zsh)⟫
⟪Add Emacs & utilities to PATH⟫
⟪Set my umask (zsh)⟫
⟪Configure TERM (zsh)⟫
⟪Set LEDGER (zsh)⟫
⟪Nethack settings (zsh)⟫
⟪Set ORGANIZATION (zsh)⟫
⟪Prevent default.profraw files from being created⟫
⟪Ensure NODE_PATH is set up properly⟫

if [[ -o interactive ]]; then
    ⟪Interactive shell options (zsh)⟫
    ⟪Use Emacs key bindings for line editing⟫
    ⟪Use less as my pager (zsh)⟫
    ⟪OS-specific tweaks (zsh)⟫
    ⟪Choose which editor to use (zsh)⟫
    ⟪Custom completion (zsh)⟫
    ⟪rmb function⟫
    ⟪byte-compile command (zsh)⟫
    ⟪get function (zsh)⟫
    ⟪hostname aliases (zsh)⟫
    ⟪Reconnect to SSH agent within screen (zsh)⟫
    ⟪Setting my prompt (zsh)⟫
fi

if [[ -o login ]]; then
    if is-in-path lolcat; then
        CAT='lolcat'
    else
        CAT='cat'
    fi

    typeset -a fortune
    fortune=(
        'Share and Enjoy!'
        'Let the soft animal of your body love what it loves.
        — Mary Oliver'
        '“Someone who does not run
  toward the allure of love
    walks a road where nothing lives.”
        — Rumi'
        'I don’t want to lose a single thread
from the intricate brocade of this
  happiness.
I want to remember everything.
Which is why I’m lying awake, sleepy
but not sleepy enough to give it up.
Just now, a moment from years ago:
the early morning light, the deft, sweet
gesture of your hand
  reaching for me.
        — Mary Oliver'
    )

    print $'\n'${fortune:$[RANDOM%$#fortune]:1} | $CAT
fi

⟪Load post.zsh⟫
⟪Don't warn when a zsh function should have declared a local variable⟫
# .zshrc ends here

bash

Sometimes I find myself in bash.

.profile⟫=

# .profile

if [ -z "$BASH" ]; then # We're using straight sh(1)
    ⟪Setting my prompt (sh)⟫
else # We're using bash(1)
    ⟪Setting my prompt (bash)⟫
fi

PowerShell

On Windows I use PowerShell.

.profile.ps1⟫=

# Tess' PowerShell config file

⟪Setting my prompt in PowerShell⟫

Eshell

Make C-a in Eshell jump to the end of the prompt⟫=

(add-hook 'eshell-mode-hook
          (lambda ()
            (local-set-key (kbd "C-a") 'eshell-bol)))

eshell faces⟫=

'(eshell-prompt-face ((t (⟪prompt face⟫))))
'(eshell-prompt ((t (⟪prompt face⟫))))

The Emacs Shell⟫=

(when (not (fboundp 'eshell))
  (autoload 'eshell "eshell" nil t))

⟪Make C-a in Eshell jump to the end of the prompt⟫

The Emacs Shell⟫=

(setq eshell-cd-on-directory nil)

The Emacs Shell⟫=

(setq eshell-save-history-on-exit t
      eshell-hist-ignoredups      nil)

The Emacs Shell⟫=

(setq eshell-default-target-is-dot t
      eshell-pushd-tohome          t)

The Emacs Shell⟫=

(setq eshell-cmpl-cycle-completions nil)

The Emacs Shell⟫=

(if tess-sufficiently-bsd-like-flag
    (defun tess-eshell-C-t ()
      "Request status of the running Eshell command.
Only works on BSD."
      (interactive)
      ;; An anamorphic `when' would be nice here.
      (let ((proc (eshell-interactive-process)))
        (if proc
            (progn
              (process-send-string proc (string 20)))
          (call-interactively 'transpose-chars))))
  (defun tess-eshell-C-t ()
    (interactive)
    (ding)))
(add-hook 'eshell-mode-hook
          (lambda ()
            (local-set-key (kbd "C-t") 'tess-eshell-C-t)))

Use ANSI escape sequences in Eshell⟫=

(autoload 'ansi-color-filter-apply "ansi-color")
(add-hook 'eshell-preoutput-filter-functions 'ansi-color-filter-apply)

fix s-p in eshell⟫=

(add-hook 'eshell-mode-hook
          (lambda ()
            (local-set-key (kbd "s-p")
                           'eshell-previous-matching-input-from-input)))

Use less as my pager (zsh)⟫=

export PAGER='less'

Various custom Eshell commands⟫=

(defun eshell/less (file)
  "Pager view of FILE."
  (view-file file)
  0)
(defalias 'eshell/more 'eshell/less)

Fix e-f-a-f on XEmacs⟫=

(defun eshell-find-alias-function (name)
  "Check whether a function called `eshell/NAME' exists."
  (let* ((sym (intern-soft (concat "eshell/" name)))
         (file (symbol-file sym)))
    ;; If the function exists, but is defined in an eshell module
    ;; that's not currently enabled, don't report it as found
    (if (and file
             (string-match "\\(em\\|esh\\)-\\(.*\\)\\(\\.el\\)?\\'" file))
        (let ((module-sym
               (intern (file-name-sans-extension
                        (file-name-nondirectory
                         (concat "eshell-" (match-string 2 file)))))))
          (if (and (functionp sym)
                   (or (null module-sym)
                       (eshell-using-module module-sym)
                       (memq module-sym (eshell-subgroups 'eshell))))
              sym))
      ;; Otherwise, if it's bound, return it.
      (if (functionp sym)
          sym))))

Various custom Eshell commands⟫=

(defun eshell/rmb ()
  "Remove Emacs backup files in this directory."
  (mapconcat (lambda (filename)
               (delete-file filename)
               filename)
             (directory-files default-directory nil "~\\'" t)
             ", "))

Various custom Eshell commands⟫=

(setq eshell-scroll-show-maximum-output nil)
(defalias 'eshell/clear 'tess-clear)

Various custom Eshell commands⟫=

(defun eshell/info (subject)
  "Read the Info manual on SUBJECT."
  (let ((buf (current-buffer)))
    (Info-directory)
    (let ((node-exists (ignore-errors (Info-menu subject))))
      (if node-exists
          0
        (switch-to-buffer buf)
        (eshell-print (format "There is no Info manual on %s.\n"
                              subject))
        1))))

Various custom Eshell commands⟫=

(defun eshell/emacs (&rest args)
  "Open a file in Emacs. Some habits die hard."
  (if (null args)
      (bury-buffer)
    (mapc 'find-file (mapcar 'expand-file-name
                             (eshell-flatten-list args))))
  0)
  (defalias 'eshell/emacsclient 'eshell/emacs)

Various custom Eshell commands⟫=

(defun eshell/vi (file)
  "Open a file with Viper."
  (with-current-buffer (find-file file)
    (setq viper-mode t)
    (viper-mode))
  0)

Various custom Eshell commands⟫=

(defalias 'eshell/concat 'eshell/cat)

Augment eshell's ls to allow middle-clicking on files⟫=

(defvar tess-eshell-ls-keymap
  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "RET")      'tess-eshell-ls-find-file-at-point)
    (define-key map (kbd "<return>") 'tess-eshell-ls-find-file-at-point) ;%
    (define-key map (if (featurep 'xemacs)
                        (kbd "<button2>")
                      (kbd "<mouse-2>"))
      'pat-eshell-ls-find-file-at-mouse-click)
    map))

(defadvice eshell-ls-decorated-name (after tess-electrify-ls activate)
  "Eshell's `ls' now lets you click or RET on file names to open them."
  (add-text-properties 0 (length ad-return-value)
                       (list 'help-echo "RET, middle-click: visit this file"
                             'mouse-face 'highlight
                             'keymap tess-eshell-ls-keymap)
                       ad-return-value)
  ad-return-value)

Augment eshell's ls to allow middle-clicking on files⟫=

(defun tess-eshell-ls-find-file-at-point (point)
  "RET on Eshell's `ls' output to open files."
  (interactive "d")
  (find-file (buffer-substring-no-properties
              (previous-single-property-change point 'help-echo)
              (next-single-property-change point 'help-echo))))

Augment eshell's ls to allow middle-clicking on files⟫=

;; Not defined in Emacs.
(unless (fboundp 'event-point)
  (defun event-point (event)
    "Return the character position of mouse EVENT."
    (posn-point (event-end event))))

(defun pat-eshell-ls-find-file-at-mouse-click (event)
  "Middle click on Eshell's `ls' output to open files.
From Patrick Anderson via the EmacsWiki."
  (interactive "e")
  (tess-eshell-ls-find-file-at-point (event-point event)))

eshell faces⟫=

'(eshell-ls-archive-face ((t (:foreground "⟪medium red⟫")))) ;%
'(eshell-ls-archive ((t (:foreground "⟪medium red⟫")))) ;%
'(eshell-ls-backup-face ((t (:foreground "⟪medium blue⟫"))))
'(eshell-ls-backup ((t (:foreground "⟪medium blue⟫"))))
'(eshell-ls-clutter-face ((t (⟪warning face⟫))))
'(eshell-ls-clutter ((t (⟪warning face⟫))))
'(eshell-ls-directory-face ((t (⟪directory face⟫))))
'(eshell-ls-directory ((t (⟪directory face⟫))))
'(eshell-ls-executable-face ((t (⟪executable face⟫))))
'(eshell-ls-executable ((t (⟪executable face⟫))))
'(eshell-ls-missing-face ((t (⟪error face⟫))))
'(eshell-ls-missing ((t (⟪error face⟫))))
`(eshell-ls-product-face ((t ⟪dim this face when appropriate⟫)))
`(eshell-ls-product ((t ⟪dim this face when appropriate⟫)))
`(eshell-ls-readonly-face ((t ⟪dim this face when appropriate⟫)))
`(eshell-ls-readonly ((t ⟪dim this face when appropriate⟫)))
'(eshell-ls-special-face ((t (:foreground "⟪light magenta⟫")))) ;%
'(eshell-ls-special ((t (:foreground "⟪light magenta⟫")))) ;%
'(eshell-ls-symlink-face ((t (⟪symlink face⟫))))
'(eshell-ls-symlink ((t (⟪symlink face⟫))))
'(eshell-ls-unreadable-face ((t (⟪error face⟫))))
'(eshell-ls-unreadable ((t (⟪error face⟫))))

xterm, comint, gnu screen

Set LANG in Emacs⟫=

(setenv "LANG" "en_US.UTF-8")

TTY terminal-coding-system⟫=

(when (fboundp 'set-terminal-coding-system)
  (set-terminal-coding-system 'utf-8))

Configure TERM (zsh)⟫=

export TERMINFO='~/.terminfo'
if [[ -v TERM ]]; then
    if [[ $TERM = 'xterm' ]]; then
        export TERM='xterm-color'
        if [[ -d /usr/share/terminfo ]]; then
            if (( `find /usr/share/terminfo -name xterm-256color | wc -l` > 0 )); then
                export TERM='xterm-256color'
            fi
        fi
    fi

    if [[ -f /etc/debian_version ]]; then
        if [[ $TERM = 'xterm-color' ]]; then
            export TERM='xterm'
        fi
    fi
fi

256 colors in screen⟫=

term screen-256color

256 colors in Emacs⟫=

(autoload 'xterm-register-default-colors "term/xterm")
(when (and (not window-system)
           (string-match "256color" (or (getenv "TERMCAP") "")))
  (xterm-register-default-colors xterm-standard-colors))

Arrow keys in local screen instances⟫=

(when (and (not (display-graphic-p))
           (string-match "screen-256color" (or (getenv "TERMCAP") "")))
  (global-set-key (kbd "M-[ A") (kbd "<up>"))
  (global-set-key (kbd "M-[ B") (kbd "<down>"))
  (global-set-key (kbd "M-[ C") (kbd "<right>"))
  (global-set-key (kbd "M-[ D") (kbd "<left>")))

Use C-z for screen cmd char⟫=

escape ^Zz

.screenrc⟫=

⟪256 colors in screen⟫
autodetach on
⟪enable screen's nethack mode⟫
deflogin on
startup_message off
defscrollback 2048
chdir
shell "-/bin/zsh"
⟪Use C-z for screen cmd char⟫
encoding UTF-8 UTF-8
hardstatus lastline "%H | %-w%{+b r}%n %t%{-}%+w"

.screenrc⟫=

markkeys "h=^B:l=^F:$=^E"

.screenrc⟫=

screen -t Emacs 0 emacs -nw

Reconnect to SSH agent within screen (zsh)⟫=

# http://www.tolaris.com/2011/07/12/
#     reconnecting-your-ssh-agent-to-a-detached-gnu-screen-session/
alias get_ssh_auth_sock="find /tmp/ssh-* -user $USERNAME -name agent\* | tail -n 1"
if [[ $TERM =~ 'screen*' ]]; then
    if [[ -v SSH_CONNECTION ]]; then
        export SSH_AUTH_SOCK=`get_ssh_auth_sock`
        print "Fixing SSH_AUTH_SOCK [`basename $SSH_AUTH_SOCK`]."
    fi
fi

xterm colors⟫=

xterm*VT100*background: ⟪darkest black⟫
xterm*VT100*foreground: ⟪medium white⟫
xterm*color7:           ⟪medium white⟫
xterm*color15:          ⟪light white⟫
xterm*color0:           ⟪darkest black⟫
xterm*color8:           ⟪medium black⟫
xterm*color1:           ⟪medium red⟫
xterm*color9:           ⟪light red⟫
xterm*color2:           ⟪dark green⟫
xterm*color10:          DarkSeaGreen2
xterm*color3:           ⟪medium yellow⟫
xterm*color11:          ⟪light yellow⟫
xterm*color4:           ⟪medium blue⟫
xterm*color12:          ⟪light blue⟫
xterm*color5:           ⟪medium magenta⟫
xterm*color13:          ⟪light magenta⟫
xterm*color6:           ⟪dark cyan⟫
xterm*color14:          ⟪medium cyan⟫

comint faces⟫=

'(comint-highlight-input ((t (:bold t))))
'(comint-highlight-prompt ((t (⟪prompt face⟫))))

term faces⟫=

(setq ansi-term-color-vector
  [unspecified "⟪darkest black⟫" "⟪dark red⟫"
   "⟪dark green⟫" "⟪dark yellow⟫" "⟪dark blue⟫"
   "⟪light magenta⟫" "⟪medium cyan⟫" "⟪dark white⟫"]) ;%

xterm-frobs.el fetch rule⟫=

xterm-frobs.el:
        curl -O ftp://ftp.splode.com/pub/users/friedman/emacs-lisp/xterm-frobs.el

defun tess-frob-xterm⟫=

(defun tess-frob-xterm (frame)
  (when (and (tess-xterm-p) (require 'xterm-frobs nil t))
    (mapc
     (lambda (pair)
       (let ((key (car pair))
             (value (cdr pair)))
         (cond
          ((eq key 'foreground-color) (xterm-set-background-color value))
          ((eq key 'background-color) (xterm-set-foreground-color value))
          ((eq key 'mouse-color) (xterm-set-mouse-foreground-color value))
          ((eq key 'cursor-color) (xterm-set-cursor-color value)))))
     default-frame-alist)))

(add-hook 'after-make-frame-functions 'tess-frob-xterm)

fix backspace

Emacs manual fix for backspace problem⟫=

;; Translate `C-h' to <DEL>.
(keyboard-translate ?\C-h ?\C-?)

Fix backspace on terminals⟫=

(defun tess-fix-backspace-key ()
  "Fix this dumb terminal. Ugh."
  (interactive)
  ⟪Emacs manual fix for backspace problem⟫
  (message "Backspace has been fixed."))
(global-set-key (kbd "C-c b") 'tess-fix-backspace-key)

ANSI colors

ANSI color sequences⟫=

(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

don't echo passwords in comint

Don't echo passwords in comint mode⟫=

(add-hook 'comint-output-filter-functions
          'comint-watch-for-password-prompt)

Emacs

I've been a heavy Emacs user for over twenty years; my .emacs file has been continuously evolving that whole time.

Emacs UI elements

The Echo Area and *Messages*

Increase logging amount⟫=

(setq message-log-max most-positive-fixnum)

Configure XEmacs logging levels⟫=

(setq display-warning-minimum-level 'error
      log-warning-minimal-level     'info)

Reveal Messages buffer in XEmacs⟫=

(when (fboundp 'make-indirect-buffer)
  (make-indirect-buffer " *Message-Log*" "*Messages*"))

The Minibuffer

Minibuffer Electric Default Mode⟫=

(when (fboundp 'minibuffer-electric-default-mode)
  (minibuffer-electric-default-mode 1))

Fix size of temporary buffer windows⟫=

(when (fboundp 'temp-buffer-resize-mode)
  (temp-buffer-resize-mode 1))

Enable minibuffer resizing⟫=

(cond ((not (tess-variable-obsolete-p 'resize-minibuffer-window-exactly))
       (setq resize-minibuffer-window-exactly t)
       (when (fboundp 'resize-minibuffer-mode)
         (resize-minibuffer-mode 1)))
      (t
       (setq max-mini-window-height 0.30)
       (setq resize-mini-window t)))

The mode line

mode-line common⟫=

:inverse-video nil :box (:line-width 2 :style released-button)

mode-line bg⟫=

:background "⟪dark blue (alt)⟫"

mode-line fg⟫=

⟪default fg⟫

Standard mode-line face⟫=

⟪mode-line fg⟫ ⟪mode-line bg⟫ ⟪mode-line common⟫

mode-line faces⟫=

'(mode-line ((t (⟪Standard mode-line face⟫))))
'(modeline ((t (⟪Standard mode-line face⟫))))

mode-line faces⟫=

'(mode-line-inactive ((t (⟪mode-line fg⟫ :background "⟪medium black⟫"
                         ⟪mode-line common⟫))))

mode-line faces⟫=

'(mode-line-highlight ((t (:foreground "black" :background "light sky blue"
                          ⟪mode-line common⟫))))

XEmacs special mode-line face⟫=

:foreground "⟪medium yellow⟫" ⟪mode-line bg⟫ ⟪mode-line common⟫

mode-line faces⟫=

'(modeline-buffer-id ((t (⟪XEmacs special mode-line face⟫))))
'(modeline-mousable ((t (⟪XEmacs special mode-line face⟫))))
'(modeline-mousable-minor-mode ((t (⟪XEmacs special mode-line face⟫))))

Disable Emacs menubar⟫=

Emacs*menuBar:             false

disbale menu bar in elisp⟫=

(when (fboundp 'menu-bar-mode)
  (menu-bar-mode (tess-menu-bar-lines)))

(when (featurep 'xemacs)
  (set-specifier menubar-visible-p nil)
  (defun menu-bar-mode ()
    (interactive)
    (set-specifier menubar-visible-p
                   (not (specifier-instance menubar-visible-p)))))

Scroll bars and scrolling

Fix scrolling⟫=

(setq-default scroll-step              1
              scroll-conservatively    most-positive-fixnum
              scroll-up-aggressively   0.0
              scroll-down-aggressively 0.0)

.exrc⟫=

set scroll=1

scroll bar⟫=

(setq frame-title-format
      (concat (if (string-equal (user-login-name) "root")
                  "SU: "
                "")
              "%b (" tess-emacs-name
              "@" (or (getenv "HOST") (system-name) "unknown")
              ")"))

scroll bar⟫=

(cond ((featurep 'xemacs)
       (setq scrollbars-visible-p nil)
       (defun scroll-bar-mode ()
         (interactive)
         (set-specifier
          vertical-scrollbar-visible-p
          (not (specifier-instance vertical-scrollbar-visible-p))))
       (set-specifier horizontal-scrollbar-visible-p nil)
       (set-specifier vertical-scrollbar-visible-p nil))
      ((fboundp 'scroll-bar-mode)
       (scroll-bar-mode -1)))

scroll bar⟫=

(add-hook 'after-make-frame-functions
          (lambda (frame)
            (when (tess-w32-window-system-p frame)
              (scroll-bar-mode -1))))

Tool bars

Disable Emacs toolbar⟫=

Emacs*toolBar:             false
Emacs*verticalScrollBars:  false

tool bar⟫=

(cond ((featurep 'xemacs)
       (customize-set-variable 'toolbar-visible-p nil)
       (setq toolbar-visible-p nil)
       (defun tool-bar-mode ()
         (interactive)
         (set-specifier
          default-toolbar-visible-p
          (not (specifier-instance default-toolbar-visible-p))))
       (set-specifier default-toolbar-visible-p nil))
      ((fboundp 'tool-bar-mode)
       (tool-bar-mode -1)
       (add-to-list 'default-frame-alist '(tool-bar-lines . 0))))

Gutters

gutter⟫=

(when (boundp 'default-gutter-visible-p)
  (set-specifier default-gutter-visible-p nil))

gutter⟫=

(setq progress-feedback-use-echo-area t)

Tooltips

tooltips⟫=

(when (featurep 'tooltip)
  (setq tooltip-gud-tips-p t))

tooltip face⟫=

'(tooltip ((t (:background "⟪light yellow⟫" :foreground "⟪dark black⟫"
               :box (:line-width 4 :color "⟪light yellow⟫")
               :inherit variable-pitch :height 120))))

Speedbar

speedbar faces⟫=

'(speedbar-button-face ((t (:foreground "⟪medium green⟫"))))
'(speedbar-directory-face ((t (⟪directory face⟫))))
'(speedbar-file-face ((t (⟪filename face⟫))))
'(speedbar-highlight-face ((t (⟪highlight face⟫))))
'(speedbar-selected-face ((t (⟪marked face⟫)))) ;%
'(speedbar-tag-face ((t (:foreground "⟪medium yellow⟫"))))

Frames

Disable one-buffer-one-frame-mode⟫=

(setq ns-pop-up-frames nil) ; NSEmacs (Emacs.app, aqua, from NeXT Emacs)
(when (fboundp 'one-buffer-one-frame-mode)
  (setq one-buffer-one-frame nil) ; Aquamacs is dumb.
  (one-buffer-one-frame-mode 0))

Disable CUA-mode⟫=

(cua-mode 0)

Disable smart-frame-positioning-mode⟫=

(when (fboundp 'smart-frame-positioning-mode)
  (smart-frame-positioning-mode 0))

Windows

Buffers

Buffer switching: ido, icomplete, iswitchb

Better buffer switching⟫=

(cond ((require 'ido nil t)
       (ido-mode 1)
       (setq ido-show-dot-for-dired t)
       (setcar (cddr ido-decorations) ",")
       (setcar (cddr (cdr ido-decorations)) ",…"))
      ((and (fboundp 'icomplete-mode)
            (require 'icomplete nil t)
            ;; Only sufficiently recent versions of icomplete-mode allow
            ;; me to tweak its key bindings to my liking, so we should
            ;; only enable it when that's the case
            (boundp 'icomplete-minibuffer-map))
       (icomplete-mode 1))
      ((fboundp 'iswitchb-mode)
       (iswitchb-mode 1))
      ((fboundp 'iswitchb-default-keybindings)
       (iswitchb-default-keybindings)))
(global-set-key (kbd "C-x C-b") (global-key-binding (kbd "C-x b")))

Better buffer switching⟫=

(setq icomplete-show-matches-on-no-input t
      icomplete-separator ","
      read-buffer-completion-ignore-case t)

(eval-after-load "icomplete"
  '(when (boundp 'icomplete-minibuffer-map)
     (let ((map icomplete-minibuffer-map))
       (define-key map (kbd "C-s") 'icomplete-forward-completions)
       (define-key map (kbd "C-r") 'icomplete-backward-completions)
       (define-key map (kbd "RET") 'minibuffer-force-complete-and-exit))))

Better buffer switching⟫=

(add-hook 'iswitchb-define-mode-map-hook
          (lambda ()
            (mapc (lambda (key)
                    (define-key iswitchb-mode-map key nil))
                  (list (kbd "C-n") (kbd "C-k")))))

Better buffer switching⟫=

(eval-after-load "iswitchb"
  '(add-to-list 'iswitchb-buffer-ignore "[*]Completions[*]"))

iswitchb faces⟫=

'(iswitchb-current-match ((t (:foreground "⟪medium cyan⟫"))))
'(iswitchb-single-match ((t (:foreground "⟪medium green⟫"))))
'(iswitchb-invalid-regexp ((t (⟪error face⟫))))
'(iswitchb-virtual-matches ((t (:foreground "⟪dark yellow⟫"))))

icomplete faces⟫=

'(icomplete-first-match ((t (:foreground "⟪medium cyan⟫"))))

ido faces⟫=

'(ido-first-match ((t (:foreground "⟪medium cyan⟫"))))
'(ido-indicator ((t ())))
'(ido-only-match ((t (:foreground "⟪medium green⟫"))))
'(ido-subdir ((t ())))
'(ido-virtual ((t (:foreground "⟪dark yellow⟫"))))

ibuffer face variables⟫=

'(ibuffer-deletion-face 'font-lock-warning-face)
;; '(ibuffer-filter-group-name-face 'bold)
'(ibuffer-marked-face 'font-lock-comment-face)
;; '(ibuffer-title-face 'dired-header)

ibuffer-fontification-alist⟫=

(setq
 ibuffer-fontification-alist
 '(;; read-only buffers
   (10 buffer-read-only eshell-ls-readonly-face)
   ;; emacs' "special" buffers
   (15 (string-match "^*" (buffer-name)) eshell-ls-special-face)
   ;; hidden buffers
   (20 (and (string-match "^ " (buffer-name)) (null buffer-file-name))
       eshell-ls-symlink-face)
   ;; help buffers
   (25 (memq major-mode ibuffer-help-buffer-modes)
       eshell-ls-archive-face)
   ;; IRC buffers
   (30 (eq major-mode 'erc-mode) erc-notice-face)
   ;; dired buffers
   (35 (eq major-mode 'dired-mode) eshell-ls-directory-face)))

Key bindings

.Xmodmap⟫=

! .Xmodmap

clear lock
clear control
clear mod1
clear mod3
clear mod4
clear mod5

⟪Make Caps Lock be an additional Control key⟫
⟪Make the left Windows key be Super⟫
⟪Make the left Alt key be Meta⟫

! .Xmodmap ends here

Make Caps Lock be an additional Control key⟫=

keysym Caps_Lock = Control_L
add Control = Caps_Lock Control_L Control_R

Make the left Windows key be Super⟫=

keycode 115 = Super_L
add Mod3 = Super_L

Make the left Alt key be Meta⟫=

keycode 64 = Meta_L
add Mod1 = Meta_L

Make the right Alt key be Alt⟫=

keycode 113 = Alt_R
add Mod4 = Alt_R

Make the right Windows key be Hyper⟫=

keycode 116 = Hyper_R
add Mod5 = Hyper_R

Windows modifier key bindings⟫=

(setq w32-pass-lwindow-to-system nil
      w32-pass-rwindow-to-system nil
      w32-pass-alt-to-system     nil
      w32-alt-is-meta            t
      w32-pass-apps-to-system    nil
      w32-lwindow-modifier       'super
      w32-rwindow-modifier       'hyper
      w32-apps-modifier          nil)
(define-key function-key-map (kbd "<apps>") (kbd "<menu>"))

Mac modifier key bindings⟫=

(setq ns-alternate-modifier 'super
      ;; ns-function-modifier  'SOMETHING
      ;; ns-control-modifier   'SOMETHING
      ns-command-modifier   'meta)

emacs-app modifiers⟫=

<key>AlternateModifier</key>
<string>alt</string>
<key>CommandModifier</key>
<string>meta</string>
<key>ControlModifier</key>
<string>control</string>
<key>FunctionModifier</key>
<string>none</string>

Sun Type 6 USB keyboard key bindings⟫=

(global-set-key [SunPowerSwitch] 'save-buffers-kill-emacs)
(global-set-key [SunCut]         'clipboard-kill-region)
(global-set-key [SunCopy]        'clipboard-kill-ring-save)
(global-set-key [SunPaste]       'clipboard-yank)
(global-set-key [find]           'apropos)
(global-set-key [SunOpen]        'find-file)
(global-set-key [cancel]         'keyboard-quit)
(global-set-key [SunProps]       'list-text-properties-at)

Sun keyboard key bindings that we get for free⟫=

(global-set-key [f20] 'clipboard-kill-region)
(global-set-key [f16] 'clipboard-kill-ring-save)
(global-set-key [f18] 'clipboard-yank)

Sun keyboard key bindings⟫=

(global-set-key [f14] 'undo)
(global-set-key [f12] 'repeat)
(global-set-key [f19] 'apropos)
(global-set-key [f17] 'find-file)
(global-set-key [f11] 'keyboard-quit)

find-function key bindings⟫=

(when (fboundp 'find-function-setup-keys)
  (find-function-setup-keys))

Key binding for list-text-properties-at⟫=

(when (fboundp 'list-text-properties-at)
  (global-set-key (kbd "C-c p") 'list-text-properties-at))

Key binding for FFAP⟫=

(when (fboundp 'find-file-at-point)
  (global-set-key (kbd "C-c F") 'find-file-at-point))

Fix insertchar key binding⟫=

(global-set-key [insertchar] 'overwrite-mode)

Key binding for bury-buffer⟫=

(mapc (lambda (key)
        (global-set-key key 'bury-buffer))
      (list (kbd "s-z") (kbd "A-z") (kbd "M-z")))

Bindings for the scroll wheel in the mode line⟫=

(global-set-key (kbd "<mode-line> <wheel-down>") 'next-buffer)
(global-set-key (kbd "<mode-line> <wheel-up>") 'previous-buffer)

Duplicate some meta keys on super⟫=

(global-set-key (kbd "C-s-x") 'eval-defun)
(global-set-key (kbd "s-%") 'query-replace)
(global-set-key (kbd "s-/") 'dabbrev-expand)
(global-set-key (kbd "s-:") 'eval-expression)
(global-set-key (kbd "s-;") 'comment-dwim)
(global-set-key (kbd "s-<") 'beginning-of-buffer)
(global-set-key (kbd "s-<SPC>") 'just-one-space)
(global-set-key (kbd "s-<backspace>") 'backward-kill-word)
(global-set-key (kbd "s->") 'end-of-buffer)
(global-set-key (kbd "s-\\") 'delete-horizontal-space)
(global-set-key (kbd "s-b") 'backward-word)
(global-set-key (kbd "s-d") 'kill-word)
(global-set-key (kbd "s-f") 'forward-word)
(global-set-key (kbd "s-l") 'downcase-word)
(global-set-key (kbd "s-p") (kbd "M-p"))
(global-set-key (kbd "s-q") 'fill-paragraph)
(global-set-key (kbd "s-v") 'scroll-down)
(global-set-key (kbd "s-w") 'kill-ring-save)
(global-set-key (kbd "s-x") 'execute-extended-command)
(global-set-key (kbd "s-~") 'not-modified)

Selection

transient mark mode⟫=

(setq zmacs-regions t)

(when (fboundp 'transient-mark-mode)
  (transient-mark-mode 1)
  (setq highlight-nonselected-windows nil
        mark-even-if-inactive         t))

disable shifted selection in XEmacs⟫=

(setq shifted-motion-keys-select-region     nil
      unshifted-motion-keys-deselect-region nil)

multi-region.el fetch rule⟫=

multi-region.el:
        curl -O http://purl.org/NET/wence/multi-region.el

multi-region⟫=

(when (require 'multi-region nil t)
  (global-set-key (kbd "C-c 2") multi-region-map))

multi-region faces⟫=

'(multi-region-face ((t (⟪region face (alt)⟫))))

additional rectangle command bindings⟫=

(let ((map (make-sparse-keymap)))
  (define-key map (kbd "t") 'string-insert-rectangle)
  (global-set-key (kbd "C-c r") map))

Abbrevs

Enable abbrevs⟫=

(setq-default abbrev-mode t)
(when (file-exists-p abbrev-file-name)
  (quietly-read-abbrev-file))

abbrev-definitions⟫=

(define-abbrev-table 'vc-dired-mode-abbrev-table '(
    ))

(define-abbrev-table 'vc-annotate-mode-abbrev-table '(
    ))

(define-abbrev-table 'smarty-mode-abbrev-table '(
    ))

(define-abbrev-table 'sgml-mode-abbrev-table '(
    ))

(define-abbrev-table 'pike-mode-abbrev-table '(
    ("while" "while" c-electric-continued-statement 0)
    ("else" "else" c-electric-continued-statement 0)
    ))

(define-abbrev-table 'outline-mode-abbrev-table '(
    ))

(define-abbrev-table 'objc-mode-abbrev-table '(
    ("while" "while" c-electric-continued-statement 0)
    ("else" "else" c-electric-continued-statement 0)
    ))

(define-abbrev-table 'message-mode-abbrev-table '(
    ))

(define-abbrev-table 'java-mode-abbrev-table '(
    ("while" "while" c-electric-continued-statement 0)
    ("finally" "finally" c-electric-continued-statement 0)
    ("else" "else" c-electric-continued-statement 0)
    ("catch" "catch" c-electric-continued-statement 0)
    ))

(define-abbrev-table 'idl-mode-abbrev-table '(
    ))

(define-abbrev-table 'html-mode-abbrev-table '(
    ))

(define-abbrev-table 'gnus-article-edit-mode-abbrev-table '(
    ))

(define-abbrev-table 'eshell-mode-abbrev-table '(
    ("snv" "svn" nil 1)
    ))

(define-abbrev-table 'erc-mode-abbrev-table '(
    ))

(define-abbrev-table 'docTeX-mode-abbrev-table '(
    ))

(define-abbrev-table 'css-mode-abbrev-table '(
    ))

(define-abbrev-table 'comint-mode-abbrev-table '(
    ))

(define-abbrev-table 'c-mode-abbrev-table '(
    ("while" "while" c-electric-continued-statement 0)
    ("else" "else" c-electric-continued-statement 0)
    ))

(define-abbrev-table 'c++-mode-abbrev-table '(
    ("while" "while" c-electric-continued-statement 0)
    ("else" "else" c-electric-continued-statement 0)
    ("catch" "catch" c-electric-continued-statement 0)
    ))

(define-abbrev-table 'awk-mode-abbrev-table '(
    ))

(define-abbrev-table 'apropos-mode-abbrev-table '(
    ))

(define-abbrev-table 'occur-mode-abbrev-table '(
    ))

(define-abbrev-table 'text-mode-abbrev-table '(
    ))

(define-abbrev-table 'fundamental-mode-abbrev-table '(
    ))

(define-abbrev-table 'sh-mode-abbrev-table '(
    ))

(define-abbrev-table 'makefile-mode-abbrev-table '(
    ))

abbrev-definitions⟫=

(define-abbrev-table 'global-abbrev-table '(
    ("..." "…" nil 1)
    ("ehre" "here" nil 1)
    ("hoebr" "hober" nil 1)
    ("libary" "library" nil 1)
    ("noet" "note" nil 1)
    ("ocmmit" "commit" nil 1)
    ("setp" "step" nil 1)
    ("teh" "the" nil 1)
    ("wbe" "web" nil 1)
    ("yoru" "your" nil 1)
    ))

Completion

Line wrapping: auto-fill-mode and visual-line-mode

filladapt face variables⟫=

;; '(filladapt-debug-indentation-face-1 'highlight)
'(filladapt-debug-indentation-face-2 'secondary-selection)
;; '(filladapt-debug-paragraph-face 'bold)

fill-column⟫=

(setq-default fill-column 72)
(setq emacs-lisp-docstring-fill-column 72)

Basic auto-fill configuration⟫=

(setq-default auto-fill-function 'do-auto-fill)

Basic auto-fill configuration⟫=

(mapc (lambda (mode-hook)
         (add-hook mode-hook 'turn-off-auto-fill))
      '(emacs-lisp-mode-hook sh-mode-hook comint-mode-hook
        shell-mode-hook lisp-mode-hook erc-mode-hook ruby-mode-hook))

defun turn-off-auto-fill⟫=

(defun turn-off-auto-fill ()
  "Unconditionally turn off Auto Fill mode."
  (interactive)
  (auto-fill-mode -1))

longlines⟫=

(setq longlines-wrap-follows-window-size t)

alias longlines with visual-line-mode⟫=

(defalias 'longlines-mode 'visual-line-mode)

Line numbers

setnu.el fetch rule⟫=

setnu.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/setnu.el

linum⟫=

;; linum from g.e.s -- much better than setnu
(when (and (locate-library "linum") (facep 'fringe))
  (setq linum-format (propertize "%5d " 'face 'fringe)))

Key binding for goto-line⟫=

(global-set-key (kbd "C-c l") 'goto-line)

Line and Column numbering⟫=

(line-number-mode 1)
(when (fboundp 'column-number-mode)
  (column-number-mode 1))

Dired

dired faces⟫=

'(dired-directory ((t (⟪directory face⟫))))
'(dired-face-directory ((t (⟪directory face⟫))))

dired faces⟫=

'(dired-face-executable ((t (⟪executable face⟫))))

dired faces⟫=

`(dired-ignored ((t ⟪dim this face when appropriate⟫)))
`(dired-face-boring ((t ⟪dim this face when appropriate⟫)))

dired faces⟫=

`(dired-face-permissions ((t ⟪dim this face when appropriate⟫)))
'(dired-face-setuid ((t (:bold t ⟪executable face⟫))))
`(dired-face-socket ((t ⟪dim this face when appropriate⟫)))

dired faces⟫=

'(dired-symlink ((t (⟪symlink face⟫))))
'(dired-face-symlink ((t (⟪symlink face⟫))))

wdired.el fetch rule⟫=

wdired.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/wdired.el

Dired, the Directory Editor⟫=

(require 'dired-x nil t)

Dired, the Directory Editor⟫=

(setq dired-dwim-target t)

Dired, the Directory Editor⟫=

(setq dired-recursive-deletes 'top
      dired-recursive-copies  'top)

Dired, the Directory Editor⟫=

(when (locate-library "wdired")
  (autoload 'wdired-change-to-wdired-mode "wdired" nil t)
  (add-hook 'dired-load-hook
            (lambda ()
              (define-key dired-mode-map (kbd "r")
                'wdired-change-to-wdired-mode))))

dired faces⟫=

'(dired-flagged ((t (⟪warning face⟫))))
'(dired-face-flagged ((t (⟪warning face⟫))))

dired header face⟫=

:foreground "⟪medium green⟫"

dired faces⟫=

'(dired-header ((t (⟪dired header face⟫))))
'(dired-face-header ((t (⟪dired header face⟫))))

dired faces⟫=

'(dired-mark ((t (:foreground "⟪medium yellow⟫"))))

dired faces⟫=

'(dired-marked ((t (⟪marked face⟫))))
'(dired-face-marked ((t (⟪marked face⟫))))

dired faces⟫=

'(dired-warning ((t (⟪warning face⟫))))

dired face variables⟫=

;; '(dired-header-face 'dired-header)
;; '(dired-mark-face 'dired-mark)
;; '(dired-marked-face 'dired-marked)
;; '(dired-flagged-face 'dired-flagged)
;; '(dired-warning-face 'dired-warning)
'(dired-directory-face 'dired-directory)
;; '(dired-symlink-face 'dired-symlink)
;; '(dired-ignored-face 'dired-ignored)

Emoji

Emoji utilities⟫=

(defvar tess-expand-emoji-flag t
  "Non-nil iff I should fall back to my emoji expansion code.")

(defun tess-emoji-char-p (char)
  "Non-nil iff CHAR is in the Unicode emoji range."
  (and
   ;; Not in blacklist
   (not (memq char '()))
   ;; Ranges
   (or (and (>= char ?\x1f100)
            (< char ?\x1f700))
       (and (>= char ?\x2600)
            (< char ?\x2800)))))

(defun tess-expand-emoji ()
  "Replace emoji with [unicode name of emoji]."
  (while (< (point) (point-max))
    (let ((char (char-after (point))))
      (cond
       ;; Strip out variation selectors
       ((and (>= char ?\xfe00) (< char ?\xfe10))
        (delete-char 1))
       ;; Apple logo
       ((= char ?\xf8ff)
        (insert "[Apple Inc.]")
        (delete-char 1))
       ;; Expand emoji
       ((tess-emoji-char-p char)
        (insert (format "[%s]"
                        (get-char-code-property (char-after (point)) 'name)))
        (delete-char 1))
       ;; Skip other charaters
       (t
        (goto-char (1+ (point))))))))

(defun tess-fixup-emoji-on-mac ()
  "Make Emacs display emoji correctly on Mac."
  (set-fontset-font t 'unicode "Apple Color Emoji" nil 'prepend)
  ;; Disable my fallback emoji expansion hack.
  (setq tess-expand-emoji-flag nil))

Emoji in Gnus⟫=

(defun tess-gnus-article-treat-emoji ()
  "Expand emoji to [unicode name of emoji] in this article."
  (interactive)
  (when tess-expand-emoji-flag
    (with-current-buffer gnus-article-buffer
      (save-excursion
        (let ((inhibit-read-only t))
          (save-restriction
            (article-goto-body)
            (let (buffer-read-only)
              (tess-expand-emoji)))))
    (gnus-article-fill-long-lines t))))

(eval-after-load "gnus-art"
  '(add-hook 'gnus-part-display-hook 'tess-gnus-article-treat-emoji))

Emoji in ERC⟫=

(defun tess-erc-expand-emoji ()
  "Expand emoji to [unicode name of emoji]."
  (goto-char (point-min))
  (tess-expand-emoji))

(when tess-expand-emoji-flag
  (add-hook 'erc-insert-modify-hook 'tess-erc-expand-emoji)
  (add-hook 'erc-send-modify-hook 'tess-erc-expand-emoji))

Emacs theming

color-theme fetch rules⟫=

color-theme.el: color-theme.el.gz
        gzip -d -c color-theme.el.gz > color-theme.el
color-theme.el.gz:
        curl -O http://download.gna.org/color-theme/color-theme.el.gz

preferred color themes⟫=

color-theme-hober2 color-theme-resolve color-theme-hober

custom-theme⟫=

((and (fboundp 'load-theme) (locate-library "hober2-theme"))
 (let ((tess-theme-dir (file-name-directory (locate-library "hober2-theme"))))
   (when (boundp 'custom-theme-load-path)
     (add-to-list 'custom-theme-load-path tess-theme-dir))
   (load "hober2-theme")
   (enable-theme 'hober2)))

color-theme⟫=

((require 'color-theme nil t)
  ;; (setq color-theme-is-cumulative nil)
  (require 'color-theme-hober2 nil t)
  (let ((theme (seq-find 'fboundp '(⟪preferred color themes⟫))))
    (when theme
      (add-hook 'tess-after-local-init-hook theme))))

The hober2 Emacs theme

face-list⟫=

(when (locate-library "face-list")
  (autoload 'customize-face-at "face-list" nil t)
  (global-set-key (kbd "C-c f c") 'customize-face-at)

  (autoload 'describe-face-at "face-list" nil t)
  (global-set-key (kbd "C-c f d") 'describe-face-at))

deftheme hober2⟫=

(deftheme hober2
  "Color theme by Theresa O'Connor <tess@oconnor.cx>.

Like my previous theme, I've attempted to make sure things look
reasonably similar under console or window system. The colors of
`hober2-theme' are often washed-out variants of the colors
of `color-theme-hober'.

Includes antlr, apropos, AUCTeX (font-latex), bbdb, Buffer-menu,
calendar, change-log, comint, compilation, cperl, custom, diary, diff,
dired, ediff, erc, eshell, filladapt, font-lock, forms, gnus,
goto-address, help, highline, hl-line, holiday, html-helper,
hyper-apropos, ibuffer, Info, isearch, jde, makefile, Man, message,
multi-region, nxml, psvn, sgml, sh, show-paren, show-tabs, slime, sldb,
speedbar, tex, view, viper, w3m, widget, woman")

hober2-theme variables⟫=

⟪man face variables⟫
⟪apropos face variables⟫
⟪cperl face variables⟫
⟪dired face variables⟫
⟪erc face variables⟫
⟪filladapt face variables⟫
;; '(forms-ro-face 'custom-comment-tag-face)
;; '(forms-rw-face 'custom-comment-face)

⟪goto-address face variables⟫
'(help-highlight-face 'font-lock-variable-name-face)

⟪hl-line face variables⟫
⟪ibuffer face variables⟫
;; '(list-matching-lines-face 'bold)
'(list-matching-lines-buffer-name-face 'font-lock-type-face)

;; '(view-highlight-face 'highlight)

⟪viper face variables⟫
⟪widget face variables⟫

hober2-theme faces⟫=

⟪default face⟫
⟪antlr faces⟫
⟪bbdb faces⟫
⟪erc ansi bg faces⟫
'(bold ((t (:bold t))))
'(bold-italic ((t (:bold t :slant italic))))

'(border ((t nil)))

'(Buffer-menu-buffer-face ((t (:foreground "⟪light yellow⟫")))) ;%
'(button ((t (⟪button face⟫))))

'(calendar-today-face ((t (:foreground "⟪medium yellow⟫")))) ;%

⟪change log faces⟫
⟪comint faces⟫
⟪compilation faces⟫
⟪cperl faces⟫
⟪css-mode (monnier) faces⟫
'(cursor ((t (:background "⟪medium yellow⟫" ⟪dark fg⟫))))

⟪Custom faces⟫

hober2-theme faces⟫=

'(diary-face ((t (:foreground "⟪medium red⟫"))))
'(diary-button-face ((t (⟪button face⟫))))

⟪diff faces⟫
⟪dired faces⟫
⟪ediff faces⟫
⟪erc faces⟫
`(escape-glyph ((t ⟪dim this face when appropriate⟫)))
⟪eshell faces⟫
⟪erc ansi fg faces⟫
`(file-name-shadow ((t ⟪dim this face when appropriate⟫)))
⟪font latex faces⟫

⟪font lock faces⟫
'(fringe ((t (:background "⟪dark black (alt)⟫" :foreground "⟪light white⟫"))))

⟪gnus faces⟫
'(header-line ((t (:box (:line-width 2
                         :color "⟪dark black (alt)⟫"
                         :style nil)
                   :background "⟪dark black (alt)⟫" :foreground "⟪light white⟫"))))

⟪help faces⟫
⟪html helper faces⟫
⟪hyper apropos faces⟫

hober2-theme faces⟫=

'(highlight ((t (⟪highlight face⟫))))

⟪highline faces⟫
'(holiday-face ((t (:foreground "⟪light magenta⟫"))))

⟪icomplete faces⟫
⟪ido faces⟫
⟪info faces⟫
⟪isearch faces⟫
⟪iswitchb faces⟫
'(italic ((t (:slant italic))))

⟪jde faces⟫
⟪js2 faces⟫

'(link ((t (:foreground "⟪light cyan⟫" ⟪link face⟫))))

'(makefile-shell-face ((t ())))
'(makefile-space-face ((t (⟪whitespace face⟫))))
'(makefile-targets-face ((t ())))

⟪markdown-mode faces⟫

'(match ((t (:background "⟪light blue⟫" :foreground "⟪medium white⟫")))) ;%

'(menu ((t (:background "⟪medium white⟫" :foreground "⟪dark black⟫"))))

⟪message faces⟫
'(minibuffer-prompt ((t (⟪prompt face⟫))))
⟪mm faces⟫

⟪mode-line faces⟫
'(mouse ((t (:foreground "⟪medium yellow⟫" ⟪default bg⟫))))

⟪multi-region faces⟫
⟪nxml faces⟫
⟪mic-paren faces⟫
⟪parenface faces⟫
'(primary-selection ((t (⟪region face⟫))))
⟪psvn faces⟫
⟪rcirc faces⟫

region bg color⟫=

⟪dark blue (alt)⟫

region bg⟫=

:background "⟪region bg color⟫"

region face⟫=

:foreground "⟪light white⟫" ⟪region bg⟫

region face (alt)⟫=

:background "⟪medium blue⟫" :foreground "⟪light white⟫"

hober2-theme faces⟫=

'(region ((t (⟪region face⟫))))

hober2-theme faces⟫=

⟪rng faces⟫

'(scroll-bar ((t (:background "⟪medium white⟫" :foreground "⟪dark black⟫"))))

hober2-theme faces⟫=

'(secondary-selection ((t (⟪region face (alt)⟫))))

⟪sgml faces⟫
`(shadow ((t ⟪dim this face when appropriate⟫)))
⟪shell faces⟫
⟪show paren faces⟫
⟪show tabs faces⟫
⟪slime compliler faces⟫
⟪slime debugger faces⟫
⟪slime repl faces⟫
⟪slime inspector faces⟫
⟪slime reader faces⟫
⟪smerge-mode faces⟫
⟪speedbar faces⟫
'(subscript ((t ())))
'(superscript ((t ())))
'(tex-math-face ((t (⟪math face⟫))))
'(tex-math ((t (⟪math face⟫))))
'(tex-verbatim-face ((t ())))
'(tex-verbatim ((t ())))

'(tool-bar ((t (⟪button face⟫))))
⟪tooltip face⟫

'(trailing-whitespace ((t (⟪whitespace face⟫))))

'(underline ((t (:underline t))))

⟪viper faces⟫
⟪w3m faces⟫
'(whitespace-highlight-face ((t (⟪whitespace face⟫))))
⟪widget faces⟫
⟪woman faces⟫
'(zmacs-region ((t (⟪region face⟫))))

widget face variables⟫=

;; '(widget-mouse-face 'highlight)

widget faces⟫=

'(widget-button-face ((t (⟪link face⟫))))
'(widget-button-pressed-face ((t (⟪link face⟫))))
'(widget-documentation-face ((t (:foreground "⟪medium green⟫")))) ;%
'(widget-field-face ((t (⟪default (alt)⟫))))
`(widget-inactive-face ((t ⟪dim this face when appropriate⟫)))
'(widget-single-line-field-face ((t (⟪default (alt)⟫))))

elisp/hober2-theme.el⟫=

;;; hober2-theme.el --- Theresa O'Connor's second theme.

⟪Elisp Copyright Statement⟫

;;; Commentary:

;; This is my second theme. Apologies for the formatting; this
;; file is automatically extracted from a LaTeX master file.

;;; Code:

(require 'dired) ;; FIXME

⟪deftheme hober2⟫

;; Placate the byte compiler and elint
(defvar window-system)

⟪defun hober2-use-underline-p⟫

⟪defvar hober2-insignificant-face⟫

(custom-theme-set-variables
 'hober2
 ⟪hober2-theme variables⟫)

(custom-theme-set-faces
 'hober2
 ⟪hober2-theme faces⟫)

(provide-theme 'hober2)

;;; hober2-theme.el ends here

Basic faces

darkest black⟫=

black

dark black⟫=

gray4

dark black (alt)⟫=

gray8

medium black⟫=

gray30

light black⟫=

gray40

dark red⟫=

orange red

medium red⟫=

indian red

light red⟫=

IndianRed1

dark green⟫=

DarkGreen

medium green⟫=

medium sea green

light green⟫=

DarkSeaGreen2

dark yellow⟫=

sandy brown

medium yellow⟫=

khaki

light yellow⟫=

lemon chiffon

dark blue⟫=

dark slate blue

dark blue (alt)⟫=

#5f5f87

medium blue⟫=

LightSteelBlue4

light blue⟫=

DodgerBlue3

dark magenta⟫=

dark orchid

medium magenta⟫=

medium orchid

light magenta⟫=

pale violet red

very light magenta⟫=

light pink

dark cyan⟫=

steel blue

medium cyan⟫=

cadet blue

light cyan⟫=

light sea green

dark white⟫=

gray

medium white⟫=

light gray

light white⟫=

white

default bg⟫=

:background "⟪darkest black⟫"

default bg (alt)⟫=

:background "⟪dark black (alt)⟫"

default fg⟫=

:foreground "⟪medium white⟫"

default fg (alt)⟫=

:foreground "⟪dark white⟫"

default face⟫=

'(default ((t (⟪default bg⟫ ⟪default fg⟫
               :stipple nil :box nil :strike-through nil :overline nil
               :underline nil :slant normal :weight normal
               :inverse-video nil))))

directory face⟫=

:foreground "⟪medium yellow⟫"

filename face⟫=

:foreground "⟪medium cyan⟫"

symlink face⟫=

:foreground "⟪medium cyan⟫"

executable face⟫=

:foreground "⟪medium green⟫"

cursor color⟫=

⟪medium yellow⟫

cursor color (alt)⟫=

⟪very light magenta⟫

cursor color (warning)⟫=

⟪light magenta⟫

warning face⟫=

:background "⟪medium red⟫" :foreground "⟪light white⟫"

error face⟫=

⟪warning face⟫ :bold t

whitespace face⟫=

:background "⟪light red⟫" :foreground "⟪medium white⟫"

defvar hober2-insignificant-face⟫=

(defvar hober2-insignificant-face
  (if window-system
     '(:foreground "⟪medium black⟫")
   '()))

dim this face when appropriate⟫=

,hober2-insignificant-face

cyan bg⟫=

:background "⟪medium cyan⟫"

cyan bg (alt)⟫=

:background "⟪dark cyan⟫"

dark fg⟫=

:foreground "⟪dark black⟫"

dark fg (alt)⟫=

:foreground "⟪medium black⟫"

comment face⟫=

:foreground "⟪medium magenta⟫"

comment delimiter face⟫=

⟪comment face (alt)⟫

marked face⟫=

⟪cyan bg⟫ ⟪dark fg⟫

comment face (alt)⟫=

:foreground "⟪dark magenta⟫"

prompt face⟫=

:foreground "⟪light magenta⟫"

button face⟫=

:foreground "⟪dark black⟫" :background "⟪medium white⟫"
:bold t :box (:line-width 1 :style released-button)

pressed button face⟫=

:foreground "⟪dark black⟫" :background "⟪medium white⟫"
:bold t :box (:line-width 1 :style pressed-button)

link face⟫=

:underline t

default (alt)⟫=

:background "⟪medium black⟫" :foreground "⟪light white⟫"

highlight face⟫=

:background "⟪dark green⟫" ⟪default fg⟫ ⟪link face⟫

compilation faces⟫=

'(compilation-warning-face ((t (⟪warning face⟫))))
'(compilation-warning ((t (⟪warning face⟫))))
'(compilation-info-face ((t (⟪comment face⟫))))
'(compilation-info ((t (⟪comment face⟫))))
'(compilation-error-face ((t (⟪comment face⟫))))
'(compilation-error ((t (⟪comment face⟫))))

table-insert

table⟫=

(when (locate-library "table")
  (autoload 'table-insert "table" nil t)
  (global-set-key (kbd "C-c t") 'table-insert))

Org mode

ensure org-mode is autoloaded⟫=

(when (and (not (fboundp 'org-mode))
           (locate-library "org"))
  (autoload 'org-mode "org" nil t))

org-mode⟫=

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key (kbd "C-c o l") 'org-store-link)
(global-set-key (kbd "C-c o a") 'org-agenda)

Deft

deft.el fetch rule⟫=

deft.el:
        curl -O http://jblevins.org/projects/deft/deft.el

Deft⟫=

(setq deft-directory (expand-file-name "~/Notes/")
      deft-text-mode (seq-find 'fboundp '(markdown-mode text-mode)))
(setq deft-extension
      (assoc-default deft-text-mode '((markdown-mode . "md"))
                     'eq "txt"))

;; Completely override Deft's keybindings to be more like Dired and
;; Gnus:
(setq deft-mode-map (make-sparse-keymap))
(define-key deft-mode-map (kbd "a") 'deft-new-file-named)
(define-key deft-mode-map (kbd "d") 'deft-delete-file)
(define-key deft-mode-map (kbd "g") 'deft-refresh)
(define-key deft-mode-map (kbd "n") 'next-line)
(define-key deft-mode-map (kbd "q") 'quit-window)
(define-key deft-mode-map (kbd "p") 'previous-line)
(define-key deft-mode-map (kbd "r") 'deft-rename-file)
(define-key deft-mode-map (kbd "s") 'deft-filter)
(define-key deft-mode-map (kbd "z") 'deft-filter-clear)
(define-key deft-mode-map (kbd "<RET>") 'deft-complete)

EMMS

EMMS⟫=

(when (require 'emms nil t)
  (global-set-key (kbd "s-n") 'emms-next)
  (global-set-key (kbd "s-p") 'emms-previous)
  (global-set-key (kbd "s-s") 'emms-shuffle)
  (global-set-key (kbd "s-<RET>") 'emms-play-directory-tree)
  (global-set-key (kbd "s-<SPC>") 'emms-stop))

tidy.el

tidy.el fetch rule⟫=

tidy.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/tidy.el

http-twiddle

http-twiddle.el fetch rule⟫=

http-twiddle.el:
        curl -O http://fresh.homeunix.net/~luke/misc/emacs/http-twiddle.el

Mathematics

math face⟫=

:foreground "⟪dark yellow⟫"

Mathematics⟫=

(when (locate-library "maxima")
  (autoload 'maxima "maxima" nil t)
  (add-to-list 'auto-mode-alist '("\\.max\\'" . maxima))
  (autoload 'maxima-mode "maxima" nil t))

Mathematics⟫=

(when (locate-library "imaxima")
  (autoload 'imaxima "imaxima" nil t)
  (setq imaxima-pt-size 12
        imaxima-fnt-size "Huge"
        imaxima-image-type 'ps
        imaxima-use-maxima-mode-flag (locate-library "maxima")))

DNS

DNS mode⟫=

(add-hook 'dns-mode-hook
          (lambda ()
            (add-hook 'before-save-hook
                      'dns-mode-soa-increment-serial
                      nil t)))

user-mail-address function

defun user-mail-address⟫=

(unless (fboundp 'user-mail-address)
  (defun user-mail-address ()
    "Returns the value of the `user-mail-address' variable."
    user-mail-address))

generic x

generic-x⟫=

(when (ignore-errors (require 'generic-x))
  (setq default-major-mode 'default-generic-mode))

Browsers, browser engines, and their bug trackers

TTY web browser default⟫=

(setq browse-url-browser-function 'browse-url-lynx-emacs)

Integer thing at point⟫=

(defun tess-intatpt-end-op ()
  (while (looking-at "[0-9]")
    (forward-char 1)))
(put 'integer 'end-op 'tess-intatpt-end-op)

(defun tess-intatpt-beginning-op ()
  (unless (looking-at "[0-9]")
    (backward-char 1))
  (while (looking-at "[0-9]")
    (backward-char 1))
  (forward-char 1))
(put 'integer 'beginning-op 'tess-intatpt-beginning-op)

Bug tracker links⟫=

(defmacro tess-define-bug-linker (cmd docstring format-string)
  `(defun ,cmd (bug-number)
     ,docstring
     (interactive (list (or (thing-at-point 'integer)
                            (read-string "Bug number: "))))
     (browse-url (format ,format-string bug-number))))
(put 'tess-define-bug-linker 'lisp-indent-function 1)
(put 'tess-define-bug-linker 'doc-string-elt 2)

(tess-define-bug-linker tess-moz-bug
  "Browse to the Mozilla bug whose number is at point.
If there's no bug number at point, prompt for one."
  "https://bugzilla.mozilla.org/show_bug.cgi?id=%s")
(tess-define-bug-linker tess-radar-bug
  "Browse to the Radar bug whose number is at point.
If there's no bug number at point, prompt for one."
  "rdar://problem/%s")
(tess-define-bug-linker tess-w3c-bug
  "Browse to the W3C bug whose number is at point.
If there's no bug number at point, prompt for one."
  "http://www.w3.org/Bugs/Public/show_bug.cgi?id=%s")
(tess-define-bug-linker tess-webkit-bug
  "Browse to the WebKit bug whose number is at point.
If there's no bug number at point, prompt for one."
  "https://bugs.webkit.org/show_bug.cgi?id=%s")

(defun tess-read-bug-dwim (&optional num)
  (interactive (list (or (thing-at-point 'integer)
                         (read-string "Bug number: "))))
  (cond
   ((eq (erc-current-network) 'apple)
    (tess-radar-bug num))
   ((save-excursion (re-search-forward "bugs.webkit.org" nil t))
    (tess-webkit-bug num))
   ((save-excursion (re-search-forward "bugzilla.mozilla.org" nil t))
    (tess-moz-bug num))
   ((save-excursion (re-search-forward "www.w3.org[/]Bugs" nil t))
    (tess-w3c-bug num))
   ((save-excursion (re-search-backward "public-html-bugzilla" nil t))
    (tess-w3c-bug num))
   ((save-excursion
      (re-search-backward
       "This notification covers \\(\\d \\)?problemIDs?" nil t))
    (tess-radar-bug num))
   ((and (string-match "^[*]Article" (buffer-name))
         (save-excursion
           (gnus-summary-toggle-header 1)
           (gnus-article-goto-header "Return-path")
           (prog1 (string-equal "bugzilla-daemon@webkit.org"
                                (buffer-substring-no-properties
                                 (+ 2 (point)) (1- (line-end-position))))
             (gnus-summary-toggle-header -1))))
    (tess-webkit-bug num))
   (t (error "Unable to determine bug db for bug #%s" num))))

W3M

.w3m/config⟫=

# Render frames automatically
frame true

# Use ASCII equivalents to display entities
alt_entity true

# Display DEL, S and STRIKE element
display_ins_del true

# Use URL history
use_history true

# Number of remembered URL
history 2048

# Save URL history
save_hist true

# Confirm when quitting with q
confirm_qq false

# Enable Emacs-style line editing
emacs_like_lineedit true

# Wrap search
wrap_search true

# Search case-insensitively
ignorecase_search true

# Enable mouse
use_mouse true

# Editor
editor emacsclient

# Default value for open-URL command
default_url http://www.google.com/

# Enable cookie processing
use_cookie true

# Action to be taken on invalid cookie
accept_bad_cookie true

emacs-w3m⟫=

(autoload 'w3m "w3m" nil t)
(autoload 'w3m-goto-url "w3m" nil t)
(autoload 'w3m-region "w3m")

emacs-w3m⟫=

(setq w3m-home-page
      (if (file-readable-p "~/html/home.html")
          (concat "file://" (expand-file-name "~/html/home.html"))
        "http://tess.oconnor.cx/home"))

emacs-w3m⟫=

(setq w3m-use-toolbar t
      w3m-use-tab     nil
      w3m-key-binding 'info)

emacs-w3m⟫=

(setq w3m-search-default-engine "google")

emacs-w3m⟫=

(setq w3m-command-arguments       '("-F" "-cookie")
      w3m-mailto-url-function     'compose-mail
      browse-url-browser-function 'w3m
      mm-text-html-renderer       'w3m)

emacs-w3m⟫=

(add-hook 'w3m-mode-hook 'tess-hide-trailing-whitespace)

emacs-w3m⟫=

(eval-after-load "w3m"
  '(define-key w3m-mode-map (kbd "z") 'bury-buffer))

emacs-w3m⟫=

(defalias 'eshell/w3m 'w3m)

disable use of ? as completion help in minibuffer⟫=

(define-key minibuffer-local-must-match-map (kbd "?") nil)
(define-key minibuffer-local-completion-map (kbd "?") nil)

emacs-w3m⟫=

(setq w3m-use-cookies t)
(setq w3m-cookie-accept-bad-cookies t)

Gnus w3m⟫=

(when (fboundp 'w3m)
  (setq mm-inline-text-html-renderer 'w3m))

w3m faces⟫=

'(w3m-anchor-face ((t (:foreground "⟪light cyan⟫" ⟪link face⟫)))) ;%
'(w3m-anchor ((t (:foreground "⟪light cyan⟫" ⟪link face⟫)))) ;%
'(w3m-arrived-anchor-face ((t (:foreground "⟪medium cyan⟫" ⟪link face⟫))))
'(w3m-arrived-anchor ((t (:foreground "⟪medium cyan⟫" ⟪link face⟫))))
'(w3m-bitmap-image-face ((t (:foreground "⟪dark black⟫"
                             :background "⟪light white⟫"))))
'(w3m-bitmap-image ((t (:foreground "⟪dark black⟫"
                        :background "⟪light white⟫"))))
'(w3m-bold-face ((t (:foreground "⟪medium green⟫"))))
'(w3m-bold ((t (:foreground "⟪medium green⟫"))))
'(w3m-current-anchor-face ((t (:foreground "⟪light cyan⟫"
                               :bold t ⟪link face⟫))))
'(w3m-current-anchor ((t (:foreground "⟪light cyan⟫"
                          :bold t ⟪link face⟫))))
'(w3m-form-button-face ((t (⟪button face⟫))))
'(w3m-form-button ((t (⟪button face⟫))))
'(w3m-form-button-mouse-face ((t (⟪highlight face⟫))))
'(w3m-form-button-mouse ((t (⟪highlight face⟫))))
'(w3m-form-button-pressed-face ((t (⟪pressed button face⟫))))
'(w3m-form-button-pressed ((t (⟪pressed button face⟫))))
'(w3m-form-face ((t (⟪button face⟫))))
'(w3m-form ((t (⟪button face⟫))))
'(w3m-header-line-location-title-face ((t (:foreground "⟪medium cyan⟫")))) ;%
'(w3m-header-line-location-title ((t (:foreground "⟪medium cyan⟫")))) ;%
'(w3m-header-line-location-content-face ((t (:foreground "⟪medium yellow⟫"))))
'(w3m-header-line-location-content ((t (:foreground "⟪medium yellow⟫"))))
'(w3m-history-current-url-face ((t (:foreground "⟪light yellow⟫"))))
'(w3m-history-current-url ((t (:foreground "⟪light yellow⟫"))))
'(w3m-image-face ((t (:foreground "⟪light green⟫" :bold t))))
'(w3m-image ((t (:foreground "⟪light green⟫" :bold t))))
'(w3m-insert-face ((t (:underline t))))
'(w3m-insert ((t (:underline t))))
'(w3m-link-numbering-face ((t (:foreground "⟪medium green⟫" :bold t)))) ;%
'(w3m-link-numbering ((t (:foreground "⟪medium green⟫" :bold t)))) ;%
'(w3m-strike-through-face ((t (:strike-through t :strikethru t))))
'(w3m-strike-through ((t (:strike-through t :strikethru t))))
'(w3m-underline-face ((t (:underline t))))
'(w3m-underline ((t (:underline t))))

defun tess-follow-link-at-point⟫=

(defun tess-link-at-point (point)
  "Returns the URL at point, if there is one.
This works for links created by `shr', w3/m, and on URLs embedded in text."
  (let ((props (text-properties-at point)))
    (or (plist-get props 'shr-url)
        (plist-get (plist-get props 'w3-hyperlink-info) :href)
        (plist-get props 'w3m-href-anchor)
        (thing-at-point 'url)
        (error "Couldn't determine link at point."))))

(defun tess-follow-link-at-point (point)
  "Try to follow an HTML link at point."
  (interactive "d")
  (browse-url (tess-link-at-point point)))

(defun tess-display-link-at-point (point)
  "Display the HTML link at point."
  (interactive "d")
  (message "URL at point is %s" (tess-link-at-point point)))

(defun tess-kill-link-at-point (point)
  "Put the HTML link at point on the kill ring."
  (interactive "d")
  (kill-new (tess-link-at-point point)))

(add-hook 'gnus-article-mode-hook
          (lambda ()
            (local-set-key (kbd "C-c a") 'tess-follow-link-at-point)
            (local-set-key (kbd "C-c k") 'tess-kill-link-at-point)))

goto-address⟫=

(when (fboundp 'goto-address)
  (setq goto-address-fontify-maximum-size most-positive-fixnum)
  (add-hook 'find-file-hooks 'goto-address))

goto-address face variables⟫=

'(goto-address-url-face 'font-lock-string-face)
;; '(goto-address-url-mouse-face 'highlight)
'(goto-address-mail-face 'font-lock-string-face)
;; '(goto-address-mail-mouse-face 'highlight)

Choose the right browser⟫=

(global-set-key (kbd "C-c a") 'browse-url)
(cond ((eq system-type 'darwin)
       (setq browse-url-browser-function
             'browse-url-default-macosx-browser))
      (t
       (dolist (candidate '("chromium-browser" "google-chrome"))
         (when (executable-find candidate)
           (setq browse-url-browser-function 'browse-url-generic
                 browse-url-generic-program candidate)))))

lj: URLs in emacs-w3m⟫=

(add-to-list 'w3m-uri-replace-alist
             '("\\`lj:\\(.+\\)" w3m-pattern-uri-replace
               "http://www.livejournal.com/users/\\1/"))

LiveJournal

ljupdate, an Emacs LiveJournal client⟫=

;; When I have a local copy of my website, use the ljupdate there.
(let ((web-lib "~/web/html/ljupdate/"))
  (when (file-directory-p web-lib)
    (add-to-list 'load-path web-lib)))

(when (require 'ljupdate nil t)
  (setq lj-cache-login-information t
        lj-default-username        "hober"
        lj-fill-function           'ignore)
  (global-set-key (kbd "C-c j c") 'lj-compose)
  (global-set-key (kbd "C-c j l") 'lj-login)
  ;; handy for developing / testing in *ielm*
  (setq lj "www.livejournal.com"
        dj "www.deadjournal.com"))

Google

Using Google⟫=

(setq google-referer "http://tess.oconnor.cx/")

Using Google⟫=

(when (ignore-errors (require 'g))
  (setq g-user-email "hober0@gmail.com"))

Emacs Lisp List

ELL⟫=

(when (locate-library "ell")
  (setq ell-locate t)
  (setq ell-goto-addr t)
  (autoload 'ell-packages "ell" nil t))

twitter

twit.el fetch rule⟫=

twit.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/twit.el

Using Twitter from within Emacs⟫=

(cond ((locate-library "twitter")
       (autoload 'twitter "twitter" nil t)
       (global-set-key (kbd "C-c t") 'twitter))
      ((locate-library "twit")
       (autoload 'twit-post "twit" nil t)))

(when (locate-library "twittering-mode")
  (autoload 'twit "twittering-mode" nil t)
  ;; Don't forget to set `twittering-password' locally.
  (setq twittering-username "hober")
  ;; Work-around for a bug in `twittering-mode' in some Emacsen.
  (unless (fboundp 'clear-image-cache)
    (defun clear-image-cache (&rest ignore))))

backpack

Using Backpack from within Emacs⟫=

(when (locate-library "backpack")
  (setq backpack-username "hober")

  (defvar tess-backpack-map (make-sparse-keymap))
  (global-set-key (kbd "C-c b") tess-backpack-map)

  (mapc (lambda (cons)
          (let ((command (car cons)))
            (autoload command "backpack" nil t)
            (define-key tess-backpack-map (cdr cons) command)))
        '((backpack-remind             . "r")
          (backpack-remind-from-region . "R"))))

applescript-mode.el fetch rule⟫=

applescript-mode.el:
        curl -O http://jaist.dl.sourceforge.jp/macemacsjp/9401/applescript-mode.el

Ensure after-make-frame-functions get run for first frame⟫=

(defun tess-run-after-make-frame-functions (&optional frame)
  (run-hook-with-args 'after-make-frame-functions
                      (or frame (selected-frame))))
(add-hook 'tess-after-local-init-hook 'tess-run-after-make-frame-functions)

defsubst tess-alist⟫=

(defsubst tess-alist (list)
  "Given LIST of the form (A B .. Z), create an alist of the form
\((A . A) (B . B) .. (Z . Z)). If LIST is nil, return nil. Useful
for making arguments for `completing-read'."
  (mapcar (lambda (item) (cons item item)) list))

defun tess-add-to-list*⟫=

(defun tess-add-to-list* (list-var &rest directories)
  "Add to the value of LIST-VAR each existing directory in DIRECTORIES.
Effectively a multi-argument version of `add-to-list', but custom-made
for variables like `load-path' and `Info-default-directory-list'."
  (mapc (lambda (directory)
          (when (file-directory-p directory)
            (add-to-list list-var (file-name-as-directory directory))))
        directories))
(put 'tess-add-to-list* 'lisp-indent-function 1)

package.el and install.el

Configuring package.el⟫=

(setq package-archives
      '(("gnu" . "http://elpa.gnu.org/packages/")
        ("marmalade" . "http://marmalade-repo.org/packages/")
        ("technomancy" . "http://repo.technomancy.us/emacs/")))

defun tess-install-url⟫=

(defun tess-install-url (url)
    (interactive "sURL: ")
    (let ((filename (car (last (split-string url "/")))))
      (when (= 0 (shell-command (format "curl -o %s \"%s\""
                                        filename url)))
        (install-file filename))))

defun tess-install-url-at-point⟫=

(defun tess-install-url-at-point ()
    (interactive)
    (tess-install-url (thing-at-point-url-at-point)))

install.el fetch rule⟫=

install.el:
        curl -O http://www.iro.umontreal.ca/~monnier/elisp/install.el

autoloads make rule⟫=

autoloads: install.el
        emacs -q --no-site-file -batch -L . -l install.el \
                -eval '(install-update-autoloads "autoloads")'

Use install.el⟫=

;; `locate-file' isn't defined in Emacs 21.
(when (and (not (featurep 'aquamacs))
           (locate-library "install.el")
           (fboundp 'locate-file))
  ;; install.el `require's em-glob.el (part of Eshell). There's a bug in
  ;; XEmacs' em-glob.el: it depends on esh-util.el but does not
  ;; `require' it. So we `require' it here.
  (require 'esh-util)
  ;; XEmacs doesn't bind `site-run-file' or `load-suffixes' by default,
  ;; and install.el assumes they're both bound.
  (let ((site-run-file (if (boundp 'site-run-file)
                           site-run-file
                         nil))
        (load-suffixes (if (boundp 'load-suffixes)
                           load-suffixes
                         '(".elc" ".elc.gz" ".el" ".el.gz"))))
    (require 'install))
  ;; FIXME: Under Emacs, install.el figures out a good value of
  ;; `install-home-dir' by itself, but under XEmacs, it doesn't guess
  ;; correctly, so I explicitly set `install-home-dir' now.
  ;; (setq install-home-dir  tess-elisp-dir
  ;;       install-home-file tess-local-elisp-config)
  ;; don't automatically byte-compile under XEmacs. FIXME.
  (setq install-byte-compile (featurep 'emacs))
  ;; install.el calls `update-directory-autoloads', which isn't defined
  ;; under XEmacs. So I defalias it here.
  ;; (XEmacs only has `batch-update-directory-autoloads'.)
  (unless (fboundp 'update-directory-autoloads)
    (defalias 'update-directory-autoloads 'ignore))
  ⟪defun tess-install-url⟫
  ⟪defun tess-install-url-at-point⟫)

who knows

Poor-man's diminish.el⟫=

(setcar (cdr (assq 'abbrev-mode minor-mode-alist)) " A")
(setcar (cdr (assq 'auto-fill-function minor-mode-alist)) " F")
(let ((el-hook (lambda () (setq mode-name "el"))))
  (add-hook 'emacs-lisp-mode-hook el-hook)
  (add-hook 'lisp-interaction-mode-hook el-hook))
(add-hook 'sh-mode-hook (lambda () (setq mode-name "sh")))

Macro DWIM stuff⟫=

(defun tess-macro-dwim (arg)
  "DWIM keyboard macro recording and executing."
  (interactive "P")
  (if defining-kbd-macro
      (if arg
          (end-kbd-macro arg)
        (end-kbd-macro))
    (if last-kbd-macro
        (call-last-kbd-macro arg)
      (start-kbd-macro arg))))

Macro DWIM stuff⟫=

(defun tess-macro-clear ()
  "Clear out the last keyboard macro."
  (interactive)
  (setq last-kbd-macro nil)
  (message "Last keyboard macro cleared."))

Macro DWIM stuff⟫=

(global-set-key (kbd "<f9>") 'tess-macro-dwim) ;%
(global-set-key (kbd "M-<f9>") 'tess-macro-clear)
(define-key esc-map (kbd "<f9>") 'tess-macro-clear)

provide emacs⟫=

(unless (featurep 'xemacs)
  (provide 'emacs))

multi-tty C-x C-c hack⟫=

(when (featurep 'multi-tty)
  (defun tess-delete-frame-or-kill-emacs ()
    (interactive)
    (if (cdr (frame-list)) ; (> (length (frame-list)) 1)
        (delete-frame)
      (save-buffers-kill-emacs)))
  (global-set-key (kbd "C-x C-c") 'tess-delete-frame-or-kill-emacs))

Define display type predicates⟫=

(when (or (featurep 'xemacs) (not (fboundp 'display-graphic-p)))
  (defun display-graphic-p (&optional display)
    "Is DISPLAY is a graphical display?"
    (tess-window-system display)))

defun display-color-p⟫=

(defun display-color-p (&optional display)
  "Does this display support colors?"
  (or (featurep 'xemacs) (display-graphic-p display)))

Define display type predicates⟫=

;; Not defined in XEmacs.
(unless (fboundp 'display-color-p)
  ⟪defun display-color-p⟫)

(if (fboundp 'console-type)
    (defun tess-tty-p (&rest ignore)
      "Is this a TTY that we're on?"
      (eq (console-type) 'tty))
  (defun tess-tty-p (&optional display)
    "Is this a TTY that we're on?"
    (not (display-graphic-p display))))

(defun tess-xterm-p (&optional display)
  "Non-nil if DISPLAY is an xterm.
If DISPLAY is nil, the current displaly is used."
  (and (tess-tty-p display)
       (let ((TERM (getenv "TERM")))
         (if TERM
             (string-match "^xterm.*\\'" TERM)
           nil))))

Define display type predicates⟫=

(defun tess-w32-window-system-p (&optional frame)
  "Non-nil if FRAME is on a Microsoft Windows display.
If FRAME is nil, the current frame is used."
  (memq (tess-window-system frame) '(w32 win32)))

(defun tess-aqua-p (&optional frame)
  "Non-nil if FRAME is on a macOS display.
If FRAME is nil, the current frame is used."
  (memq (tess-window-system frame) '(mac ns)))

(defun tess-menu-bar-lines (&optional frame)
  "Returns the number of menu bar lines to be used on FRAME."
  (if (tess-aqua-p frame) 1 0))

Define operating system type predicates⟫=

(defconst tess-w32-flag (eq system-type 'windows-nt)
  "Are we running under Microsoft Windows?")

(defconst tess-sufficiently-bsd-like-flag
  (memq system-type '(berkeley-unix darwin))
  "Are we running on a sufficiently BSD-like system?")

(defconst tess-lion-flag
  (and (eq system-type 'darwin)
       (version<= operating-system-release "11"))
  "Are we running on OS X Lion?")

defconst tess-emacs-name⟫=

(defconst tess-emacs-name
  (let ((version-int (number-to-string emacs-major-version)))
    (cond ((featurep 'xemacs) (concat "XEmacs-" version-int "."
                                   (number-to-string emacs-minor-version)))
          (t  (concat "Emacs-" version-int))))
  "The name of this Emacs.")

Configure load-path⟫=

(dolist (dir (list "~/web/entries/elisp/" "~/web/lib/"))
  (when (file-directory-p dir)
    (add-to-list 'load-path dir)))

Configure load-path⟫=

(defsubst tess-file-in-workspace (file)
  (expand-file-name file tess-workspace))

(apply 'tess-add-to-list* 'load-path
  (mapcar 'tess-file-in-workspace
          '("bikeshed/emacs" "editorconfig-emacs" "facebook-el" "gitsum"
            "ljupdate" "markdown-mode" "mediawiki-el" "ninja/misc"
            "slime")))

Configure load-path⟫=

;; Ducking the incompatible byte-code issue.
(unless (featurep 'xemacs)
  (apply 'tess-add-to-list* 'load-path
    (mapcar 'tess-file-in-workspace
            '("37emacs" "auctex" "bbdb/lisp" "circe" "emacs-w3m" "erc"
              "g-client" "gnus/lisp" "js2-mode/build" "nxml"))))

Configure Info-default-directory-list⟫=

(apply 'tess-add-to-list* 'Info-default-directory-list
  (mapcar 'tess-file-in-workspace
          '("auctex/doc""bbdb/texinfo" "emacs-w3m/doc" "gnus/texi")))

defsubst tess-variable-obsolete-p⟫=

(defsubst tess-variable-obsolete-p (variable)
  "Non-nil if VARIABLE is marked as obsolete."
  (get variable 'byte-obsolete-variable))

defun propertize⟫=

(defun propertize (string &rest props)
  "Propertize STRING with PROPS.
Copied from `erc-propertize'."
  (let ((length (length string)))
    (while props
      (put-text-property 0 length (car props) (cadr props) string)
      (setq props (cddr props))))
  string)

Emacs' Custom mode

Host-specific customizations⟫=

(setq custom-unlispify-tag-names       nil
      custom-unlispify-menu-entries    nil
      custom-unlispify-remove-prefixes nil)

Host-specific customizations⟫=

(setq custom-file
      (expand-file-name (concat tess-emacs-name "-custom.el")
                        tess-elisp-dir))
(load custom-file t)

Custom faces⟫=

'(custom-button ((t (⟪button face⟫))))
'(custom-button-face ((t (⟪button face⟫))))
'(custom-button-pressed ((t (⟪pressed button face⟫))))
'(custom-button-pressed-face ((t (⟪pressed button face⟫))))
'(custom-face-tag ((t (:bold t))))
'(custom-face-tag-face ((t (:bold t))))
'(custom-variable-tag ((t (:bold t))))
'(custom-variable-tag-face ((t (:bold t))))
'(custom-state ((t (:foreground "⟪medium green⟫"))))
'(custom-state-face ((t (:foreground "⟪medium green⟫"))))

Show tabs

show tabs faces⟫=

'(show-tabs-space ((t (⟪whitespace face⟫))))
'(show-tabs-space-face ((t (⟪whitespace face⟫))))
'(show-tabs-tab ((t (⟪whitespace face⟫))))
'(show-tabs-tab-face ((t (⟪whitespace face⟫))))

Trailing whitespace

Highlight Trailing Whitespace⟫=

(if (boundp 'show-trailing-whitespace)
    (progn
      ⟪Enable highlighting trailing whitespace for Emacs 21⟫)
  (defalias 'tess-hide-trailing-whitespace 'ignore))

Enable highlighting trailing whitespace for Emacs 21⟫=

(setq-default show-trailing-whitespace t)

(defun tess-hide-trailing-whitespace ()
  "Do not highlight trailing whitespace in this buffer."
  (interactive)
  (setq show-trailing-whitespace nil))

(defun tess-show-trailing-whitespace ()
  "Highlight trailing whitespace in this buffer."
  (interactive)
  (setq show-trailing-whitespace t))

(defun tess-toggle-show-trailing-whitespace ()
  "Highlight trailing whitespace in this buffer."
  (interactive)
  (setq show-trailing-whitespace (not show-trailing-whitespace)))

(mapc (lambda (mode-hook)
        (add-hook mode-hook
                  'tess-hide-trailing-whitespace))
      '(Buffer-menu-mode-hook custom-mode-hook text-mode-hook
        term-mode-hook Info-mode-hook comint-mode-hook
        buffer-menu-mode-hook apropos-mode-hook
        tooltip-show-hook gnus-article-mode-hook mail-mode-hook
        gnus-summary-mode-hook message-mode-hook
        gnus-group-mode-hook eshell-mode-hook w3-mode-hook
        initial-calendar-window-hook))

(mapc (lambda (mode-hook)
        (add-hook mode-hook
                  'tess-show-trailing-whitespace))
      '(latex-mode-hook LaTeX-mode-hook html-mode-hook))

Emacs in various window systems

Windowing⟫=

⟪Configuring the frame alists⟫
⟪disbale menu bar in elisp⟫
(when (display-graphic-p)
  ⟪scroll bar⟫
  ⟪tool bar⟫
  (when (featurep 'xemacs)
    ⟪gutter⟫)

  ⟪tooltips⟫)

(when (display-graphic-p)
  ⟪Mouse focus⟫
  ⟪Fix pasting in X11⟫
  (cond ((fboundp 'mouse-wheel-mode)
         ⟪mouse-wheel-mode⟫)
        ((locate-library "mwheel")
         ⟪mwheel⟫)))

emacs-app default-frame-alist⟫=

<key>Left</key>
<string>0</string>
<key>Top</key>
<string>22</string>
<key>InternalBorderWidth</key>
<string>2</string>
<key>Menus</key>
<string>YES</string>
<key>VerticalScrollBars</key>
<string>NO</string>

Fonts

Monospaced 12⟫=

-*-bitstream vera sans mono-medium-r-*-*-12-*-*-*-*-*-*-*

Monospaced 12 Bold⟫=

-*-bitstream vera sans mono-bold-r-*-*-12-*-*-*-*-*-*-*

Monospaced 14⟫=

-*-bitstream vera sans mono-medium-r-*-*-14-*-*-*-*-*-*-*

Monospaced 14 Bold⟫=

-*-bitstream vera sans mono-bold-r-*-*-14-*-*-*-*-*-*-*

lucidatypewriter 17⟫=

-*-lucidatypewriter-medium-r-*-*-17-*-*-*-*-*-*-*

Monospaced 17⟫=

-*-bitstream vera sans mono-medium-r-*-*-17-*-*-*-*-*-*-*

Monospaced 18⟫=

-*-bitstream vera sans mono-medium-r-*-*-18-*-*-*-*-*-*-*

Monospaced 18 Bold⟫=

-*-bitstream vera sans mono-bold-r-*-*-18-*-*-*-*-*-*-*

lucidatypewriter 20⟫=

-*-lucidatypewriter-medium-r-*-*-20-*-*-*-*-*-*-*

Monospaced 24⟫=

-*-bitstream vera sans mono-medium-r-*-*-24-*-*-*-*-*-*-*

Monospaced 24 Bold⟫=

-*-bitstream vera sans mono-bold-r-*-*-24-*-*-*-*-*-*-*

Font configuration⟫=

(setq ns-antialias-text t)

Font configuration⟫=

(defvar tess-fonts
  '(;; The best
    "Menlo"
    ;; Very nice console font from Microsoft
    "Consolas"
    ;; Free-as-in-* options
    "Inconsolata"
    "Ubuntu Mono"
    "Monospace"
    "DejaVu Sans Mono"
    ;; Decent defaults on the Mac
    "Andale Mono" "Monaco"
    ;; My old X11 standbys
    "Screen" "Lucida Console"
    ;; A fallback that's on every system ever.
    "Courier")
  "Fonts I like, in decreasing order of preference.")

(defvar tess-typographic-scale
  '(6 7 8 9 10 11 12 14 16 18 21 24 ;36 48 60 72
      )
  "The typographic scale used for selecting a font size.")

(defvar tess-screen-height-to-type-size-ratio 56.0
  "Ratio of screen height (in pixels) to my preferred type size.")

(defun tess-closest-traditional-type-size (size)
  "Return the entry in `tess-typographic-scale' closest to SIZE."
  (caar (sort (mapcar (lambda (candidate)
                        (cons candidate (abs (- size candidate))))
                      tess-typographic-scale)
              (lambda (a b) (< (cdr a) (cdr b))))))

(defun tess-guess-font-size ()
  "Guess an appropriate font size for this display."
  (tess-closest-traditional-type-size
   (/ (display-pixel-height) tess-screen-height-to-type-size-ratio)))

(defvar tess-font-size (if window-system (tess-guess-font-size) nil)
  "My preferred font size.
Can be overridden in local.el.")

(if (fboundp 'font-family-list)
    ;; New font backend
    (progn
      (defun tess-font-spec (font size)
        (format "%s-%d" font size))

      (defun tess-find-font ()
        "Return the first available font listed in `tess-fonts'."
        (let ((family-list (font-family-list)))
          (seq-find (lambda (font) (member font family-list))
                   tess-fonts))))

  ;; Old font backend
  (defun tess-font-spec (font size)
    (format "-*-%s-*-r-*-*-%d-*-*-*-*-*-*-*" (downcase font) size))

  (defun tess-find-font ()
    "Return the first available font listed in `tess-fonts'."
    (seq-find (lambda (font)
               (x-list-fonts (tess-font-spec font tess-font-size)))
             tess-fonts))

  (defun font-family-list ()
    "Dummy `font-family-list'.
So that `tess-set-font's `interactive' spec works in old Emacsen."
    tess-fonts))

(defvar tess-font nil
  "My preferred font.
Can be overridden in local.el.")

(defun tess-font-init ()
  (when window-system
    (setq tess-font (tess-find-font))))

(add-hook 'tess-after-local-init-hook 'tess-font-init)

(defun tess-set-font (&optional font size)
  "Figure out and install which font and size I use on this system.
If called interactively, prompts the user for the font and size to use."
  (interactive
   (list (completing-read (format "Font (default %s): " tess-font)
                          (font-family-list) nil t nil nil tess-font)
         (read-number "Size: " (tess-guess-font-size))))
  (let* ((font (or font (tess-find-font)))
         (size (or size tess-font-size))
         (font-spec (tess-font-spec font size)))
    (setq tess-font-size size)
    (add-to-list 'default-frame-alist (cons 'font font-spec))
    (set-frame-font font-spec)))

(unless (tess-tty-p)
  (add-hook 'tess-after-local-init-hook 'tess-set-font)
  ;; Now that we've picked a font, we can fixup Emacs' fontset to
  ;; correctly display emoji.
  (when (and (tess-aqua-p)
             (version<= emacs-version "25.0.91"))
    (add-hook 'tess-after-local-init-hook 'tess-fixup-emoji-on-mac)))

(when (fboundp 'text-scale-increase)
  (global-set-key (kbd "M-=") 'text-scale-increase)
  (global-set-key (kbd "M--") 'text-scale-decrease))

emacs-app font settings⟫=

<key>Font</key>
<string>Inconsolata</string>
<key>FontSize</key>
<string>18</string>
<key>GSFontAntiAlias</key>
<string>YES</string>
<key>NSFontPanelAttributes</key>
<string>1, 0</string>
<key>NSFontPanelPreviewHeight</key>
<real>0.0</real>
<key>NSWindow Frame NSFontPanel</key>
<string>1001 153 445 270 0 0 1680 1028 </string>
<key>UseQuickdrawSmoothing</key>
<string>NO</string>

Emacs geometry at startup

Configuring the frame alists⟫=

(setq default-frame-alist '())

⟪defun tess-frob-xterm⟫
⟪Font configuration⟫

(when (featurep 'emacs)
  (add-to-list 'default-frame-alist '(wait-for-wm . nil))
  (add-to-list 'default-frame-alist
               (cons 'menu-bar-lines (tess-menu-bar-lines))))

(defvar tess-emacs-width nil
  "Iff non-null, the initial width that Emacs should use.")
(defvar tess-emacs-height nil
  "Iff non-null, the initial height that Emacs should use.")
(defvar tess-emacs-top nil
  "Iff non-null, the initial top that Emacs should use.")
(defvar tess-emacs-left nil
  "Iff non-null, the initial left that Emacs should use.")

(defun tess-reset-emacs-geometry ()
  (set-frame-parameter nil 'width tess-emacs-width)
  (set-frame-parameter nil 'height tess-emacs-height)
  (set-frame-parameter nil 'top 0)
  (set-frame-parameter nil 'left 0))

(defun tess-respond-to-screen-geometry ()
  (interactive)
  (tess-set-font nil (tess-guess-font-size))
  (setq tess-emacs-width 81)
  (cond ((= (display-pixel-width) 1280) ;; 12" MacBooks
         (setq tess-emacs-height 46))
        ((and (= (display-pixel-width) 1366) ;; yt
              (eq system-type 'gnu/linux))
         (setq tess-emacs-height 34))
        ((and (= (display-pixel-width) 1366) ;; oban
              (eq system-type 'darwin))
         (setq tess-emacs-height 44))
        ((= (display-pixel-width) 2560) ;; 27" iMacs
         (setq tess-emacs-height 47)))
  (tess-reset-emacs-geometry))

(defun tess-init-emacs-geometry ()
  (when window-system
    (when tess-emacs-width
      (add-to-list 'default-frame-alist (cons 'width tess-emacs-width)))
    (when tess-emacs-height
      (add-to-list 'default-frame-alist (cons 'height tess-emacs-height)))
    (when tess-emacs-left
      (add-to-list 'default-frame-alist (cons 'left tess-emacs-height)))
    (when tess-emacs-top
      (add-to-list 'default-frame-alist (cons 'top tess-emacs-top))))
  ;; Finally, ensure both frame alists are the same.
  (setq initial-frame-alist default-frame-alist))

(add-hook 'tess-before-local-init-hook 'tess-init-emacs-geometry)

(when window-system
  (add-hook 'tess-after-local-init-hook 'tess-respond-to-screen-geometry))

Emacs stack size

max-lisp-eval-depth⟫=

1500

max-specpdl-size⟫=

3000

Configure max-lisp-eval-depth and max-specpdl-size⟫=

(setq max-lisp-eval-depth ⟪max-lisp-eval-depth⟫
      max-specpdl-size    ⟪max-specpdl-size⟫)

Garbage collect when tabbing away from Emacs⟫=

(add-hook 'focus-out-hook 'garbage-collect)

Mouse wheels

mouse-wheel-mode⟫=

(mouse-wheel-mode 1)

mwheel⟫=

(unless (fboundp 'mwheel-install)
  (autoload 'mwheel-install "mwheel" nil nil))
(setq mwheel-follow-mouse t)
(setq mwheel-scroll-amount '(4 . 1))
(mwheel-install)

Mouse focus⟫=

(setq focus-follows-mouse (eq (tess-window-system) 'x)
      mouse-autoselect-window t)

Indicate emtpy lines

indicate-empty-lines⟫=

(setq-default indicate-empty-lines       t
              indicate-buffer-boundaries t)

indicate-empty-lines⟫=

(let ((hook (lambda ()
              (setq indicate-empty-lines       nil
                    indicate-buffer-boundaries nil)))
      (mode-hooks '(shell-mode-hook term-mode-hook gnus-article-mode-hook
                    gnus-summary-mode-hook gnus-group-mode-hook
                    eshell-mode-hook)))
  (mapc (lambda (mode-hook)
          (add-hook mode-hook hook))
        mode-hooks))

CSV in Emacs

csv.el fetch rule⟫=

csv.el:
        curl -o csv.el http://ulf.epplejasper.de/downloads/csv.el

CSV⟫=

(autoload 'csv-parse-buffer "csv")

DOM and HTTP libraries for Emacs

dom.el fetch rule⟫=

dom.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/dom.el

http-FOO.el fetch rules⟫=

SAVANNAH_VIEWVC=http://cvs.savannah.gnu.org/viewvc/*checkout*
http-cookies.el http-get.el http-post.el:
        curl -o $*.el $(SAVANNAH_VIEWVC)/http-emacs/$*.el?root=http-emacs

Local variable specs

defun tess-insert-local-variables-spec⟫=

(defun tess-insert-local-variables-spec ()
  "Insert a minimal local variables spec for this buffer."
  (interactive)
  (save-excursion
    (save-restriction
      (widen)
      (goto-char (point-min))
      ;; FIXME: only strip the last 5 characters when they're "-mode"
      (insert (format "-*- mode: %s; coding: %s -*-"
                      (substring (symbol-name major-mode) 0 -5)
                      buffer-file-coding-system))
      ;; If there's some kind of local comment syntax, ensure the local
      ;; variables spec lives in one.
      (when comment-start
        (comment-region (point-min) (point)))
      (insert "\n"))))

HTML entities

html4 entity map⟫=

(defvar tess-html4-entity-map
  '(;; latin-1
    ("nbsp" . 160) ("iexcl" . 161) ("cent" . 162) ("pound" . 163)
    ("curren" . 164) ("yen" . 165) ("brvbar" . 166) ("sect" . 167)
    ("uml" . 168) ("copy" . 169) ("ordf" . 170) ("laquo" . 171)
    ("not" . 172) ("shy" . 173) ("reg" . 174) ("macr" . 175)
    ("deg" . 176) ("plusmn" . 177) ("sup2" . 178) ("sup3" . 179)
    ("acute" . 180) ("micro" . 181) ("para" . 182) ("middot" . 183)
    ("cedil" . 184) ("sup1 #185") ("ordm" . 186) ("raquo" . 187)
    ("frac14" . 188) ("frac12" . 189) ("frac34" . 190) ("iquest" . 191)
    ("Agrave" . 192) ("Aacute" . 193) ("Acirc" . 194) ("Atilde" . 195)
    ("Auml" . 196) ("Aring" . 197) ("AElig" . 198) ("Ccedil" . 199)
    ("Egrave" . 200) ("Eacute" . 201) ("Ecirc" . 202) ("Euml" . 203)
    ("Igrave" . 204) ("Iacute" . 205) ("Icirc" . 206) ("Iuml" . 207)
    ("ETH" . 208) ("Ntilde" . 209) ("Ograve" . 210) ("Oacute" . 211)
    ("Ocirc" . 212) ("Otilde" . 213) ("Ouml" . 214) ("times" . 215)
    ("Oslash" . 216) ("Ugrave" . 217) ("Uacute" . 218) ("Ucirc" . 219)
    ("Uuml" . 220) ("Yacute" . 221) ("THORN" . 222) ("szlig" . 223)
    ("agrave" . 224) ("aacute" . 225) ("acirc" . 226) ("atilde" . 227)
    ("auml" . 228) ("aring" . 229) ("aelig" . 230) ("ccedil" . 231)
    ("egrave" . 232) ("eacute" . 233) ("ecirc" . 234) ("euml" . 235)
    ("igrave" . 236) ("iacute" . 237) ("icirc" . 238) ("iuml" . 239)
    ("eth" . 240) ("ntilde" . 241) ("ograve" . 242) ("oacute" . 243)
    ("ocirc" . 244) ("otilde" . 245) ("ouml" . 246) ("divide" . 247)
    ("oslash" . 248) ("ugrave" . 249) ("uacute" . 250) ("ucirc" . 251)
    ("uuml" . 252) ("yacute" . 253) ("thorn" . 254) ("yuml" . 255)
    ;; special
    ; ("quot" . 34) ("amp" . 38) ("lt" . 60) ("gt" . 62)
    ("OElig" . 338) ("oelig" . 339) ("Scaron" . 352) ("scaron" . 353)
    ("Yuml" . 376) ("circ" . 710) ("tilde" . 732) ("ensp" . 8194)
    ("emsp" . 8195) ("thinsp" . 8201) ("zwnj" . 8204) ("zwj" . 8205)
    ("lrm" . 8206) ("rlm" . 8207) ("ndash" . 8211) ("mdash" . 8212)
    ("lsquo" . 8216) ("rsquo" . 8217) ("sbquo" . 8218) ("ldquo" . 8220)
    ("rdquo" . 8221) ("bdquo" . 8222) ("dagger" . 8224) ("Dagger" . 8225)
    ("permil" . 8240) ("lsaquo" . 8249) ("rsaquo" . 8250) ("euro" . 8364)
    ;; symbol
    ("fnof" . 402) ("Alpha" . 913) ("Beta" . 914) ("Gamma" . 915)
    ("Delta" . 916) ("Epsilon" . 917) ("Zeta" . 918) ("Eta" . 919)
    ("Theta" . 920) ("Iota" . 921) ("Kappa" . 922) ("Lambda" . 923)
    ("Mu" . 924) ("Nu" . 925) ("Xi" . 926) ("Omicron" . 927)
    ("Pi" . 928) ("Rho" . 929) ("Sigma" . 931) ("Tau" . 932)
    ("Upsilon" . 933) ("Phi" . 934) ("Chi" . 935) ("Psi" . 936)
    ("Omega" . 937) ("alpha" . 945) ("beta" . 946) ("gamma" . 947)
    ("delta" . 948) ("epsilon" . 949) ("zeta" . 950) ("eta" . 951)
    ("theta" . 952) ("iota" . 953) ("kappa" . 954) ("lambda" . 955)
    ("mu" . 956) ("nu" . 957) ("xi" . 958) ("omicron" . 959)
    ("pi" . 960) ("rho" . 961) ("sigmaf" . 962) ("sigma" . 963)
    ("tau" . 964) ("upsilon" . 965) ("phi" . 966) ("chi" . 967)
    ("psi" . 968) ("omega" . 969) ("thetasym" . 977) ("upsih" . 978)
    ("piv" . 982) ("bull" . 8226) ("hellip" . 8230) ("prime" . 8242)
    ("Prime" . 8243) ("oline" . 8254) ("frasl" . 8260) ("weierp" . 8472)
    ("image" . 8465) ("real" . 8476) ("trade" . 8482) ("alefsym" . 8501)
    ("larr" . 8592) ("uarr" . 8593) ("rarr" . 8594) ("darr" . 8595)
    ("harr" . 8596) ("crarr" . 8629) ("lArr" . 8656) ("uArr" . 8657)
    ("rArr" . 8658) ("dArr" . 8659) ("hArr" . 8660) ("forall" . 8704)
    ("part" . 8706) ("exist" . 8707) ("empty" . 8709) ("nabla" . 8711)
    ("isin" . 8712) ("notin" . 8713) ("ni" . 8715) ("prod" . 8719)
    ("sum" . 8721) ("minus" . 8722) ("lowast" . 8727) ("radic" . 8730)
    ("prop" . 8733) ("infin" . 8734) ("ang" . 8736) ("and" . 8743)
    ("or" . 8744) ("cap" . 8745) ("cup" . 8746) ("int" . 8747)
    ("there4" . 8756) ("sim" . 8764) ("cong" . 8773) ("asymp" . 8776)
    ("ne" . 8800) ("equiv" . 8801) ("le" . 8804) ("ge" . 8805)
    ("sub" . 8834) ("sup" . 8835) ("nsub" . 8836) ("sube" . 8838)
    ("supe" . 8839) ("oplus" . 8853) ("otimes" . 8855) ("perp" . 8869)
    ("sdot" . 8901) ("lceil" . 8968) ("rceil" . 8969) ("lfloor" . 8970)
    ("rfloor" . 8971) ("lang" . 9001) ("rang" . 9002) ("loz" . 9674)
    ("spades" . 9824) ("clubs" . 9827) ("hearts" . 9829) ("diams" . 9830)
    )
  "Alist mapping HTML 4.01 named character entity references to their
  numerical counterparts. Taken from the HTML 4.01 specification:
    http://www.w3.org/TR/html401/")

tess-run-executable

defun tess-run-executable⟫=

(defun tess-run-executable (executable &rest args)
  ""
  (with-temp-buffer
    (apply 'call-process executable nil t nil args)
    (buffer-substring (point-min) (1- (point-max)))))

mwe-log-commands

mwe-log-commands.el fetch rule⟫=

mwe-log-commands.el:
        curl -O http://www.foldr.org/~michaelw/emacs/mwe-log-commands.el

load home init file

load-home-init-file⟫=

;; Make sure that XEmacs doesn't try to move this file somewhere else.
(setq load-home-init-file t)

ucs-insert

bind ucs-insert to C-c u⟫=

(global-set-key (kbd "C-c u") 'ucs-insert)

fix emacs pasting in X11

Fix pasting in X11⟫=

(setq-default mouse-yank-at-point t)

tess-wash-smart-quotes

defun tess-wash-smart-quotes⟫=

(defun tess-wash-smart-quotes ()
  "Replace MS smart quotes with normal quotes in this buffer."
  (interactive)
  (save-excursion
    (let ((fixes '((342396 . "\"") (342392 . "'") (342387 . "--")
                   (342397 . "\"") (342393 . "'"))))
      (goto-char (point-min))
      (while (/= (point) (point-max))
        (let* ((this (char-after (point)))
               (match (assq this fixes)))
          (when match
            (delete-char 1)
            (insert (cdr match))))
        (forward-char 1)))))

disable emacs splash screen

Disable the Emacs splash screen⟫=

(setq inhibit-startup-message t
      initial-major-mode      'lisp-interaction-mode)

fix common emacs typos

Fix common Emacs typos⟫=

(global-set-key (kbd "C-x C-g") 'keyboard-quit)
(global-set-key (kbd "C-x C-k") 'kill-buffer)
(global-set-key (kbd "C-x f") 'find-file)

visual bell

visual-bell⟫=

(setq ring-bell-function 'ignore
      visible-bell       nil)

(defun tess-ding ()
  "Like `ding', but always makes a noise."
  (let ((visual-bell nil) (ring-bell-function nil))
    (ding)))

always y-or-n

defalias yes-or-no-p⟫=

(defalias 'yes-or-no-p 'y-or-n-p)

enable some emacs commands disabled by default

Enable disabled commands⟫=

(mapc (lambda (sym)
        (put sym 'disabled nil))
      '(downcase-region erase-buffer eval-expression narrow-to-page
        narrow-to-region upcase-region))

Enable disabled commands⟫=

(setq minibuffer-max-depth         nil ; XEmacs
      enable-recursive-minibuffers t)  ; Emacs

Enable disabled commands⟫=

(when (featurep 'emacs)
  (require 'mb-depth nil t)
  (cond
   ((fboundp 'minibuffer-depth-indicate-mode)
    (minibuffer-depth-indicate-mode 1))
   ((fboundp 'minibuffer-indicate-depth-mode)
    (minibuffer-indicate-depth-mode 1))))

mb-depth fetch rule⟫=

mb-depth.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/mb-depth.el

indent-tabs-mode

indent-tabs-mode⟫=

(setq-default indent-tabs-mode nil)

editorconfig

editorconfig⟫=

(autoload 'editorconfig-mode "editorconfig" nil t)
(autoload 'editorconfig-core-get-properties-hash "editorconfig-core")

(defun tess-enable-editorconfig-mode ()
  (editorconfig-mode 1))

(add-hook 'tess-after-local-init-hook 'tess-enable-editorconfig-mode)

(setq editorconfig-mode-lighter " EC")

overwrite mode

disable overwrite-mode⟫=

(put 'overwrite-mode 'disabled t)

defun tess-clear

defun tess-clear⟫=

(defun tess-clear (&optional prefix)
  "Move the line containing point to the top of the window.
With PREFIX, move the line containing point to line PREFIX of the window."
  (interactive "P")
  (recenter (or prefix 0)))
(global-set-key (kbd "C-c c") 'tess-clear)

require final newline

require-final-newline⟫=

(setq require-final-newline t)

inhibit default init⟫=

(setq inhibit-default-init  t)

(defun tess-warn-about-default-init ()
  (when (locate-library "default")
    (message "Warning: `default.el' not loaded")
    (sit-for 2)))

(add-hook 'tess-after-local-init-hook 'tess-warn-about-default-init)

sentence end double space

sentence-end-double-space⟫=

(setq sentence-end-double-space nil)

(defvar tess-sentence-end-re
  "\\(\\w+\\)\\([.?!]\\)\\B"
  "Regular expression which matches potential sentence endings.")

(defvar tess-abbreviations
  '("Mr" "Mrs" "St")
  "Abbreviations which should not be considered to end sentences.")

(defun tess-sentence-end ()
  "Returns the location of the next sentence-end in the current buffer.
Resorts to `point-max' if it can't find a sentence end."
  (or (catch 'found
        (while (re-search-forward tess-sentence-end-re nil t)
          (when (or
                 (member (match-string 2) '("?" "!"))
                 (not (member (match-string 1) tess-abbreviations)))
            (throw 'found (point)))))
      (point-max)))

isearch

isearch highlight current match⟫=

(setq search-highlight t)
(setq isearch-highlight-all-matches t) ; XEmacs
(setq-default case-fold-search t)
(eval-after-load "isearch"
  '(define-key isearch-mode-map (kbd "C-h") 'isearch-mode-help))

isearch fg⟫=

:foreground "⟪light yellow⟫"

isearch faces⟫=

'(isearch ((t (⟪cyan bg (alt)⟫ ⟪isearch fg⟫))))
'(isearch-lazy-highlight-face ((t (:background "⟪dark green⟫"
                                   ⟪isearch fg⟫))))
'(lazy-highlight ((t (:background "⟪medium red⟫" ⟪isearch fg⟫))))
'(isearch-secondary ((t (:background "⟪medium red⟫" ⟪isearch fg⟫))))
'(isearch-fail ((t (:background "⟪medium red⟫" ⟪isearch fg⟫))))

tess-kill-mode-buffers

defun tess-kill-mode-buffers⟫=

(defun tess-kill-mode-buffers (&optional mode)
  "Kill all buffers of this major mode.
With optional argument MODE, all buffers in major mode MODE are killed
instead."
  (interactive (list (when current-prefix-arg (tess-read-major-mode))))
  (setq mode (or mode major-mode))
  (when (or current-prefix-arg
            (y-or-n-p (format "Really kill all %s buffers? " mode)))
    (mapc (lambda (buffer)
            (when (with-current-buffer buffer
                    (eq major-mode mode))
              (kill-buffer buffer)))
          (buffer-list))))

some random eldoc hack

defun help-default-arg-highlight⟫=

(defun help-default-arg-highlight (arg)
  "Upcase and fontify ARG for use with `eldoc-mode' and help."
  (propertize (upcase arg)
              'face 'font-lock-variable-name-face))

help faces⟫=

'(help-argument-name ((t (⟪variable face⟫))))

uniquify

uniquify⟫=

(when (ignore-errors (require 'uniquify))
  (setq-default uniquify-buffer-name-style 'forward))

timestamp

timestamp⟫=

(add-hook 'write-file-hooks 'time-stamp)

organize buffer menu by major mode

Organize buffer menu by major mode⟫=

(setq mouse-buffer-menu-mode-mult 1)

apropos do all

Apropos do all⟫=

(setq apropos-do-all t)

truncate-lines

truncate-lines⟫=

(setq truncate-partial-width-windows nil)

(setq-default truncate-lines t)
(let ((foo (lambda () (setq truncate-lines nil))))
  (mapc (lambda (hook)
          (add-hook hook foo))
        '(term-mode-hook eshell-mode-hook html-mode-hook)))

kr-edit-region

edit region in a different major mode⟫=

(defun kr-edit-region (&optional edit-mode)
  "Edit the current region in a separate buffer.
With a prefix arg, change `major-mode' to EDIT-MODE."
  (interactive (list (when current-prefix-arg (tess-read-major-mode))))
  (clone-indirect-buffer nil t)
  (narrow-to-region (region-beginning) (region-end))
  (shrink-window-if-larger-than-buffer)
  (when edit-mode (funcall edit-mode)))

defun tess-read-major-mode⟫=

(defun tess-read-major-mode ()
  "Read a major mode from the user, and return it.
Based on Kevin Rogers' `edit-region' interactive spec."
  (intern (completing-read
           (format "Major mode (default `%s'): " major-mode)
           obarray 'kr-major-mode-p t nil nil
           (symbol-name major-mode))))

defun kr-major-mode-p⟫=

(defun kr-major-mode-p (symbol)
  "Return non-nil if SYMBOL is a major mode.
Used in `interactive' forms to read major mode names from the user."
  (and (fboundp symbol)
       (let ((function-name (symbol-name symbol)))
         (and (string-match "-mode\\'" function-name)
              (not (string-match "\\`turn-\\(on\\|off\\)-"
                                 function-name))))
       (not (assq symbol minor-mode-alist))))

auto-mode-case-fold

auto-mode-case-fold⟫=

(setq auto-mode-case-fold t)

tess-find-mode

tess-find-mode⟫=

(defun tess-find-mode (extension &optional interactive)
  "Returns the mode in which a file with EXTENSION would be opened."
  (interactive "sExtension: \np")
  (let ((mode (assoc-default (concat "." extension) auto-mode-alist
                             'string-match default-major-mode)))
    (when interactive
      (message "A file with extension .%s would be opened with mode %s"
               extension mode))
    mode))

assoc-default

defun assoc-default⟫=

(defun assoc-default (key alist &optional test default)
  "Find object KEY in ALIST."
  (let ((thing (assoc* key alist :test (lambda (a b) (funcall test b a)))))
    (if (consp thing)
        (cdr thing)
      default)))

custom autoload

defun custom-autoload⟫=

(defun custom-autoload (symbol load)
  "Mark SYMBOL as autoloaded custom variable and add dependency LOAD."
  (put symbol 'custom-autoload t)
  (custom-add-load symbol load))

Emacsclient

defvar tess-server-emacs⟫=

(defvar tess-server-emacs t
  "If non-null, this emacs should run an edit server.
By edit server, I mean the bit that emacsclient or gnuclient talk to.")

Choose which editor to use (zsh)⟫=

if is-in-path emacsclient; then
    export EDITOR='emacsclient'
elif is-in-path gnuclient-emacs; then
    export EDITOR='gnuclient-emacs'
elif is-in-path gnuclient; then
    export EDITOR='gnuclient'
elif is-in-path emacs; then
    export EDITOR='emacs'
else
    export EDITOR='vi'
fi
export VISUAL=$EDITOR
alias e=$EDITOR

gnuserv⟫=

(when (and (featurep 'emacs) tess-sufficiently-bsd-like-flag)
  (require 'gnuserv-compat nil t))
(unless (fboundp 'gnuserv-start)
  (require 'gnuserv))
(add-hook 'tess-after-local-init-hook
          (lambda ()
            (when tess-server-emacs
              (gnuserv-start))))

server-start⟫=

(defun tess-start-server-if-wanted ()
  (when tess-server-emacs
    (server-start)))
(when (or (fboundp 'make-network-process)
          (file-executable-p (expand-file-name "emacsserver"
                                               exec-directory)))
  (add-hook 'tess-after-local-init-hook
            'tess-start-server-if-wanted))

gnuserv⟫=

(add-hook 'tess-after-local-init-hook
          (lambda () (setq gnuserv-frame (selected-frame))))

emacs server⟫=

(setq display-buffer-reuse-frames t)

gnuserv or emacs server⟫=

(cond ((and (not (featurep 'multi-tty)) (locate-library "gnuserv"))
       ⟪gnuserv⟫)
      ((not tess-w32-flag)
       ⟪emacs server⟫
       ⟪server-start⟫))

archive-mode

archive-mode⟫=

(add-to-list 'auto-mode-alist '("\\.egg\\'" . archive-mode))

XEmacs

Aquamacs

Fix Viper under Aquamacs⟫=

;; Fixes some kind of Viper/Aquamacs interaction issue
(raise-frame)

Disable Aquamacs' various bells and whistles⟫=

(setq aquamacs-buffer-specific-frame-themes nil
      aquamacs-mode-specific-default-themes nil
      aquamacs-auto-frame-parameters-flag   nil
      special-display-buffer-names          nil
      special-display-regexps               nil)

(setq kill-emacs-query-functions
      (delq 'aquamacs-ask-to-save-options kill-emacs-query-functions))

vi and friends: nvi, vim, and Viper

vi

.exrc⟫=

set autoindent
set shiftwidth=2

nvi

vim

Viper

Enable Viper in .emacs⟫=

;; Enable Viper
;; (setq viper-mode t)
;; (add-hook 'tess-after-local-init-hook 'viper-mode)

Configure Viper's toggle key⟫=

(setq viper-toggle-key (kbd "M-a"))

Ensure Viper doesn't mess with my cursor type⟫=

(eval-after-load "viper-init"
  '(progn
     (mapc (lambda (hook)
             (remove-hook hook 'viper-restore-cursor-type))
           '(viper-vi-state-hook viper-replace-state-hook
             viper-emacs-state-hook))
     (remove-hook 'viper-insert-state-hook
                  'viper-set-insert-cursor-type)))

viper face variables⟫=

'(viper-replace-overlay-cursor-color "⟪cursor color (warning)⟫") ;%
'(viper-insert-state-cursor-color "⟪cursor color (alt)⟫") ;%
'(viper-vi-state-cursor-color "⟪cursor color⟫")

viper faces⟫=

'(viper-search-face ((t (⟪cyan bg (alt)⟫ ⟪isearch fg⟫))))
'(viper-replace-overlay-face ((t (:foreground "⟪dark black⟫" :bold t
                                 :background "⟪very light magenta⟫"))))
'(viper-minibuffer-emacs-face ((t (:foreground "⟪dark black⟫"
                                  :background "DarkSeaGreen2"))))
'(viper-minibuffer-insert-face ((t (:foreground "⟪dark black⟫" ;%
                                   :background "⟪very light magenta⟫"))))
'(viper-minibuffer-vi-face ((t (:foreground "⟪dark black⟫" ;%
                               :background "⟪light cyan⟫"))))

.viper⟫=

;;; .viper --- Theresa O'Connor's Viper configuration -*- emacs-lisp -*-

⟪Elisp Copyright Statement⟫

;;; Code:

.viper⟫=

(put 'viper-add-local-keys 'lisp-indent-function 1)

(setq viper-inhibit-startup-message   t
      viper-expert-level              5
      viper-electric-mode             t
      viper-always                    t
      viper-want-ctl-h-help           t
      viper-want-emacs-keys-in-insert t
      viper-want-emacs-keys-in-vi     t
      viper-vi-style-in-minibuffer    nil
      viper-no-multiple-ESC           nil
      viper-keep-point-on-repeat      nil
      viper-keep-point-on-undo        t
      viper-case-fold-search          t)

(setq-default viper-ex-style-editing nil
              viper-ex-style-motion  nil
              viper-auto-indent      t)

(when (fboundp 'viper-buffer-search-enable)
  (viper-buffer-search-enable))

.viper⟫=

(when (featurep 'iswitchb)
  (setq viper-read-buffer-function 'iswitchb-read-buffer))

.viper⟫=

(let ((open-entry (assoc "open" ex-token-alist)))
  (when (consp open-entry)
    (setcdr open-entry
            '((find-file (read-file-name "Find file: "))))))

.viper⟫=

(when (boundp 'viper-insert-state-mode-list)
  (setq viper-insert-state-mode-list
        (delete 'sql-interactive-mode
                (delete 'eshell-mode
                        (delete 'inferior-lisp-mode
                                viper-insert-state-mode-list)))))

(when (boundp 'viper-emacs-state-mode-list)
  (mapc (lambda (mode)
          (add-to-list 'viper-emacs-state-mode-list mode))
        '(cfengine-mode sql-interactive-mode eshell-mode
          inferior-lisp-mode inferior-python-mode rcirc-mode)))

.viper⟫=

(when (boundp 'viper-insert-global-user-map)
  (define-key viper-insert-global-user-map (kbd "C-d") 'delete-char)
  (define-key viper-insert-global-user-map (kbd "C-v") 'scroll-up)
  (define-key viper-insert-global-user-map (kbd "C-\\") 'toggle-input-method)
  (define-key viper-insert-global-user-map (kbd "C-t") 'transpose-chars)
  (define-key viper-insert-global-user-map (kbd "C-w") 'kill-region))

(when (boundp 'viper-vi-global-user-map)
  (define-key viper-insert-global-user-map (kbd "C-d") 'delete-char)
  (define-key viper-vi-global-user-map (kbd "C-u") 'universal-argument)

  ;; These are shockingly cool.
  (define-key viper-vi-global-user-map (kbd "q") 'fill-paragraph)
  (define-key viper-vi-global-user-map (kbd "t") 'transpose-chars)

  (define-key viper-vi-global-user-map (kbd "C-v") 'scroll-up)

  (define-key viper-vi-global-user-map (kbd "C-b") 'backward-char)
  (define-key viper-vi-global-user-map (kbd "C-f") 'forward-char)
  (define-key viper-vi-global-user-map (kbd "C-p") 'previous-line)
  (define-key viper-vi-global-user-map (kbd "C-n") 'next-line)

  ;; Being able to pull up help is a good thing.
  (define-key viper-vi-global-user-map (kbd "C-h") 'help-command)

  ;; I don't know what C-e or C-t do in vi by default and I don't care.
  (define-key viper-vi-global-user-map (kbd "C-e") 'viper-goto-eol)
  (define-key viper-vi-global-user-map (kbd "C-t") 'transpose-chars)

  ;; I don't need an alternate Meta key, thank you very much.
  (define-key viper-vi-global-user-map (kbd "C-\\") 'toggle-input-method)

  (define-key viper-vi-global-user-map (kbd "C-y") 'yank))

.viper⟫=

(defun tess-viper-install-z-bindings ()
  (let ((zz-binding (key-binding (kbd "C-c C-c")))
        (zs-binding (key-binding (kbd "C-c C-s"))))
    ;; Ensure we have a local map to frob if need be
    (when (or zz-binding zs-binding)
      (unless (current-local-map)
        (use-local-map (make-sparse-keymap "Local map"))))
    (when zz-binding
      (viper-add-local-keys 'vi-state
        (list (cons "zz" zz-binding))))
    (when zs-binding
      (viper-add-local-keys 'vi-state
        (list (cons "zs" zs-binding))))))

(add-hook 'after-change-major-mode-hook 'tess-viper-install-z-bindings)

.viper⟫=

(defun tess-disable-viper-auto-indent ()
  (when viper-mode
    (setq viper-auto-indent nil)))

(mapc (lambda (hook)
        (add-hook hook 'tess-disable-viper-auto-indent))
      '(eshell-mode-hook nslookup-mode-hook wikipedia-mode-hook
        css-mode-hook))

.viper⟫=

;;; .viper ends here

Email & Gnus

Gnus Group buffer looks⟫=

(setq gnus-group-line-format "%2{%M%S%p%} %0{%5y%} %P%1{%G%}\n")
(setq gnus-topic-line-format "%i%3{[ %n -- %A ]%}%v\n")

Gnus Summary buffer looks⟫=

(setq gnus-summary-line-format
      (concat "%U%R%z%{"
              (if tess-oort+-flag
                  "%B"
                "%I")
              "%} %0{%-25,25f %}%1{%s%}\n")
      ;; Remove [List] identifiers from subject lines
      gnus-list-identifiers
      '("^[^]]+[]]\\s-"))

my current primary email address⟫=

hober0@gmail.com

user-mail-address⟫=

(setq user-mail-address "⟪my current primary email address⟫" ;%
      user-full-name    "Theresa O'Connor")

My email addresses⟫=

'(;; Gmail
  "hober0@gmail.com"
  ;; Family domain
  "tess@oconnor.cx"
  "ted@oconnor.cx"
  ;; Work
  "eoconnor@apple.com"
  ;; Old Teradata addresses
  "eo250006@teradata.com" "Edward.O'Connor@teradata.com"
  ;; Old EVDB / Eventful addresses
  "ted@evdb.com" "oconnor@evdb.com" "ted@eventful.com"
  ;; Old Tomo address
  "edward.oconnor@tomosoftware.com"
  ;; Old UCSD addresses
  "oconnor@ucsd.edu" "oconnor@soe.ucsd.edu"
  ;; RHIT
  "oconnoem@cs.rose-hulman.edu"
  "oconnoem@alumni.rose-hulman.edu"
  ;; old ISP
  "oconnoem@theworld.com")

mail-user-agent⟫=

(setq mail-user-agent   'gnus-user-agent
      read-mail-command 'gnus)

Abbrevs in mail

Enable abbrevs⟫=

(add-hook 'mail-setup-hook 'mail-abbrevs-setup)

Here's how to make Emacs take a \texttt{-gnus} argument which starts

Gnus:

enable -gnus⟫=

(add-to-list 'command-switch-alist
             '("gnus" . (lambda (&rest ignore)
                          (setq tess-server-emacs nil)
                          ;; Exit Emacs after quitting Gnus
                          (add-hook 'gnus-after-exiting-gnus-hook
                                    'save-buffers-kill-emacs)
                          ;; Start Gnus when Emacs starts
                          (add-hook 'tess-after-local-init-hook 'gnus t))))

Gnus Organization⟫=

(setq message-user-organization "Church of Emacs")

Set ORGANIZATION (zsh)⟫=

export ORGANIZATION="Theresa O'Connor <tess@oconnor.cx>"

Sieve

sieve⟫=

(when (locate-library "sieve-mode")
  (autoload 'sieve-mode "sieve-mode" nil t)
  (add-to-list 'auto-mode-alist
               '("\\.si\\(eve\\|v\\)\\'" . sieve-mode)))

.signature⟫=

Theresa O'Connor
⟪my current primary email address⟫

Ense petit placidam sub libertate quietem.

Basic email look and feel⟫=

(setq mail-signature t
      mail-yank-prefix "> "
      mail-from-style 'angles)

BBDB

bbdb faces⟫=

'(bbdb-company ((t (:foreground "⟪medium red⟫")))) ;%
'(bbdb-field-name ((t (⟪keyword face⟫))))
'(bbdb-field-value ((t (:foreground "⟪light yellow⟫")))) ;%
'(bbdb-name ((t (:foreground "⟪medium cyan⟫"))))

The Insidious Big-Brother Database⟫=

(when (require 'bbdb nil t)
  (setq bbdb-default-country nil
        bbdb-debug nil
        bbdb-file "~/.bbdb"
        bbdb-completion-display-record nil
        bbdb-quiet-about-name-mismatches 0)

  (when (tess-coding-system-p 'utf-8)
    (setq bbdb-file-coding-system 'utf-8))
  (bbdb-initialize 'sendmail 'gnus 'message)

  (when (fboundp 'eshell)
    (defun eshell/bbdb (regex)
      (bbdb regex nil)))

  (add-hook 'message-setup-hook 'bbdb-define-all-aliases))

(defconst tess-bbdb-flag (featurep 'bbdb))

EUDC⟫=

(when (locate-library "eudc")
  (setq eudc-options-file "~/.eudc")
  (defvar tess-eudc-map (make-sparse-keymap)
    "Convenience bindings for EUDC.")
  (global-set-key (kbd "C-c e") tess-eudc-map)
  (define-key tess-eudc-map (kbd "e") 'eudc-expand-inline)
  (define-key tess-eudc-map (kbd "q") 'eudc-query-form)
  (eval-after-load "message"
    '(define-key message-mode-map (kbd "C-c TAB") 'eudc-expand-inline))
  (eval-after-load "sendmail"
    '(define-key mail-mode-map (kbd "C-c TAB") 'eudc-expand-inline)))

EUDC

eudcb-mab.el fetch rule⟫=

eudcb-mab.el:
        curl -O http://braeburn.aquamacs.org/code/master/lisp/net/eudcb-mab.el

.eudc⟫=

;;; .eudc --- Theresa O'Connor's EUDC configuration -*- emacs-lisp -*-

⟪Elisp Copyright Statement⟫

;;; Code:

(setq eudc-server "localhost"
      eudc-inline-expansion-format '("%s <%s>" name email)
      eudc-multiple-match-handling-method 'select)

(if (require 'eudcb-mab nil t)
    (setq eudc-protocol 'mab)
  (setq eudc-protocol 'bbdb))

(provide 'eudc-options-file)

;;; .eudc ends here

Gnus continued

shr config⟫=

(setq shr-color-visible-distance-min 10
      shr-color-visible-luminance-min 60)

Gnus Authentication Sources⟫=

;; (when (and (eq system-type 'darwin)
;;            (file-executable-p "/usr/bin/security"))
;;   (eval-after-load "auth-source"
;;     '(setq auth-sources
;;            (append (list 'macos-keychain-internet
;;                          'macos-keychain-generic)
;;                    auth-sources))))

gnus clone rule⟫=

gnus/lisp/gnus.el:
        git clone http://git.gnus.org/gnus.git

bin/mimedown⟫=

#!/usr/bin/env python3
# mimedown - generate multipart text and HTML MIME message from Markdown input.

# Requires mistune; install it with pip:
# sudo -H python3 -m pip install mistune

import sys

import mistune

md2html = None
if 'html' in dir(mistune):
    md2html = mistune.html
elif 'markdown' in dir(mistune):
    md2html = mistune.markdown
else:
    print("mistune install is broken", file=sys.stderr)

def mimedown(infile, outfile):
    text = infile.read()
    html = md2html(text)
    html = "<htm><head><title></title><body>%s</body></html>" % html
    print('''<#multipart type=alternative>
%s
<#part type=text/html>
%s
<#/multipart>
''' % (text, html), file=outfile)

if __name__ == '__main__':
    mimedown(sys.stdin, sys.stdout)

mimedown command⟫=

(defun tess-mimedown ()
  (interactive)
  (save-excursion
    (message-goto-body)
    (shell-command-on-region
     (point) (point-max) "~/bin/mimedown" nil t)))

Use open to preview PDFs on macOS⟫=

(when (file-executable-p "/usr/bin/open")
  (eval-after-load "mailcap"
    '(mailcap-add "application/pdf" "open %s")))

I am not a Gnus novice any more⟫=

(setq gnus-novice-user nil)

handle mailing lists nicely⟫=

(setq gnus-add-to-list t
      message-subscribed-address-functions
      '(gnus-find-subscribed-addresses))

GCC header handling⟫=

;; yay oort
(setq gnus-gcc-mark-as-read t)

(defvar tess-default-gcc-group "INBOX")

(defun tess-gnus-message-archive-group (group)
  (setq group (or group tess-default-gcc-group "INBOX"))
  (let ((method (gnus-find-method-for-group group)))
    (format "%s+%s:%s" (car method) (cadr method) group)))

(setq gnus-message-archive-group 'tess-gnus-message-archive-group)

defun tess-gnus-mark-thread-advance⟫=

(defun tess-gnus-mark-thread-advance (p)
  "Mark this thread, and advance point to the next one.
With prefix P, mark the next P threads, and advance point past all of them."
  (interactive "p")
  (let ((i 0))
    (while (< i p)
      (gnus-uu-mark-thread)
      (gnus-summary-next-thread 1)
      (setq i (+ i 1)))))

(add-hook 'gnus-summary-mode-hook
          (lambda ()
            (local-set-key (kbd "<f5>") 'tess-gnus-mark-thread-advance))) ;%

Define Gnus version predicates⟫=

(defvar tess-oort+-flag nil
  "Non-nil means this Emacs is equipped with Oort Gnus (or later).")

Determine Gnus version⟫=

(defun tess-determine-gnus-version ()
  "Determine the version of Gnus."
  (setq tess-oort+-flag
        (> (gnus-continuum-version (gnus-version)) 5.09)))

(add-hook 'gnus-before-startup-hook 'tess-determine-gnus-version)

Edit Gnus score files as Gnus score files⟫=

(add-to-list 'auto-mode-alist '("\\.SCORE\\'" . gnus-score-mode))

Ensure we load the right Gnus⟫=

;; Let's make sure we load the right version of Gnus.
(ignore-errors (require 'gnus-load))

message-mail-alias-type⟫=

(setq message-mail-alias-type
      (cond ((locate-library "ecomplete") 'ecomplete)
            (t 'mailabbrev)))

subject face⟫=

:foreground "⟪light yellow⟫"

gnus faces⟫=

'(gnus-cite-attribution-face ((t ())))
'(gnus-cite-attribution ((t ())))
'(gnus-cite-face-1 ((t (:foreground "⟪light yellow⟫"))))
'(gnus-cite-1 ((t (:foreground "⟪light yellow⟫"))))
'(gnus-cite-face-2 ((t (:foreground "⟪medium yellow⟫"))))
'(gnus-cite-2 ((t (:foreground "⟪medium yellow⟫"))))
'(gnus-cite-face-3 ((t (:foreground "⟪medium cyan⟫"))))
'(gnus-cite-3 ((t (:foreground "⟪medium cyan⟫"))))
'(gnus-cite-face-4 ((t (:foreground "⟪medium red⟫"))))
'(gnus-cite-4 ((t (:foreground "⟪medium red⟫"))))
'(gnus-cite-face-5 ((t (:foreground "⟪light magenta⟫"))))
'(gnus-cite-5 ((t (:foreground "⟪light magenta⟫"))))
'(gnus-cite-face-6 ((t (:foreground "⟪medium green⟫"))))
'(gnus-cite-6 ((t (:foreground "⟪medium green⟫"))))
'(gnus-cite-face-7 ((t (:foreground "⟪medium blue⟫")))) ;%
'(gnus-cite-7 ((t (:foreground "⟪medium blue⟫"))))
'(gnus-cite-face-8 ((t (:foreground "⟪dark white⟫"))))
'(gnus-cite-8 ((t (:foreground "⟪dark white⟫"))))
'(gnus-cite-face-9 ((t (:foreground "⟪dark cyan⟫"))))
'(gnus-cite-9 ((t (:foreground "⟪dark cyan⟫"))))
'(gnus-cite-face-10 ((t (:foreground "⟪light yellow⟫"))))
'(gnus-cite-10 ((t (:foreground "⟪light yellow⟫"))))
'(gnus-cite-face-11 ((t (:foreground "⟪medium yellow⟫"))))
'(gnus-cite-11 ((t (:foreground "⟪medium yellow⟫"))))

gnus faces⟫=

'(gnus-emphasis-bold ((t (:bold t))))
'(gnus-emphasis-bold-italic ((t (:italic t :bold t))))
'(gnus-emphasis-italic ((t (:italic t))))
'(gnus-emphasis-underline ((t (:underline t))))
'(gnus-emphasis-underline-bold ((t (:bold t :underline t))))
'(gnus-emphasis-underline-bold-italic ((t (:italic t :bold t :underline t))))
'(gnus-emphasis-underline-italic ((t (:italic t :underline t))))

gnus faces⟫=

`(gnus-header-content-face ((t ⟪dim this face when appropriate⟫)))
`(gnus-header-content ((t ⟪dim this face when appropriate⟫)))
'(gnus-header-from-face ((t (:foreground "DarkSeaGreen2"))))
'(gnus-header-from ((t (:foreground "DarkSeaGreen2"))))
'(gnus-header-name-face ((t (:foreground "⟪medium cyan⟫")))) ;%
'(gnus-header-name ((t (:foreground "⟪medium cyan⟫"))))
'(gnus-header-newsgroups-face ((t (:foreground "⟪medium green⟫"))))
'(gnus-header-newsgroups ((t (:foreground "⟪medium green⟫"))))
'(gnus-header-subject-face ((t (⟪subject face⟫))))
'(gnus-header-subject ((t (⟪subject face⟫))))
`(gnus-signature-face ((t ⟪dim this face when appropriate⟫)))
`(gnus-signature ((t ⟪dim this face when appropriate⟫)))
'(gnus-summary-cancelled-face ((t (:foreground "⟪medium yellow⟫"))))
'(gnus-summary-cancelled ((t (:foreground "⟪medium yellow⟫"))))
'(gnus-summary-high-read-face ((t (:foreground "⟪medium yellow⟫"))))
'(gnus-summary-high-read ((t (:foreground "⟪medium yellow⟫"))))
'(gnus-summary-high-ticked-face ((t (:foreground "⟪medium red⟫"))))
'(gnus-summary-high-ticked ((t (:foreground "⟪medium red⟫"))))
'(gnus-summary-normal-ticked-face ((t (:foreground "⟪light red⟫"))))
'(gnus-summary-normal-ticked ((t (:foreground "⟪light red⟫"))))
'(gnus-summary-low-read-face ((t (:foreground "⟪medium yellow⟫"))))
'(gnus-summary-low-read ((t (:foreground "⟪medium yellow⟫"))))
'(gnus-summary-selected-face ((t (⟪default (alt)⟫))))
'(gnus-summary-selected ((t (⟪default (alt)⟫))))

Messages

mm faces⟫=

'(mm-uu-extract ((t (:background "⟪dark black (alt)⟫"
                     :foreground "⟪light white⟫"))))

message faces⟫=

'(message-cited-text-face ((t (:foreground "⟪medium red⟫")))) ;%
'(message-cited-text ((t (:foreground "⟪medium red⟫")))) ;%

message faces⟫=

'(message-header-cc-face ((t (:foreground "⟪medium green⟫"))))
'(message-header-cc ((t (:foreground "⟪medium green⟫"))))
'(message-header-name-face ((t (:foreground "⟪medium green⟫"))))
'(message-header-name ((t (:foreground "⟪medium green⟫"))))
'(message-header-newsgroups-face ((t (:foreground "⟪medium green⟫"))))
'(message-header-newsgroups ((t (:foreground "⟪medium green⟫"))))
'(message-header-other-face ((t (:foreground "⟪medium cyan⟫"))))
'(message-header-other ((t (:foreground "⟪medium cyan⟫"))))
'(message-header-subject-face ((t (⟪subject face⟫))))
'(message-header-subject ((t (⟪subject face⟫))))
'(message-header-to-face ((t (:foreground "⟪medium cyan⟫"))))
'(message-header-to ((t (:foreground "⟪medium cyan⟫"))))
'(message-header-xheader-face ((t (:foreground "⟪medium cyan⟫"))))
'(message-header-xheader ((t (:foreground "⟪medium cyan⟫"))))

message faces⟫=

'(message-mml-face ((t (:foreground "⟪medium green⟫"))))
'(message-mml ((t (:foreground "⟪medium green⟫"))))
'(message-separator-face ((t (⟪error face⟫))))
'(message-separator ((t (⟪error face⟫))))

Strong Bad email deletion⟫=

(defun tess-insert-centered-line (line)
  "Insert LINE into the current buffer.
Will also insert the necessary number of spaces and newlines to center
LINE in the window."
  (let ((lines (make-string (/ (frame-height) 2) ?\n))
        (spaces (make-string (- (/ (frame-width) 2)
                                (/ (length line) 2))
                             ?\ )))
    (insert lines spaces line)))

(defmacro with-compy-deleted-display (&rest body)
  "Execute forms in BODY while displaying a 'DELETED!!' buffer.
Just like on Strong Bad's Compy 386. BA-LEETED!"
  `(save-window-excursion
     (let ((old-buf (current-buffer)))
       (with-temp-buffer
         (setq mode-line-format           nil
               indicate-empty-lines       nil
               indicate-buffer-boundaries nil)
         (let ((default-bg (face-background 'default))
               (default-fg (face-foreground 'default))
               (fringe-bg (face-background 'fringe))
               (fringe-fg (face-foreground 'fringe)))
           (unwind-protect
               (progn
                 (set-face-background 'default "Medium Blue")
                 (set-face-foreground 'default "White")
                 (set-face-background 'fringe "Medium Blue")
                 (set-face-foreground 'fringe "White")
                 (tess-insert-centered-line "DELETED!!!")
                 (message "")
                 (delete-other-windows)
                 (switch-to-buffer (current-buffer))
                 (recenter)
                 (with-current-buffer old-buf
                   ,@body))
             (set-face-background 'default default-bg)
             (set-face-foreground 'default default-fg)
             (set-face-background 'fringe fringe-bg)
             (set-face-foreground 'fringe fringe-fg)))))))
(put 'with-compy-deleted-display 'lisp-indent-function 0)

;; (defadvice gnus-summary-delete-article (around compyify-deletion activate)
;;   "Ensure that article deletion always looks like Strong Bad's Compy 386."
;;   (with-compy-deleted-display
;;     (sit-for 1)
;;     ad-do-it))

SMTP

SMTP handling⟫=

(defvar tess-smtp-flag t
  "*Non-nil if I should use SMTP for sending mail.
Set this before loading ~/.gnus!")

SMTP handling⟫=

(when tess-smtp-flag
  (setq message-send-mail-function 'smtpmail-send-it
        send-mail-function         'smtpmail-send-it
        smtpmail-local-domain      nil
        smtpmail-debug-info        t))

Gnus SMTP config⟫=

(setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
      smtpmail-smtp-server "smtp.gmail.com"
      smtpmail-default-smtp-server "smtp.gmail.com"
      send-mail-function 'smtpmail-send-it
      message-send-mail-function 'smtpmail-send-it
      smtpmail-smtp-service 587
      smtpmail-auth-credentials "~/.authinfo")

Configure gnus-face-N⟫=

(setq gnus-face-0 'font-lock-type-face)
(setq gnus-face-1 'font-lock-string-face)
(setq gnus-face-2 'font-lock-variable-name-face)
(setq gnus-face-3 'font-lock-keyword-face)

Visible headers⟫=

(eval-after-load "gnus-art"
  '(setq gnus-visible-headers
         (concat (format
                  "^\\(%s\\):"
                  (regexp-opt '("User-Agent" "X-Bugzilla-Component"
                                ;; "X-Mailer"
                                "X-Newsreader" "X-Spam-Level"
                                "List-Id" "X-Report-Spam" "Archived-At"
                                "Comments" "Message-Id")))
                 "\\|" gnus-visible-headers)))

Article headers⟫=

⟪Visible headers⟫

(defun tess-save-message-url-to-kill-ring ()
  "Copy a message: URL to the current article."
  (interactive)
  (save-excursion
    (gnus-with-article-headers
     (gnus-article-goto-header "Message-Id")
     (let ((mid (buffer-substring-no-properties
                 (1+ (point)) (line-end-position))))
       (kill-new (concat "message:" (url-hexify-string mid)))))))

⟪Gnus Organization⟫
(setq gnus-treat-hide-headers        'head
      gnus-treat-hide-boring-headers 'head
      message-default-headers        mail-default-headers)

spam reporting⟫=

(defun tess-report-spam ()
  "Blah blah blah."
  (interactive)
  (let* ((server-name
          (gnus-method-to-server-name
           (gnus-find-method-for-group gnus-newsgroup-name)))
         (reporting-function (cdr (assoc server-name tess-report-spam-map))))
    (if reporting-function
        (funcall reporting-function)
      (message "No suitable spam reporting mechanism found."))))

;; Key bindings from (gnus) Spam Package Introduction
(gnus-define-keys gnus-summary-mode-map
  "Sx" tess-report-spam
  "Msx" tess-report-spam
  "\M-d" tess-report-spam)

(defvar tess-report-spam-map
  '(("nnimap+imap.gmail.com" . tess-report-spam-to-gmail)
    ("nntp+news.gmane.org" . tess-report-spam-to-gmane))
  "Blah blah blah.")

(defun tess-report-spam-to-gmail ()
  (gnus-summary-move-article nil "nnimap+imap.gmail.com:[Gmail]/Spam"))

(autoload 'url-retrieve "url")

(defun tess-report-spam-to-gmane ()
  (gnus-with-article-headers
    (gnus-article-goto-header "Archived-At")
    (let ((url (buffer-substring-no-properties
                (+ 2 (point)) (1- (line-end-position))))
          (url-request-method "POST"))
      ;; Every so often, gmane articles don't have Archived-At headers.
      (when (string-match gnus-button-url-regexp url)
        ;; N.B., we replace either 'article' or 'permalink' so that this
        ;; doesn't depend on my s/permalink/article/ hack.
        (setq url (replace-regexp-in-string
                   "\\(article\\|permalink\\)" "spam" url nil t))
        (setq url
              (replace-regexp-in-string "/\\([[:digit:]]+\\)$" ; $
                                        ":\\1:unconfirmed"
                                        url))
        ;; Fire and forget the spam report.
        (url-retrieve url (lambda (&rest ignore)
                            (message "Spam reported to Gmane.")))))))

tc.el fetch rule⟫=

tc.el:
        curl -O http://shasta.cs.uiuc.edu/~lrclause/tc.el

Trivial Cite⟫=

(autoload 'trivial-cite "tc" nil t)
(setq message-cite-function 'trivial-cite
      tc-make-attribution   'tc-tiny-attribution)

tess-insert-citation-line⟫=

(defun tess-insert-citation-line ()
  "Insert a simple citation line."
  (when message-reply-headers
    (let* ((components (mail-extract-address-components
                        (mail-header-from message-reply-headers)))
           (name (car (split-string (or (car components) "You"))))
           (email (cadr components))
           (citing-self
            (string-match gnus-ignored-from-addresses email)))
      (insert "Hi")
      (when (and (not citing-self)
                 (not (string-equal name "You")))
        (insert " " name))
      (insert ",\n\n")
      (insert (if citing-self "I" "You") " wrote:\n\n"))))

(setq message-citation-line-function 'tess-insert-citation-line)

tess-insert-citation-line⟫=

(defun tess-fixup-multireply-attributions (start end)
  (interactive "r")
  (goto-char start)
  (while (re-search-forward
          "^\\(Hi \\(\\w+\\),\n\n\\)\\(You\\) wrote:$" end t) ; $
    (replace-match "\\2" nil nil nil 3)
    (replace-match "" nil nil nil 1)))

(defun tess-fixup-multireply ()
  (interactive)
  (save-excursion
    (message-goto-body)
    (insert "Hi all,\n\n")
    (tess-fixup-multireply-attributions (point) (point-max))))

SuperCite⟫=

(add-hook 'mail-citation-hook 'sc-cite-original)
(setq news-reply-header-hook nil)
(setq sc-auto-fill-region-p nil
      sc-citation-leader " ")
(when tess-bbdb-flag
  (require 'bbdb-sc)
  (bbdb-initialize 'sc)
  (setq sc-preferred-attribution-list
        '("sc-lastchoice" "x-attribution" "sc-consult"
          "initials" "firstname" "lastname"))
  (add-to-list 'sc-attrib-selection-list
               '("sc-from-address"
                 ((".*" . (bbdb/sc-consult-attr
                           (sc-mail-field "sc-from-address"))))))
  (let ((cell (assoc "^\\'" sc-mail-glom-frame)))
    (when cell
      (setcdr cell
              '((progn (bbdb/sc-default)
                       (list 'abort '(step . 0))))))))

Choosing which citation code to use⟫=

(when (locate-library "tc")
  ⟪Trivial Cite⟫)

boxquote.el fetch rule⟫=

boxquote.el:
        curl -O http://www.davep.org/emacs/boxquote.el

boxquote⟫=

(when (locate-library "boxquote")
  (defvar tess-boxquote-map (make-sparse-keymap))
  (global-set-key (kbd "C-c q") tess-boxquote-map)
  (mapc (lambda (cons)
          (let ((command (car cons))
                (key (cdr cons)))
            (autoload command "boxquote" nil t)
            (define-key tess-boxquote-map key command)))
        '((boxquote-region            . "r")
          (boxquote-buffer            . "b")
          (boxquote-insert-file       . "i")
          (boxquote-yank              . "y")
          (boxquote-defun             . "F")
          (boxquote-paragraph         . "p")
          (boxquote-describe-function . "f")
          (boxquote-describe-variable . "v")
          (boxquote-describe-key      . "k")
          (boxquote-kill              . "K")
          (boxquote-unbox             . "u"))))

override gnus-goto-colon⟫=

(defun gnus-goto-colon ()
  (goto-char (point-at-bol)))

gnus-ignored-from-addresses⟫=

(setq gnus-ignored-from-addresses
      (regexp-opt ⟪My email addresses⟫))
;; why isn't this the default?
(setq message-dont-reply-to-names
      gnus-ignored-from-addresses)

configure gnus verbosity⟫=

(setq gnus-verbose          1
      gnus-verbose-backends 1)

use message-forward-subject-fwd if available⟫=

(when (fboundp 'message-forward-subject-fwd)
  (setq message-make-forward-subject-function 'message-forward-subject-fwd))

nnfolder configuration⟫=

(add-hook 'nnfolder-save-buffer-hook
          (lambda ()
            (set (make-local-variable 'backup-inhibited) t)))

nnmail configuration⟫=

(setq nnmail-split-methods 'nnmail-split-fancy)

(setq nnmail-treat-duplicates           'warn     ; or 'delete
      nnmail-cache-accepted-message-ids t
      nnmail-message-id-cache-length    10000)

disable killing of groups by mistake⟫=

(eval-after-load "gnus-group"
  '(define-key gnus-group-mode-map (kbd "C-k") nil))
(eval-after-load "gnus-topic"
  '(define-key gnus-topic-mode-map (kbd "C-k") nil))

disable indenting of topics by mistake⟫=

(eval-after-load "gnus-topic"
  '(define-key gnus-topic-mode-map (kbd "TAB") nil))

gnus topic configuration⟫=

(setq gnus-topic-display-empty-topics t)

; Don't display topics that have nothing in them
(setq gnus-topic-display-empty-topics nil)

gnus subscribe randomly⟫=

(when (and (fboundp 'gnus-subscribe-randomly)
           tess-oort+-flag)
  (if (listp gnus-subscribe-newsgroup-method)
      (add-to-list 'gnus-subscribe-newsgroup-method
                   'gnus-subscribe-randomly)
    (if (null gnus-subscribe-newsgroup-method)
        (setq gnus-subscribe-newsgroup-method 'gnus-subscribe-randomly)
      (setq gnus-subscribe-newsgroup-method
            (list 'gnus-subscribe-randomly
                  gnus-subscribe-newsgroup-method)))))

key binding for gnus-group-mail⟫=

(global-set-key (kbd "C-x m") 'gnus-group-mail)

tess typo gnus key bindings⟫=

;; I always hit 'j' instead of 'n'
(gnus-define-keys gnus-summary-mode-map
  "j" gnus-summary-next-unread-article)

scoring in gnus⟫=

(add-hook 'gnus-summary-mode-hook
          (lambda ()
            (setq gnus-summary-expunge-below -5)))

(add-hook 'message-sent-hook 'gnus-score-followup-thread)

enable gnus topic mode⟫=

(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)

gnus topic mode keybindings⟫=

(eval-after-load "gnus-topic"
  ;; Disable TAB
  '(define-key gnus-topic-mode-map [tab] nil))

misc gnus settings⟫=

(setq mail-source-delete-incoming           t
      gnus-activate-foreign-newsgroups      nil
      gnus-treat-display-smileys            nil
      gnus-treat-strip-trailing-blank-lines t
      gnus-treat-hide-citation              nil
      gnus-treat-strip-multiple-blank-lines nil
      gnus-inhibit-startup-message          t
      ;; My scores should be global.
      gnus-home-score-file                  "all.SCORE"
      gnus-visual                           t)

fix dumb quotes in Gnus⟫=

; Change a \205 figure to "..."
(add-hook 'gnus-part-display-hook 'article-treat-dumbquotes)

Gnus select methods⟫=

(defvar tess-has-configured-gnus nil)

(unless tess-has-configured-gnus
  ⟪Gnus SMTP config⟫
  (setq gnus-select-method '(nnimap "imap.gmail.com"
                                    (nnimap-stream ssl)
                                    (nnimap-authenticator login))
        gnus-secondary-select-methods '((nntp "news.gmane.org")
                                        (nntp "news.eternal-september.net"))
        tess-has-configured-gnus t))

Gmane special-handling⟫=

(defun tess-mangle-gmane-archival-gnus-data (link)
  "Mangle the `gnus-data' property value LINK.
Specifically, change the archival URL from permalink.gmane.org (Gmane's
blog-like interface) to article.gmane.org (Gmane's newslike interface)."
  (let ((original-date (get-text-property 5 'original-date link))
        (face (get-text-property 5 'face link)))
    (propertize (replace-regexp-in-string "permalink.gmane.org"
                                          "article.gmane.org"
                                          (substring-no-properties link))
                'face face 'original-date original-date)))

(defun tess-mangle-gmane-archival-header ()
  "Mangle Gmane's Archived-At header to be more useful.
Specifically, change the archival URL from permalink.gmane.org (Gmane's
blog-like interface) to article.gmane.org (Gmane's newslike interface)."
  (gnus-with-article-headers
   (when (gnus-article-goto-header "Archived-At")
     (save-excursion
       (alter-text-property (+ 2 (point)) (1- (line-end-position))
                            'gnus-data
                            'tess-mangle-gmane-archival-gnus-data))
     (when (re-search-forward "permalink.gmane.org"
                              (line-end-position) t)
       (replace-match (propertize "article.gmane.org"
                                  'face 'gnus-header-content))))))

(add-hook 'gnus-article-prepare-hook 'tess-mangle-gmane-archival-header)

Gnus posting styles⟫=

(unless tess-has-configured-gnus
  (setq gnus-posting-styles
        '((".*"
           (name "Theresa O'Connor")
           ("Jabber-ID" "hober0@gmail.com")
           ("X-Attribution" "Tess")
           (address "⟪my current primary email address⟫")
           (signature "\
⟪.signature⟫")
           (organization nil)))));%

Cleaning up mailing list email⟫=

(defun tess-gnus-article-treat-alexmog ()
  "Clean up alexmog's idiosyncratic quoting style."
  (save-excursion
    (when (article-goto-body)
      (let ((inhibit-read-only t))
        (while (re-search-forward "^±" nil t)
          (replace-match ">"))))))

(eval-after-load "gnus-art"
  '(add-hook 'gnus-part-display-hook 'tess-gnus-article-treat-alexmog))

Reading W3C and WHATWG mailing list archives in Gnus⟫=

(require 'calendar) ;; calendar-month-name-array

(autoload 'article-goto-body "gnus-art")
(autoload 'format-spec "format-spec")
(autoload 'gnus-group-read-ephemeral-group "gnus-group")
(autoload 'mm-make-temp-file "mm-util")
(autoload 'url-file-nondirectory "url-util")

;; Archives

(defvar tess-w3c-lists
  '("member-webapps" "public-canvas-api" "public-css-testsuite"
    "public-fx" "public-html" "public-html-a11y" "public-html-bugzilla"
    "public-html-comments" "public-html-data-tf"
    "public-html-wg-announce" "public-html-xml" "public-identity"
    "public-ietf-w3c" "public-iri" "public-script-coord"
    "public-tracking" "public-web-security" "public-webapps"
    "public-web-notification" "team-html-editors" "uri" "w3c-css-wg"
    "websec" "www-archive" "www-dom" "www-html" "www-style" "www-tag")
  "Mailing lists that I'm subscribed to over at w3.org.")

(defun tess-generate-w3c-archive-url (mailing-list year month)
  "Returns the URL for MAILING-LIST's archive mbox for YEAR and MONTH."
  (format-spec
   "https://lists.w3.org/Archives/Public/%l/mboxes/%Y-%m.mbx"
   (list (cons ?l mailing-list)
         (cons ?Y (format "%04d" year))
         (cons ?m (format "%02d" month)))))

(defun tess-read-year-month ()
  (let ((today (decode-time)))
    (list
     (read-number "Year: " (nth 5 today))
     (completing-read "Month: "
                      (append calendar-month-name-array nil)
                      nil
                      nil
                      (elt calendar-month-name-array
                           (1- (nth 4 today)))))))

(defun tess-read-w3c-archive (mailing-list year month)
  "Read the archive for MAILING LIST of YEAR and MONTH.
Based on `gnus-read-ephemeral-gmane-group' from gnus-group.el."
  (interactive
   (let ((today (decode-time)))
     (append (list (completing-read "Mailing list: " tess-w3c-lists))
             (tess-read-year-month))))
  (when (stringp month)
    (setq month (1+ (position month calendar-month-name-array
                              :test 'string-equal))))
  (let* ((url (tess-generate-w3c-archive-url mailing-list year month))
         (filename (concat mailing-list "_" (url-file-nondirectory url)))
         (tmpfile (mm-make-temp-file filename)))
    (with-temp-file tmpfile
      (url-insert-file-contents url)
      (write-region (point-min) (point-max) tmpfile)
      (gnus-group-read-ephemeral-group
       filename
       `(nndoc ,tmpfile
               (nndoc-article-type mbox))))
    (delete-file tmpfile)))

(defun tess-whatwg-year-month (year month)
  (format-spec
   "%Y-%m"
   (list (cons ?Y (format "%04d" year))
         (cons ?m month))))

(defun tess-whatwg-archive-filename (year month)
  (mm-make-temp-file (format "whatwg-%s" (tess-whatwg-year-month year month))
                     nil ".mbox.gz"))

(defun tess-generate-whatwg-archive-url (year month)
  "Returns the URL for the WHATWG's archive mbox for YEAR and MONTH."
  (format
   "http://lists.whatwg.org/pipermail/whatwg-whatwg.org/%s.txt.gz"
   (tess-whatwg-year-month year month)))

(defun tess-read-whatwg-archive (year month)
  "Read the WHATWG archive of YEAR and MONTH.
Based on `gnus-read-ephemeral-gmane-group' from gnus-group.el."
  (interactive (tess-read-year-month))
  (let* ((url (tess-generate-whatwg-archive-url year month))
         (groupname (format "whatwg-%s"
                            (tess-whatwg-year-month year month)))
         (tmpfile (tess-whatwg-archive-filename year month))
         (coding-system-for-write 'no-conversion)
         (jka-compr-inhibit t))
    (with-temp-file tmpfile
      (url-insert-file-contents url))
    (shell-command (format "gzip -d %s" tmpfile))
    (gnus-group-read-ephemeral-group
     groupname
     `(nndoc ,(substring tmpfile 0 -3)
             (nndoc-article-type mbox)))
    (delete-file tmpfile)))

IRC

I used to be one of the maintainers of ERC, one of the IRC clients included with Emacs by default.

ERC

tracking.el fetch rule⟫=

tracking.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/tracking.el

erc-robot.el fetch rule⟫=

erc-robot.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/erc-robot.el

ERC, an Emacs IRC Client⟫=

(autoload 'erc "erc" nil t)
(autoload 'erc-select "erc" nil t)
(autoload 'erc-select-read-args "erc" nil nil) ; needed for XEmacs
(autoload 'erc-select-ssl "erc" nil t)

ERC, an Emacs IRC Client⟫=

(setq erc-server                         "irc.freenode.net"
      erc-port                           6667
      erc-user-full-name                 "Theresa O'Connor"
      erc-email-userid                   "tess"
      erc-nick                           '("hober" "hober2" "hober3")
      erc-nicklist-use-icons             nil
      erc-password                       nil ; set this in local config
      erc-nickserv-passwords             nil ; set this in local config
      erc-anonymous-login                t
      erc-auto-query                     'bury
      erc-join-buffer                    'bury
      erc-max-buffer-size                30000
      erc-prompt-for-password            nil
      erc-prompt-for-nickserv-password   nil
      erc-command-indicator              "CMD"
      erc-echo-notices-in-current-buffer t
      erc-send-whitespace-lines          nil
      erc-hide-list                      '("JOIN" "PART" "QUIT")
      erc-ignore-list                    '("jibot")
      erc-autojoin-timing                'ident
      erc-autojoin-delay                 30
      erc-autojoin-channels-alist        '())

ERC, an Emacs IRC Client⟫=

(setq erc-quit-reason-various-alist
      '(("brb"    "I'll be right back.")
        ("lunch"  "Having lunch.")
        ("dinner" "Having dinner.")
        ("food"   "Getting food.")
        ("sleep"  "Sleeping.")
        ("work"   "Getting work done.")
        (".*"     (yow))))

(setq erc-part-reason-various-alist erc-quit-reason-various-alist
      erc-part-reason               'erc-part-reason-various
      erc-quit-reason               'erc-quit-reason-various)

ERC, an Emacs IRC Client⟫=

(defvar tess-erc-autojoin t
  "Whether or not ERC should autojoin on connect.")

(defvar tess-erc-identify t
  "Whether or not ERC should identify with NickServ on connect.")

(setq erc-server-alist
      '(("apple" apple "irc.sd.apple.com" 6697)
        ("coldfront" coldfront "irc.coldfront.net" 6667)
        ("freenode" freenode "irc.freenode.net" 8001)
        ("w3c" w3c "irc.w3.org" 6665))
      erc-networks-alist
      '((apple "apple.com")
        (coldfront "coldfront.net")
        (freenode "freenode.net")
        (w3c "w3.org")))

(defvar tess-erc-default-network "freenode"
  "Which IRC network to connect to by default.")

(defun tess-erc-nick ()
  (cond
   ((listp erc-nick) (car erc-nick))
   ((stringp erc-nick) erc-nick)
   (t "hober")))

(defun tess-irc-server-uses-ssl-p (server)
  "If non-null, SERVER requires SSL."
  (eq server 'apple))

(defun tess-irc (netspec)
  "Interactively select an IRC network to connect to.
Loosely based on `erc-server-select'."
  (interactive
   (list (assoc (completing-read
                 (format "IRC network (default %s)? "
                         tess-erc-default-network)
                 erc-server-alist nil t nil nil
                 tess-erc-default-network)
                erc-server-alist)))
  (let* ((network (nth 1 netspec))
         (nick (tess-erc-nick))
         (args (list :server (nth 2 netspec)
                     :port (nth 3 netspec)
                     :nick nick))
         (password (cdr (assoc nick
                               (cadr (assoc network
                                            erc-nickserv-passwords))))))
    (when password
      (setq args (append (list :password password) args)))
    (setq tess-erc-identify (not (eq network 'freenode)))
    ;; setq not let because of dumb reasons
    (setq erc-server-connect-function
          (if (tess-irc-server-uses-ssl-p network)
              'erc-open-tls-stream
            'open-network-stream))
    (apply 'erc args)))

erc face variables⟫=

;; '(erc-button-nickname-face 'underline)

erc faces⟫=

'(erc-action-face ((t (:bold t))))
'(erc-bold-face ((t (:bold t))))
'(erc-command-indicator-face ((t (:bold t))))
'(erc-current-nick-face ((t (:foreground "⟪light cyan⟫"))))
'(erc-my-nick-face ((t (:foreground "#fd9ef1223e85"))))
'(erc-default-face ((t ())))
'(erc-direct-msg-face ((t (:foreground "⟪medium cyan⟫")))) ;%
'(erc-error-face ((t (⟪error face⟫))))
`(erc-fool-face ((t ⟪dim this face when appropriate⟫)))
'(erc-input-face ((t (:foreground "⟪light yellow⟫"))))
'(erc-inverse-face ((t (:inverse-video t))))
'(erc-keyword-face ((t (:foreground "⟪medium magenta⟫" :bold t))))
'(erc-nick-default-face ((t (:foreground "⟪medium cyan⟫"))))
'(erc-nick-msg-face ((t (:foreground "⟪light magenta⟫" :bold t))))
'(erc-notice-face ((t (:foreground "⟪dark cyan⟫"))))
'(erc-pal-face ((t (:foreground "⟪medium yellow⟫"))))
'(erc-prompt-face ((t (⟪prompt face⟫)))) ;%
'(erc-timestamp-face ((t (:foreground "⟪medium green⟫")))) ;%
'(erc-underline-face ((t (:underline t)))) ;%

erc ansi bg faces⟫=

'(bg:erc-color-face0 ((t (:background "⟪medium white⟫"))))
'(bg:erc-color-face1 ((t (:background "⟪medium black⟫"))))
'(bg:erc-color-face2 ((t (:background "⟪dark blue⟫"))))
'(bg:erc-color-face3 ((t (:background "⟪dark green⟫"))))
'(bg:erc-color-face4 ((t (:background "⟪medium red⟫"))))
'(bg:erc-color-face5 ((t (:background "⟪dark yellow⟫"))))
'(bg:erc-color-face6 ((t (:background "⟪medium magenta⟫")))) ;%
'(bg:erc-color-face7 ((t (:background "⟪dark red⟫"))))
'(bg:erc-color-face8 ((t (:background "⟪light yellow⟫"))))
'(bg:erc-color-face9 ((t (:background "⟪medium green⟫")))) ;%
'(bg:erc-color-face10 ((t (:background "⟪medium blue⟫"))))
'(bg:erc-color-face11 ((t (:background "⟪medium cyan⟫"))))
'(bg:erc-color-face12 ((t (:background "⟪dark cyan⟫"))))
'(bg:erc-color-face13 ((t (:background "⟪light magenta⟫"))))
'(bg:erc-color-face14 ((t (:background "gray50"))))
'(bg:erc-color-face15 ((t (:background "gray90"))))

erc ansi fg faces⟫=

'(fg:erc-color-face0 ((t (⟪default fg⟫))))
'(fg:erc-color-face1 ((t (:foreground "⟪medium black⟫")))) ;%
'(fg:erc-color-face2 ((t (:foreground "⟪dark blue⟫"))))
'(fg:erc-color-face3 ((t (:foreground "⟪dark green⟫"))))
'(fg:erc-color-face4 ((t (:foreground "⟪medium red⟫"))))
'(fg:erc-color-face5 ((t (:foreground "⟪dark yellow⟫"))))
'(fg:erc-color-face6 ((t (:foreground "⟪medium magenta⟫"))))
'(fg:erc-color-face7 ((t (:foreground "⟪dark red⟫"))))
'(fg:erc-color-face8 ((t (:foreground "⟪light yellow⟫")))) ;%
'(fg:erc-color-face9 ((t (:foreground "⟪medium green⟫")))) ;%
'(fg:erc-color-face10 ((t (:foreground "⟪medium blue⟫"))))
'(fg:erc-color-face11 ((t (:foreground "⟪medium cyan⟫"))))
'(fg:erc-color-face12 ((t (:foreground "⟪dark cyan⟫"))))
'(fg:erc-color-face13 ((t (:foreground "⟪light magenta⟫")))) ;%
'(fg:erc-color-face14 ((t (:foreground "gray50"))))
'(fg:erc-color-face15 ((t (:foreground "gray90"))))

.ercrc.el⟫=

;;; .ercrc.el --- Theresa O'Connor's ERC configuration -*- emacs-lisp -*-

⟪Elisp Copyright Statement⟫

;;; Code:

.ercrc.el⟫=

(setq erc-header-line-uses-help-echo-p nil
      ;; Just the topic, ma'am.
      erc-header-line-format "%o")

.ercrc.el⟫=

(require 'erc-autojoin nil t)
(require 'erc-join nil t)

(add-to-list 'erc-autojoin-channels-alist
             '(".*freenode.net"
               "#emacs" "#emacs-ops" "#erc" "#gnus" "#microformats"
               "#serviceworker" "#temporaldeadzone" "#webkit"
               "#whatwg"))
(add-to-list 'erc-autojoin-channels-alist
             '(".*w3.org"
               "#css" "#css-test" "#editing" "#fx" "#gpu" "#houdini"
               "#html-wg" "#idcg" "#mediawg" "#privacycg" "#pwe"
               "#serviceworker" "#tag" "#tagmem" "#testing" "#web-adv"
               "#webapps" "#webplat" "#wicg" "#wpwg" "#zami"))

.ercrc.el⟫=

(require 'erc-nickserv nil t)
(require 'erc-services nil t)
(when tess-erc-identify ; Defined in .emacs
  (erc-nickserv-mode 1)
  (erc-services-mode 1))

.ercrc.el⟫=

(defun tess-erc-spc-dwim ()
  "DWIMmy behavior for the SPC key in ERC."
  (interactive)
  (condition-case nil (insert " ")
    (text-read-only
     (condition-case nil (scroll-up)
       (end-of-buffer (recenter 0))))))

(eval-after-load "erc"
  '(define-key erc-mode-map (kbd "SPC") 'tess-erc-spc-dwim))

.ercrc.el⟫=

(cond ((require 'erc-hl-nicks nil t)
       (erc-hl-nicks-mode 1))
      ((require 'erc-highlight-nicknames nil t)
       (erc-highlight-nicknames-mode 1)))

erc faces⟫=

'(erc-highlight-nick-base-face ((t ())))
'(erc-hl-nicks-nick-base-face ((t ())))

erc-highlight-nicknames.el fetch rule⟫=

erc-highlight-nicknames.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/erc-highlight-nicknames.el
erc-hl-nicks.el:
        curl -O $(GITHUB)/leathekd/erc-hl-nicks/master/erc-hl-nicks.el

.ercrc.el⟫=

(require 'erc-match)
(erc-match-mode 1)
(setq erc-pals nil
      erc-fools '(;; bots
                  "\\bcchelpbot\\b" "\\bCIA-47\\b" "\\bfsbot\\b"
                  "\\bjibot\\b" "\\bmfbot\\b" "\\bpimpbot\\b"
                  "\\bRRSAgent\\b" "\\brudybot\\b" "\\bwhereisbot\\b"
                  "\\bZakim\\b"
                  ;; #emacs
                  "\\bams\\b" "\\bimnowme\\b" "\\bjordanb\\b"
                  "\\bkamo9088\\b" "\\bmicka\\b" "\\btknudsen\\b"
                  "\\bxah\\b")
      erc-fool-highlight-type 'all
      erc-keywords '("ljupdate"))

.ercrc.el⟫=

(require 'erc-fill)
(erc-fill-mode 1)
(setq erc-fill-column 72)
;; protected, for using ERC in emacs -q
(when (fboundp 'tess-hide-trailing-whitespace)
  (add-hook 'erc-mode-hook 'tess-hide-trailing-whitespace))

.ercrc.el⟫=

(require 'erc-stamp)
(erc-stamp-mode 1)
(setq erc-insert-timestamp-function      'erc-insert-timestamp-left
      erc-timestamp-format               "[%H:%M] "
      erc-insert-away-timestamp-function 'erc-insert-timestamp-left
      erc-away-timestamp-format          "<%H:%M> ")

.ercrc.el⟫=

(require 'erc-button)
(erc-button-mode 1)
(setq erc-button-wrap-long-urls  nil
      erc-button-buttonize-nicks nil)

.ercrc.el⟫=

(require 'erc-netsplit)
(erc-netsplit-mode 1)

.ercrc.el⟫=

(require 'erc-ring)
(erc-ring-mode 1)

.ercrc.el⟫=

(require 'erc-dcc)

.ercrc.el⟫=

(require 'erc-page)
(erc-page-mode 1)

.ercrc.el⟫=

(require 'erc-track)
(erc-track-mode 1)
(setq erc-track-switch-direction 'importance)
(setq erc-track-exclude-types
      '("324" "329" "332" "333" "353"
        "JOIN" "NAMES" "NICK" "QUIT" "PART" "TOPIC"))
(global-set-key (kbd "C-c SPC") 'erc-track-switch-buffer)
(global-set-key (kbd "<f5>") 'erc-track-switch-buffer)

.ercrc.el⟫=

(defvar tess-modified-channels-length 0
  "Last recorded length of `erc-modified-channels-alist'.
This is updated each time `tess-erc-growl' gets called from
`etc-track-list-changed-hook'.")

(defun tess-erc-growl ()
  "Use growl for ERC track change notifications."
  (let ((modified-channels-length (length erc-modified-channels-alist)))
    (when (> modified-channels-length tess-modified-channels-length)
      (let ((msg (format "New messages in: %s"
                         (mapconcat (lambda (pair)
                                      (buffer-name (car pair)))
                                    erc-modified-channels-alist
                                    ", "))))
        (growl "IRC Activity" msg)
        (message "%s" msg)))
    (setq tess-modified-channels-length modified-channels-length)))

(when (and (eq system-type 'darwin)
           (locate-library "growl")
           window-system)
  (autoload 'growl "growl")
  (add-hook 'erc-track-list-changed-hook 'tess-erc-growl))

.ercrc.el⟫=

;; emacs-w3m clobbers erc-track-mode's C-c C-SPC binding.
(eval-after-load "w3m"
  '(define-key w3m-mode-map (kbd "C-c C-SPC") 'erc-track-switch-buffer))

.ercrc.el⟫=

(require 'erc-truncate)
(erc-truncate-mode 1)

.ercrc.el⟫=

(defun erc-cmd-SHOW (&rest form)
  "Eval FORM and send the result and the original form as:

FORM => (eval FORM)."
  (let* ((form-string (mapconcat 'identity form " "))
         (result
          (condition-case err
              (eval (read-from-whole-string form-string))
            (error
             (format "Error: %s" error)))))
    (erc-send-message (format "%s => %S" form-string result))))
(add-to-list 'erc-noncommands-list 'erc-cmd-SHOW)

.ercrc.el⟫=

(defun erc-cmd-OPME ()
  "Ask ChanServ to grant me op in this channel."
  (erc-message "PRIVMSG"
               (format "ChanServ op %s"
                       (erc-default-target)
                       (erc-current-nick))
               nil))

(defun erc-cmd-DEOPME ()
  "Deop myself from this channel."
  (erc-cmd-DEOP (format "%s" (erc-current-nick))))

(defun erc-cmd-BAN (nick)
  "Ban NICK from this channel."
  (erc-server-send
   (format "mode %s +b *!*~%s@*" (erc-default-target) nick)))

.ercrc.el⟫=

(defun erc-cmd-NP ()
  "Display currently playing iTunes track"
  (erc-send-message (shell-command-to-string "osascript -e 'tell
  application \"iTunes\" to if player state is playing then \"NP: \"
  \& name of current track \& \" - \" \& artist of current track'")))
(add-to-list 'erc-noncommands-list 'erc-cmd-NP)

.ercrc.el⟫=

(defun erc-cmd-YOW ()
  (erc-send-message (erc-replace-regexp-in-string "\n" "" (yow))))
(add-to-list 'erc-noncommands-list 'erc-cmd-YOW)

.ercrc.el⟫=

(when (and (boundp 'viper-mode) viper-mode)
  (require 'erc-viper nil t))

.ercrc.el⟫=

(defvar tess-erc-pcomplete-nick-postfix-overrides
  '(("Zakim" . ", "))
  "An alist of nicks which take non-default completion postfixes.
Each cell is of the form (NICK . POSTFIX), both strings.")

(defun tess-erc-pcomplete-format-nick (nick &optional postfix)
  "Return NICK, formatted for completion.
Will use POSTFIX for formatting, unless an override is provided for NICK
in `tess-erc-pcomplete-nick-postfix-overrides'. If POSTFIX is not
provided, we default to `erc-pcomplete-nick-postfix'."
  (concat nick
          (or (cdr (assoc nick
                          tess-erc-pcomplete-nick-postfix-overrides))
              postfix
              erc-pcomplete-nick-postfix)))

(defun tess-pcomplete-erc-nicks (&optional postfix ignore-self)
  "Returns a list of nicks in the current channel.
Optional argument POSTFIX is something to append to the nickname.
If optional argument IGNORE-SELF is non-nil, don't return the current nick."
  (let ((users (if erc-pcomplete-order-nickname-completions
                   (erc-sort-channel-users-by-activity
                    (erc-get-channel-user-list))
                 (erc-get-channel-user-list)))
        (nicks nil))
    (dolist (user users)
      (let ((nick (erc-server-user-nickname (car user))))
        (unless (and ignore-self (string= nick (erc-current-nick)))
          (setq nicks
                (cons (tess-erc-pcomplete-format-nick nick postfix)
                      nicks)))))
    (nreverse nicks)))

(eval-after-load "erc-pcomplete"
  '(defalias 'pcomplete-erc-nicks 'tess-pcomplete-erc-nicks))

.ercrc.el⟫=

(defun tess-unprollify ()
  (goto-char (point-min))
  (while (search-forward "prolly" nil t)
    (replace-match "probably" nil t)))
(add-hook 'erc-insert-modify-hook 'tess-unprollify)

.ercrc.el⟫=

⟪Emoji in ERC⟫

.ercrc.el⟫=

;;; .ercrc.el ends here

rcirc

rcirc⟫=

(setq rcirc-nick "hober")
(add-hook 'rcirc-mode-hook 'tess-hide-trailing-whitespace)

rcirc faces⟫=

'(rcirc-my-nick ((t (:foreground "⟪light cyan⟫"))))
'(rcirc-mode-line-nick ((t (:foreground "⟪medium magenta⟫" :bold t))))
'(rcirc-other-nick ((t (:foreground "⟪medium cyan⟫"))))
'(rcirc-nick-in-message ((t (:foreground "⟪light magenta⟫" :bold t))))
'(rcirc-server ((t (:foreground "⟪dark cyan⟫"))))
'(rcirc-prompt ((t (⟪prompt face⟫)))) ;%

Utilities

SSH

Use SSH for M-x rsh, and make M-x ssh⟫=

(when (fboundp 'rsh)
  (setq remote-shell-program "ssh")
  (defalias 'ssh 'rsh))

TRAMP

TRAMP: Transparent Remote Access over Multiple Protocols⟫=

(when (locate-library "tramp")
  (setq tramp-default-method "sudo"))

Public keys

.ssh/public-keys⟫=

⟪niamh-pubkey-1⟫⟪niamh-pubkey-2⟫⟪niamh-pubkey-3⟫ ⟪niamh-pubkey-4⟫
⟪oban-key-1⟫⟪oban-key-2⟫⟪oban-key-3⟫⟪oban-key-4⟫⟪oban-key-5⟫⟪oban-key-6⟫⟪oban-key-7⟫⟪oban-key-8⟫
⟪yt-key-1⟫⟪yt-key-2⟫⟪yt-key-3⟫⟪yt-key-4⟫⟪yt-key-5⟫⟪yt-key-6⟫
⟪ap-key-1⟫⟪ap-key-2⟫⟪ap-key-3⟫⟪ap-key-4⟫⟪ap-key-5⟫⟪ap-key-6⟫
⟪mb81-key-1⟫⟪mb81-key-2⟫⟪mb81-key-3⟫⟪mb81-key-4⟫⟪mb81-key-5⟫⟪mb81-key-6⟫
⟪mb101-key-1⟫⟪mb101-key-2⟫⟪mb101-key-3⟫⟪mb101-key-4⟫⟪mb101-key-5⟫⟪mb101-key-6⟫
⟪talisker-key-1⟫⟪talisker-key-2⟫⟪talisker-key-3⟫⟪talisker-key-4⟫⟪talisker-key-5⟫⟪talisker-key-6⟫

talisker-key-1⟫=

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDITed8UwhOFo8t1x5qyth2lvYr2Qu25s

talisker-key-2⟫=

d0rPCpnDHCOZhPbEdYNXvNte1OUC1gMjBqrJDy5rYMY1jqKIA/Er7uy2w656E2vvouTCjk

talisker-key-3⟫=

CDezdxAhVTG7ThEQOhQ54TUKbZ/PX03vGojxrYksC5opODcjAOtANbWqbk/QefmuaPqQpC

talisker-key-4⟫=

feaES2pA/cACIGVcCuVWO0Bo2MM8Q2xlalEwUmrvkKbT3QVYd09+2PFZmK7rOxUT/+3DI7

talisker-key-5⟫=

CWo1eIbGPZXHO4sFh+EeUQS7Wg28XALBdkq69RU04tck5PAJjcwfl6r9OctY57YIxhae9A

talisker-key-6⟫=

ZaBHD1hhiwMXo4C7Rd3hEtBpTbjSRL tess@talisker.lan

oban-key-1⟫=

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC5Z9rqoHoy3G9Rcdi972VzUE0Sh8RgY6

oban-key-2⟫=

ITepfm9gyNbPdh3DNolA8eu4xE51J4nwDgObYLHyFIu6SA8moxJD71ggVVANIgHvQrLegE

oban-key-3⟫=

ssrUFy8CDjQJBVCCHt4CeDnINOIeBz2jC8tuLC00LLWdo+XG5B7CsKW/3s1Tughh6K3Rj/

oban-key-4⟫=

NupQOcDLjTOm6fuftc5/PeCZJeyB8ALuddH60rQ/Dknd5nhfL8pYhg1xTdjtLqQcDNu2fB

oban-key-5⟫=

hC/aBR4jNLKCQoX6JU+bb+EsiPO07omz3QqIhrhnwDmKigOy60UebcblgDxwij/KA6b0JS

oban-key-6⟫=

9OHwp744dN5aWKoiQ/GNBnjlfJuyxY+ReTnClkZAFQxBOsxnH2r4JoPUI7opLBgf22EnUD

oban-key-7⟫=

RzcEBYeIqUOsprb47j88k7ym1iYRKolS7S70XknkYtDi5Kjo9q7T96AkZ3lRNumqsgjJ5G

oban-key-8⟫=

sBnG4kAmvifxEIxsm3UjCeuTwGhiWTT5Fpb64BIUCC/fkLF8L7GJJAcohxN4c= ted@oban.lan

yt-key-1⟫=

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAqZTGd0CMA6rh/W0ZLVPdLC4HKsfGsbWldU

yt-key-2⟫=

ZuoyfG3/p7fE/gTeAMVCcKyCxQJ5HWDURKjyIsHFTbqNzyp0rWgbYWUa8nuMxJDulVSMtV

yt-key-3⟫=

p2MBnzY94bU9qABHs/H4ZdagTLB0rkdZtgicukHbRq9SRKsTUmIaGRXNXUTCwEzdNSiKIY

yt-key-4⟫=

sYXgdCzFvND16HcJmu3lqaNUWntQtRFcBvD85iCQ0pR/rEZ2Qi0w8BIvZ0uOMDU0NhFJ5R

yt-key-5⟫=

r0xM8TqPQtpPYIIEwhjoew/eM2F30n46lTCd8UPmmjW1U+pG2O89tt1DKkioAPNxJGsCWZ

yt-key-6⟫=

Q1DCDEyI5/PQ+Xlvsc+0T5/HkdMQ== ted@yt

niamh-pubkey-1⟫=

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAsHo/tCFtrZJWysF+RoRLlz5KmyKddhlIXG

niamh-pubkey-2⟫=

09uQ/ige3Eph/MHflrPOxml5zsfwl/XVRzfSjBsPHCVTGEycB5/9V9eUT56wOrKRy+QZde

niamh-pubkey-3⟫=

Iwr6WdPF7gzqibiR4s9sYcmppwwnNGEu1083Q/YRQR+hm3olYMlpuE/1XO+mhPE2n1k=

niamh-pubkey-4⟫=

ted@niamh.cfhp.org

ap-key-1⟫=

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDdyV7OLxxi1HeVmkqu32ggtOJVTXne0n

ap-key-2⟫=

PmGmtyzGZRvZh7OSNw/471KUneQK4hDl8rVLUGBsOJN75R0c9bnmUCCONBkkNBLGwIkB5C

ap-key-3⟫=

fywxY/8vbXqAycVQJIc2scbrGMm1KIiICytcou+P10s85HPGoGd66seB8HeUNr9ovfhG+5

ap-key-4⟫=

s+BY3B08al8K23IdEIQ8Bt7qz9RgoLuoM+65RNgmf1phut9kWyLcXto5hKFjTU0SoFcFMR

ap-key-5⟫=

yrKtZUJHhcPwnY+DLrAh3G47tbbObQ82Un6gq4kBJzDBenqfvGm3QW7Gy43SqNlf0ETKJe

ap-key-6⟫=

m/SkzCeW2rToIyTbYFN9L6ODqzITiX eoconnor@apple

mb81-key-1⟫=

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpb0tkzPGNQndtUmJaslLpsq25sU1YFP

mb81-key-2⟫=

RNytlnAdQqT9kqHNcn6rxRi81ZJsY7MsDvgcknyVnVQCZOWiKT74Cjet2ZKpZ4Evci2WYl

mb81-key-3⟫=

bge++sxImBP7swAYEt1yoUmFsEAGivp2ymxRFgiKDTpAD+PGZW4WeOhYrITIkxNnTnXMiW

mb81-key-4⟫=

IHcfkh6WyS2ftltKVPJViwdLn2NHnVs9tIWpMJclGMx9LK9UgPJIcBjhPoNd4if3Stg0Ev

mb81-key-5⟫=

8ZOOk+VgTNj+QNVLtkF4EQ6a5C+YC07DX+Qx/Otn7k1vYL6s64Mlw/26pPMFNez2zFghp+

mb81-key-6⟫=

hLApIY/e3QGq3Xv4stZXqy0hoalNk1 toconnor@toconnor-mb.local

mb101-key-1⟫=

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCiW5rYMB7caLPLiU3izNcKPYbxbn62SU

mb101-key-2⟫=

xjJjfQc6QgaZtB9As9rdglwHvuu6II1IQS4EQgw1cDGnnm04LUI9YcO+DgfzBJqUiYrhQQ

mb101-key-3⟫=

QS71tS2Bt0LzLAZ0scpIu4UKexo6/5R23g90nxnCjJLX2h9ADdqJZf8RbJFhgNuAB1wj86

mb101-key-4⟫=

Z0kJAZftLrY3ETUo+uubu8P4ZYPoIZzkulugwiOKYYaIQ6vB3BZ0t776hSIvEwjNMl3fpu

mb101-key-5⟫=

vYS+K4lzqqC6MATceS4FA7KECGtjpTspHDTH/7DoLD3phWMOdgYPrbIwyBKvmqh2pTTao0

mb101-key-6⟫=

8wlHhQtLcw+WQQOMBh8Voxs20rJMSR eoconnor@Theresas-MacBook.local

.ssh/config⟫=

ControlMaster auto
ControlPath ~/tmp/%r@%h:%p

.ssh/config⟫=

ForwardAgent yes
ForwardX11 no

.ssh/config⟫=

# My machines

Host mallow
HostName mallow.cfhp.org
User tess
ForwardX11 yes

.ssh/config⟫=

# Default settings.

Host *
# MACs hmac-sha1,hmac-md5,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
ForwardAgent no

Info, man, apropos, and other help

info title face⟫=

:foreground "⟪light red⟫"

info xref face⟫=

:foreground "⟪medium cyan⟫"

info faces⟫=

'(Info-title-1-face ((t (⟪info title face⟫))))
'(Info-title-2-face ((t (⟪info title face⟫))))
'(Info-title-3-face ((t (⟪info title face⟫))))
'(Info-title-4-face ((t (⟪info title face⟫))))
'(info-header-node ((t (⟪info title face⟫))))
'(info-header-xref ((t (⟪info xref face⟫))))
'(info-menu-5 ((t ())))
'(info-menu-star ((t ())))
'(info-menu-header ((t (⟪info title face⟫))))
'(info-node ((t (⟪info title face⟫))))
'(info-title-1 ((t (⟪info title face⟫))))
'(info-title-2 ((t (⟪info title face⟫))))
'(info-title-3 ((t (⟪info title face⟫))))
'(info-title-4 ((t (⟪info title face⟫))))
'(info-xref ((t (⟪info xref face⟫))))

man face variables⟫=

'(Man-overstrike-face 'font-lock-variable-name-face)
'(Man-underline-face 'font-lock-string-face)

configure woman⟫=

(setq woman-use-own-frame nil)

woman faces⟫=

'(woman-italic-face ((t (:slant italic))))
'(woman-bold-face ((t (:bold t))))
'(woman-unknwon-face ((t (:foreground "⟪medium cyan⟫")))) ;%
'(woman-addition-face ((t (:foreground "⟪medium green⟫"))))

apropos face variables⟫=

'(apropos-symbol-face 'font-lock-keyword-face)
'(apropos-keybinding-face 'font-lock-constant-face)
'(apropos-label-face 'font-lock-type-face)
'(apropos-property-face 'font-lock-string-face)
'(apropos-match-face 'font-lock-function-name-face)

hyper apropos faces⟫=

'(hyper-apropos-documentation ((t (:foreground "⟪light white⟫")))) ;%
'(hyper-apropos-hyperlink ((t (⟪link face⟫))))
'(hyper-apropos-major-heading ((t (:foreground "⟪light yellow⟫")))) ;%
'(hyper-apropos-section-heading ((t (:foreground "⟪medium yellow⟫"))))
'(hyper-apropos-apropos-heading ((t (:foreground "⟪dark yellow⟫"))))
'(hyper-apropos-apropos-warning ((t (⟪warning face⟫))))

cfengine

cfengine⟫=

(when (locate-library "cfengine")
  (autoload 'cfengine-mode "cfengine" nil t)
  (add-to-list 'auto-mode-alist
               '("cf\\(\\.\\|agent\\.conf\\)" . cfengine-mode))
  (defalias 'cfengine-beginning-of-line 'beginning-of-line)
  (setq cfengine-indent 4))

Ledger

Set LEDGER (zsh)⟫=

export LEDGER='~/.ledger'

ledger-mode⟫=

(when (locate-library "ledger")
  (autoload 'ledger-mode "ledger" nil t))

Operating Systems

OS-specific tweaks (zsh)⟫=

⟪ls defaults (zsh)⟫

case `uname -s` in
    Darwin)
        ⟪ls in freebsd (zsh)⟫
        ⟪fix top under macOS (zsh)⟫
        ⟪macOS shell aliases (zsh)⟫
        ;;
    FreeBSD)
        ⟪ls in freebsd (zsh)⟫
        ⟪FreeBSD keymap (zsh)⟫
        ;;
    Linux)
        ⟪ls in linux (zsh)⟫
        ;;
esac

Setting PATH (zsh)⟫=

if is-in-path xcode-select; then
    add-to-path `xcode-select -p`/usr/bin
fi

FreeBSD

FreeBSD keymap (zsh)⟫=

if [[ $TERM = 'cons25' ]]; then
    if [[ -r ~/.freebsd-keymap ]]; then
        kbdcontrol -l ~/.freebsd-keymap
        export HOBER_KEYMAP='YES'
    fi
fi

Handle my FreeBSD keymap⟫=

(let ((hober-keymap (getenv "HOBER_KEYMAP"))
      (term (getenv "TERM")))
  (when (and hober-keymap (string-equal hober-keymap "YES")
             term (string-equal term "cons25"))
    ⟪FreeBSD console⟫))

FreeBSD console⟫=

(when (fboundp 'normal-erase-is-backspace-mode)
  (normal-erase-is-backspace-mode -1))

FreeBSD console⟫=

(define-key function-key-map (kbd "ESC [ }") (kbd "<menu>")) ;%

FreeBSD console⟫=

(define-key function-key-map (kbd "ESC [ J") 'event-apply-super-modifier)

FreeBSD console⟫=

(define-key function-key-map (kbd "ESC [ ~") 'event-apply-hyper-modifier)

Console keymap

.freebsd-keymap⟫=

#                                                         alt
# scan                       cntrl          alt    alt   cntrl lock
# code  base   shift  cntrl  shift  alt    shift  cntrl  shift state
# ------------------------------------------------------------------
  000   nop    nop    nop    nop    nop    nop    nop    nop     O
  001   esc    esc    esc    esc    esc    esc    esc    esc     O
  002   '1'    '!'    nop    nop    177    161    nop    nop     O
  003   '2'    '@'    nul    nul    178    192    128    128     O
  004   '3'    '#'    nop    nop    179    163    nop    nop     O
  005   '4'    '$'    nop    nop    180    164    nop    nop     O
  006   '5'    '%'    nop    nop    181    165    nop    nop     O
  007   '6'    '^'    rs     rs     182    222    158    158     O
  008   '7'    '&'    nop    nop    183    166    nop    nop     O
  009   '8'    '*'    nop    nop    184    170    nop    nop     O
  010   '9'    '('    nop    nop    185    168    nop    nop     O
  011   '0'    ')'    nop    nop    176    169    nop    nop     O
  012   '-'    '_'    us     us     173    223    159    159     O
  013   '='    '+'    nop    nop    189    171    nop    nop     O
  014   del    del    bs     bs     255    255    136    136     O
  015   ht     ht     ht     ht     137    137    137    137     O
  016   'q'    'Q'    dc1    dc1    241    209    145    145     C
  017   'w'    'W'    etb    etb    247    215    151    151     C
  018   'e'    'E'    enq    enq    229    197    133    133     C
  019   'r'    'R'    dc2    dc2    242    210    146    146     C
  020   't'    'T'    dc4    dc4    244    212    148    148     C
  021   'y'    'Y'    em     em     249    217    153    153     C
  022   'u'    'U'    nak    nak    245    213    149    149     C
  023   'i'    'I'    ht     ht     233    201    137    137     C
  024   'o'    'O'    si     si     239    207    143    143     C
  025   'p'    'P'    dle    dle    240    208    144    144     C
  026   '['    '{'    esc    esc    219    251    155    155     O
  027   ']'    '}'    gs     gs     221    253    157    157     O
  028   cr     cr     nl     nl     141    141    138    138     O
  029   lctrl  lctrl  lctrl  lctrl  lctrl  lctrl  lctrl  lctrl   O
  030   'a'    'A'    soh    soh    225    193    129    129     C
  031   's'    'S'    dc3    dc3    243    211    147    147     C
  032   'd'    'D'    eot    eot    228    196    132    132     C
  033   'f'    'F'    ack    ack    230    198    134    134     C
  034   'g'    'G'    bel    bel    231    199    135    135     C
  035   'h'    'H'    bs     bs     232    200    136    136     C
  036   'j'    'J'    nl     nl     234    202    138    138     C
  037   'k'    'K'    vt     vt     235    203    139    139     C
  038   'l'    'L'    ff     ff     236    204    140    140     C
  039   ';'    ':'    nop    nop    187    186    nop    nop     O
  040   '''    '"'    nop    nop    167    162    nop    nop     O # "
  041   '`'    '~'    nop    nop    224    254    nop    nop     O
  042   lshift lshift lshift lshift lshift lshift lshift lshift  O
  043   '\'    '|'    fs     fs     220    252    156    156     O
  044   'z'    'Z'    sub    sub    250    218    154    154     C
  045   'x'    'X'    can    can    248    216    152    152     C
  046   'c'    'C'    etx    etx    227    195    131    131     C
  047   'v'    'V'    syn    syn    246    214    150    150     C
  048   'b'    'B'    stx    stx    226    194    130    130     C
  049   'n'    'N'    so     so     238    206    142    142     C
  050   'm'    'M'    cr     cr     237    205    141    141     C
  051   ','    '<'    nop    nop    172    188    nop    nop     O
  052   '.'    '>'    nop    nop    174    190    nop    nop     O
  053   '/'    '?'    nop    nop    175    191    nop    nop     O
  054   rshift rshift rshift rshift rshift rshift rshift rshift  O
  055   '*'    '*'    nl     nl     170    170    138    138     O
  056   lalt   lalt   lalt   lalt   lalt   lalt   lalt   lalt    O
  057   ' '    ' '    nul    nul    160    160    128    128     O
  058   lctrl  lctrl  lctrl  lctrl  lctrl  lctrl  lctrl  lctrl   O
  059   fkey01 fkey13 fkey25 fkey37 scr01  scr11  scr01  scr11   O
  060   fkey02 fkey14 fkey26 fkey38 scr02  scr12  scr02  scr12   O
  061   fkey03 fkey15 fkey27 fkey39 scr03  scr13  scr03  scr13   O
  062   fkey04 fkey16 fkey28 fkey40 scr04  scr14  scr04  scr14   O
  063   fkey05 fkey17 fkey29 fkey41 scr05  scr15  scr05  scr15   O
  064   fkey06 fkey18 fkey30 fkey42 scr06  scr16  scr06  scr16   O
  065   fkey07 fkey19 fkey31 fkey43 scr07  scr07  scr07  scr07   O
  066   fkey08 fkey20 fkey32 fkey44 scr08  scr08  scr08  scr08   O
  067   fkey09 fkey21 fkey33 fkey45 scr09  scr09  scr09  scr09   O
  068   fkey10 fkey22 fkey34 fkey46 scr10  scr10  scr10  scr10   O
  069   nlock  nlock  nlock  nlock  nlock  nlock  nlock  nlock   O
  070   slock  slock  slock  slock  slock  slock  slock  slock   O
  071   fkey49 '7'    '7'    '7'    183    183    183    183     N
  072   fkey50 '8'    '8'    '8'    184    184    184    184     N
  073   fkey51 '9'    '9'    '9'    185    185    185    185     N
  074   fkey52 '-'    '-'    '-'    173    173    173    173     N
  075   fkey53 '4'    '4'    '4'    180    180    180    180     N
  076   fkey54 '5'    '5'    '5'    181    181    181    181     N
  077   fkey55 '6'    '6'    '6'    182    182    182    182     N
  078   fkey56 '+'    '+'    '+'    171    171    171    171     N
  079   fkey57 '1'    '1'    '1'    177    177    177    177     N
  080   fkey58 '2'    '2'    '2'    178    178    178    178     N
  081   fkey59 '3'    '3'    '3'    179    179    179    179     N
  082   fkey60 '0'    '0'    '0'    176    176    176    176     N
  083   del    '.'    '.'    '.'    174    174    boot   boot    N
  084   us     us     us     us     us     us     us     us      O
  085   nop    nop    nop    nop    nop    nop    nop    nop     O
  086   nop    nop    nop    nop    nop    nop    nop    nop     O
  087   fkey11 fkey23 fkey35 fkey47 scr11  scr11  scr11  scr11   O
  088   fkey12 fkey24 fkey36 fkey48 scr12  scr12  scr12  scr12   O
  089   nop    cr     cr     cr     141    141    141    141     N
  090   rctrl  rctrl  rctrl  rctrl  rctrl  rctrl  rctrl  rctrl   O
  091   nop    '/'    '/'    '/'    175    175    175    175     N
  092   nscr   pscr   debug  debug  nop    nop    nop    nop     O
  093   ralt   ralt   ralt   ralt   ralt   ralt   ralt   ralt    O
  094   fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49  O
  095   fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50  O
  096   fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51  O
  097   fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53  O
  098   fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55  O
  099   fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57  O
  100   fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58  O
  101   fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59  O
  102   fkey60 paste  fkey60 fkey60 fkey60 fkey60 fkey60 fkey60  O
  103   fkey61 fkey61 fkey61 fkey61 fkey61 fkey61 boot   fkey61  O
  104   slock  saver  slock  saver  susp   nop    susp   nop     O
  105   fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62  O
  106   fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63  O
  107   fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64  O
  108   nop    nop    nop    nop    nop    nop    nop    nop     O

Linux

RPM specs

rpm-spec-mode.el fetch rule⟫=

rpm-spec-mode.el:
        curl -O http://www.tihlde.org/~stigb/rpm-spec-mode.el

Open RPM spec files in rpm-spec-mode⟫=

(when (locate-library "rpm-spec-mode")
  ⟪defun user-mail-address⟫
  (autoload 'rpm-spec-mode "rpm-spec-mode" nil t)
  ;; RPM specfiles are .spec
  (add-to-list 'auto-mode-alist '("\\.spec\\'" . rpm-spec-mode)))

macOS

Ensure XCode Command Line Tools are in exec-path⟫=

(when (executable-find "xcode-select")
  (let ((xcode-developer-path
         (substring (shell-command-to-string "xcode-select -p") 0 -1)))
    (add-to-list 'exec-path
                 (expand-file-name "usr/bin" xcode-developer-path))))

Ensure we can click on Apple URLs⟫=

(defun tess-thingatpt-install-apple-uri-schemes ()
  (let ((schemes '("rdar://" "adir://" "afp://" "message:")))
    (mapc (lambda (scheme)
            (add-to-list 'thing-at-point-uri-schemes scheme))
          schemes))
  (setq thing-at-point-url-regexp
        (concat "\\<\\(" (mapconcat 'identity thing-at-point-uri-schemes
                                    "\\|") "\\)"
                thing-at-point-url-path-regexp)))

(eval-after-load "thingatpt"
  '(tess-thingatpt-install-apple-uri-schemes))

Stop Cocoa Emacs from using the system highlight⟫=

(setq ns-use-system-highlight-color nil)

Emacs.plist⟫=

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
          "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        ⟪emacs-app modifiers⟫

        ⟪emacs-app default-frame-alist⟫

        ⟪emacs-app font settings⟫

        ⟪emacs-app cursor⟫

        <key>AutoLower</key>
        <string>NO</string>
        <key>AutoRaise</key>
        <string>NO</string>
        <key>ExpandSpace</key>
        <string>0.0</string>
        <key>UseSystemHighlightColor</key>
        <string>NO</string>
</dict>
</plist>

fix top under macOS (zsh)⟫=

alias top='top -ocpu -Otime'

Update environment under macOS⟫=

(when (and (eq system-type 'darwin)
           (featurep 'emacs)
           (require 'osx-plist nil t)
           (file-exists-p "~/.MacOSX/environment.plist"))
  (osx-plist-update-environment))

OS X Lion⟫=

;; Disable the iOS-like accent typing which interferes with holding down
;; alphanumeric keys. <rdar://problem/9591132>
(when (fboundp 'ns-get-resource)
  (let ((pne-enabled "ApplePressAndHoldEnabled"))
    (unless (string-equal "NO" (ns-get-resource nil pne-enabled))
      (ns-set-resource nil pne-enabled "NO"))))

Fix Emacs behavior when in the macOS dock⟫=

(when (and (eq system-type 'darwin)
           (boundp 'mac-apple-event-map)
           (keymapp mac-apple-event-map))
  (define-key mac-apple-event-map
    [core-event reopen-application] 'raise-frame))

OpenDarwin Ports

defvar tess-ports-tree-root⟫=

(defvar tess-ports-tree-root
  (cond ((eq system-type 'darwin)
         (concat "/opt/local/var/db/dports/sources/"
                 "rsync.rsync.opendarwin.org_dpupdate_dports"))
        ((eq system-type 'berkeley-unix)
         "/usr/ports")
        (t nil))
  "Directory under which this system's ports tree lives.")

Emacs code for browsing the ports tree⟫=

(defun tess-list-ports-tree-categories ()
  (let* ((default-directory tess-ports-tree-root)
         (subdirs (directory-files default-directory nil "[a-z].*"))
         (case-fold-search nil)
         retval)
    (mapc (lambda (file)
            (when (and (file-directory-p file)
                       (string-match "^[a-z]" file))
              (push file retval)))
          subdirs)
    (nreverse retval)))

(defun tess-list-ports-in-category (category)
  (let* ((default-directory (expand-file-name category tess-ports-tree-root))
         (listing (directory-files default-directory))
         subdirs)
    (mapc (lambda (file)
            (when (and (file-directory-p file)
                       (string-match "^[a-z]" file))
              (push file subdirs)))
          listing)
    (nreverse subdirs)))

(defun tess-read-port ()
  (let* ((categories (tess-list-ports-tree-categories))
         (category (completing-read "Port category: "
                                    (mapcar (lambda (entry)
                                              (cons entry entry))
                                            categories)
                                    nil t))
         (ports (tess-list-ports-in-category category))
         (port (completing-read "Port: " (mapcar (lambda (entry)
                                                   (cons entry entry))
                                                 ports)
                                nil t)))
    (concat category "/" port)))

Property list files

https://en.wikipedia.org/wiki/Property_list

bin/env2plist⟫=

#!/bin/sh

# Generates a new ~/.MacOSX/environment.plist for you, based on your
# current shell environment. Note that you should probably trim several
# of the resulting entries.

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
echo "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
echo "          \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"
echo "<plist version=\"1.0\">"
echo "  <dict>"
env | sed -e "s/=/      /" -e "s/</\&lt;/g" -e "s/>/\&gt;/g" \
    | awk 'BEGIN { FS = "[\t]+" } /^[^_]/ {\
        print "    <key>" $1 "</key>\n    <string>" $2 "</string>"}'
echo "  </dict>"
echo "</plist>"

templates/template.plist⟫=

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
          "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key></key>
    <string></string>
  </dict>
</plist>

plist template⟫=

(let ((plist-template "template.plist"))
  (when (file-exists-p (expand-file-name plist-template
                                         auto-insert-directory))
    (add-to-list 'auto-insert-alist
                 `(("\\.plist\\'" . "Apple plist") . ,plist-template))))

Games

Nethack

Nethack settings (zsh)⟫=

export NETHACKOPTIONS='name:Hober, align:neutral, race:Elf,
role:Rogue, gender:random, fruit:apple, horsename:Kirin,
dogname:Maggie, color, catname:Molly'

enable screen's nethack mode⟫=

nethack on

freeciv.serv⟫=

# Server commands to set up a nice game.

FreeCiv

freeciv.serv⟫=

# map
set size 4
set generator 3
set landmass 40

freeciv.serv⟫=

# starting conditions
set startpos 3
set dispersion 4

freeciv.serv⟫=

# cities
set citynames 3
set citymindist 4

freeciv.serv⟫=

# ai
set aifill 8
easy

freeciv.serv⟫=

# gameplay
set barbarians 0
set onsetbarbs 5000
set civilwarsize 6

freeciv.serv⟫=

# endgame
set spacerace 0
set endyear 2100

Emacs Games⟫=

(add-hook 'tetris-mode-hook 'tess-hide-trailing-whitespace)

Emacs Games⟫=

(when (locate-library "chess-auto")
  (load-library "chess-auto"))

Emacs Games⟫=

(when (locate-library "malyon")
  (autoload 'malyon "malyon" nil t)
  (add-hook 'malyon-mode-hook 'tess-hide-trailing-whitespace))

Documents

Editing documents

Wikis

oddmuse.el fetch rule⟫=

oddmuse.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/oddmuse.el

EmacsWiki⟫=

(when (require 'oddmuse nil t)
  (setq oddmuse-directory "~/wikis")
  (oddmuse-mode-initialize))

defun tess-w3m-edit-emacswiki-page⟫=

(defun tess-w3m-edit-emacswiki-page (url)
  (let ((node (substring (substring w3m-current-url
                                    (string-match "wiki[/?][^/&=]+\\'"
                                                  w3m-current-url))
                         5)))
    (w3m-goto-url (concat "http://www.emacswiki.org/cgi-bin/wiki"
                          "?action=edit;id=" node))))

editing emacswiki pages with w3m⟫=

(add-to-list 'w3m-edit-function-alist
             '(".*emacswiki.org/cgi-bin/wiki.*"
               . tess-w3m-edit-emacswiki-page))

wikiarea⟫=

(when (locate-library "wikiarea")
  (autoload 'wikiarea "wikiarea" nil t)
  (setq wikiarea-managed-directory
        (expand-file-name "emacs-wiki/" tess-elisp-dir)))

wikipedia elisp fetch rules⟫=

WIKIPEDIA_ROOT="http://cvs.gna.org/viewcvs/*checkout*/wikipedia-el"
WIKIPEDIA_PATH="wikipedia-el/wikipedia.el?rev=HEAD&content-type=text/plain"
wikipedia.el:
        curl -o wikipedia.el $(WIKIPEDIA_ROOT)/$(WIKIPEDIA_PATH)

wikipedia elisp fetch rules⟫=

wikipedia-mode.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/wikipedia-mode.el

wikipedia major mode⟫=

(when (locate-library "wikipedia-mode")
  (autoload 'wikipedia-mode "wikipedia-mode" nil t)
  (add-to-list 'auto-mode-alist '("\\.wiki\\'" . wikipedia-mode)))

mediawiki major mode⟫=

(when (locate-library "mediawiki-mode")
  (autoload 'mediawiki-mode "mediawiki-mode" nil t)
  (add-to-list 'auto-mode-alist '("\\.mw$" . mediawiki-mode)) ; $

  ;; do this in a hook because mediawiki-mode resets its keybindings on
  ;; evey mode change.
  (add-hook 'mediawiki-mode-hook
            (lambda ()
              (define-key mediawiki-mode-map (kbd "C-x C-s") 'save-buffer))))

TeX

disable TeX {sub,super}script frobbing⟫=

;; AUC-TeX
(setq font-latex-script-display nil)
;; TeX mode
(eval-after-load "tex-mode"
  '(defun tex-font-lock-suscript (pos)
     '(face default)))

AUCTeX⟫=

(when (require 'tex-site nil t)
  (setq-default TeX-auto-untabify nil)
  (setq TeX-auto-untabify nil))

latex template⟫=

(let ((latex-template "template.tex"))
  (when (file-exists-p (expand-file-name latex-template
                                         auto-insert-directory))
    (add-to-list 'auto-insert-alist
                 `(("\\.tex\\'" . "LaTeX") . ,latex-template))))

templates/template.tex⟫=

\documentclass[10pt,letterpaper,oneside,openany]{article}

templates/template.tex⟫=

\title{}
\author{Theresa O'Connor $<$\href{mailto:tess@oconnor.cx}{tess@oconnor.cx}$>$}
\date{\today}

templates/template.tex⟫=

\usepackage[letterpaper,body={6.5in,9in},top=1in,left=1in]{geometry}

templates/template.tex⟫=

\newif\ifPDF
\ifx\pdfoutput\undefined\PDFfalse
\else\ifnum\pdfoutput > 0\PDFtrue
     \else\PDFfalse
     \fi
\fi

templates/template.tex⟫=

\ifPDF
  \usepackage[pdftex]{color,graphicx}
  \usepackage[pdftex,pdfpagemode=UseNone,colorlinks=true,
              urlcolor=blue,pdfstartview={FitH},
              plainpages=false]{hyperref}
\else
  \usepackage[dvips]{color,graphicx}
  \usepackage[hypertext]{hyperref}
\fi

templates/template.tex⟫=

\usepackage{makeidx} \makeindex

templates/template.tex⟫=

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\lhead{} \chead{} \rhead{}
\lfoot{} \cfoot{\thepage} \rfoot{}

templates/template.tex⟫=

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}

templates/template.tex⟫=

\begin{document}
\maketitle
\end{document}

font latex faces⟫=

'(font-latex-bold-face ((t (:bold t :foreground "⟪medium green⟫"))));%
'(font-latex-italic-face ((t (:slant italic :foreground "⟪medium green⟫"))));%
'(font-latex-math-face ((t (⟪math face⟫))))
'(font-latex-sectioning-0-face ((t (:foreground "⟪medium yellow⟫"))))
'(font-latex-sectioning-1-face ((t (:foreground "⟪medium yellow⟫"))))
'(font-latex-sectioning-2-face ((t (:foreground "⟪medium yellow⟫"))))
'(font-latex-sectioning-3-face ((t (:foreground "⟪medium yellow⟫"))))
'(font-latex-sectioning-4-face ((t (:foreground "⟪medium yellow⟫"))))
`(font-latex-sedate-face ((t ⟪dim this face when appropriate⟫)))
'(font-latex-string-face ((t (⟪string face⟫))))
'(font-latex-subscript-face ((t ())))
'(font-latex-title-1-face ((t (:foreground "⟪medium blue⟫"))))
'(font-latex-title-2-face ((t (:foreground "⟪medium blue⟫"))));%
'(font-latex-title-3-face ((t (:foreground "⟪medium blue⟫"))))
'(font-latex-title-4-face ((t (:foreground "⟪medium blue⟫"))))
'(font-latex-verbatim-face ((t ())))
'(font-latex-warning-face ((t (⟪warning face⟫))))

HTML and XML

Web Development⟫=

(defvar tess-xml-mode 'xml-mode
  "Which major-mode to use for editing XML.")

(defvar tess-html-mode 'html-mode
  "Which major-mode to use for editing HTML.")

(defun tess-linkify-region (start end)
    (interactive "r")
    (let ((str (buffer-substring-no-properties start end)))
      (delete-region start end)
      (insert "<a href=\"\">" str "</a>")))

;;; nxml
(when (and (featurep 'emacs)
           (or (load "rng-auto" t)
               (locate-library "nxml-mode")))

  (unless (fboundp 'nxml-mode)
    (autoload 'nxml-mode "nxml-mode" nil t))

  (unless (fboundp 'rng-validate-mode)
    (autoload 'rng-validate-mode "rng-valid" nil t))

  (setq tess-xml-mode 'nxml-mode)
  ;; (setq tess-html-mode 'nxml-mode)

  (setq nxml-sexp-element-flag t
        nxml-slash-auto-complete-flag t)

  ;; Hack `;' in nxml mode to automatically fix named character entity
  ;; references.
  (defun tess-nxml-semicolon-dwim (&rest ignore)
    "If we've just typed an HTML 4 named character entity reference,
replace it with its numerical equivalent. Otherwise, just insert `;'."
    (interactive)
    (or (tess-numericalize-entity) (insert ";")))

  (when (boundp 'nxml-mode-abbrev-table)
    (add-hook 'nxml-mode-hook
              (lambda ()
                (setq local-abbrev-table nxml-mode-abbrev-table))))

  (eval-after-load "nxml-mode"
    '(progn
       (define-key nxml-mode-map (kbd "<f8>") 'tess-linkify-region)
       (define-key nxml-mode-map (kbd "RET") 'newline-and-indent)
       ;; Install my `;' hack.
       (define-key nxml-mode-map (kbd ";") 'tess-nxml-semicolon-dwim))))

Web Development⟫=

(add-to-list 'auto-mode-alist
             (cons "\\.bs\\'" tess-html-mode))
(add-to-list 'auto-mode-alist
             (cons "\\.\\(x?html\\|xht\\)\\'" tess-html-mode))
(add-to-list 'auto-mode-alist
             (cons "\\.\\(jsp\\|tpl\\|tag\\)\\'" tess-html-mode))
(add-to-list 'auto-mode-alist
             (cons "\\.\\(wsd[dl]\\|tld\\|xslt\\|plist\\)\\'"
                   tess-xml-mode))

Web Development⟫=

(let ((html5-lib "~/code/html5-el/"))
  (when (file-directory-p html5-lib)
    (add-to-list 'load-path html5-lib)
    (eval-after-load "rng-loc"
      '(add-to-list 'rng-schema-locating-files
                    "~/code/html5-el/schemas.xml"))
    (require 'whattf-dt nil t)))

Web Development⟫=

(defvar tess-html4-link-relations
  '("alternate" "stylesheet" "start" "next" "prev" "contents" "index"
    "glossary" "copyright" "chapter" "section" "subsection" "appendix"
    "help" "bookmark")
  "http://www.w3.org/TR/html4/types.html#type-links")

(defvar tess-html5-link-relations
  '("alternate" "archives" "author" "bookmark" "contact" "external"
    "feed" "first" "help" "icon" "index" "last" "license" "next"
    "nofollow" "pingback" "prefetch" "prev" "search" "stylesheet"
    "sidebar" "tag" "up")
  "http://www.whatwg.org/specs/web-apps/current-work/#linkTypes")

(defvar tess-atom-link-relations
  '(;; http://atompub.org/rfc4287.html#rel_attribute
    "alternate" "related" "self" "enclosure" "via"
    ;; http://www.iana.org/assignments/link-relations/
    "current" "edit" "edit-media" "first" "last" "next" "next" "payment"
    "prev" "previous")
  "")

(defvar tess-xfn-link-relations
  '("contact" "acquaintance" "friend"         ; Friendship
    "met"                                     ; Physical
    "co-worker" "colleague"                   ; Professional
    "co-resident" "neighbor"                  ; Geographical
    "child" "parent" "sibling" "spouse" "kin" ; Family
    "muse" "crush" "date" "sweetheart"        ; Romantic
    "me")                                     ; Identity
  "http://gmpg.org/xfn/11")

(defvar tess-uf-link-relations
  '("license"   ; http://microformats.org/wiki/rel-license
    "nofollow"  ; http://microformats.org/wiki/rel-nofollow
    "tag"       ; http://microformats.org/wiki/rel-tag
    ;; Drafts
    "directory" ; http://microformats.org/wiki/rel-directory
    "enclosure" ; http://microformats.org/wiki/rel-enclosure
    "home"      ; http://microformats.org/wiki/rel-home
    "payment"   ; http://microformats.org/wiki/rel-payment
    ;; Exploratory
    "cite"      ; http://microformats.org/wiki/distributed-conversation-brainstorming
    "group"     ; http://microformats.org/wiki/group-brainstorming
    "product"   ; http://microformats.org/wiki/rel-product
    "profile")  ; http://microformats.org/wiki/xmdp-brainstorming#linking_to_the_XMDP
  "")

(defvar tess-custom-link-relations
  '("http://tess.oconnor.cx/link-relations/include"
    "http://tess.oconnor.cx/link-relations/legacy"
    "http://tess.oconnor.cx/link-relations/listening"
    "http://tess.oconnor.cx/link-relations/livejournal"
    "http://tess.oconnor.cx/link-relations/pingback"
    "http://tess.oconnor.cx/link-relations/reddit"
    "http://tess.oconnor.cx/link-relations/stylesheet")
  "http://tess.oconnor.cx/link-relations/")

(defvar tess-link-relations
  (seq-uniq
   (sort (append tess-html4-link-relations tess-html5-link-relations
                 tess-atom-link-relations tess-xfn-link-relations
                 tess-uf-link-relations tess-custom-link-relations)
         'string<))
  "List of Atom and HTML link relations.")

(defun tess-read-link-relation ()
  "Read a link relation from the user, with completion."
  (interactive)
  (completing-read "Link relation: " tess-link-relations nil t))

(defun tess-read-link-relations ()
  "Read link relations from the user until they hit RET."
  (interactive)
  (let ((relations '())
        (relation (tess-read-link-relation)))
    (if (equal relation "me")
        relation
      (while (not (equal relation ""))
        (push relation relations)
        (setq relation (tess-read-link-relation)))
      (mapconcat (lambda (x) x) (sort relations 'string<) " "))))

(define-skeleton tess-rel-expand
  "Expand @rel."
  nil
  "rel=\""
  (tess-read-link-relations)
  "\"")

(defun tess-nuke-nofollow ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "\\s-*rel=[\"']nofollow[\"']" nil t)
      (replace-match ""))))

abbrev-definitions⟫=

(define-abbrev-table 'nxml-mode-abbrev-table '(
    ("rel" "" tess-rel-expand 0)
    ))

sgml faces⟫=

'(sgml-namespace-face ((t (⟪keyword face⟫)))) ;%

defun hober2-use-underline-p⟫=

(if (fboundp 'display-supports-face-attributes-p)
    (defun hober2-use-underline-p (&optional display)
      "Non-nil if DISPLAY supports underlining.
This is only sometimes accurate."
      (display-supports-face-attributes-p '(:underline) display))
  (defalias 'hober2-use-underline-p 'window-system))

rng faces⟫=

'(rng-error ((t ,(if (hober2-use-underline-p)
                    '(:underline "red")
                  '(⟪error face⟫)))))

html helper faces⟫=

'(html-helper-bold-face ((t ())))
'(html-helper-italic-face ((t ())))
'(html-helper-underline-face ((t ())))
'(html-helper-strikethrough-face ((t ())))
'(html-helper-link-face ((t ())))
'(html-helper-significant-tag-face ((t (:foreground "⟪medium cyan⟫")))) ;%

nxml faces⟫=

'(nxml-text ((t ())))
'(nxml-text-face ((t ())))

'(nxml-attribute-colon ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-attribute-colon-face ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-attribute-local-name ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-attribute-local-name-face ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-attribute-prefix ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-attribute-prefix-face ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-attribute-value ((t (⟪string face⟫))))
'(nxml-attribute-value-face ((t (⟪string face⟫))))
'(nxml-attribute-value-delimiter ((t (⟪string face⟫))))
'(nxml-attribute-value-delimiter-face ((t (⟪string face⟫))))
'(nxml-cdata-section-CDATA ((t (:foreground "⟪medium cyan⟫"))))
'(nxml-cdata-section-CDATA-face ((t (:foreground "⟪medium cyan⟫"))))
'(nxml-cdata-section-content ((t ())))
'(nxml-cdata-section-content-face ((t ())))
`(nxml-cdata-section-delimiter ((t ⟪dim this face when appropriate⟫)))
`(nxml-cdata-section-delimiter-face ((t ⟪dim this face when appropriate⟫)))
'(nxml-char-ref-delimiter ((t (⟪variable face⟫))))
'(nxml-char-ref-delimiter-face ((t (⟪variable face⟫))))
'(nxml-char-ref-number-face ((t (⟪variable face⟫))))
'(nxml-comment-content ((t (⟪comment face⟫))))
'(nxml-comment-content-face ((t (⟪comment face⟫))))
'(nxml-comment-delimiter ((t (⟪comment delimiter face⟫))))
'(nxml-comment-delimiter-face ((t (⟪comment delimiter face⟫))))
'(nxml-element-colon ((t (⟪keyword face⟫))))
'(nxml-element-colon-face ((t (⟪keyword face⟫))))
'(nxml-element-local-name ((t (:foreground "⟪medium cyan⟫"))))
'(nxml-element-local-name-face ((t (:foreground "⟪medium cyan⟫"))))
'(nxml-element-prefix ((t (⟪keyword face⟫)))) ;%
'(nxml-element-prefix-face ((t (⟪keyword face⟫)))) ;%
'(nxml-entity-ref-delimiter ((t (⟪variable face⟫))))
'(nxml-entity-ref-delimiter-face ((t (⟪variable face⟫))))
'(nxml-entity-ref-name ((t (⟪variable face⟫))))
'(nxml-entity-ref-name-face ((t (⟪variable face⟫))))
`(nxml-markup-declaration-delimiter ((t ⟪dim this face when appropriate⟫)))
`(nxml-markup-declaration-delimiter-face ((t ⟪dim this face when appropriate⟫)))
'(nxml-namespace-attribute-colon ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-namespace-attribute-colon-face ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-namespace-attribute-prefix ((t (:foreground "⟪dark yellow⟫")))) ;%
'(nxml-namespace-attribute-prefix-face ((t (:foreground "⟪dark yellow⟫")))) ;%
'(nxml-namespace-attribute-xmlns ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-namespace-attribute-xmlns-face ((t (:foreground "⟪dark yellow⟫"))))
'(nxml-processing-instruction-content-face ((t ())))
`(nxml-processing-instruction-delimiter-face ((t ⟪dim this face when appropriate⟫)))
'(nxml-processing-instruction-target ((t (:foreground "⟪dark cyan⟫"))))
'(nxml-processing-instruction-target-face ((t (:foreground "⟪dark cyan⟫"))))
'(nxml-prolog-keyword ((t (:foreground "⟪medium cyan⟫"))))
'(nxml-prolog-keyword-face ((t (:foreground "⟪medium cyan⟫"))))
'(nxml-prolog-literal-content ((t (⟪string face⟫))))
'(nxml-prolog-literal-content-face ((t (⟪string face⟫))))
'(nxml-prolog-literal-delimiter ((t (⟪string face⟫))))
'(nxml-prolog-literal-delimiter-face ((t (⟪string face⟫))))
`(nxml-tag-delimiter ((t ⟪dim this face when appropriate⟫)))
`(nxml-tag-delimiter-face ((t ⟪dim this face when appropriate⟫)))
`(nxml-tag-slash ((t ⟪dim this face when appropriate⟫)))
`(nxml-tag-slash-face ((t ⟪dim this face when appropriate⟫)))

;; (nxml-heading ((t ())))
;; (nxml-heading-face ((t ())))
;; (nxml-outline-indicator ((t ())))
;; (nxml-outline-indicator-face ((t ())))
;; (nxml-outline-active-indicator ((t ())))
;; (nxml-outline-active-indicator-face ((t ())))
;; (nxml-outline-ellipsis ((t ())))
;; (nxml-outline-ellipsis-face ((t ())))
;; (nxml-delimited-data ((t ())))
;; (nxml-delimited-data-face ((t ())))
;; (nxml-name ((t ())))
;; (nxml-name-face ((t ())))
;; (nxml-ref ((t ())))
;; (nxml-ref-face ((t ())))
;; (nxml-delimiter ((t ())))
;; (nxml-delimiter-face ((t ())))
;; (nxml-namespace-attribute-value ((t ())))
;; (nxml-namespace-attribute-value-face ((t ())))
;; (nxml-namespace-attribute-value-delimiter ((t ())))
;; (nxml-namespace-attribute-value-delimiter-face ((t ())))
;; (nxml-hash ((t ())))
;; (nxml-hash-face ((t ())))
;; (nxml-glyph ((t ())))
;; (nxml-glyph-face ((t ())))

html template⟫=

(let ((html-template "template.html"))
  (when (file-exists-p (expand-file-name html-template
                                         auto-insert-directory))
    (add-to-list 'auto-insert-alist
                 `(("\\.html\\'" . "HTML") . ,html-template))))

atom template⟫=

(let ((atom-template "template.atom"))
  (when (file-exists-p (expand-file-name atom-template
                                         auto-insert-directory))
    (add-to-list 'auto-insert-alist
                 `(("\\.atom\\'" . "Atom") . ,atom-template))))

how to use a stylesheet⟫=

<link rel="stylesheet" type="text/css" href="style.css"/>

templates/template.atom⟫=

<entry xmlns="http://www.w3.org/2005/Atom">
  <id>tag:tess.oconnor.cx,2020-MM-DD:slug</id>

  <link rel="alternate" type="text/html" href="/2020/MM/slug" />

  <updated></updated>

  <title type="text"></title>

  <author>
    <name>Theresa O&#8217;Connor</name>
    <email>hober0@gmail.com</email>
    <uri>http://tess.oconnor.cx/</uri>
  </author>

  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">
    </div>
  </content>

  <rights type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">
      Copyright &#169; 2020
      <a href="http://tess.oconnor.cx/">Theresa O&#8217;Connor</a>.
      <a href="http://creativecommons.org/licenses/by-sa/3.0/"
         rel="license">Some rights reserved (CC BY-SA 3.0).</a>
    </div>
  </rights>
</entry>

templates/template.html⟫=

<!DOCTYPE html>
<meta charset=utf-8>
<title></title>

tess-unescape-html

Web Development⟫=

(defun tess-unescape-html (start end)
  (interactive "r")
  (save-excursion
    (goto-char start)
    (while (re-search-forward "&\\(lt\\|gt\\|quot\\|amp\\);" end t)
      (let* ((entities '(("quot" . "\"") ("amp" . "&")
                         ("lt" . "<") ("gt" . ">")))
             (replacement (assoc (match-string 1) entities)))
        (when replacement
          (replace-match (cdr replacement)))))))

editing html entities

Web Development⟫=

(defvar tess-html4-intrinsic-events
  '("load" "unload" "click" "dblclick" "mousedown" "mouseup" "mouseover"
    "mousemove" "mouseout" "focus" "blur" "keypress" "keydown" "keyup"
    "submit" "reset" "select" "change")
  "HTML4 intrinsic events.")

⟪html4 entity map⟫

(defun tess-numericalize-entity ()
  "Replace the named character entity reference at point with its
numerical equivalent, if known."
  (interactive)
  (let ((end (point))
        (start (search-backward "&" (- (point) 7) t)))
    (when start
      (if (looking-at "&\\([a-z][a-z0-9]+\\)")
          (let* ((name (match-string 1))
                 (num (cdr (assoc name tess-html4-entity-map))))
            (if num
                (progn
                  (delete-region start end)
                  (insert (format "&#%s;" num))
                  t)
              (goto-char end)
              nil))
        (goto-char end)
        nil))))

htmlize

htmlize⟫=

(when (locate-library "htmlize")
  (autoload 'htmlize-buffer "htmlize" nil t))

tess-htmlize⟫=

(defun tess-stringify-face-name (face)
  "Blah blah blah."
  (when (listp face)
    (setq face (car (last face))))
  (let ((name (if (symbolp face) (symbol-name face) face)))
    (if (string-match "^\\(font-lock-\\)?\\(.+?\\)\\(-name\\)?\\(-face\\)?$" ; $
                      name)
        (match-string 2 name)
      name)))

(defvar tess-htmlize-face-translation-map
  '(;; I don't want to highlight parens in lisp
    (paren-face . nil)
    ;; Parts of X{,HT}ML I don't want to highlight
    (nxml-tag-delimiter . nil)
    (nxml-tag-delimiter-face . nil)
    (nxml-tag-slash . nil)
    (nxml-tag-slash-face . nil)
    (nxml-text . nil)
    (nxml-text-face . nil)
    ;; CSS
    (css-property . font-lock-function-name-face)
    ;; Map nXML faces onto standard font-lock faces
    (nxml-attribute-value-delimiter . font-lock-string-face)
    (nxml-attribute-value-delimiter-face . font-lock-string-face)
    (nxml-attribute-value . font-lock-string-face)
    (nxml-attribute-value-face . font-lock-string-face)
    (nxml-attribute-local-name . font-lock-builtin-face)
    (nxml-attribute-local-name-face . font-lock-builtin-face)
    (nxml-element-local-name . font-lock-keyword-face)
    (nxml-element-local-name-face . font-lock-keyword-face)
    ;; Makefiles
    (makefile-targets . font-lock-function-name-face)
    (makefile-shell . nil)
    ;; MML tags should look like types
    (message-mml-face . font-lock-type-face)
    (message-mml . font-lock-type-face))
  "Blah blah blah")

(defun tess-htmlize-face-at-point (&optional pos)
  "Blah blah blah."
  (unless pos (setq pos (point)))
  (let* ((face (get-text-property pos 'face))
         (translation (member* face tess-htmlize-face-translation-map
                               :key 'car)))
    (if translation
        (cdar translation)
      face)))

(defun tess-htmlize-region (start end)
  "Place an htmlized version of the region into the kill ring."
  (interactive "r")
  (let ((code (buffer-substring start end))
        (language (substring (symbol-name major-mode) 0 -5))
        current-face)
    (with-temp-buffer
      (fundamental-mode)
      (font-lock-mode -1)

      (insert code)

      (goto-char (point-min))

      (setq current-face (tess-htmlize-face-at-point))
      (insert (format "<pre><code class=\"%s\">" language))
      (when current-face
        (insert (format "<span class=\"%s\">"
                        (tess-stringify-face-name current-face))))

      (let (n-p-c)
        (while (setq n-p-c (next-property-change (point)))
          (goto-char n-p-c)
          (cond
           ((and current-face (eq current-face (tess-htmlize-face-at-point))))
           ((and current-face (null (tess-htmlize-face-at-point)))
            (insert "</span>")
            (setq current-face nil))
           ((and current-face (tess-htmlize-face-at-point))
            (insert "</span>")
            (setq current-face (tess-htmlize-face-at-point))
            (when current-face
              (insert (format "<span class=\"%s\">"
                              (tess-stringify-face-name current-face)))))
           ((tess-htmlize-face-at-point)
            (setq current-face (tess-htmlize-face-at-point))
            (when current-face
              (insert (format "<span class=\"%s\">"
                              (tess-stringify-face-name current-face))))))))
      (goto-char (point-max))
      (insert "</code></pre>")
      (setq code (buffer-substring-no-properties (point-min) (point-max))))
    (kill-new code)))

Web Development⟫=

(setq html-tag-face-alist
      '(("b" . bold)
        ("big" . bold)
        ("blink" . highlight)
        ("h1" bold underline)
        ("h4" . underline)
        ("h5" . underline)
        ("h6" . underline)
        ("rev"  . modeline)
        ("s" . underline)
        ("small" . default)
        ("strong" . bold)
        ("title" bold underline)
        ("tt" . default)
        ("u" . underline)
        ;; Were italic
        ("cite" . default)
        ("em" . bold)
        ("h2" bold underline)
        ("h3" underline)
        ("i" . italic)
        ("var" . default)))

CSS

css-mode.el fetch rule⟫=

css-mode.el:
        curl -O http://www.garshol.priv.no/download/software/css-mode/css-mode.el

Web Development⟫=

(when (locate-library "css-mode")
  (autoload 'css-mode "css-mode" nil t)
  (add-to-list 'auto-mode-alist '("\\.css\\'" . css-mode))
  ⟪customize each css mode⟫)

customize each css mode⟫=

(eval-after-load "css-mode"
  '(cond ((boundp 'cssm-indent-function) ; larsga's css-mode.el
            ⟪larsga css-mode.el customizations⟫)
           ((fboundp 'css-extract-keyword-list) ; monnier's css-mode.el
            ⟪monnier css-mode.el customizations⟫)
    (t nil)))

css-mode (monnier) faces⟫=

'(css-selector ((t (:foreground "⟪medium red⟫"))))
'(css-property ((t (:foreground "⟪light cyan⟫"))))
'(css-proprietary-property ((t (:foreground "⟪light cyan⟫"))))

monnier css-mode.el customizations⟫=

(setq css-basic-offset 2
      css-indent-offset 2)

larsga css-mode.el customizations⟫=

(add-hook 'css-mode-hook
          (lambda ()
            (setq cssm-mirror-mode nil
                  cssm-newline-before-closing-bracket nil
                  cssm-indent-function 'cssm-c-style-indenter)))

css template⟫=

(let ((css-template "template.css"))
  (when (file-exists-p (expand-file-name css-template
                                         auto-insert-directory))
    (add-to-list 'auto-insert-alist
                 `(("\\.css\\'" . "CSS") . ,css-template))))

templates/template.css⟫=

body {
}

RSS and Atom

Web Development⟫=

(add-to-list 'auto-mode-alist
             (cons "\\.\\(rdf\\|rss\\|atom\\)\\'" tess-xml-mode))

Spec writing

Markdown

markdown-mode faces⟫=

'(markdown-italic-face ((t (:inherit italic))))
'(markdown-bold-face ((t (:inherit bold))))
'(markdown-strike-through-face ((t (:strike-through t))))
'(markdown-markup-face ((t (:inherit shadow :slant normal :weight normal))))
'(markdown-header-rule-face ((t (:inherit markdown-markup-face))))
'(markdown-header-delimiter-face ((t (:inherit markdown-markup-face))))
'(markdown-list-face ((t (:inherit markdown-markup-face))))
'(markdown-blockquote-face ((t (⟪string face (alt)⟫))))
'(markdown-code-face ((t (:inherit fixed-pitch))))
'(markdown-inline-code-face ((t (:inherit (markdown-code-face
                                           font-lock-constant-face)))))
'(markdown-pre-face ((t (:inherit (markdown-code-face
                                   font-lock-constant-face)))))
'(markdown-table-face ((t (:inherit (markdown-code-face)))))
'(markdown-language-keyword-face ((t (⟪keyword face⟫))))
'(markdown-language-info-face ((t (⟪string face⟫))))
'(markdown-link-face ((t (:inherit link))))
'(markdown-missing-link-face ((t (⟪warning face⟫))))
'(markdown-reference-face ((t (:inherit markdown-markup-face))))
'(markdown-footnote-marker-face ((t (:inherit markdown-markup-face))))
'(markdown-footnote-text-face ((t (⟪comment face⟫))))
'(markdown-url-face ((t (⟪string face⟫))))
'(markdown-plain-url-face ((t (:inherit markdown-link-face))))
'(markdown-link-title-face ((t (⟪comment face⟫))))
'(markdown-line-break-face ((t (⟪constant face⟫ :underline t))))
'(markdown-comment-face ((t (⟪comment face⟫))))
'(markdown-math-face ((t (⟪string face⟫))))
'(markdown-metadata-key-face ((t (⟪variable face⟫))))
'(markdown-metadata-value-face ((t (⟪string face⟫))))
'(markdown-gfm-checkbox-face ((t (⟪builtin face⟫))))
'(markdown-highlight-face ((t (:inherit highlight))))
'(markdown-hr-face ((t (:inherit markdown-markup-face))))
'(markdown-html-tag-name-face ((t (⟪function face⟫))))
'(markdown-html-tag-delimiter-face ((t (:inherit markdown-markup-face))))
'(markdown-html-attr-name-face ((t (⟪variable face⟫))))
'(markdown-html-attr-value-face ((t (⟪string face⟫))))
'(markdown-html-entity-face ((t (⟪variable face⟫))))

Editing Markdown files⟫=

(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

(add-hook 'markdown-mode-hook 'turn-off-auto-fill)
(add-hook 'markdown-mode-hook
          (lambda ()
            (setq fill-column most-positive-fixnum)))
(add-hook 'markdown-mode-hook (lambda () (visual-line-mode 1)))

(when (executable-find "markdown2")
  (setq markdown-command "markdown2"))

Bikeshed

Editing Bikeshed files⟫=

(add-to-list 'auto-mode-alist '("\\.bs\\'" . bikeshed-mode))

RFCs

rfcview⟫=

(when (locate-library "rfcview")
  (autoload 'rfcview-mode "rfcview" nil t)
  (add-to-list 'auto-mode-alist '("rfc[0-9]+\\.txt" . rfcview-mode)))

Relax-NG

Web Development⟫=

;;; editing relax-ng compact schema
(when (locate-library "rnc-mode")
  (autoload 'rnc-mode "rnc-mode" nil t)
  (add-to-list 'auto-mode-alist '("\\.rnc\\'" . rnc-mode)))

Programming

comment style

comment-style⟫=

(setq comment-style 'indent)

fillcode.el

fillcode.el fetch rule⟫=

fillcode.el:
        curl -O http://snarfed.org/space/fillcode/fillcode.el

shell mode faces

shell faces⟫=

'(sh-heredoc-face ((t (⟪string face (alt)⟫))))
'(sh-quoted-exec ((t (⟪string face (alt)⟫))))

glasses-mode

Configuring glasses-mode⟫=

(setq glasses-separator           "-"
      glasses-uncapitalize-regexp ".*"
      glasses-uncapitalize-p      t)

paredit

paredit.el fetch rule⟫=

paredit.el:
        curl -O http://mumble.net/~campbell/emacs/paredit.el

Programming Utilities⟫=

(ignore-errors (require 'paredit))

skeleton pairs

Make paired characters electric⟫=

(setq skeleton-pair t)
(global-set-key "[" 'skeleton-pair-insert-maybe)
(global-set-key "{" 'skeleton-pair-insert-maybe)
(global-set-key "\"" 'skeleton-pair-insert-maybe)

syntax highlighting

Enable Font Locking⟫=

(require 'font-lock)

(setq font-lock-maximum-size most-positive-fixnum)

;; XEmacs
(setq font-lock-auto-fontify t)

(when (fboundp 'global-font-lock-mode)
  (defun tess-enable-font-lock-globally ()
    (global-font-lock-mode 1))
  (add-hook 'tess-after-local-init-hook
            'tess-enable-font-lock-globally))

(when (featurep 'xemacs)
  (setq font-lock-support-mode 'lazy-lock-mode))

(when (fboundp 'toggle-global-lazy-font-lock-mode)
  (add-hook 'tess-after-local-init-hook
            'toggle-global-lazy-font-lock-mode))

builtin face⟫=

:foreground "⟪dark yellow⟫"

font lock faces⟫=

'(font-lock-builtin-face ((t (⟪builtin face⟫)))) ;%
'(font-lock-color-constant-face ((t (:foreground "⟪medium yellow⟫")))) ;%
'(font-lock-comment-face ((t (⟪comment face⟫))))
'(font-lock-comment-delimiter-face ((t (⟪comment delimiter face⟫))))

constant face⟫=

:foreground "⟪light magenta⟫"

font lock faces⟫=

'(font-lock-constant-face ((t (⟪constant face⟫))))

font lock faces⟫=

'(font-lock-doc-face ((t (⟪string face (alt)⟫)))) ;%

font lock faces⟫=

`(font-lock-doc-string-face ((t ,(if (featurep 'xemacs)
                                     '(⟪string face (alt)⟫)
                                   '(⟪comment face (alt)⟫)))))

string face⟫=

:foreground "⟪light yellow⟫"

string face (alt)⟫=

:foreground "⟪medium yellow⟫"

variable face⟫=

:foreground "⟪light red⟫"

variable face (alt)⟫=

:foreground "⟪medium red⟫"

function face⟫=

:foreground "⟪medium cyan⟫"

keyword face⟫=

:foreground "⟪dark cyan⟫"

type face⟫=

:foreground "⟪medium green⟫"

font lock faces⟫=

'(font-lock-function-name-face ((t (⟪function face⟫))))
'(font-lock-keyword-face ((t (⟪keyword face⟫))))
'(font-lock-preprocessor-face ((t (:foreground "⟪medium yellow⟫"))))
'(font-lock-reference-face ((t (:foreground "⟪medium yellow⟫"))))
'(font-lock-string-face ((t (⟪string face⟫))))
'(font-lock-type-face ((t (⟪type face⟫)))) ;%
'(font-lock-variable-name-face ((t (⟪variable face⟫))))
'(font-lock-warning-face ((t (⟪warning face⟫))))

Enable Font Locking⟫=

(when (featurep 'xemacs)
  (mapc (lambda (hook) (add-hook hook (lambda () (font-lock-mode 1))))
        '(lisp-interaction-mode-hook ielm-mode-hook latex-mode-hook)))

CamelCase-aware stuff

CamelCase-aware killing functions⟫=

(defun tess-c-kill-backwards-into-nomenclature ()
  "Delete the CamelCase word before point."
  (interactive)
  (let ((end (point)))
    (c-backward-into-nomenclature 1)
    (kill-region (point) end)))

(defun tess-c-kill-forwards-into-nomenclature ()
  "Delete the CamelCase word after point."
  (interactive)
  (let ((beg (point)))
    (c-forward-into-nomenclature 1)
    (kill-region beg (point))))

(let ((hooks '(c-mode-common-hook espresso-mode-hook js-mode-hook
               js2-mode-hook python-mode-hook swift-mode-hook))
      (enable-subword-bindings
       (cond ((fboundp 'subword-mode)
              (lambda () (subword-mode 1)))
             ((fboundp 'c-subword-mode)
              (lambda () (c-subword-mode 1)))
             (t
              (lambda ()
                (local-set-key (kbd "M-DEL")
                               'tess-c-kill-backwards-into-nomenclature)
                (local-set-key (kbd "M-d")
                               'tess-c-kill-forwards-into-nomenclature))))))
  (mapc (lambda (hook) (add-hook hook enable-subword-bindings)) hooks))

Change Logs

change-log-default-name⟫=

(setq change-log-default-name "ChangeLog")

change log faces⟫=

'(change-log-date-face ((t (:foreground "⟪light yellow⟫"))))
'(change-log-name-face ((t (:foreground "⟪medium yellow⟫"))))
'(change-log-email-face ((t (:foreground "⟪medium red⟫"))))
'(change-log-file-face ((t (⟪filename face⟫))))
'(change-log-list-face ((t (:foreground "⟪medium blue⟫"))))
'(change-log-conditionals-face ((t (:foreground "⟪medium red⟫"))))
'(change-log-function-face ((t (:foreground "⟪medium red⟫"))))
'(change-log-acknowledgement-face ((t (⟪cyan bg⟫ ⟪dark fg⟫))))

Diff, ediff, emerge, smerge

Programming Utilities⟫=

(setq diff-switches "-u")

Programming Utilities⟫=

(autoload 'diff-context->unified "diff-mode" nil t)
(autoload 'diff-unified->context "diff-mode" nil t)

diff faces⟫=

'(diff-added ((t (⟪default bg⟫ :foreground "⟪medium green⟫"))))
'(diff-changed ((t (⟪default bg⟫ :foreground "⟪medium green⟫"))))
'(diff-context ((t (⟪default bg⟫ ⟪default fg⟫))))
'(diff-file-header ((t (⟪default bg (alt)⟫ ⟪default fg⟫ :bold t))))
'(diff-function ((t (⟪default bg (alt)⟫ ⟪default fg (alt)⟫))))
'(diff-header ((t (⟪default bg (alt)⟫ ⟪default fg (alt)⟫))))
'(diff-hunk-header ((t (⟪default bg⟫ ⟪default fg (alt)⟫))))
'(diff-index ((t (⟪default bg⟫ ⟪default fg⟫ :bold t))))
'(diff-indicator-added ((t (⟪default bg⟫ :foreground "⟪medium green⟫"))))
'(diff-indicator-changed ((t (⟪default bg⟫ :foreground "⟪medium yellow⟫"))))
'(diff-indicator-removed ((t (⟪default bg⟫ :foreground "⟪medium red⟫"))))
'(diff-nonexistent ((t (⟪warning face⟫))))
'(diff-removed ((t (⟪default bg⟫ :foreground "⟪medium red⟫"))))

smerge-mode faces⟫=

'(smerge-refined-change ((t (:background "⟪medium black⟫"))))

smerge-mode⟫=

(setq smerge-command-prefix (kbd "C-c s"))

ediff bg ancestor⟫=

:background "⟪light red⟫"

ediff bg b⟫=

:background "⟪light yellow⟫"

ediff bg c⟫=

:background "⟪medium green⟫"

ediff faces⟫=

'(ediff-current-diff-face-A ((t (⟪cyan bg⟫ ⟪dark fg⟫))))
'(ediff-current-diff-face-Ancestor ((t (⟪ediff bg ancestor⟫
                                        ⟪dark fg⟫))))
'(ediff-current-diff-face-B ((t (⟪ediff bg b⟫ ⟪dark fg (alt)⟫))))
'(ediff-current-diff-face-C ((t (⟪ediff bg c⟫
                                 ⟪dark fg⟫))))
'(ediff-even-diff-face-A ((t (⟪cyan bg⟫ ⟪dark fg⟫ :bold t))))
'(ediff-even-diff-face-Ancestor ((t (⟪ediff bg ancestor⟫
                                     ⟪dark fg⟫
                                     :bold t))))
'(ediff-even-diff-face-B ((t (⟪ediff bg b⟫ ⟪dark fg (alt)⟫
                              :bold t))))
'(ediff-even-diff-face-C ((t (⟪ediff bg c⟫ ⟪dark fg⟫
                              :bold t))))
'(ediff-fine-diff-face-A ((t (⟪cyan bg (alt)⟫ ⟪dark fg⟫))))
'(ediff-fine-diff-face-Ancestor ((t (:background "⟪dark red⟫"
                                     ⟪dark fg⟫))))
'(ediff-fine-diff-face-B ((t (⟪region face (alt)⟫))))
'(ediff-fine-diff-face-C ((t (:background "⟪dark green⟫"
                              ⟪dark fg⟫))))
'(ediff-odd-diff-face-A ((t (⟪cyan bg (alt)⟫ ⟪dark fg⟫
                             :bold t))))
'(ediff-odd-diff-face-Ancestor ((t (:background "⟪dark red⟫"
                                    ⟪dark fg⟫
                                    :bold t))))
'(ediff-odd-diff-face-B ((t (⟪region face (alt)⟫ :bold t))))
'(ediff-odd-diff-face-C ((t (:background "⟪dark green⟫"
                             ⟪dark fg⟫ :bold t))))
'(ediff-current-diff-A ((t (⟪cyan bg⟫ ⟪dark fg⟫))))
'(ediff-current-diff-Ancestor ((t (⟪ediff bg ancestor⟫
                                        ⟪dark fg⟫))))
'(ediff-current-diff-B ((t (⟪ediff bg b⟫ ⟪dark fg (alt)⟫))))
'(ediff-current-diff-C ((t (⟪ediff bg c⟫
                                 ⟪dark fg⟫))))
'(ediff-even-diff-A ((t (⟪cyan bg⟫ ⟪dark fg⟫ :bold t))))
'(ediff-even-diff-Ancestor ((t (⟪ediff bg ancestor⟫
                                     ⟪dark fg⟫
                                     :bold t))))
'(ediff-even-diff-B ((t (⟪ediff bg b⟫ ⟪dark fg (alt)⟫
                              :bold t))))
'(ediff-even-diff-C ((t (⟪ediff bg c⟫ ⟪dark fg⟫
                              :bold t))))
'(ediff-fine-diff-A ((t (⟪cyan bg (alt)⟫ ⟪dark fg⟫))))
'(ediff-fine-diff-Ancestor ((t (:background "⟪dark red⟫"
                                     ⟪dark fg⟫))))
'(ediff-fine-diff-B ((t (⟪region face (alt)⟫))))
'(ediff-fine-diff-C ((t (:background "⟪dark green⟫"
                              ⟪dark fg⟫))))
'(ediff-odd-diff-A ((t (⟪cyan bg (alt)⟫ ⟪dark fg⟫
                             :bold t))))
'(ediff-odd-diff-Ancestor ((t (:background "⟪dark red⟫"
                                    ⟪dark fg⟫
                                    :bold t))))
'(ediff-odd-diff-B ((t (⟪region face (alt)⟫ :bold t))))
'(ediff-odd-diff-C ((t (:background "⟪dark green⟫"
                             ⟪dark fg⟫ :bold t))))

Version Control

Subversion

.subversion/config⟫=

[miscellany]
interactive-conflicts = no

psvn.el fetch rule⟫=

psvn.el:
        curl -O http://www.xsteve.at/prg/emacs/psvn.el

psvn⟫=

(autoload 'svn-status "psvn" nil t)

psvn faces⟫=

'(svn-status-marked-face ((t (⟪marked face⟫))))
'(svn-status-marked-popup-face ((t (⟪error face⟫))))
'(svn-status-update-available-face ((t (⟪warning face⟫))))
'(svn-status-directory-face ((t (⟪directory face⟫))))
'(svn-status-filename-face ((t (⟪filename face⟫))))
'(svn-status-symlink-face ((t (⟪symlink face⟫))))
'(svn-status-locked-face ((t (⟪comment face⟫))))
'(svn-status-switched-face ((t (⟪string face⟫))))
'(svn-status-blame-highlight-face ((t (⟪highlight face⟫))))
'(svn-status-blame-rev-number-face ((t (⟪marked face⟫))))

vc-svn.el fetch rule⟫=

vc-svn.el:
        curl -O http://www.tug.org/ftp/dist/vc-svn.el

vc-svn⟫=

(unless (memq 'SVN vc-handled-backends)
  (add-to-list 'vc-handled-backends 'SVN))

Mercurial

.hgrc⟫=

[ui]
username = Theresa O'Connor <tess@oconnor.cx>

Git

gitsum⟫=

(autoload 'gitsum "gitsum" nil t)

Disable pager when git is run from Emacs⟫=

(setenv "GIT_PAGER" "cat")

.gitconfig⟫=

[user]
name = Theresa O'Connor
# Set email in $XDG_CONFIG_HOME/git/config '

[color]
diff = auto
status = auto
branch = auto

[init]
defaultBranch = main

[merge]
ff = only

[pull]
rebase = true
autoStash = true

[push]
default = matching

github elisp make rules⟫=

logito/logito.el:
        git clone https://github.com/sigma/logito.git
pcache/pcache.el:
        git clone https://github.com/sigma/pcache.git
gh.el/gh.el:
        git clone https://github.com/sigma/gh.el.git
gist.el/gist.el:
        git clone https://github.com/defunkt/gist.el
tabulated-list.el/tabulated-list.el:
        git clone https://github.com/sigma/tabulated-list.el

gh.el/gh.elc: gh.el/gh.el pcache/pcache.el logito/logito.el \
              pcache/pcache.elc logito/logito.elc
        make -C gh.el lisp EMACS="$(EMACS) -L $(CWD)/pcache -L $(CWD)/logito"

put gist.el and dependencies in load-path⟫=

(apply 'tess-add-to-list* 'load-path
       (mapcar 'tess-file-in-workspace
               '("gh.el" "gist.el" "logito" "pcache"
                 "tabulated-list.el")))

gist⟫=

(ignore-errors (require 'gist))

vc mode

Programming Utilities⟫=

(setq vc-follow-symlinks t)

Languages

SQL

Open PostgreSQL views and source files in sql-mode⟫=

(add-to-list 'auto-mode-alist '("\\.view\\'" . sql-mode))
(add-to-list 'auto-mode-alist '("\\.psql\\'" . sql-mode))

Open PostgreSQL views and source files in sql-mode⟫=

(setq sql-sqlite-program "sqlite3")

JavaScript

Ensure NODE_PATH is set up properly⟫=

if [[ -d '/usr/local/lib/node_modules' && ! -v NODE_PATH ]]; then
    export NODE_PATH='/usr/local/lib/node_modules'
fi

js2 faces⟫=

'(js2-builtin-face ((t (⟪builtin face⟫))))
'(js2-comment-face ((t (⟪comment face⟫))))
'(js2-constant-face ((t (⟪constant face⟫))))
'(js2-error-face ((t (⟪error face⟫))))
'(js2-external-variable-face ((t (⟪variable face (alt)⟫))))
'(js2-function-name-face ((t (⟪function face⟫))))
'(js2-function-param-face ((t (⟪variable face⟫))))
'(js2-instance-member-face ((t (⟪variable face⟫))))
;; Copied from `nxml-tag-delimiter'
`(js2-jsdoc-html-tag-delimiter-face ((t ⟪dim this face when appropriate⟫)))
;; Copied from `nxml-element-local-name'
'(js2-jsdoc-html-tag-name-face ((t (:foreground "⟪medium cyan⟫"))))
'(js2-jsdoc-tag-face ((t (⟪comment face (alt)⟫))))
'(js2-jsdoc-type-face ((t (⟪comment face (alt)⟫))))
'(js2-jsdoc-value-face ((t (⟪comment face (alt)⟫))))
'(js2-keyword-face ((t (⟪keyword face⟫))))
'(js2-private-function-call-face ((t (⟪function face⟫))))
'(js2-private-member-face ((t (⟪variable face⟫))))
'(js2-regexp-face ((t (⟪string face (alt)⟫))))
'(js2-string-face ((t (⟪string face⟫))))
'(js2-type-face ((t (⟪type face⟫))))
'(js2-variable-name-face ((t (⟪variable face⟫))))
'(js2-warning-face ((t (⟪warning face⟫))))

js template⟫=

(let ((js-template "template.js"))
  (when (file-exists-p (expand-file-name js-template
                                         auto-insert-directory))
    (add-to-list 'auto-insert-alist
                 `(("\\.js\\'" . "JS") . ,js-template))))

templates/template.js⟫=

(function () {
})();

moz.el fetch rule⟫=

moz.el:
        curl -O http://github.com/bard/mozrepl/raw/master/chrome/content/moz.el

espresso.el fetch rule⟫=

espresso.el:
        curl -O http://download.savannah.gnu.org/releases-noredirect/espresso/espresso.el

ecmascript-mode.el fetch rule⟫=

ecmascript-mode.el:
        curl -O $(EMACSWIKI_DOWNLOAD)/ecmascript-mode.el

javascript.el fetch rule⟫=

javascript.el: javascript.el.zip
        unzip -fo javascript.el.zip
javascript.el.zip:
        curl -O http://web.comhem.se/~u34308910/emacs/javascript.el.zip

js2 config⟫=

(autoload 'js2-mode "js2-mode" nil t)
(setq js2-highlight-level 3
      js2-cleanup-whitespace nil
      js2-bounce-indent-p nil
      js2-auto-indent-p nil
      js2-indent-on-enter-key t)
(add-hook 'js2-mode-hook
          (lambda () (setq mode-name "JS2")))

javascript.el config⟫=

(setq js-indent-level 4
      javascript-indent-level 4
      javascript-auto-indent-flag nil)
(autoload 'javascript-mode "javascript" nil t)
(when (boundp 'javascript-mode-abbrev-table)
  (add-hook 'javascript-mode-hook
            (lambda ()
              (setq local-abbrev-table javascript-mode-abbrev-table))))

js.el config⟫=

(setq js-indent-level 4)

espresso.el config⟫=

(autoload 'espresso-mode "espresso" nil t)

(setq espresso-indent-level 4)

Web Development⟫=

(defvar tess-javascript-mode 'javascript-generic-mode
  "What major mode should I be using for JavaScript.")

(cond ((locate-library "js")
       (setq tess-javascript-mode 'js-mode)
       ⟪js.el config⟫)
      ((locate-library "espresso")
       (setq tess-javascript-mode 'espresso-mode)
       ⟪espresso.el config⟫)
      ((locate-library "js2-mode")
       (setq tess-javascript-mode 'js2-mode)
       ⟪js2 config⟫)
      ((locate-library "javascript")
       (setq tess-javascript-mode 'javascript-mode)
       ⟪javascript.el config⟫))

(add-to-list 'auto-mode-alist (cons "\\.htc\\'" tess-javascript-mode))
(add-to-list 'auto-mode-alist (cons "\\.m?js\\'" tess-javascript-mode))
(add-to-list 'auto-mode-alist (cons "\\.json\\'" tess-javascript-mode))

abbrev-definitions⟫=

(define-abbrev-table 'javascript-mode-abbrev-table '(
    ))

Java and the JDE

jde faces⟫=

'(jde-bug-breakpoint-cursor ((t (:background "cyan"))))
'(jde-db-active-breakpoint-face ((t (:background "cyan"))))
'(jde-db-requested-breakpoint-face ((t (:background "cyan"))))
'(jde-db-spec-breakpoint-face ((t (:background "cyan"))))
'(jde-java-font-lock-api-face ((t (:background "cyan"))))
'(jde-java-font-lock-bold-face ((t (:bold t ⟪comment face⟫))))
'(jde-java-font-lock-code-face ((t (:foreground "⟪medium red⟫" ;%
                                   ⟪cyan bg⟫))))
'(jde-java-font-lock-constant-face ((t (⟪constant face⟫))))
'(jde-java-font-lock-doc-tag-face ((t (:foreground "⟪medium yellow⟫"
                                      ⟪cyan bg⟫))))
'(jde-java-font-lock-italic-face ((t (:slant italic ⟪comment face⟫))))
'(jde-java-font-lock-link-face ((t (:background "cyan"))))
'(jde-java-font-lock-modifier-face ((t (:foreground "⟪medium blue⟫")))) ;%
'(jde-java-font-lock-number-face ((t (:foreground "⟪medium yellow⟫"))))
'(jde-java-font-lock-operator-face ((t (:background "cyan"))))
'(jde-java-font-lock-package-face ((t (:foreground "⟪medium yellow⟫"))))
'(jde-java-font-lock-pre-face ((t (:background "cyan"))))
'(jde-java-font-lock-underline-face ((t (:underline t ⟪comment face⟫))))

antlr faces⟫=

'(antlr-font-lock-keyword-face ((t (⟪keyword face⟫)))) ;%
'(antlr-font-lock-literal-face ((t (:foreground "⟪light magenta⟫"))))
'(antlr-font-lock-ruledef-face ((t (:foreground "⟪dark green⟫"))))
'(antlr-font-lock-ruleref-face ((t (:foreground "⟪dark cyan⟫"))))
'(antlr-font-lock-tokendef-face ((t (:foreground "⟪medium yellow⟫"))))
'(antlr-font-lock-tokenref-face ((t (:foreground "⟪medium blue⟫"))))

Open .jar files with archive-mode⟫=

(when (boundp 'auto-coding-alist)
  (add-to-list 'auto-coding-alist '("\\.[jw]ar\\'" . no-conversion))
  (add-to-list 'auto-coding-alist '("\\.[JW]AR\\'" . no-conversion)))
(add-to-list 'auto-mode-alist '("\\.[jw]ar\\'" . archive-mode))
(add-to-list 'auto-mode-alist '("\\.[JW]AR\\'" . archive-mode))

C sharp

C sharp⟫=

(add-to-list 'auto-mode-alist '("\\.cs\\'" . java-mode))

C sharp⟫=

(defun tess-c-sharp-fix-tab-width ()
  (when (string-match "\\.cs\\'" (buffer-file-name))
    (setq tab-width 2)))

(add-hook 'java-mode-hook 'tess-c-sharp-fix-tab-width)

Lisp

Lisp Development⟫=

(add-to-list 'auto-mode-alist '("\\.arc\\'" . lisp-mode))

Lisp Development⟫=

;; completion in M-:
(when (keymapp read-expression-map)
  (define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol))

Lisp Development⟫=

(defun tess-comment-sexp ()
  (interactive)
  (call-interactively 'mark-sexp)
  (call-interactively 'comment-region))

(defun tess-install-lispy-bindings (map bind-ret)
  "FIXME"
  (define-key map (kbd "M-k") 'kill-sexp)
  (define-key map (kbd "\"")
    (seq-find 'commandp '(paredit-doublequote skeleton-pair-insert-maybe)))
  (define-key map (kbd "C-M-;") 'tess-comment-sexp)
  (when bind-ret
    (define-key map (kbd "RET")
      (seq-find 'commandp '(paredit-newline newline-and-indent))))
  (define-key map (kbd "(")
    (seq-find 'commandp '(paredit-open-parenthesis
                         paredit-open-list
                         insert-parentheses)))
  (define-key map (kbd ")")
    (seq-find 'commandp '(paredit-close-parenthesis-and-newline
                         ;; paredit-close-list-and-newline
                         move-past-close-and-reindent))))

Lisp Development⟫=

(tess-install-lispy-bindings
 (cond ((boundp 'lisp-mode-shared-map) lisp-mode-shared-map)
       ((boundp 'shared-lisp-mode-map) shared-lisp-mode-map)
       (t emacs-lisp-mode-map))
 t)

Lisp Development⟫=

(eval-after-load "ielm"
  '(tess-install-lispy-bindings ielm-map nil))

Lisp Development⟫=

(define-key minibuffer-local-map (kbd "M-i") (lambda () (interactive) (insert ?i)))

Lisp Development⟫=

(add-to-list 'auto-mode-alist '("\\.elc\\'" . emacs-lisp-mode))

Lisp Development⟫=

(defun tess-dedangle-parens-in-region (start end)
  "De-dangle close parens between START and END."
  (interactive "r")
  (goto-char start)
  (while (re-search-forward "[ \t\n]+)" end t)
    (replace-match ")")))

(defun tess-make-lisp-idiomatic-in-region (start end)
  "Make the Lisp code from START to END a bit more idiomatic.
You might consider running `checkdoc' as well."
  (interactive "r\nP")
  (save-restriction
    (widen)
    (narrow-to-region start end)
    (setq start (point-min-marker)
          end   (point-max-marker))
    (tess-dedangle-parens-in-region start end)
    (indent-region start end)))

Enable paren matching⟫=

(when (fboundp 'show-paren-mode)
  (show-paren-mode 1)
  (make-variable-buffer-local 'show-paren-mode))

;; to make paredit behave.
(setq blink-matching-paren-on-screen nil)
(setq blink-matching-delay 0.125)

;; Emacs.app (Cocoa/GNUStep port) uses mic-paren by default
(when (featurep 'mic-paren)
  (setq paren-sexp-mode nil))

XEmacs paren matching⟫=

(setq paren-mode 'paren)

paren match face⟫=

⟪cyan bg⟫ ⟪dark fg⟫

paren mismatch face⟫=

⟪error face⟫

show paren faces⟫=

'(show-paren-match ((t (⟪paren match face⟫))))
'(show-paren-match-face ((t (⟪paren match face⟫))))
'(show-paren-mismatch ((t (⟪paren mismatch face⟫))))
'(show-paren-mismatch-face ((t (⟪paren mismatch face⟫))))

mic-paren faces⟫=

'(paren-face-match ((t (⟪paren match face⟫))))
'(paren-face-mismatch ((t (⟪paren mismatch face⟫))))
'(paren-face-no-match ((t (⟪paren mismatch face⟫))))

highline faces⟫=

'(highline-face ((t (⟪default (alt)⟫))))
'(highline-vertical-face ((t (⟪default (alt)⟫))))

hl-line face variables⟫=

;; '(hl-line-face 'fringe)

parenface.el fetch rule⟫=

parenface.el:
        curl -O http://www.davep.org/emacs/parenface.el

Lisp Development⟫=

(add-hook 'after-make-frame-functions
          (lambda (frame)
            (when (display-graphic-p (tess-frame-display frame))
              (require 'parenface nil t))))

parenface faces⟫=

`(paren-face ((t ⟪dim this face when appropriate⟫)))

Lisp Development⟫=

(dolist (candidate '("mzscheme"))
  (when (executable-find candidate)
    (setq scheme-program-name candidate)))
Emacs Lisp

defun find-library⟫=

(cond ((commandp 'find-library)
       (defalias 'tess-find-library 'find-library))
      ((fboundp 'find-library)
       (defun tess-find-library (library)
         "Open LIBRARY."
         (interactive "sLibrary: ")
         (find-library library)))
      (t
       (defun tess-find-library (library)
         "Open LIBRARY."
         (interactive "sLibrary: ")
         (let ((filename (locate-library (concat library ".el"))))
           (if (stringp filename)
               (find-file filename)
             (message "Library %s not found." library))))))

(global-set-key (kbd "C-c L") 'tess-find-library)

abbrev-definitions⟫=

(define-abbrev-table 'lisp-mode-abbrev-table '(
    ("wll" "" tess-elisp-when-locate-library-skeleton 0)
    ))

(define-abbrev-table 'emacs-lisp-mode-abbrev-table '(
    ("wll" "" tess-elisp-when-locate-library-skeleton 0)
    ))

(define-abbrev-table 'lisp-interaction-mode-abbrev-table '(
    ("wll" "" tess-elisp-when-locate-library-skeleton 0)
    ))

Lisp Development⟫=

(define-skeleton tess-elisp-when-locate-library-skeleton
  "Skeleton for (when (locate-library \"foo\") ... ) forms."
  ;; This `completing-read' form based on `find-library's `interactive'
  ;; spec, but generalized to work under different Emacsen.
  (completing-read "Library name: "
                   (when (fboundp 'locate-file-completion)
                     'locate-file-completion)
                   (cons (if (boundp 'find-function-source-path)
                             find-function-source-path
                           load-path)
                         ;; (find-library-suffixes)
                         '(".el" ".el.gz" ".gz")))
  "when (locate-library \"" str "\")")

Lisp Development⟫=

(when (locate-library "eldoc")
  (mapc (lambda (mode-hook)
          (add-hook mode-hook 'turn-on-eldoc-mode))
        '(emacs-lisp-mode-hook lisp-interaction-mode-hook
          ielm-mode-hook))

  (setq eldoc-argument-case 'help-default-arg-highlight))

Lisp Development⟫=

(defun tess-macroexpand-sexp-at-point ()
  "Replace the s-expresion at point with its macroexpansion."
  (interactive)

  (let (pre start end)
    (save-excursion
      (up-list -1)
      (setq start (point))
      (setq pre (sexp-at-point))
      (forward-sexp 1)
      (setq end (point)))

    (goto-char start)
    (kill-region start end)

    (pp (macroexpand pre) (current-buffer))))

Lisp Development⟫=

(defun tess-indent-containing-sexp ()
  "Fix the indentation of the sexp containing point."
  (interactive)
  (save-excursion
    (up-list -1)
    (indent-sexp)))

(global-set-key (kbd "C-c i") 'tess-indent-containing-sexp)

Lisp Development⟫=

(setq ielm-prompt "* ")

Lisp Development⟫=

(add-to-list 'auto-mode-alist '("\\.asd\\'" . lisp-mode))

Lisp Development⟫=

(add-to-list 'auto-mode-alist '("\\.lisp-expr\\'" . lisp-mode))

Lisp Development⟫=

(mapc (lambda (hook)
        (add-hook hook
                  (lambda ()
                    (set (make-local-variable 'lisp-indent-function)
                         'common-lisp-indent-function))))
      '(lisp-mode-hook inferior-lisp-mode-hook))

Lisp Development⟫=

(setq inferior-lisp-program
      (or (executable-find "sbcl")
          (executable-find "lisp")
          (executable-find "openmcl")
          (executable-find "clisp")))
Common Lisp and SLIME

.lisprc⟫=

;;;; .lisprc --- Common Lisp init file.                   -*- lisp -*-

(in-package :common-lisp-user)

#-cmu (require :asdf)

#+asdf
(progn
  #+openmcl (progn
              (pushnew "ccl:tools;asdf-install;" asdf:*central-registry*
                       :test #'string-equal)
              (asdf:operate 'asdf:load-op 'asdf-install))
  #+sbcl (when (asdf:find-system :sb-bsd-sockets nil)
           (require :asdf-install)))

Lisp Development⟫=

(when (locate-library "slime")
  (autoload 'slime-mode "slime" nil t)
  (add-hook 'lisp-mode-hook (lambda nil (slime-mode 1)))
  (autoload 'inferior-slime-mode "slime" nil t)
  (add-hook 'inferior-lisp-mode-hook
            (lambda nil (inferior-slime-mode 1)))
  (add-hook 'slime-repl-mode-hook 'tess-hide-trailing-whitespace))

slime compliler faces⟫=

'(slime-error-face ((t (⟪error face⟫))))
'(slime-warning-face ((t (⟪warning face⟫))))
'(slime-style-warning-face ((t (⟪warning face⟫))))
'(slime-note-face ((t (⟪warning face⟫))))
'(slime-highlight-face ((t (⟪warning face⟫))))

slime debugger faces⟫=

'(sldb-catch-tag-face ((t (:foreground "⟪medium yellow⟫")))) ;%
'(sldb-condition-face ((t (:foreground "⟪light cyan⟫"))))
'(sldb-detailed-frame-line-face ((t ())))
'(sldb-frame-label-face ((t (:foreground "⟪dark magenta⟫"))))
'(sldb-frame-line-face ((t ())))
'(sldb-local-name-face ((t (⟪variable face⟫))))
'(sldb-local-value-face ((t (:foreground "⟪light yellow⟫"))))
'(sldb-reference-face ((t (:background "cyan"))))
'(sldb-restart-type-face ((t (:foreground "⟪medium magenta⟫"))))
'(sldb-restart-face ((t (:foreground "⟪light magenta⟫"))))
'(sldb-restart-number-face ((t (:foreground "⟪dark magenta⟫"))))
'(sldb-section-face ((t (:foreground "⟪dark yellow⟫"))))
'(sldb-topline-face ((t (:foreground "⟪light red⟫"))))

slime repl faces⟫=

'(slime-repl-prompt-face ((t (⟪prompt face⟫))))
'(slime-repl-output-face ((t (:foreground "⟪dark magenta⟫"))))
'(slime-repl-input-face ((t (:foreground "⟪light magenta⟫"))))
'(slime-repl-result-face ((t (:foreground "⟪medium magenta⟫"))))

slime inspector faces⟫=

'(slime-inspector-topline-face ((t (⟪default (alt)⟫))))
'(slime-inspector-label-face ((t (:foreground "⟪medium red⟫")))) ;%
'(slime-inspector-value-face ((t (:foreground "⟪very light magenta⟫"))))
'(slime-inspector-action-face ((t (:background "cyan"))))
'(slime-inspector-type-face ((t (:foreground "⟪light cyan⟫")))) ;%

slime reader faces⟫=

`(slime-reader-conditional-face ((t ⟪dim this face when appropriate⟫)))

Ruby and Rails

abbrev-definitions⟫=

(define-abbrev-table 'ruby-mode-abbrev-table '(
    ("mct" "" tess-rails-migrate-create-table 0)
    ("mdt" "" tess-rails-migrate-drop-table 0)
    ("mtc" "" tess-rails-migrate-table-column 0)
    ("mac" "" tess-rails-migrate-add-column 0)
    ("mrc" "" tess-rails-migrate-remove-column 0)
    ))

ruby fetch rules⟫=

rails.el:
        curl -O https://opensvn.csie.org/mvision/emacs/.emacs.d/rails.el
ruby: misc.tar.gz
        tar xzvf misc.tar.gz
        mv misc ruby
RUBY_CVSWEB="http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby"
misc.tar.gz:
        curl -o misc.tar.gz "$(RUBY_CVSWEB)/misc/misc.tar.gz?tarball=1"

ruby-mode⟫=

;; Autoloads
(autoload 'ruby-mode "ruby-mode" nil t)

ruby-mode⟫=

;; File associations, etc.
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile\\'" . ruby-mode))
;; fixme: use two-mode-mode when possible
(add-to-list 'auto-mode-alist '("\\.rhtml\\'" . html-mode))

ruby-mode⟫=

(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))

ruby-mode⟫=

;; Key bindings
(eval-after-load "ruby-mode"
  '(define-key ruby-mode-map (kbd "RET")
     'ruby-reindent-then-newline-and-indent))

ruby-mode⟫=

;; Install key bindings for running an inferior Ruby in `ruby-mode'.
(when (locate-library "inf-ruby")
  (autoload 'run-ruby "inf-ruby" nil t)
  (autoload 'inf-ruby-keys "inf-ruby" nil)
  (add-hook 'ruby-mode-hook 'inf-ruby-keys))

ruby-mode⟫=

;; Skeletons

(define-skeleton tess-rails-migrate-create-table
  "Skeleton for creating a table in a rails migration."
  "Table name: "
  > "create_table \"" str "\" do |t|" \n
  _ \n
  -2 "end" \n)

(define-skeleton tess-rails-migrate-drop-table
  "Skeleton for dropping a table in a rails migration."
  "Table name: "
  > "drop_table \"" str "\"" \n)

(define-skeleton tess-rails-migrate-table-column
  "Skeleton for adding a column in a rails migration."
  "Column name: "
  > "t.column \"" str "\", :" (skeleton-read "Column type: " "string"))

(define-skeleton tess-rails-migrate-add-column
  "Skeleton for adding a column in a rails migration."
  "Table name: "
  > "add_column \"" str
  "\", \"" (skeleton-read "Column name: ")
  "\", :" (skeleton-read "Column type: " "string"))

(define-skeleton tess-rails-migrate-remove-column
  "Skeleton for adding a column in a rails migration."
  "Table name: "
  > "remove_column \"" str
  "\", \"" (skeleton-read "Column name: ") "\"")

defun tess-next-warning⟫=

(defun tess-next-warning ()
  "Advance to the next buffer location in `font-lock-warning-face'."
  (interactive)
  (let ((here (point)))
    (condition-case nil
        (progn
          (goto-char (next-property-change (point)))
          (while (not (memq (get-text-property (point) 'face)
                          '(font-lock-warning-face
                            js2-error-face js2-warning-face)))
            (goto-char (next-property-change (point)))))
      (error (goto-char here)
             (error "There are no more warnings in the buffer!")))))

(global-set-key (kbd "C-c n") 'tess-next-warning)

PHP

auto-insert .php contents⟫=

(define-skeleton tess-php-new-file-skeleton
  "New PHP file skeleton."
  nil
  "<?php" \n \n _ \n \n
  "?>")

(when (fboundp 'auto-insert-mode)
  (add-to-list 'auto-insert-alist
               `(("\\.php\\'" . "PHP") . tess-php-new-file-skeleton)))

two-mode-mode.el fetch rule⟫=

two-mode-mode.el:
        curl -O http://www.welton.it/freesoftware/files/two-mode-mode.el

Perl

cperl-mode⟫=

(autoload 'cperl-mode "cperl-mode" nil t)
(add-to-list 'auto-mode-alist
             '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
(fset 'perl-mode 'cperl-mode)
(add-hook 'cperl-mode-hook 'turn-off-auto-fill)
(setq cperl-hairy t)

cperl face variables⟫=

;; '(cperl-pod-face 'font-lock-doc-string-face)
'(cperl-pod-head-face 'font-lock-variable-name-face)
;; '(cperl-here-face 'font-lock-doc-string-face)
'(cperl-invalid-face 'font-lock-warning-face)

cperl faces⟫=

'(cperl-array-face ((t (:foreground "⟪light magenta⟫")))) ;%
'(cperl-array ((t (:foreground "⟪light magenta⟫")))) ;%
'(cperl-nonoverridable-face ((t (:foreground "⟪dark yellow⟫"))))
'(cperl-nonoverridable ((t (:foreground "⟪dark yellow⟫"))))
'(cperl-hash-face ((t (:foreground "⟪medium magenta⟫"))))
'(cperl-hash ((t (:foreground "⟪medium magenta⟫"))))

Python, Pymacs, Rope, and Ropemacs

Setting PATH (zsh)⟫=

for python in 'python' 'python2' 'python3'; do
    if is-in-path $python; then
        add-to-path `$python -m site | grep USER_BASE | cut -d \' -f 2`/bin
    fi
done

Pymacs and Ropemacs⟫=

(when (locate-library "pymacs")
  (autoload 'pymacs-load "pymacs")
  ⟪Ropemacs⟫)

Ropemacs⟫=

(defun tess-load-ropemacs ()
  "Load ropemacs iff pymacs is installed and ropemacs isn't loaded."
  (interactive)
  (when (fboundp 'pymacs-load)
    (unless (featurep 'ropemacs)
      (pymacs-load "ropemacs" "rope-" t)
      (ropemacs-mode 1))))

(add-hook 'python-mode-hook 'tess-load-ropemacs)

python template⟫=

(let ((py-template "template.py"))
  (when (file-exists-p (expand-file-name py-template
                                         auto-insert-directory))
    (add-to-list 'auto-insert-alist
                 `(("\\.py\\'" . "Python") . ,py-template))))

templates/template.py⟫=

#!/usr/bin/env python

if __name__ == '__main__':
    pass

parse-sexp-ignore-comments⟫=

;; http://article.gmane.org/gmane.emacs.devel/64807
(setq parse-sexp-ignore-comments t)

Choose which python mode to use⟫=

(unless (locate-library "python")
  (when (locate-library "python-mode")
    (autoload 'python-mode "python-mode" nil t)
    (add-to-list 'auto-mode-alist
                 '("\\.\\(py\\|tac\\)\\'" . python-mode))
    (add-to-list 'interpreter-mode-alist
                 '("python" . python-mode))))

Golang

Setting PATH (zsh)⟫=

add-to-path ~/go/bin

Swift

swift major mode fetch rules⟫=

swift-mode.el:
        curl -O https://raw.githubusercontent.com/apple/swift/master/utils/swift-mode.el
swift-project-settings.el:
        curl -O https://raw.githubusercontent.com/apple/swift/master/utils/swift-project-settings.el

Setting PATH (zsh)⟫=

add-to-path /usr/share/swift/usr/bin

Swift⟫=

(when (executable-find "xcode-select")
  (let* ((xcode-dir
          (with-temp-buffer
            (call-process "xcode-select" nil t nil "-p")
            (buffer-substring (point-min) (1- (point-max)))))
         (xcode-site-lisp
          (format "%s/Toolchains/XcodeDefault.xctoolchain/%s/"
                  xcode-dir
                  "usr/share/emacs/site-lisp")))
    (add-to-list 'load-path xcode-site-lisp)))

(when (locate-library "swift-mode")
  (autoload 'swift-mode "swift-mode")
  (add-to-list 'auto-mode-alist '("\\.swift\\'" . swift-mode)))

Haskell

haskell-mode fetch fules⟫=

haskell-mode-1.45/haskell-mode.el: haskell-mode-1.45.tar.gz
        tar xzvf haskell-mode-1.45.tar.gz
haskell-mode-1.45.tar.gz:
        curl -O http://www.haskell.org/haskell-mode/haskell-mode-1.45.tar.gz

haskell-mode⟫=

(add-to-list 'auto-mode-alist '("\\.\\([hg]s\\|hi\\)\\'" . haskell-mode))
(add-to-list 'auto-mode-alist '("\\.l[hg]s\\'" . literate-haskell-mode))

(autoload 'haskell-mode "haskell-mode" nil t)
(autoload 'literate-haskell-mode "haskell-mode" nil t)

(mapc (lambda (hook)
        (add-hook 'haskell-mode-hook hook))
      '(turn-on-haskell-font-lock turn-on-haskell-decl-scan
        turn-on-haskell-doc-mode turn-on-haskell-indent
        turn-on-haskell-hugs))

Structure of some very large config files

.emacs

.emacs⟫=

;;; .emacs --- Theresa O'Connor's Emacs configuration -*- emacs-lisp -*-

⟪Elisp Copyright Statement⟫

;;; Code:

(require 'cl-lib)
(require 'seq nil t)

;;; Compatibility. Checking for the availability of various functions
;;; which I'll be using later on.

(unless (fboundp 'seq-filter)
  (autoload 'remove-if "cl")
  (defalias 'seq-filter 'remove-if))

(unless (fboundp 'seq-remove)
  (autoload 'remove-if-not "cl")
  (defalias 'seq-remove 'remove-if-not))

(unless (fboundp 'seq-uniq)
  (autoload 'remove-duplicates "cl")
  (defmacro seq-uniq (sequence &optional predicate)
    (if predicate
        `(remove-duplicates ,sequence :test ,predicate)
      `(remove-duplicates ,sequence))))

(unless (fboundp 'seq-find)
  (autoload 'find-if "cl")
  (defalias 'seq-find 'find-if))

⟪provide emacs⟫

⟪Custom hooks⟫

⟪Configure max-lisp-eval-depth and max-specpdl-size⟫
⟪Garbage collect when tabbing away from Emacs⟫

⟪Define operating system type predicates⟫

⟪basic w32 fixups⟫
⟪define xdg-config-home for emacs⟫
⟪define data-vol and shared-home for emacs⟫

⟪define tess-elisp-dirs and tess-elisp-dir⟫
⟪define tess-workspace⟫

⟪defun tess-run-executable⟫
⟪Set exec-path from path_helper on macOS⟫
⟪Set SYSNAME in Emacs⟫
⟪Ensure HOME/bin is in exec-path⟫
⟪Add SYSNAME/bin to exec-path⟫
⟪Config data-vol and shared-home in Emacs⟫
⟪Fix exec-path under Emacs⟫

;;; Compatibility ,part 2. Checking for the availability of various
;;; functions which I'll be using later on.

;; Not defined in Emacs.
(if (fboundp 'variable-obsolete-p)
    (defalias 'tess-variable-obsolete-p 'variable-obsolete-p)
  ⟪defsubst tess-variable-obsolete-p⟫)

;; Not defined in XEmacs.
(unless (fboundp 'turn-off-auto-fill)
  ⟪defun turn-off-auto-fill⟫)

;; Not defined in XEmacs.
(unless (fboundp 'propertize)
  ⟪defun propertize⟫)

;; Not defined in non-Mule XEmacs.
(if (fboundp 'coding-system-p)
    (defalias 'tess-coding-system-p 'coding-system-p)
  (defalias 'tess-coding-system-p 'ignore))

;; Not defined in older Emacsen.
(unless (fboundp 'custom-autoload)
  ⟪defun custom-autoload⟫)

;; The function `exectuable-find' isn't autoloaded in older XEmacsen.
(unless (fboundp 'executable-find)
  (autoload 'executable-find "executable"))

(cond ((fboundp 'set-frame-parameter)
       (defalias 'tess-set-frame-parameter 'set-frame-parameter))
      ((fboundp 'set-frame-property)
       (defalias 'tess-set-frame-parameter 'set-frame-property)))

;; Defined in multi-tty Emacs
(if (fboundp 'window-system)
    (defalias 'tess-window-system 'window-system)
  (defun tess-window-system (&optional frame)
    window-system))

(cond ((fboundp 'frame-display) ;; Multi-TTY Emacs
       (defalias 'tess-frame-display 'frame-display))
      ((fboundp 'frame-device) ;; XEmacs
       (defalias 'tess-frame-display 'frame-device))
      (t (defalias 'tess-frame-display 'ignore)))

;; I use `assoc-default' in `tess-find-mode'.
(unless (fboundp 'assoc-default)
  (warn "This Emacs does not define `assoc-default'!")
  ⟪defun assoc-default⟫)

⟪Set LANG in Emacs⟫

;;; Utilities.

⟪defsubst tess-alist⟫
⟪defun tess-add-to-list*⟫

;;; Frob the Emacs command line.

⟪defvar tess-server-emacs⟫
⟪enable -gnus⟫

;;; Frobbing `load-path' and checking for any third-party elisp files on
;;; this machine.

⟪Configure load-path⟫
⟪put gist.el and dependencies in load-path⟫
(message "Load path is %s" load-path)
⟪Configure Info-default-directory-list⟫
⟪Ensure we load the right Gnus⟫

(when (locate-library "package")
  ⟪Configuring package.el⟫)

;;; Define various constants and predicates that will be used throughout
;;; this .emacs file to conditionalize code. For instance, I define
;;; `tess-tty-p' so that I can specify particular Emacs configuration
;;; bits for TTYs only.

⟪Define Gnus version predicates⟫
⟪Define display type predicates⟫
⟪defconst tess-emacs-name⟫

;;; Work-arounds for things I find annoying in their default state, and
;;; basic customizations.

⟪case-insensitive filename completion⟫
⟪Update environment under macOS⟫
⟪Stop Cocoa Emacs from using the system highlight⟫
⟪Ensure after-make-frame-functions get run for first frame⟫
⟪load-home-init-file⟫
⟪Disable the Emacs splash screen⟫
⟪setq cd-path⟫
(when tess-w32-flag
  ⟪Fix exec-path under Windows⟫)
⟪Key binding for goto-line⟫
⟪require-final-newline⟫
⟪inhibit default init⟫
⟪change-log-default-name⟫
(when (featurep 'aquamacs)
  ⟪Disable CUA-mode⟫)
⟪transient mark mode⟫
⟪Enable disabled commands⟫
⟪disable overwrite-mode⟫
⟪sentence-end-double-space⟫
⟪defalias yes-or-no-p⟫
⟪indent-tabs-mode⟫
⟪truncate-lines⟫
⟪Disable blinking cursors⟫
⟪Fix scrolling⟫
⟪multi-region⟫
⟪Minibuffer Electric Default Mode⟫
⟪Fix size of temporary buffer windows⟫
⟪Enable minibuffer resizing⟫
⟪uniquify⟫
⟪Line and Column numbering⟫
⟪Don't echo passwords in comint mode⟫
⟪Poor-man's diminish.el⟫
⟪Ensure XCode Command Line Tools are in exec-path⟫
⟪Fix Emacs behavior when in the macOS dock⟫
⟪LC COLLATE in Emacs⟫
⟪comment-style⟫
⟪auto-mode-case-fold⟫
⟪defun tess-insert-local-variables-spec⟫
⟪Apropos do all⟫
⟪Disable pager when git is run from Emacs⟫
⟪setq completion-ignore-case⟫

;; completion

⟪Disable SPC minibuffer completion⟫
(when (locate-library "pcomplete")
  ⟪pcomplete⟫)

(cond ((locate-library "longlines")
       ⟪longlines⟫)
      ((fboundp 'visual-line-mode)
       ⟪alias longlines with visual-line-mode⟫))

⟪isearch highlight current match⟫
⟪Enable abbrevs⟫
⟪Enable paren matching⟫
⟪Basic auto-fill configuration⟫
⟪fill-column⟫
⟪Highlight Trailing Whitespace⟫
⟪user-mail-address⟫
⟪Increase logging amount⟫
⟪defun tess-clear⟫
⟪defun tess-ip⟫
⟪timestamp⟫
⟪goto-address⟫
⟪indicate-empty-lines⟫
⟪templates⟫
⟪defun kr-major-mode-p⟫
⟪defun tess-read-major-mode⟫
⟪edit region in a different major mode⟫
⟪defun tess-kill-mode-buffers⟫
⟪defun help-default-arg-highlight⟫
⟪tess-find-mode⟫
⟪defun tess-wash-smart-quotes⟫
⟪linum⟫
⟪archive-mode⟫
⟪configure woman⟫
⟪Emoji utilities⟫

;; Customizations particular to XEmacs.
(when (featurep 'xemacs)
  ⟪Reveal Messages buffer in XEmacs⟫
  ⟪disable shifted selection in XEmacs⟫
  ⟪Configure XEmacs logging levels⟫
  ⟪XEmacs paren matching⟫)

;; Customizations which we only want to happen when we're using
;; Emacs on a TTY.
(add-hook
 'after-make-frame-functions
 (lambda (frame)
   (when (tess-tty-p (tess-frame-display frame))
     ⟪TTY terminal-coding-system⟫
     ⟪Handle my FreeBSD keymap⟫
     ⟪TTY web browser default⟫)))

;;; Easy installing of third-party elisp.

⟪Use install.el⟫

;;; Various buffer-switching enhancements.

⟪Organize buffer menu by major mode⟫
⟪Better buffer switching⟫
⟪ibuffer-fontification-alist⟫

;;; gnuclient / emacsclient / remote editing

⟪gnuserv or emacs server⟫
⟪TRAMP: Transparent Remote Access over Multiple Protocols⟫

;;; Key bindings.

⟪multi-tty C-x C-c hack⟫
(add-hook 'after-make-frame-functions
          (lambda (frame)
            (when (tess-w32-window-system-p frame)
              ⟪Windows modifier key bindings⟫)
            (when (tess-aqua-p frame)
              ⟪Mac modifier key bindings⟫)))

⟪Key binding for bury-buffer⟫
⟪Bindings for the scroll wheel in the mode line⟫
⟪Key binding for list-text-properties-at⟫
⟪find-function key bindings⟫
⟪bind ucs-insert to C-c u⟫
⟪Sun Type 6 USB keyboard key bindings⟫
⟪Sun keyboard key bindings⟫
⟪Fix insertchar key binding⟫
⟪Key binding for FFAP⟫
⟪Fix common Emacs typos⟫
⟪additional rectangle command bindings⟫
⟪Macro DWIM stuff⟫
⟪Duplicate some meta keys on super⟫
⟪smerge-mode⟫

;;; Major Emacs-based applications, and Emacs interfaces to other major
;;; applications.

⟪ledger-mode⟫
⟪EMMS⟫
;; Emacs games
⟪Emacs Games⟫

;; Viper, the VI-like editor in Emacs

⟪Enable Viper in .emacs⟫
⟪Configure Viper's toggle key⟫
⟪Ensure Viper doesn't mess with my cursor type⟫
(when (and (boundp 'viper-mode) viper-mode (featurep 'aquamacs))
  ⟪Fix Viper under Aquamacs⟫)

⟪Use SSH for M-x rsh, and make M-x ssh⟫

;; Eshell, the Emacs Shell
(when (locate-library "eshell")
  ⟪The Emacs Shell⟫
  ⟪Eshell prompt⟫
  ⟪Use ANSI escape sequences in Eshell⟫
  ⟪fix s-p in eshell⟫
  (when (featurep 'xemacs)
    (eval-after-load "esh-cmd"
      '⟪Fix e-f-a-f on XEmacs⟫))

  ⟪Various custom Eshell commands⟫
  (eval-after-load "em-ls"
    '(progn
       ⟪Augment eshell's ls to allow middle-clicking on files⟫)))

;; Emacs web browsing, web searching, and more!
⟪disable use of ? as completion help in minibuffer⟫
(when (locate-library "w3m")
  ⟪emacs-w3m⟫
  ⟪defun tess-w3m-edit-emacswiki-page⟫
  (eval-after-load "w3m"
    '(progn
       ⟪lj: URLs in emacs-w3m⟫
       ⟪editing emacswiki pages with w3m⟫)))

⟪Using Backpack from within Emacs⟫
⟪Using Twitter from within Emacs⟫
⟪Using Google⟫
⟪ELL⟫
⟪wikiarea⟫
⟪EmacsWiki⟫
⟪wikipedia major mode⟫
⟪mediawiki major mode⟫

;; Email.
⟪sieve⟫
⟪mail-user-agent⟫
⟪Basic email look and feel⟫
⟪Determine Gnus version⟫
⟪Edit Gnus score files as Gnus score files⟫
⟪boxquote⟫
⟪The Insidious Big-Brother Database⟫

;; Dired, the Emacs directory editor.

⟪Dired, the Directory Editor⟫

;; ljupdate, an Emacs LiveJournal client
⟪ljupdate, an Emacs LiveJournal client⟫

;; Disable trying gnutls when it's not available
(when (and (not (gnutls-available-p))
           (require 'tls nil t))
  (unless (executable-find "gnutls-cli")
    (setq tls-program
          (seq-filter (lambda (candidate)
                       (string-match "gnutls-cli" candidate))
                     tls-program))))

;; ERC, an Emacs IRC client
(when (locate-library "erc")
  ⟪ERC, an Emacs IRC Client⟫)

;; rcirc
(when (locate-library "rcirc")
  ⟪rcirc⟫)

(when (locate-library "csv")
  ⟪CSV⟫)

;;; Programming and other forms of document preparation.

(when (locate-library "editorconfig")
  ⟪editorconfig⟫)

⟪ninja-mode⟫

⟪parse-sexp-ignore-comments⟫
⟪Programming Utilities⟫
⟪defun tess-next-warning⟫
⟪Make paired characters electric⟫
⟪Configuring glasses-mode⟫

⟪Swift⟫

(when (locate-library "gitsum")
  ⟪gitsum⟫)

(when (locate-library "gist")
  ⟪gist⟫)

(when (locate-library "psvn")
  ⟪psvn⟫)

(when (and (featurep 'emacs) (locate-library "vc-svn"))
  ⟪vc-svn⟫)

⟪C sharp⟫
⟪CamelCase-aware killing functions⟫
⟪Open .jar files with archive-mode⟫

(when (locate-library "haskell-mode")
  ⟪haskell-mode⟫)

;; Moved load of generic-x up before we look for javascript.el: both put
;; entries in `auto-mode-alist' for "\\.js\\'", and I want the entry
;; from javascript.el.
⟪generic-x⟫

⟪Web Development⟫

(when (locate-library "shr")
  ⟪shr config⟫)

(when (locate-library "markdown-mode")
  (autoload 'markdown-mode "markdown-mode" nil t)
  ⟪Editing Markdown files⟫)

(when (locate-library "bikeshed")
  (autoload 'bikeshed-mode "bikeshed" nil t)
  ⟪Editing Bikeshed files⟫)

(when (locate-library "deft")
  (autoload 'deft "deft" nil t)
  ⟪Deft⟫)

⟪Lisp Development⟫
⟪defun find-library⟫
(when (locate-library "dns-mode")
  ⟪DNS mode⟫)
⟪Open RPM spec files in rpm-spec-mode⟫
⟪rfcview⟫
⟪cfengine⟫
⟪defvar tess-ports-tree-root⟫
(when (and (stringp tess-ports-tree-root)
           (file-directory-p tess-ports-tree-root))
  ⟪Emacs code for browsing the ports tree⟫)

(when (locate-library "ruby-mode")
  ⟪ruby-mode⟫)

(when (locate-library "cperl-mode")
  ⟪cperl-mode⟫)

;;; Python

⟪Pymacs and Ropemacs⟫
⟪Choose which python mode to use⟫

⟪Open PostgreSQL views and source files in sql-mode⟫
⟪Mathematics⟫
⟪AUCTeX⟫
⟪disable TeX {sub,super}script frobbing⟫
⟪table⟫
⟪ensure org-mode is autoloaded⟫
(when (fboundp 'org-mode)
  ⟪org-mode⟫)

⟪noweb⟫

;;; Work.

⟪Ensure we can click on Apple URLs⟫

⟪Integer thing at point⟫

⟪Bug tracker links⟫

;;; Customizations which are specific to using Emacs under the various
;;; windowing systems.

⟪Choose the right browser⟫

⟪Windowing⟫
⟪Disable one-buffer-one-frame-mode⟫
(when (featurep 'aquamacs)
  ⟪Disable Aquamacs' various bells and whistles⟫)
⟪Disable smart-frame-positioning-mode⟫

;;; Customizing Emacs' colors.

⟪256 colors in Emacs⟫
⟪Arrow keys in local screen instances⟫

⟪face-list⟫
(when (display-color-p)
  ⟪htmlize⟫
  ⟪tess-htmlize⟫
  (cond
   ⟪custom-theme⟫
   ⟪color-theme⟫)
  ⟪term faces⟫
  ⟪Enable Font Locking⟫
  ⟪ANSI color sequences⟫)

;;; OS version-specific customizations.

(when tess-lion-flag
  ⟪OS X Lion⟫)

;;; Host-specific customizations.

⟪Host-specific customizations⟫

;;; .emacs ends here

.gnus

.gnus⟫=

;;; .gnus --- Theresa O'Connor's Gnus configuration -*- emacs-lisp -*-

⟪Elisp Copyright Statement⟫

;;; Code:

(setq gnus-agent nil)

(add-hook 'gnus-load-hook
  (lambda () ⟪Gnus config that should only run once⟫))

⟪Gnus config that should run each time Gnus is started⟫

;; Local configuration

⟪Local Gnus configuration⟫

;;; .gnus ends here

Gnus config that should only run once⟫=

Gnus config that should run each time Gnus is started⟫=

⟪Gnus Authentication Sources⟫
⟪I am not a Gnus novice any more⟫
⟪Article headers⟫
⟪tess-insert-citation-line⟫
⟪Choosing which citation code to use⟫
⟪Configure gnus-face-N⟫
⟪Gnus *Group* buffer looks⟫
⟪Gnus *Summary* buffer looks⟫
⟪override gnus-goto-colon⟫
⟪gnus-ignored-from-addresses⟫
⟪defun tess-follow-link-at-point⟫
⟪use message-forward-subject-fwd if available⟫
⟪configure gnus verbosity⟫
⟪mimedown command⟫
⟪misc gnus settings⟫
⟪Use open to preview PDFs on macOS⟫
⟪scoring in gnus⟫
⟪enable gnus topic mode⟫
⟪gnus topic mode keybindings⟫
⟪nnfolder configuration⟫
⟪nnmail configuration⟫
⟪fix dumb quotes in Gnus⟫
⟪gnus topic configuration⟫
⟪gnus subscribe randomly⟫
⟪tess typo gnus key bindings⟫
⟪key binding for gnus-group-mail⟫
⟪disable killing of groups by mistake⟫
⟪disable indenting of topics by mistake⟫
⟪Strong Bad email deletion⟫
⟪defun tess-gnus-mark-thread-advance⟫
⟪GCC header handling⟫
⟪SMTP handling⟫
⟪Gnus select methods⟫
⟪spam reporting⟫
⟪Gnus posting styles⟫
⟪Emoji in Gnus⟫

;; Mailing lists, at the W3C and elsewhere

⟪handle mailing lists nicely⟫

⟪Gmane special-handling⟫

⟪Cleaning up mailing list email⟫

⟪Reading W3C and WHATWG mailing list archives in Gnus⟫

Generating this HTML file from source

Noweb

I use noweb to generate all of my dotfiles from this source file.

I edit the single source file using noweb-mode in Emacs.

noweb⟫=

(when (locate-library "noweb-mode")
  (autoload 'noweb-mode "noweb-mode" nil t)
  (add-to-list 'auto-mode-alist '("\\.nw\\'" . noweb-mode))
  (setq noweb-mode-prefix (kbd "<f5>")) ;%

  ⟪fix noweb redisplay⟫
  ⟪fix M-q in noweb⟫
  ⟪fix highlighting in noweb elisp⟫
  ⟪fix noweb-default-code-mode⟫
  (when (featurep 'xemacs)
    ⟪fix noweb under XEmacs⟫))

fix highlighting in noweb elisp⟫=

(when (fboundp 'font-lock-add-keywords)
  (add-hook 'emacs-lisp-mode-hook
            (lambda ()
              (when (and (boundp 'noweb-mode) noweb-mode)
                (font-lock-add-keywords
                 nil
                 '(("\\([<][<][^>]*[>][>]\\)" ;%
                    (1 font-lock-string-face))))))))

fix noweb redisplay⟫=

(defadvice noweb-update-chunk-vector (around tess-noweb-redisplay
                                             activate)
  (let ((inhibit-redisplay t)
        (tess-noweb-redisplay-message
         "Updating noweb's chunk vector"))
    (message "%s..." tess-noweb-redisplay-message)
    ad-do-it
    (message "%s...done" tess-noweb-redisplay-message)))

fix noweb-default-code-mode⟫=

(setq-default noweb-default-code-mode 'emacs-lisp-mode
              noweb-code-mode         'emacs-lisp-mode)

fix noweb under XEmacs⟫=

(unless (fboundp 'ess-write-to-dribble-buffer)
  (defalias 'ess-write-to-dribble-buffer 'ignore))

fix noweb under XEmacs⟫=

(add-hook 'noweb-mode-hook
          (lambda ()
            (require 'noweb-font-lock-mode)
            (noweb-font-lock-mode 1)))

fix M-q in noweb⟫=

(eval-after-load "noweb-mode"
  '(fset 'noweb-fill-paragraph-chunk 'fill-paragraph))

Extracting dotfiles

Makefile⟫=

# Note that this Makefile only works with GNU Make.

DOTFILES=.Xmodmap .alias .emacs .ercrc.el .eudc .exrc .freebsd-keymap \
         .gitconfig .gnus .hgrc .lisprc .profile .profile.ps1 \
         .screenrc .signature .viper .zshrc

SCRIPTS=bin/ip bin/dr bin/nw-to-md bin/randomize-mac-address \
        bin/sendcfg bin/ssid bin/mimedown bin/installcfg.ps1 \
        bin/recvcfg.ps1 bin/recvcfg

TEMPLATES=templates/template.atom templates/template.css \
          templates/template.html templates/template.js \
          templates/template.plist templates/template.py \
          templates/template.tex

ELISP=elisp/hober2-theme.el elisp/Makefile elisp/subdirs.el

LISPCONFIG=.sbclrc init.lisp openmcl-init.lisp

SSHAUTHKEYS=.ssh/authorized_keys .ssh/authorized_keys2
SSHCONFIG=.ssh/config

SVNCONFIG=.subversion/config

W3MCONFIG=.w3m/config

DIRS=.ssh .subversion .w3m bin code elisp local \
     templates

# we don't extract these by default.
OTHER=abbrev-definitions freeciv.serv

SOURCE=hobercfg.nw

HOBERCFG=$(DOTFILES) $(SCRIPTS) $(TEMPLATES) $(ELISP) \
         $(SSHCONFIG) $(SSHAUTHKEYS) $(SVNCONFIG) \
         $(W3MCONFIG) .abbrev_defs code/Makefile

Makefile⟫=

usage:
        @echo "USAGE: gmake [config|html|tarball|clean|<filename>]"

html: index.html

index.html: hobercfg.html
        cp hobercfg.html index.html

Makefile⟫=

Library/Preferences/Emacs.plist:
        notangle -t8 -REmacs.plist $(SOURCE) > $@

Makefile⟫=

code/Makefile: code $(SOURCE)
        notangle -t8 -R$@ $(SOURCE) > $@

Makefile⟫=

wc:
        wc -l $(DOTFILES) $(SCRIPTS) $(TEMPLATES) $(ELISP)
        wc -l $(SOURCE)

Makefile⟫=

dist tarball: hobercfg.tar.gz
extract: hobercfg.tar
        tar xvf hobercfg.tar
hobercfg.tar: hobercfg.tar.gz
        gzip -d hobercfg.tar.gz

Makefile⟫=

config: Makefile $(HOBERCFG)

Makefile⟫=

clean:
        rm -f hobercfg.aux hobercfg.core hobercfg.ilg hobercfg.ind \
                hobercfg.idx hobercfg.log hobercfg.out hobercfg.toc \
                hobercfg.md hobercfg.nw~

Makefile⟫=

distclean: clean
        rm -f $(DOTFILES) $(SCRIPTS) $(TEMPLATES)
        rmdir bin templates

Makefile⟫=

copy: $(DOTFILES)
        cp $(DOTFILES) "$(TODIR)"

Makefile⟫=

hobercfg.tar.gz: $(HOBERCFG)
        tar czvf $@ $(HOBERCFG)

Makefile⟫=

.abbrev_defs: abbrev-definitions
        mv abbrev-definitions $@

Makefile⟫=

Makefile $(DOTFILES) $(OTHER) : $(SOURCE)
        notangle -t8 -R$@ $(SOURCE) > $@
        @if [ "x$@" = "x.xsession" ]; then \
                chmod +x $@; \
        fi

Makefile⟫=

$(DIRS):
        mkdir -p $@

Makefile⟫=

$(SCRIPTS): bin $(SOURCE)
        notangle -t8 -R$@ $(SOURCE) > $@
        chmod +x $@

Makefile⟫=

$(TEMPLATES): templates $(SOURCE)
        notangle -t8 -R$@ $(SOURCE) > $@

Makefile⟫=

$(ELISP): elisp $(SOURCE)
        notangle -t8 -R$@ $(SOURCE) > $@

Makefile⟫=

$(SSHAUTHKEYS): .ssh $(SOURCE)
        notangle -t8 -R.ssh/public-keys $(SOURCE) > $@
$(SSHCONFIG): .ssh $(SOURCE)
        notangle -t8 -R$@ $(SOURCE) > $@
        chmod 700 .ssh

Makefile⟫=

$(SVNCONFIG): .subversion $(SOURCE)
        notangle -t8 -R$@ $(SOURCE) > $@

Makefile⟫=

$(W3MCONFIG): .w3m $(SOURCE)
        notangle -t8 -R$@ $(SOURCE) > $@

Makefile⟫=

$(LISPCONFIG): .lisprc $(SOURCE)
        ln -s .lisprc $@

Makefile⟫=

%.md: %.nw
        noweave -n -backend bin/nw-to-md $< > $@
%.html: %.md
        notangle -t8 -Rpreamble $(SOURCE) > $@
        doctoc --maxlevel 6 $<
        marked --gfm --smart-lists -i $< >> $@
        notangle -t8 -Rpostamble $(SOURCE) >> $@

Makefile⟫=

.SUFFIXES : .nw .html .md

Distributing my dotfiles to different machines

bin/sendcfg⟫=

#!/bin/sh

TARBALL=hobercfg.tar.gz

cd
make $TARBALL
for target in "$@"; do
    scp $TARBALL ${target}: && ssh $target tar xzvf $TARBALL
done

bin/recvcfg⟫=

#!/bin/sh

TARBALL=hobercfg.tar.gz

if [ "x$1" != "x" ]; then
    REMOTEHOST=$1
else
    REMOTEHOST=mallow
fi

cd
scp $REMOTEHOST:$TARBALL $TARBALL && tar xPzvf $TARBALL

bin/installcfg.ps1⟫=

#!/usr/bin/env powershell

cd $Home

# Remove my SSH config until I figure out how to fix it on Windows
if (Test-Path -Path .ssh\config -PathType Leaf) {
    Remove-Item .ssh\config
}

# Make sure my .emacs file ends up where Emacs expects it to be
$emacs_d = "AppData\Roaming\.emacs.d"
if (!(Test-Path -Path $emacs_d -PathType Container)) {
    New-Item -Path $emacs_d -ItemType Directory
}
Move-Item -Path $HOME\.emacs -Destination $emacs_d\init.el -Force

# Install my PowerShell config file
if (!(Test-Path -Path $Home\Documents\WindowsPowerShell -PathType Container)) {
    New-Item -Path $Home\Documents\WindowsPowerShell -ItemType Directory
}
Move-Item $Home\.profile.ps1 -Destination $PROFILE -Force

bin/recvcfg.ps1⟫=

#!/usr/bin/env powershell

param (
    [string]$remotehost="tess@mallow.cfhp.org"
)

$tarball="hobercfg.tar.gz"

cd $HOME
scp ${remotehost}:${tarball} ${tarball}
tar xPzvf ${tarball}

bin\installcfg.ps1

Custom markdown backend for Noweb

bin/nw-to-md⟫=

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
import re, sys

class ToMarkdown:
    def __init__(self):
        self.prefixes = []
    def run(self, infile=sys.stdin, outfile=sys.stdout):
        [self.process_line(line, outfile) for line in infile]
    def process_line(self, line, outfile):
        if False:
            pass
        # Structural keywords <xmp>
        elif line.startswith("@quote"):
            self.prefixes.append("> ")
            # print(''.join(self.prefixes), file=outfile)
        elif line.startswith("@endquote"):
            self.prefixes.pop()
            # print(''.join(self.prefixes), file=outfile)
        elif line.startswith("@begin"):
            pass
        elif line.startswith("@text"):
            keyword = line[6:-1]
            print("%s" % keyword, end='', file=outfile)
        elif line.startswith("@nl"):
            print("\n%s" % ''.join(self.prefixes), end='', file=outfile)
        elif line.startswith("@defn"):
            keyword = line[6:-1]
            print("\n⟪**%s**⟫=" % keyword, file=outfile)
            self.prefixes.append("    ")
        elif line.startswith("@end"):
            ignore, chunktype, chunknum = line.split()
            if chunktype == "code":
                self.prefixes.pop()
        elif line.startswith("@use"):
            keyword = line[5:-1]
            print("⟪%s⟫" % keyword, end='', file=outfile)
        # Tagging keywords
        elif line.startswith("@file"):
            pass
        elif line.startswith("@line"):
            pass
        elif line.startswith("@language"):
            pass
        elif line.startswith("@index"):
            pass
        elif line.startswith("@xref"):
            pass
        # Wrapper keywords
        elif line.startswith("@header"):
            pass
        elif line.startswith("@trailer"):
            pass
        # Error keyword
        elif line.startswith("@fatal"):
            pass
        # Lying, cheating, stealing keyword
        elif line.startswith("@literal"):
            pass

if __name__ == "__main__":
    ToMarkdown().run()

Markdown to HTML

preamble⟫=

<!doctype html>
<html lang=en>
<meta charset=utf-8>
<meta name="viewport" content="width=device-width">
<link rel=stylesheet href=/css/base.css>
<title>hobercfg</title>

postamble⟫=

<script>
let generated_ids = {};
function gfm_id(str) {
    var initial=str.toLowerCase().replace(/\s+/g, "-");
    initial = initial.replace(/,/g, "");

    var final=initial;
    var n=2;
    while (generated_ids[final]) {
        final = initial + "-" + n;
        n++;
    }
    generated_ids[final] = true;
    return final;
}

function format_defn(defn) {
    let parent = defn.parentElement;
    let anchor = document.createElement("a");
    let id = gfm_id(defn.wholeText);
    anchor.setAttribute("id", id);
    anchor.setAttribute("href", "#" + id);
    parent.replaceChild(anchor, defn);
    anchor.appendChild(defn);
}


function format_use(use) {
    let parent = use.parentElement;
    let anchor = document.createElement("a");
    let id = gfm_id(use.wholeText);
    anchor.setAttribute("href", "#" + id);
    parent.replaceChild(anchor, use);
    anchor.appendChild(use);
}

function linkify_header(el) {
    let id = gfm_id(el.textContent);
    el.setAttribute("id", id);
}

function linkify_headers() {
    document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(linkify_header);
}

function linkify_defns() {
    let walker = document.createTreeWalker(document.documentElement,
                                       NodeFilter.SHOW_TEXT,
                                       null);

    let STATE_DEFAULT = 0;
    var state = STATE_DEFAULT;

    let STATE_DEFN = 1;
    var defn = null;

    let STATE_ERROR = 9;

    while (walker.nextNode()) {
        switch(state) {
          case STATE_DEFN:
            if (walker.currentNode.wholeText == "⟫=") {
                format_defn(defn);
                defn = null;
                state = STATE_DEFAULT;
            } else if (walker.currentNode.wholeText == "⟫") {
                format_use(defn);
                defn = null;
                state = STATE_DEFAULT;
            } else {
                defn = walker.currentNode;
            }
            break;
          case STATE_DEFAULT:
            if (walker.currentNode.wholeText == "⟪") {
                state = STATE_DEFN;
            }
            break;
          case STATE_ERROR:
            break;
        }
    }
}

document.addEventListener("DOMContentLoaded", function() {
    linkify_headers();
    linkify_defns();
});
</script>

Back matter

Elisp Copyright Statement⟫=

;; ⟪Copyright⟫

;; Author: Theresa O'Connor <tess@oconnor.cx>
;; Keywords: local

;; This is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free
;; Software Foundation; either version 2, or (at your option) any later
;; version.

;; This file is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with Emacs; see the file COPYING, or type `C-h C-c'. If not,
;; see <https://www.gnu.org/licenses/>.

Emacs local variables for hobercfg.nw

Emacs local variables⟫=