From 317f0d9fc8eb33bd8d1443bd7c0926f3376b9ce8 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 16 Mar 2017 16:30:01 +0100 Subject: Gems: Install to .local/bin alongside other package managers --- gemrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gemrc b/gemrc index aaa70a9..ab4f784 100644 --- a/gemrc +++ b/gemrc @@ -1 +1 @@ -gem: --user-install -n~/bin \ No newline at end of file +gem: --user-install -n~/.local/bin \ No newline at end of file -- cgit 1.4.1 From e8d81ffd8e87977317d8120e0735e44b550fa302 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 16 Mar 2017 16:30:30 +0100 Subject: zsh: Remove autoenv --- tag-zsh/config/zsh/zshrc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tag-zsh/config/zsh/zshrc b/tag-zsh/config/zsh/zshrc index fb9a36a..4b86717 100644 --- a/tag-zsh/config/zsh/zshrc +++ b/tag-zsh/config/zsh/zshrc @@ -2,7 +2,6 @@ source $ZPLUG_HOME/init.zsh zplug "zsh-users/zsh-completions", depth:1, defer:0 -zplug "Tarrasch/zsh-autoenv", as:plugin zplug "junegunn/fzf-bin", from:gh-r, as:command, rename-to:fzf zplug "junegunn/fzf", as:plugin, use:"shell/*.zsh", defer:2 zplug "junegunn/fzf", as:command, use:"bin/*" @@ -134,13 +133,6 @@ then eval $(ssh-agent) fi -if zplug check Tarrasch/zsh-autoenv -then - AUTOENV_FILE_ENTER=.envrc - AUTOENV_HANDLE_LEAVE=1 - AUTOENV_LOOK_UPWARDS=1 -fi - # Then, source plugins and add commands to $PATH zplug load -- cgit 1.4.1 From 5c124af7c747b6eec279109bd61950c58514e6a5 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 16 Mar 2017 16:30:40 +0100 Subject: zsh: Unset auto_cd --- tag-zsh/config/zsh/zshrc | 1 - 1 file changed, 1 deletion(-) diff --git a/tag-zsh/config/zsh/zshrc b/tag-zsh/config/zsh/zshrc index 4b86717..f2102b3 100644 --- a/tag-zsh/config/zsh/zshrc +++ b/tag-zsh/config/zsh/zshrc @@ -137,7 +137,6 @@ fi zplug load # General configuration -setopt auto_cd # Change directories without `cd` if [[ -n $commands[hub] ]] then -- cgit 1.4.1 From db6903e6fab9cff359a530ca2eee6ba3c7e44525 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 16 Mar 2017 16:32:58 +0100 Subject: Emacs: Install projectile-ripgrep correctly It used to be bundled with ripgrep.el, now it seems to be separate --- tag-emacs/emacs.d/init.org | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index 82e1755..151efbf 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -446,8 +446,9 @@ Step over Silver Search, here comes a new challenger. :if (executable-find "rg")) (use-package projectile-ripgrep - :bind (("C-c p s r" . projectile-ripgrep)) - :ensure nil) + :after (ripgrep projectile) + :if (executable-find "rg") + :bind (("C-c p s r" . projectile-ripgrep))) #+END_SRC ** Projectile -- cgit 1.4.1 From 397ce671bb028802d528faf8811101e08557e527 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 17 Mar 2017 09:48:24 +0100 Subject: Re-structure tags to GNU stow format --- atop/.atoprc | 2 + clojure/.lein/profiles.clj | 11 + dwm/dwm/config.h | 106 ++ emacs/.emacs.d/init.org | 2522 +++++++++++++++++++++++++ fish/.config/fish/config.fish | 2 + git/.config/git/config | 34 + git/.config/git/gitk | 61 + git/.config/git/ignore | 29 + global/.globalrc | 6 + hg/.hgrc | 9 + karabiner/.config/karabiner/karabiner.json | 63 + minttyrc/minttyrc | 33 + rcrc | 3 - ssh/.ssh/rc | 5 + tag-atop/atoprc | 2 - tag-clojure/lein/profiles.clj | 11 - tag-dwm/dwm/config.h | 106 -- tag-emacs/emacs.d/init.org | 2522 ------------------------- tag-fish/config/fish/config.fish | 2 - tag-git/config/git/config | 34 - tag-git/config/git/gitk | 61 - tag-git/config/git/ignore | 29 - tag-global/globalrc | 6 - tag-hg/hgrc | 9 - tag-karabiner/config/karabiner/karabiner.json | 63 - tag-minttyrc/minttyrc | 33 - tag-ssh/ssh/rc | 5 - tag-tmux/tmux.conf | 19 - tag-vagrant/vagrant.d/Vagrantfile | 7 - tag-vagrant/vagrant.d/ansible/centos.yml | 31 - tag-vagrant/vagrant.d/ansible/debian.yml | 15 - tag-vagrant/vagrant.d/ansible/site.yml | 32 - tag-xbindkeys/xbindkeysrc.scm | 57 - tag-xmobar/xmobarrc | 40 - tag-xmonad/xmonad/xmonad.hs | 92 - tag-xprofile/xprofile | 9 - tag-xresources/xresources/main | 13 - tag-xresources/xresources/solarized-light | 70 - tag-zsh/config/zsh/zshenv | 43 - tag-zsh/config/zsh/zshrc | 241 --- tag-zsh/zshenv | 3 - tmux/.tmux.conf | 19 + vagrant/.vagrant.d/Vagrantfile | 7 + vagrant/.vagrant.d/ansible/centos.yml | 31 + vagrant/.vagrant.d/ansible/debian.yml | 15 + vagrant/.vagrant.d/ansible/site.yml | 32 + xbindkeys/xbindkeysrc.scm | 57 + xmobar/.xmobarrc | 40 + xmonad/xmonad/xmonad.hs | 92 + xprofile/.xprofile | 9 + xresources/.xresources/main | 13 + xresources/.xresources/solarized-light | 70 + zsh/.config/zsh/.zshenv | 43 + zsh/.config/zsh/.zshrc | 241 +++ zsh/.zshenv | 3 + 55 files changed, 3555 insertions(+), 3558 deletions(-) create mode 100644 atop/.atoprc create mode 100644 clojure/.lein/profiles.clj create mode 100644 dwm/dwm/config.h create mode 100644 emacs/.emacs.d/init.org create mode 100755 fish/.config/fish/config.fish create mode 100644 git/.config/git/config create mode 100644 git/.config/git/gitk create mode 100644 git/.config/git/ignore create mode 100644 global/.globalrc create mode 100644 hg/.hgrc create mode 100644 karabiner/.config/karabiner/karabiner.json create mode 100644 minttyrc/minttyrc delete mode 100644 rcrc create mode 100755 ssh/.ssh/rc delete mode 100644 tag-atop/atoprc delete mode 100644 tag-clojure/lein/profiles.clj delete mode 100644 tag-dwm/dwm/config.h delete mode 100644 tag-emacs/emacs.d/init.org delete mode 100755 tag-fish/config/fish/config.fish delete mode 100644 tag-git/config/git/config delete mode 100644 tag-git/config/git/gitk delete mode 100644 tag-git/config/git/ignore delete mode 100644 tag-global/globalrc delete mode 100644 tag-hg/hgrc delete mode 100644 tag-karabiner/config/karabiner/karabiner.json delete mode 100644 tag-minttyrc/minttyrc delete mode 100755 tag-ssh/ssh/rc delete mode 100644 tag-tmux/tmux.conf delete mode 100644 tag-vagrant/vagrant.d/Vagrantfile delete mode 100644 tag-vagrant/vagrant.d/ansible/centos.yml delete mode 100644 tag-vagrant/vagrant.d/ansible/debian.yml delete mode 100644 tag-vagrant/vagrant.d/ansible/site.yml delete mode 100644 tag-xbindkeys/xbindkeysrc.scm delete mode 100644 tag-xmobar/xmobarrc delete mode 100644 tag-xmonad/xmonad/xmonad.hs delete mode 100755 tag-xprofile/xprofile delete mode 100644 tag-xresources/xresources/main delete mode 100644 tag-xresources/xresources/solarized-light delete mode 100644 tag-zsh/config/zsh/zshenv delete mode 100644 tag-zsh/config/zsh/zshrc delete mode 100644 tag-zsh/zshenv create mode 100644 tmux/.tmux.conf create mode 100644 vagrant/.vagrant.d/Vagrantfile create mode 100644 vagrant/.vagrant.d/ansible/centos.yml create mode 100644 vagrant/.vagrant.d/ansible/debian.yml create mode 100644 vagrant/.vagrant.d/ansible/site.yml create mode 100644 xbindkeys/xbindkeysrc.scm create mode 100644 xmobar/.xmobarrc create mode 100644 xmonad/xmonad/xmonad.hs create mode 100755 xprofile/.xprofile create mode 100644 xresources/.xresources/main create mode 100644 xresources/.xresources/solarized-light create mode 100644 zsh/.config/zsh/.zshenv create mode 100644 zsh/.config/zsh/.zshrc create mode 100644 zsh/.zshenv diff --git a/atop/.atoprc b/atop/.atoprc new file mode 100644 index 0000000..d03319e --- /dev/null +++ b/atop/.atoprc @@ -0,0 +1,2 @@ +flags Aa +maxlinecpu 0 \ No newline at end of file diff --git a/clojure/.lein/profiles.clj b/clojure/.lein/profiles.clj new file mode 100644 index 0000000..99c0de2 --- /dev/null +++ b/clojure/.lein/profiles.clj @@ -0,0 +1,11 @@ +{:user {:plugins [[org.clojure/tools.namespace "0.2.10"] + [lein-autoexpect "1.6.0"] + [lein-ancient "0.6.7"] + [lein-droid "0.4.0-alpha4"]] + :dependencies [[org.clojure/tools.trace "0.7.8"]] + :repl-options {:init + (do + (require '[clojure.java.javadoc :refer [javadoc]]) + (clojure.java.javadoc/add-local-javadoc + "/usr/share/doc/java8-openjdk/api/"))}} + :repl {:plugins [cider/cider-nrepl "0.9.1"]}} diff --git a/dwm/dwm/config.h b/dwm/dwm/config.h new file mode 100644 index 0000000..ae1d8bb --- /dev/null +++ b/dwm/dwm/config.h @@ -0,0 +1,106 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const char font[] = "-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*"; +static const char normbordercolor[] = "#657b83"; +static const char normbgcolor[] = "#002b36"; +static const char normfgcolor[] = "#fdf6e3"; +static const char selbordercolor[] = "#859900"; +static const char selbgcolor[] = "#586e75"; +static const char selfgcolor[] = "#fdf6e3"; +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ +static const Bool showbar = True; /* False means no bar */ +static const Bool topbar = True; /* False means bottom bar */ + +/* tagging */ +static const char *tags[] = { "shell", "code", "web", "misc" }; + +static const Rule rules[] = { + /* class instance title tags mask isfloating monitor */ + { "Firefox", NULL, NULL, 1 << 2, False, -1 }, + { "URxvt", NULL, NULL, 1 << 0, False, -1 }, + { "Emacs", "emacs", NULL, 1 << 1, False, -1 }, + { "KeePass2", NULL, NULL, 1 << 3, False, -1 }, + { "deadbeef", NULL, NULL, 1 << 3, False, -1 }, + { "Emacs", "Ediff", NULL, 0, True, -1 }, +}; + +/* layout(s) */ +static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const int nmaster = 1; /* number of clients in master area */ +static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ + +static const Layout layouts[] = { + /* symbol arrange function */ + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, +}; + +/* key definitions */ +#define MODKEY Mod4Mask +#define TAGKEYS(KEY,TAG) \ + { MODKEY, KEY, toggleview, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask, KEY, view, {.ui = 1 << TAG} }, \ + { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, + +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + +/* commands */ +static const char *termcmd[] = { "urxvt", NULL }; + +static Key keys[] = { + /* modifier key function argument */ + { MODKEY|ShiftMask, XK_b, togglebar, {0} }, + { MODKEY, XK_e, focusstack, {.i = +1 } }, + { MODKEY, XK_i, focusstack, {.i = -1 } }, + { MODKEY, XK_s, incnmaster, {.i = +1 } }, + { MODKEY, XK_r, incnmaster, {.i = -1 } }, + { MODKEY, XK_n, setmfact, {.f = -0.05} }, + { MODKEY, XK_o, setmfact, {.f = +0.05} }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, + { MODKEY, XK_g, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_q, quit, {0} }, + { MODKEY|ShiftMask, XK_r, quit, { .i = 5 } }, +}; + +/* button definitions */ +/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +static Button buttons[] = { + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + { ClkTagBar, 0, Button1, toggleview, {0} }, + { ClkTagBar, 0, Button3, view, {0} }, + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, +}; diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org new file mode 100644 index 0000000..151efbf --- /dev/null +++ b/emacs/.emacs.d/init.org @@ -0,0 +1,2522 @@ +#+TITLE: Emacs Configuration for Alan Pearce +#+OPTIONS: ^:nil +#+PROPERTY: results silent +#+PROPERTY: eval no-export +#+PROPERTY: header-args :comments link +* Introduction +This is a living document, detailing my Emacs configuration using org-mode +* Basics +** Startup +Open Emacs with just a plain window. No graphics or messages, please! +#+BEGIN_SRC emacs-lisp +(put 'inhibit-startup-echo-area-message 'saved-value + (setq inhibit-startup-echo-area-message (user-login-name))) +(setq inhibit-startup-screen t) +(setq gc-cons-threshold 100000000) +(defvar file-name-handler-alist-backup file-name-handler-alist) +(setq file-name-handler-alist nil) +(remove-hook 'find-file-hooks #'vc-refresh-state) +#+END_SRC + +** Scratch buffers +I usually use scratch buffers for any sort of text. If I need a +programming mode in one, then I’ll just call it manually. I also like +the buffer to be empty. +#+BEGIN_SRC emacs-lisp +(setq initial-scratch-message "" + initial-major-mode 'text-mode) +#+END_SRC + +** Personal Information +#+BEGIN_SRC emacs-lisp +(setq user-mail-address "alan@alanpearce.co.uk" + user-full-name "Alan Pearce") +#+end_src + +* Packaging + +** Use-package + +#+BEGIN_SRC emacs-lisp +(eval-and-compile + (setq tls-checktrust t + gnutls-verify-error t + package-archives '(("gnu" . "https://elpa.gnu.org/packages/") + ("melpa-stable" . "https://stable.melpa.org/packages/") + ("melpa" . "https://melpa.org/packages/")) + package-user-dir (concat "~/.emacs.d/packages/" emacs-version "/elpa") + package-pinned-packages '(("use-package" . melpa-stable) + ("diminish" . melpa-stable) + ("bind-key" . melpa-stable)) + package-archive-priorities '(("melpa-stable" . 10) + ("gnu" . 10) + ("marmalade" . 5) + ("melpa" . 0)) + package-menu-async t + package-menu-hide-low-priority t) + (package-initialize) + (unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package))) +(eval-when-compile (require 'use-package)) +(unless (featurep 'use-package) + (require 'diminish) + (require 'bind-key) + (use-package use-package + :commands (use-package-autoload-keymap) + :defer 5)) +(setq use-package-verbose t + use-package-always-ensure t + package-enable-at-startup nil) +#+END_SRC + +* Customize +I don’t really like using customize for normal configuration. +Instead, I use it for things that get saved automatically. That’s why +I use a different file, which is ignored by the VCS. It also means +that it’s not important whether the file exists or not, which is why I +pass =:noerror= to =load= + +#+BEGIN_SRC emacs-lisp +(setq custom-file "~/.emacs.d/custom.el") +(load custom-file :noerror :nomessage) +#+END_SRC + +* Styles + +I prefer an always-visible cursor. Feels less distracting. +#+BEGIN_SRC emacs-lisp +(when (fboundp #'blink-cursor-mode) + (blink-cursor-mode -1)) +#+END_SRC + +Disable all the bars, unless on OSX, in which case, keep the menu bar. + +#+BEGIN_SRC emacs-lisp +(when (and menu-bar-mode (not (eq window-system 'ns))) + (menu-bar-mode -1)) +(with-eval-after-load 'scroll-bar + (set-scroll-bar-mode nil)) +(with-eval-after-load 'tooltip + (tooltip-mode -1)) +(with-eval-after-load 'tool-bar + (tool-bar-mode -1)) +#+END_SRC + +Ring the bell sometimes, but not so often +#+BEGIN_SRC emacs-lisp +(setq ring-bell-function + (lambda () + (unless (memq this-command + '(isearch-abort abort-recursive-edit exit-minibuffer keyboard-quit undo-tree-undo)) + (ding)))) +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(use-package dash) +#+END_SRC + +** Colours + +Let’s try a more minimal theme. + +#+BEGIN_SRC emacs-lisp +(use-package minimal-theme + :disabled t + :config (progn + (load-theme 'minimal-light t))) +#+END_SRC + +Let’s try a basic theme. + +#+BEGIN_SRC emacs-lisp +(use-package basic-theme + :if (display-graphic-p) + :config (progn + (load-theme 'basic t) + + (set-face-background 'mode-line "#a1b56c") + (set-face-background 'border "#a1b56c") + (set-face-foreground 'border "#a1b56c") + (set-face-background 'vertical-border "#a1b56c") + (set-face-foreground 'vertical-border "#a1b56c") + (set-face-background 'window-divider "#a1b56c") + (set-face-foreground 'window-divider "#a1b56c") + + (defvar mode-line-default-format mode-line-format) + (defvar mode-line-default-hidden nil + "Whether to hide the mode line by default") + + (defun show-mode-line () + (interactive) + (setq mode-line-format mode-line-default-format) + (when (called-interactively-p 'interactive) + (setq-default mode-line-format mode-line-default-format) + (setq mode-line-default-hidden nil))) + (defun hide-mode-line () + (interactive) + (setq mode-line-format nil) + (when (called-interactively-p 'interactive) + (setq-default mode-line-format nil) + (setq mode-line-default-hidden t))) + + (setq-default cursor-type '(bar . 1)) + (setq-default cursor-in-non-selected-windows nil) + + (defun hide-clutter () + (interactive) + (fringe-mode '(0 . 4)) + (hide-mode-line)) + + (defun show-clutter () + (interactive) + (fringe-mode '(8 . 4)) + (show-mode-line)) + (hide-clutter) + + (when mode-line-default-hidden + (call-interactively #'hide-mode-line)) + + (defun hide-mode-line-if-default-hidden () + (if mode-line-default-hidden + (hide-mode-line) + (show-mode-line))) + + (add-to-list 'default-frame-alist '(border-width . 0)) + (add-to-list 'default-frame-alist '(internal-border-width . 0)) + (when (eq window-system 'x) + (setq window-divider-default-bottom-width 1 + window-divider-default-right-width 1 + window-divider-default-places t) + (setq mode-line-default-hidden t) + (window-divider-mode +1)) + + (add-hook 'after-change-major-mode-hook #'hide-mode-line-if-default-hidden) + + (add-hook 'minibuffer-setup-hook #'show-mode-line) + (add-hook 'minibuffer-exit-hook #'hide-mode-line))) +#+END_SRC + +Highlighting quasi-quoted expressions in lisps is quite useful, but I +don't need it all the time. I'll keep it around for a while so that I +can enable it if needed. +#+BEGIN_SRC emacs-lisp +(use-package highlight-stages + :diminish highlight-stages-mode) +#+END_SRC + +** Fonts + +When possible, set up fonts. I don’t have any settings here for X11, +because I manage those in my [[file:~/projects/dotfiles/tag-xresources/xresources/main][XResources file]]. +#+BEGIN_SRC emacs-lisp +(when (or (display-graphic-p) + (daemonp)) + + (defun use-variable-fonts () + (interactive) + (variable-pitch-mode) + (setq cursor-type 'bar)) + + (defun ap/set-fonts (mono-face mono-font-size variable-face variable-font-size antialias) + (if (boundp 'ns-antialias-text) + (setq ns-antialias-text antialias)) + (when mono-face + (let ((default-font (font-spec :family mono-face :size mono-font-size))) + (add-to-list 'default-frame-alist `(font . ,(format "%s %s" mono-face mono-font-size))) + (set-face-font 'fixed-pitch default-font) + (set-frame-font default-font t t))) + (when variable-face + (set-face-font 'variable-pitch (font-spec :name variable-face :size variable-font-size)))) + + (defun ap/set-fonts-according-to-system () + (interactive) + (cond + ((eq window-system 'w32) + (ap/set-fonts "Liberation Mono" 11 "Segoe UI" 11 t)) + ((eq window-system 'ns) + (let ((displays (string-to-number (shell-command-to-string "system_profiler SPDisplaysDataType | grep \"Online: Yes\" | wc -l")))) + (if (eq displays 1) + (ap/set-fonts "Roboto Mono" 13 "Lucida Grande" 13 t) + (ap/set-fonts "Monaco" 10 "Lucida Grande" 12 nil)))) + ((eq window-system 'x) + (set-fontset-font "fontset-default" 'unicode (font-spec :name "Terminus" :size 8)) + (ap/set-fonts "Fixed" 8 "Lucida" 8 nil)))) + + (ap/set-fonts-according-to-system)) +#+END_SRC + +Reduce font decoration. I’m trying to see whether this helps me focus +on the right things. +#+BEGIN_SRC emacs-lisp +(setq font-lock-maximum-decoration '((dired-mode . 1) + (t . 1))) +#+END_SRC + +** Page Breaks + +By default, Emacs displays page breaks as ^L. Lines look much nicer. +On Windows, Emacs incorrectly detects that U+2500 (Box Drawings Light +Horizontal) can only be displayed with a different font, which is not +correct, at least for Liberation Mono. + +#+BEGIN_SRC emacs-lisp +(use-package page-break-lines + :defer 5 + :diminish page-break-lines-mode + :config (progn + (global-page-break-lines-mode) + (unless (eq (char-displayable-p ?─) (char-displayable-p ?a)) + (set-fontset-font "fontset-default" + (cons page-break-lines-char page-break-lines-char) + (face-attribute 'default :family))))) +#+END_SRC +** Modeline + +#+BEGIN_SRC emacs-lisp +(column-number-mode t) +(size-indication-mode t) + +(setq frame-title-format '("%f" (dired-directory dired-directory))) +#+END_SRC + +** Highlight Changes + +Highlight what just changed when I undo, yank, and so on. + +#+BEGIN_SRC emacs-lisp +(use-package volatile-highlights + :diminish volatile-highlights-mode + :config (progn + (volatile-highlights-mode t))) +#+END_SRC + +** Beacon + +I was against the idea of having flashy animations inside Emacs, but +this one is useful. It highlights the cursor when scrolling or +switching windows. + +#+BEGIN_SRC emacs-lisp +(use-package beacon + :diminish beacon-mode + :config (beacon-mode +1)) +#+END_SRC + +** Renaming major modes + +Diminishing major modes does not happen in the same manner as minor +modes. + +#+BEGIN_SRC emacs-lisp +(use-package cyphejor + :defer 2 + :config (progn + (setq cyphejor-rules `(("emacs" "ε") + ("diff" "Δ") + ("js2" "js") + ("magit-status" ,(char-to-string (-find #'char-displayable-p '(11942 5848 177)))) + ("inferior" "i" :prefix) + ("interaction" "i" :prefix) + ("interactive" "i" :prefix) + ("menu" "▤" :postfix) + ("ledger" "Ledger") + ("mode" "") + ("shell" "sh" :postfix))) + (cyphejor-mode 1))) +#+END_SRC + + +* Environment Variables + +MacOS doesn’t have a reasonable way to set environment variables and +read them automatically any more. So, let’s use the +[[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]] package to set up ~exec-path~ and similar +variables from whatever my shell configuration is. + +#+BEGIN_SRC emacs-lisp +(use-package exec-path-from-shell + :if (eq system-type 'darwin) + :config (exec-path-from-shell-initialize)) +#+END_SRC + +* Keybindings + +I think =set-keyboard-coding-system= stops OS X from doing something +annoying to add accents. The modifier setup is to match my +re-arrangement of modifiers on OSX: Cmd on the outside, then +Option/alt, then Control. + +#+BEGIN_SRC emacs-lisp +(when (eq system-type 'darwin) + (set-keyboard-coding-system nil) + (custom-set-variables + '(mac-option-modifier 'meta) + '(mac-right-option-modifier 'none) + '(mac-control-modifier 'control) + '(mac-right-control-modifier 'left) + '(mac-command-modifier 'super) + '(mac-right-command-modifier 'left) + '(mac-function-modifier 'hyper)) + (unbind-key "s-x")) +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(unbind-key "") +(bind-key* "" #'compile) +(bind-key* "" #'kmacro-start-macro-or-insert-counter) +(bind-key* "" #'kmacro-end-or-call-macro) + +(bind-key* "" #'execute-extended-command) + +(unbind-key "C-z") +(bind-key* "C-" #'other-window) + +(bind-key* "C-x C-r" #'revert-buffer) +(bind-key* "C-x C-j" #'delete-indentation) +(unbind-key "C-x C-c") + +(bind-key* "C-c i" #'insert-char) +(bind-key* "M-/" #'hippie-expand) + +(unbind-key "s-h") +(unbind-key "s-n") +(unbind-key "s-p") +(unbind-key "s-w") +(bind-key* "s-k" #'kill-or-delete-this-buffer-dwim) + +(bind-key "C-M-a" #'backward-paragraph text-mode-map) +(bind-key "C-M-e" #'forward-paragraph text-mode-map) + +(bind-key* "s-x" (define-prefix-command 'super-x-map)) +(bind-key* "s-," #'switch-to-dotfiles) +(bind-key* "C-M-x" #'execute-extended-command) +(set-register ?z `(file . ,(expand-file-name ".config/zsh/zshrc" "~"))) +#+END_SRC + +** Crux + +I can replace most of the simple helper/wrapper functions in my +configuration with crux.el + +#+BEGIN_SRC emacs-lisp +(use-package crux + :bind (("M-o" . crux-smart-open-line-above) + ("C-o" . crux-smart-open-line) + + ("C-x 4 t" . crux-transpose-windows) + ("C-c e" . crux-eval-and-replace) + ("C-c D" . crux-delete-file-and-buffer) + ("C-c R" . crux-rename-file-and-buffer)) + :init (progn + (defalias 'delete-current-buffer-file #'crux-delete-file-and-buffer) + (defalias 'rename-current-buffer-file #'crux-rename-file-and-buffer))) +#+END_SRC + +* Projects + +#+BEGIN_SRC emacs-lisp +(defvar work-project-directory "~/work") +(defvar home-project-directory "~/projects") +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(defun switch-to-dotfiles () + (interactive) + (projectile-switch-project-by-name (expand-file-name "dotfiles" home-project-directory))) +#+END_SRC + +** The Silver Searcher + +#+BEGIN_SRC emacs-lisp +(use-package ag + :defer 30 + :config (setq ag-project-root-function #'projectile-project-root)) + +(use-package wgrep-ag + :after ag) +#+END_SRC + +** Ripgrep + +Step over Silver Search, here comes a new challenger. + +#+BEGIN_SRC emacs-lisp +(use-package ripgrep + :if (executable-find "rg")) + +(use-package projectile-ripgrep + :after (ripgrep projectile) + :if (executable-find "rg") + :bind (("C-c p s r" . projectile-ripgrep))) +#+END_SRC + +** Projectile + +Projectile is awesome for working in projects, especially VCS-backed +ones. I added a couple of functions to allow me to open new projects +based upon some folder conventions I use. + +#+BEGIN_SRC emacs-lisp +(use-package projectile + :bind (("s-p" . projectile-switch-project) + ("C-c C-f" . projectile-find-file) + ("s-x s-f" . projectile-find-file) + ("C-x g" . projectile-vc) + ("s-G" . projectile-vc)) + :demand t + :diminish projectile-mode + :config (progn + (projectile-global-mode) + (add-to-list 'projectile-globally-ignored-directories ".stversions") + (defun ap/subfolder-projects (dir) + (--map (file-relative-name it dir) + (-filter (lambda (subdir) + (--reduce-from (or acc (funcall it subdir)) nil + projectile-project-root-files-functions)) + (-filter #'file-directory-p (directory-files dir t "\\<"))))) + + (defun ap/open-subfolder-project (from-dir &optional arg) + (let ((project-dir (projectile-completing-read "Open project: " + (ap/subfolder-projects from-dir)))) + (projectile-switch-project-by-name (expand-file-name project-dir from-dir) arg))) + + (defun yarn-install (&optional arg) + (interactive "P") + (projectile-with-default-dir (projectile-project-root) + (cmd-to-echo "yarn" "install"))) + + (defun yarn-add-dev (package) + (interactive "spackage: ") + (projectile-with-default-dir (projectile-project-root) + (cmd-to-echo "yarn" (concat "add --dev " package)))) + + (defun yarn-add (package) + (interactive "spackage: ") + (projectile-with-default-dir (projectile-project-root) + (cmd-to-echo "yarn" (concat "add " package)))) + + (defun ap/open-work-project (&optional arg) + (interactive "P") + (ap/open-subfolder-project work-project-directory arg)) + + (defun ap/open-home-project (&optional arg) + (interactive "P") + (ap/open-subfolder-project home-project-directory arg)) + + (setq projectile-switch-project-action #'projectile-commander + projectile-completion-system 'ivy))) +#+END_SRC + +** vc + +This is nice for some things that magit doesn’t do, and for those rare +occasions that I’m working with something other than git. + +#+BEGIN_SRC emacs-lisp +(use-package vc + :defer t + :bind (("C-x v C" . vc-resolve-conflicts)) + :config (progn + (setq vc-follow-symlinks t) + (setq vc-ignore-dir-regexp (format "\\(%s\\)\\|\\(%s\\)" + vc-ignore-dir-regexp + tramp-file-name-regexp)))) +#+END_SRC + +** git-gutter-fringe + +It’s nice to be able to see at a glance which lines of a file have +changed. This package colours the fringe. I have it set to the right +fringe so it doesn’t interfere with flycheck. + +#+BEGIN_SRC emacs-lisp +(use-package git-gutter-fringe + :defer 2 + :diminish git-gutter-mode + :config (progn + (global-git-gutter-mode 1) + (set-face-foreground 'git-gutter:modified "grey") + (setq git-gutter-fr:side 'right-fringe))) +#+END_SRC + +** magit + +Magit is my favourite way to use git. I use selective staging all the +time. Make sure to set it up with a nice =completing-read-function= + +#+BEGIN_SRC emacs-lisp +(use-package magit + :defer 5 + :commands (magit-status) + :config (progn (setq magit-completing-read-function #'ivy-completing-read + magit-popup-use-prefix-argument 'default + magit-display-buffer-function #'magit-display-buffer-fullcolumn-most-v1 + global-magit-file-mode nil) + (add-to-list 'magit-no-confirm 'safe-with-wip)) + :init (add-hook 'magit-mode-hook #'magit-load-config-extensions)) +#+END_SRC + +** git-timemachine + +This package allow me to go through a file’s history with just a few +keys. It makes it very easy to figure what what exactly was in a file +in the past. I often find it useful when I remember writing something +a particular way, but it changed later. + +#+BEGIN_SRC emacs-lisp +(use-package git-timemachine + :commands git-timemachine) +#+END_SRC + +* Files + +** Auto-saving + +Auto-save everything to a temporary directory, instead of cluttering +the filesystem. I don’t want emacs-specific lockfiles, either. + +#+BEGIN_SRC emacs-lisp +(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)) + create-lockfiles nil) +#+END_SRC +** Backups + +I like to keep my backups out of regular folders. I tell emacs to use +a subfolder of its configuration directory for that. Also, use the +trash for deleting on OS X. +#+BEGIN_SRC emacs-lisp +(let ((backup-dir (expand-file-name "~/.emacs.d/backups/"))) + (unless (file-directory-p backup-dir) + (make-directory backup-dir)) + (setq backup-directory-alist `((".*" . ,backup-dir)) + backup-by-copying-when-linked t + backup-by-copying-when-mismatch t)) +(if (eq system-type 'darwin) + (setq delete-by-moving-to-trash t) + (if (and (executable-find "trash") (not (fboundp #'system-move-file-to-trash))) + (defun system-move-file-to-trash (file) + (call-process (executable-find "trash") + nil 0 nil + file)))) +#+END_SRC + +** autorevert + +#+BEGIN_SRC emacs-lisp +(use-package autorevert + :diminish auto-revert-mode + :init (progn + (global-auto-revert-mode 1) + (setq auto-revert-verbose nil + auto-revert-use-notify (not (eq system-type 'darwin))))) +#+END_SRC + +** Encoding + +UTF-8 is usually appropriate. Note that =prefer-coding-system= expects +only a coding system, not a coding system and line ending combination. + +#+BEGIN_SRC emacs-lisp +(prefer-coding-system 'utf-8) +(setq-default buffer-file-coding-system 'utf-8-auto-unix) +#+END_SRC + +** Buffer-file management + +Ask if I want to create a directory when it doesn’t exist. This is +especially nice when starting new projects. + +#+BEGIN_SRC emacs-lisp +(defun my-create-non-existent-directory () + (let ((parent-directory (file-name-directory buffer-file-name))) + (when (and (not (file-exists-p parent-directory)) + (y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory))) + (make-directory parent-directory t)))) +(add-to-list 'find-file-not-found-functions #'my-create-non-existent-directory) +#+END_SRC + +I often want to rename or delete the file that I’m currently visiting +with a buffer. + +#+BEGIN_SRC emacs-lisp +(defun kill-or-delete-this-buffer-dwim (&optional arg) + "Kills current buffer. With prefix arg, delete it." + (interactive "P") + (if (equal arg '(4)) + (delete-current-buffer-file) + (if server-buffer-clients + (server-edit) + (let ((buf (buffer-name))) + (when (equal buf "*HTTP Response*") + (other-window 1)) + (kill-buffer buf))))) +#+END_SRC + +** Whitespace Butler + +I don’t like it when editors change an entire file’s layout when I +open it. Whitespace butler fixes whitespace only for lines that I’m editing. + +#+BEGIN_SRC emacs-lisp +(use-package ws-butler + :if window-system + :diminish ws-butler-mode + :config (ws-butler-global-mode 1)) +(if (daemonp) + (add-hook 'before-make-frame-hook (lambda () + (use-package ws-butler + :config (ws-butler-global-mode 1))))) +#+END_SRC + +** shrink-whitespace + +DWIM whitespace removal. So I don’t need =M-SPC=, =M-\= and =C-x o= +for similar things any more. + +#+BEGIN_SRC emacs-lisp +(use-package shrink-whitespace + :bind ("M-SPC" . shrink-whitespace)) +#+END_SRC + +** Tramp + +Tramp is awesome. It makes SSH feel Unix-y. The proxy setup is so +that I can sudo on remote machines + +#+BEGIN_SRC emacs-lisp +(use-package tramp + :defer 7 + :config (progn + (unless (getenv "SSH_AUTH_SOCK") + (setenv "SSH_AUTH_SOCK" (format "/run/user/%s/ssh-agent" (user-uid)))) + (setq tramp-default-method "ssh" + tramp-default-user-alist '(("\\`su\\(do\\)?\\'" nil "root")) + tramp-backup-directory-alist backup-directory-alist + tramp-completion-reread-directory-timeout 60 + tramp-ssh-controlmaster-options nil + backup-enable-predicate (lambda (name) + (and (normal-backup-enable-predicate name) + (not (let ((method (file-remote-p name 'method))) + (when (stringp method) + (member method '("su" "sudo"))))))) + tramp-shell-prompt-pattern "\\(?:^\\| \\)[^]#$%>\n]*#?[]#$%>❯›] *\\(\\[\\??[0-9;]*[a-zA-Z] *\\)*") + (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" (concat "/" tramp-default-method ":%h:"))) + (add-to-list 'tramp-default-proxies-alist `(,(regexp-quote (system-name)) nil nil)) + (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)))) + +(use-package tramp-sh + :ensure nil + :defer t + :config (progn + (add-to-list 'tramp-remote-path "/usr/local/sbin") + (add-to-list 'tramp-remote-path "~/bin"))) +#+END_SRC + +** ediff + +I like a horizonal diff setup, with everything in one frame. + +#+BEGIN_SRC emacs-lisp +(use-package ediff + :defer t + :config (progn + (setq ediff-split-window-function 'split-window-horizontally + ediff-window-setup-function 'ediff-setup-windows-plain))) +#+END_SRC + +* Indentation + +Ah, a complicated topic. One day we’ll all be using elastic +tabstops. I’ve recently switched to using two spaces, since elastic +tabstops is probably never going to happen. + +#+BEGIN_SRC emacs-lisp +(setq-default tab-width 2 + indent-tabs-mode nil) +#+END_SRC + + +** smart-tabs-mode + +Not related to [[smart-tab][=smart-tab=]], this mode indents with tabs and aligns +with spaces. Perfect! + +#+BEGIN_SRC emacs-lisp +(use-package smart-tabs-mode + :defer 1 + :config (progn + (smart-tabs-insinuate 'c 'cperl 'python) + (add-hook 'php-mode-hook (lambda () + (smart-tabs-mode indent-tabs-mode))))) +#+END_SRC + +** editorconfig + +#+BEGIN_SRC emacs-lisp +(use-package editorconfig + :config (editorconfig-mode 1)) +#+END_SRC + +** dtrt-indent-mode + +Sometimes people use different indentation settings. [[https://github.com/jscheid/dtrt-indent][dtrt-indent]] +guesses the correct settings for me. + +#+BEGIN_SRC emacs-lisp +(use-package dtrt-indent + :config (progn + (defun ap/dtrt-adapt-if-needed () + (unless editorconfig-mode + (dtrt-indent-adapt))) + (if (fboundp #'editorconfig-mode) + (add-hook 'after-change-major-mode-hook #'ap/dtrt-adapt-if-needed) + (add-hook 'after-change-major-mode-hook #'dtrt-indent-adapt)) + (defadvice dtrt-indent-try-set-offset (after toggle-smart-tabs activate) + (smart-tabs-mode (or indent-tabs-mode -1))))) +#+END_SRC + +* Security + +** password-store + +This is a frontend to the GPG-powered =pass= program. +#+BEGIN_SRC emacs-lisp +(use-package password-store + :defer 15 + :config (progn + (setq password-store-password-length 16))) +#+END_SRC +* Buffers + +** Ibuffer +Ibuffer is quite nice for listing all buffers. + +#+BEGIN_SRC emacs-lisp +(use-package ibuffer + :bind (("C-x C-b" . ibuffer)) + :config (progn + (setq ibuffer-saved-filter-groups + (quote (("default" + ("org" (mode . org-mode)) + ("emacs" (mode . emacs-lisp-mode)) + ("zsh" (filename . "/zsh")) + ("server" (filename . "/su:root@server")))))) + + ;; Human-readable base-2 size column + (define-ibuffer-column size-h + (:name "Size" :inline t) + (cond + ((> (buffer-size) 1024) + (format "%7.2fK" (/ (buffer-size) 1024.0))) + ((> (buffer-size) 1048576) + (format "%7.2fM" (/ (buffer-size) 1048576.0))) + (t + (format "%8d" (buffer-size))))) + + (setq ibuffer-formats + '((mark modified read-only " " + (name 18 18 :left :elide) + " " + (size-h 9 -1 :right) + " " + (mode 16 16 :left :elide) + " " + filename-and-process))))) +#+END_SRC + +** Relative Buffer names + +#+BEGIN_SRC emacs-lisp +(use-package relative-buffers + :defer 15 + :config (progn + (global-relative-buffers-mode))) +#+END_SRC +** Narrowing + +Enable it without prompting + +#+BEGIN_SRC emacs-lisp +(put 'narrow-to-defun 'disabled nil) +(put 'narrow-to-page 'disabled nil) +(put 'narrow-to-region 'disabled nil) +#+END_SRC + +** ace-window + +I don’t often have many windows open at once, but when I do, +=ace-window= is really nice to jump around them in the same way that +=ace-jump= or =avy= work. +#+BEGIN_SRC emacs-lisp +(use-package ace-window + :bind (("s-s" . ace-window)) + :config (progn + (setq aw-dispatch-always t + aw-dispatch-alist '((?k aw-delete-window " Ace - Delete Window") + (?K aw-delete-window) + (?m aw-swap-window " Ace - Swap Window") + (?f aw-flip-window) + (?v aw-split-window-vert " Ace - Split Vert Window") + (?b aw-split-window-horz " Ace - Split Horz Window") + (?m delete-other-windows " Ace - Maximize Window") + (?l delete-other-windows) + (?, winner-undo) + (?. winner-redo)) + aw-keys '(?a ?r ?s ?t ?n ?e ?i ?o)))) +#+END_SRC + +* Windows + +Scrolling is tricky. I use this setup to help me keep track of the +point whilst I’m moving about. + +#+BEGIN_SRC emacs-lisp +(setq scroll-conservatively 100 + scroll-margin 1 + scroll-preserve-screen-position t + mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control))) + split-height-threshold 80 + split-width-threshold 160 + frame-resize-pixelwise nil) +(if (boundp 'ns-pop-up-frames) + (setq ns-pop-up-frames nil)) +#+END_SRC + +** winner + +Undo, for window-based commands. + +#+BEGIN_SRC emacs-lisp +(use-package winner + :config (setq winner-boring-buffers '("*Completions*" "*Help*" "*Apropos*" "*Buffer List*" "*info*" "*Compile-Log*")) + :init (progn + (winner-mode 1))) +#+END_SRC + +** windmove + +Directional window movement + +#+BEGIN_SRC emacs-lisp +(use-package windmove + :bind (("S-" . windmove-left) + ("S-" . windmove-right) + ("S-" . windmove-up) + ("S-" . windmove-down))) +#+END_SRC +* Completion + +Make built-in completion a bit more intelligent, by adding substring +and initial-based completion and ignoring case. + +#+BEGIN_SRC emacs-lisp +(setq completion-styles '(basic initials partial-completion substring) + completion-ignore-case t + tab-always-indent 'complete) +#+END_SRC + +** Company + +The main choices for automatic completion in Emacs are company and +auto-complete-mode. I’ve not tried auto-complete-mode as company +seems to work perfectly well for me. + +#+BEGIN_SRC emacs-lisp +(use-package company + :commands (company-mode) + :diminish "Cmpl" + :bind (("C-" . company-complete) + ("TAB" . company-indent-or-complete-common)) + :init (progn + (add-hook 'prog-mode-hook #'company-mode) + (setq company-backends '(company-bbdb company-web-html company-tern company-nxml company-css company-eclim company-semantic company-elisp + company-clang company-xcode company-cmake company-capf + company-files (company-gtags + company-etags company-keywords) company-oddmuse) + company-frontends '(company-pseudo-tooltip-unless-just-one-frontend + company-preview-frontend + company-echo-metadata-frontend) + company-idle-delay .3 + company-begin-commands '(self-insert-command) + company-auto-complete #'company-explicit-action-p + company-auto-complete-chars '(?\ ?\( ?\) ?.) + company-tooltip-align-annotations t))) +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(use-package company-web + :after company) +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(use-package company-nixos-options + :if (eq system-type 'gnu/linux) + :config (progn + (add-to-list 'company-backends 'company-nixos-options))) +#+END_SRC + +* Dates & Times + +** Calendar + +Weeks start on Monday for me and I prefer ISO-style dates. +#+BEGIN_SRC emacs-lisp +(use-package calendar + :defer 1 + :config (progn + (setq calendar-week-start-day 1) + (calendar-set-date-style 'iso))) +#+END_SRC + +Sometimes I want to insert a date or time into a buffer. +#+BEGIN_SRC emacs-lisp +(defun insert-date (prefix) + "Insert the current date. With prefix-argument, use British format. With + two prefix arguments, write out the day and month name." + (interactive "P") + (let ((format (cond + ((not prefix) "%Y-%m-%d") + ((equal prefix '(4)) "%d/%m/%Y") + ((equal prefix '(16)) "%A, %d %B %Y")))) + (insert (format-time-string format)))) + +(defun insert-datetime (prefix) + "Insert the current date and time." + (interactive "P") + (let ((format (cond + ((not prefix) "%Y-%m-%d %H:%M:%S") + ((equal prefix '(4)) "%Y-%m-%dT%H:%M:%SZ")))) + (insert (format-time-string format)))) +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(defun yesterday-time () + "Provide the date/time 24 hours before the time now in the format of current-time." + (timer-relative-time (current-time) -86400)) +#+END_SRC + +* Directories + +Dired works quite nicely, but not always in the way I want. I don’t +like having so many prompts for recursive operations. Also, when I +have two dired windows open, assume that I’m going to be +copying/moving files between them. + +#+BEGIN_SRC emacs-lisp +(use-package dired + :defer 3 + :ensure nil + :config (progn + (bind-key "" #'dired-find-file dired-mode-map) + (bind-key "^" (lambda () (interactive) (find-alternate-file "..")) dired-mode-map) + (setq dired-dwim-target t + dired-recursive-copies 'top + dired-recursive-deletes 'top + dired-listing-switches "-alh") + (when (and (eq system-type 'darwin) (executable-find "gls")) + (setq insert-directory-program (executable-find "gls"))) + (put 'dired-find-alternate-file 'disabled nil))) +#+END_SRC + +Don’t show uninteresting files in dired listings. + +#+BEGIN_SRC emacs-lisp +(defun turn-on-dired-omit-mode () + (interactive) + (dired-omit-mode 1)) + +(use-package dired-x + :commands (dired-omit-mode + dired-expunge) + :ensure nil + :config (progn + (setq dired-omit-files "#\\|\\.$" + dired-omit-verbose nil + dired-find-subdir t + dired-bind-jump nil)) + :init (progn + (add-hook 'dired-mode-hook #'turn-on-dired-omit-mode))) +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(use-package dired+ + :defer 5 + :config (progn + (diredp-toggle-find-file-reuse-dir 1) + (unbind-key "C-h C-m" dired-mode-map))) +#+END_SRC + +Expand subfolders like a tree inside the parent + +#+BEGIN_SRC emacs-lisp +(with-eval-after-load 'dired + (use-package dired-subtree + :functions (dired-subtree--get-ov + dired-subtree-maybe-up) + :init (progn + (setq dired-subtree-use-backgrounds nil) + (defun dired-subtree-maybe-up () + "Jump up one subtree or directory" + (interactive) + (let ((ov (dired-subtree--get-ov))) + (if ov + (progn (goto-char (overlay-start ov)) + (dired-previous-line 1)) + (dired-up-directory)))) + (bind-key "^" #'dired-subtree-maybe-up dired-mode-map) + (bind-key "i" #'dired-subtree-toggle dired-mode-map)))) +#+END_SRC + +** Dired-narrow +One can already use dired with wildcards to browse a filtered +directory listing, but it opens a new buffer. Dired-narrow is a +slightly nicer interface: with a currently-open dired buffer, use =/= +to start filtering, =RET= to complete the filter and =g= to refresh +the buffer, removing the filter. + +#+BEGIN_SRC emacs-lisp +(with-eval-after-load 'dired + (use-package dired-narrow + :bind (:map dired-mode-map + ("/" . dired-narrow)))) +#+END_SRC + +* Documentation + +** ehelp + +ehelp is a less well-known package that’s part of Emacs and slightly +improves the normal help commands, mostly by making quitting them easier. + +#+BEGIN_SRC emacs-lisp +(use-package ehelp + :bind-keymap ("C-h" . ehelp-map)) +#+END_SRC +** counsel-dash + +Emacs’ documentation is great to read from inside Emacs. Counsel-dash +helps to make documentation for other languages easier to access + +#+BEGIN_SRC emacs-lisp +(defmacro ap/create-counsel-dash-hook (mode docsets) + (let* ((mode-s (symbol-name mode)) + (fun (intern (concat "counsel-dash-hook-" mode-s))) + (hook (intern (concat mode-s "-mode-hook")))) + `(progn + (defun ,fun () + (when (require 'counsel-dash nil :noerror) + (-each (-difference ',docsets + (helm-dash-installed-docsets)) + #'counsel-dash-install-docset) + (setq-local counsel-dash-docsets ',docsets))) + (add-hook (quote ,hook) (function ,fun))))) + +(use-package counsel-dash + :defer 20 + :defines counsel-dash-docsets + :config (progn + (setq counsel-dash-browser-func #'eww) + (ap/create-counsel-dash-hook nginx ("Nginx")) + (ap/create-counsel-dash-hook ansible ("Ansible")) + (ap/create-counsel-dash-hook php ("PHP" "Symfony")) + (ap/create-counsel-dash-hook twig ("Twig")) + (ap/create-counsel-dash-hook js2 ("JavaScript" "NodeJS" "jQuery" "Express" "SailsJS" "Lo-Dash")) + (ap/create-counsel-dash-hook markdown ("Markdown")) + (ap/create-counsel-dash-hook saltstack ("SaltStack")) + (ap/create-counsel-dash-hook clojure ("Clojure")) + (ap/create-counsel-dash-hook sql ("PostgreSQL" "MySQL")))) +#+END_SRC + +** discover-my-major + +A nicer way to browse keybindings for major modes. + +#+BEGIN_SRC emacs-lisp +(use-package discover-my-major + :bind ("" . discover-my-major)) +#+END_SRC + +** which-key + +Popup keybindings following a prefix automatically. + +#+BEGIN_SRC emacs-lisp +(use-package which-key + :diminish which-key-mode + :config (progn + (which-key-mode 1) + (which-key-setup-side-window-right-bottom))) +#+END_SRC + +** eldoc + +Documentation in the echo-area (where the minibuffer is displayed) is +rather useful. + +#+BEGIN_SRC emacs-lisp +(use-package eldoc + :commands (eldoc-mode) + :diminish eldoc-mode + :config (progn + (setq eldoc-idle-delay 0.1) + (eldoc-add-command 'paredit-backward-delete 'paredit-close-round))) +#+END_SRC +* Misc + +#+BEGIN_SRC emacs-lisp +(defvar *init-file* + (let ((init-file (or user-init-file + (expand-file-name "init.el" user-emacs-directory)))) + (expand-file-name "init.el" + (file-name-directory (file-truename init-file)))) + "Where the emacs init file really is, passing through symlinks.") +(set-register ?e `(file . ,*init-file*)) + +(defun ap/remove-extra-cr () + "Remove extraneous CR codes from a file" + (interactive) + (save-excursion + (goto-char (point-min)) + (while (search-forward " + " nil t) + (replace-match "")))) + +(use-package rect + :ensure nil + :init (defun copy-rectangle (start end) + "Copy the region-rectangle." + (interactive "r") + (setq killed-rectangle (extract-rectangle start end)))) + +(defun shell-execute (to-current-buffer) + (interactive "P") + (let ((file-buffer (if (buffer-file-name) + (file-name-nondirectory (buffer-file-name)) + "")) + (command (read-shell-command "Shell command: " nil nil nil))) + (shell-command (replace-regexp-in-string "%" file-buffer command) to-current-buffer))) + +(defun process-exit-code (program &rest args) + "Run PROGRAM with ARGS and return the exit code" + (apply 'call-process program nil nil nil args)) + +(defun narrow-to-region-indirect (start end) + "Restrict editing in this buffer to the current region, indirectly." + (interactive "r") + (deactivate-mark) + (let ((buf (clone-indirect-buffer nil nil))) + (with-current-buffer buf + (narrow-to-region start end)) + (switch-to-buffer buf))) + +(bind-key* "M-!" #'shell-execute) +(bind-key* "C-x r M-w" #'copy-rectangle) +#+END_SRC + +** Auxillary Configuration + +#+BEGIN_SRC emacs-lisp +(require 'pinentry) + +(defvar have-private-key + (file-exists-p (expand-file-name "secring.gpg" "~/.gnupg/"))) + +(defvar gpg-agent-ssh-sock + (or (getenv "GPG_AGENT_INFO") + (concat "/run/user/" (number-to-string (user-uid)) "/gnupg/S.gpg-agent.ssh"))) + +(defun read-gpg-file (file) + (let ((file-to-decrypt (expand-file-name file user-emacs-directory)) + (ctx (epg-make-context epa-protocol))) + (if (file-exists-p file-to-decrypt) + (epg-decrypt-file ctx file-to-decrypt nil) + (message "Decrypting %s...failed" file-to-decrypt) + (error "File %s does not exist" file-to-decrypt)))) + +(defun load-gpg (file) + (if have-private-key + (load file) + (message "WARNING: Couldn't load %s (No gpg key found)" file))) + +; load this in a post-frame hook because gpg-agent asks for a password on first +; startup and caches it. Don't want emacs daemon to hang because of gpg-agent. +(defun load-private-data () + (interactive) + (if (not have-private-key) + (message "ERROR: Private GPG key not found") + (unless (or (getenv "GPG_AGENT_INFO") + (getenv "SSH_AUTH_SOCK")) + (start-process "gpg-agent" nil "gpg-agent" "--daemon") + (setenv "SSH_AUTH_SOCK" gpg-agent-ssh-sock)) + (setq password-cache-expiry nil) + (unless (file-exists-p (concat pinentry--socket-dir "pinentry")) + (pinentry-start) + (add-hook 'kill-emacs-hook 'pinentry-stop)) + (add-to-list 'load-suffixes ".el.gpg") + (load-gpg (expand-file-name "private" user-emacs-directory)))) + +(defun first-frame-hook (frame) + (remove-hook 'after-make-frame-functions #'first-frame-hook) + (run-at-time nil nil 'load-private-data)) + +(if (eq 1 (length (frame-list))) + (add-hook 'after-init-hook #'load-private-data) + (add-hook 'after-make-frame-functions #'first-frame-hook)) +#+END_SRC + +* Minibuffer + +Sometimes I want to use the minibuffer, but I’m already inside it. +Fortunately, this is possible. Of course, I need to know how many +minibuffers there are on the stack. + +#+BEGIN_SRC emacs-lisp +(setq enable-recursive-minibuffers t) +(minibuffer-depth-indicate-mode t) +#+END_SRC + +This avoids some issue with the minibuffer and the point being behind +the prompt. I don’t remember what exactly. +#+BEGIN_SRC emacs-lisp +(setq minibuffer-prompt-properties '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)) +#+END_SRC + +Occasionally, I exit emacs. I should probably reduce the frequency of this. +#+BEGIN_SRC emacs-lisp +(if (daemonp) + (defalias 'exit-emacs #'delete-frame) + (defalias 'exit-emacs #'save-buffers-kill-emacs)) +#+END_SRC + +** swiper/ivy + +Ivy is the new kid on the completion block. It seems to be a strong +replacement for helm so far. + +#+BEGIN_SRC emacs-lisp +(use-package swiper + :bind (("C-s" . swiper) + ("C-r" . swiper) + ("C-x i" . ivy-imenu-goto) + ("C-=" . swiper)) + :diminish ivy-mode + :demand t + :config (progn + (ivy-mode 1) + (setq ivy-re-builders-alist '((internal-complete-buffer . ivy--regex-fuzzy) + (t . ivy--regex-plus))) + (defun ivy-imenu-get-candidates-from (alist &optional prefix) + (cl-loop for elm in alist + nconc (if (imenu--subalist-p elm) + (ivy-imenu-get-candidates-from + (cl-loop for (e . v) in (cdr elm) collect + (cons e (if (integerp v) (copy-marker v) v))) + (concat prefix (if prefix ".") (car elm))) + (and (cdr elm) ; bug in imenu, should not be needed. + (setcdr elm (copy-marker (cdr elm))) ; Same as [1]. + (list (cons (concat prefix (if prefix ".") (car elm)) + (copy-marker (cdr elm)))))))) + + (defun ivy-imenu-goto () + "Go to buffer position" + (interactive) + (let ((imenu-auto-rescan t) items) + (unless (featurep 'imenu) + (require 'imenu nil t)) + (setq items (imenu--make-index-alist t)) + (ivy-read "imenu items:" + (ivy-imenu-get-candidates-from (delete (assoc "*Rescan*" items) items)) + :action (lambda (k) (goto-char k))))) + (ivy-set-actions 'ivy-switch-buffer '(("k" (lambda (x) + (kill-buffer x) + (ivy--reset-state ivy-last)) + "kill"))) + (add-to-list 'ivy-initial-inputs-alist '(counsel-M-x . "")))) +#+END_SRC + +** counsel + +#+BEGIN_SRC emacs-lisp +(use-package counsel + :config (progn + (bind-key "M-x" #'counsel-M-x) + (bind-key "" #'counsel-M-x) + (bind-key "" #'counsel-M-x) + (bind-key "C-c M-x" #'execute-extended-command) + (bind-key "C-x C-f" #'counsel-find-file) + (bind-key "M-y" #'counsel-yank-pop) + (bind-key "M-y" #'ivy-next-line ivy-minibuffer-map) + (defadvice counsel-find-file (after find-file-sudo activate) + "Find file as root if necessary." + (when (and buffer-file-name + (not (file-writable-p buffer-file-name))) + (message "File not writable %s" buffer-file-name) + (find-alternate-file (concat "/sudo::" buffer-file-name)))))) +#+END_SRC + + +** smex + +Smex is my favourite way to use =M-x=. Counsel’s =counsel-M-x= +function uses it internally, so I’m keeping it around, even though I +don’t use it directly. + +#+BEGIN_SRC emacs-lisp +(use-package smex + :commands (smex + smex-update + smex-initialize) + :config (progn + (setq smex-key-advice-ignore-menu-bar t + smex-auto-update nil) + (defun smex-update-after-load (_unused) + (if (boundp 'smex-cache) + (smex-update))) + (add-hook 'after-load-functions 'smex-update-after-load)) + :init (progn + (setq smex-history-length 100 + smex-save-file (concat user-emacs-directory + "smex-items")))) +#+END_SRC + +** cmd-to-echo + +I’ve been looking for some way to run programming projects (mostly +node.js) inside emacs. =cmd-to-echo= seems great for this, as new +output pops up in the echo area. + +#+BEGIN_SRC emacs-lisp +(use-package cmd-to-echo + :commands (cmd-to-echo) + :config (setq cmd-to-echo-add-output-to-process-buffers t)) +#+END_SRC +* Modes + +Setup some modes for systemd files +#+BEGIN_SRC emacs-lisp +(add-to-list 'auto-mode-alist '("\\.service\\'" . conf-mode)) +(add-to-list 'auto-mode-alist '("\\.target\\'" . conf-mode)) +(add-to-list 'auto-mode-alist '("\\.socket\\'" . conf-mode)) +#+END_SRC + +=direnv=’s files are basically shell scripts, it’s a nice way to +set environment variables for projects. +#+BEGIN_SRC emacs-lisp +(add-to-list 'auto-mode-alist '("\\.envrc\\'" . sh-mode)) +#+END_SRC + +Some modes that I don’t really customise much, mostly for +configuration files. +#+BEGIN_SRC emacs-lisp +(use-package xrdb-mode + :ensure nil + :mode (("\\.Xdefaults\\'" . xrdb-mode) + ("\\.Xresources\\'" . xrdb-mode))) + +(use-package haskell-mode + :mode (("\\.hs\\'" . haskell-mode))) + +(use-package dockerfile-mode + :mode (("Dockerfile\\'" . dockerfile-mode))) + +(use-package nix-mode + :mode (("\\.nix\\'" . nix-mode))) + +(define-derived-mode xmonad-mode haskell-mode "XM") +(add-to-list 'auto-mode-alist '("xmobarrc\\'" . xmonad-mode)) +(add-to-list 'auto-mode-alist '("xmonad.hs\\'" . xmonad-mode)) + +(use-package nginx-mode + :defer t + :mode (("/nginx/servers/" . nginx-mode) + ("/nginx/.*\\.d/" . nginx-mode))) + +(use-package lua-mode + :defer t) + +(use-package ruby-mode + :mode (("\\.rb\\'" . ruby-mode) + ("\\.cap\\'" . ruby-mode))) + +(use-package go-mode + :mode (("\\.go\\'" . go-mode))) + +(use-package jinja2-mode + :mode (("\\.j2\\'" . jinja2-mode) + ("\\.jinja\\'" . jinja2-mode))) + +(use-package scss-mode + :defer t + :config (progn + (setq scss-compile-at-save nil))) + +(use-package yaml-mode + :mode (("/group_vars/.*" . yaml-mode) + ("/host_vars/.*" . yaml-mode))) + +(define-derived-mode ansible-mode yaml-mode "Ansible") +(add-to-list 'auto-mode-alist '("\\(?:ansible.+\\|roles/.+/\\(?:tasks\\|handlers\\)\\)/.+\\.yml\\'" . ansible-mode)) + +(define-derived-mode saltstack-mode yaml-mode "Salt") +(add-to-list 'auto-mode-alist '("\\.sls\\'" . saltstack-mode)) +#+END_SRC + +** ledger + +I use [[http://ledger-cli.org/][=ledger=]] to manage my finances. It has an Emacs mode, which +works really nicely. + +#+BEGIN_SRC emacs-lisp +(use-package ledger-mode + :mode ("\\.ledger\\'" . ledger-mode) + :init (progn + (defun open-budget () + (interactive) + (projectile-switch-project-by-name "~/Sync/Default") + (find-file (expand-file-name "ledger/my.ledger" (projectile-project-root))) + (ledger-report "Budget (Cumulative)" nil))) + :config (progn + (setq ledger-use-iso-dates t + ledger-post-use-completion-engine :built-in + ledger-reconcile-default-commodity "€" + ledger-clear-whole-transactions t + ledger-narrow-on-reconcile t + ledger-default-date-format "%Y-%m-%d" + ledger-reports '(("Monthly Expenses" "ledger -f %(ledger-file) reg -M Expenses --real -l \"payee != 'Opening Balances'\"") + ("Expenses:This Month" "ledger -f %(ledger-file) bal \\^Expenses -p \"this month\"") + ("On-budget Balances" "ledger -f %(ledger-file) bal --current -R :Budget: Assets:Receivable Liabilities:Personal") + ("All Account Balances" "ledger -f %(ledger-file) bal --current -R \\^Assets \\^Liabilities") + ("Budget Values (Current Month)" "ledger -f %(ledger-file) bal -p \"this month\" --limit \"payee=~/budget/\" \\^Funds") + ("Budget (Cumulative)" "ledger -f %(ledger-file) bal -E \\^Funds \\^Assets:Budget$") + ("Budget Allocation" "ledger -f %(ledger-file) bal -p \"this month\" --limit \"payee=~/budget/\" \\^Funds --format \"\\ + %-17((depth_spacer)+(partial_account))\\ + %10(percent(market(display_total), market(parent.total)))\\ + %16(market(display_total))\n%/\"") + ("bal" "ledger -f %(ledger-file) bal") + ("reg" "ledger -f %(ledger-file) reg") + ("equity" "ledger -f %(ledger-file) equity") + ("payee" "ledger -f %(ledger-file) reg @%(payee)") + ("account" "ledger -f %(ledger-file) reg %(account)"))))) +#+END_SRC + +** Markdown + +#+BEGIN_SRC emacs-lisp +(use-package markdown-mode + :defer t + :config (progn + (add-hook 'markdown-mode-hook #'turn-on-auto-fill))) +#+END_SRC + +** Org + +Org is wünderbar. + +#+BEGIN_SRC emacs-lisp +(use-package org + :bind (("C-c C-a" . org-agenda-list) + ("C-c a" . org-agenda) + ("C-c l" . org-store-link)) + :defer 8 + :init (setq org-replace-disputed-keys t + org-ellipsis "…") + :config (progn + (setq org-directory "~/Sync/org" + org-agenda-files `(,(concat org-directory "/agenda")) + + org-default-notes-file (concat org-directory "/notes") + + ;; ‘Remember’: new items at top + org-reverse-note-order t + + org-modules '(org-protocol) + + ;; Add time done to ‘done’ tasks + org-log-done 'time + + org-list-allow-alphabetical t + + org-adapt-indentation nil + + org-pretty-entities t + + org-table-duration-custom-format 'seconds + + org-src-fontify-natively nil + + org-export-have-math t + + org-blank-before-new-entry '((heading . t) + (plain-list-item . auto)) + org-fontify-done-headline t + + org-todo-keywords '((sequence "BACKLOG(b)" "TODO(t)" "WAIT(w@/!)" "STARTED(s!)" "|" "DONE(d!)") + (sequence "|" "CANCELLED(c@)")) + org-log-into-drawer "LOGBOOK") + (set-register ?o `(file . ,(expand-file-name "organiser.org" org-directory))) + (add-hook 'org-mode-hook #'turn-on-auto-fill) + (org-load-modules-maybe t))) +#+END_SRC + +**** org-babel + +Org’s babel feature is really nice. I use it for this file, and I can +use it to communicate between programming languages. Sometime I hope +to have my =ledger= setup in an org file with some graph processing +with R or something. + +#+BEGIN_SRC emacs-lisp +(use-package ob-core + :defer t + :ensure nil + :config (progn + (org-babel-do-load-languages 'org-babel-load-languages + '((ledger . t) + (sh . t))) + (setq org-src-tab-acts-natively t + org-edit-src-content-indentation 0 + org-src-preserve-indentation t))) +#+END_SRC + +**** org-journal + +I can use this to keep a journal. I should use it. + +#+BEGIN_SRC emacs-lisp +(use-package org-journal + :bind ("s-j" . org-journal-new-entry) + :defer 20 + :config (progn + (setq org-journal-date-format "%A, %d %B %Y") + (defun org-journal-display-entry-yesterday () + "Show org-journal entry for yesterday" + (interactive) + (org-journal-read-or-display-entry (yesterday-time))))) +#+END_SRC + +**** org-mobile + +#+BEGIN_SRC emacs-lisp +(defun ap/org-mobile-pull (descriptor action file) + (org-mobile-pull)) +(use-package org-mobile + :defer 30 + :ensure nil + :disabled t + :config (progn + (setq org-mobile-directory "~/Mobile/Org" + org-mobile-inbox-for-pull "~/Mobile/Org/from-mobile.org") + (defvar org-mobile-push-timer nil + "Timer that `org-mobile-push-timer' used to reschedule itself, or nil.") + + (defun org-mobile-push-with-delay (secs) + (when org-mobile-push-timer + (cancel-timer org-mobile-push-timer)) + (setq org-mobile-push-timer + (run-with-idle-timer + (* 1 secs) nil 'org-mobile-push))) + + (add-hook 'after-save-hook + (lambda () + (when (eq major-mode 'org-mode) + (dolist (file (org-mobile-files-alist)) + (if (string= (file-truename (expand-file-name (car file))) + (file-truename (buffer-file-name))) + (org-mobile-push-with-delay 30)))))) + + (run-at-time "00:05" 86400 '(lambda () (org-mobile-push-with-delay 1))) ;; refreshes agenda file each day + (org-mobile-pull) ;; run org-mobile-pull at startup + + (defvar org-mobile-watcher nil) + (when file-notify--library + (let ((org-file (expand-file-name + (concat + (file-name-as-directory org-mobile-directory) + org-mobile-capture-file)))) + (setq org-mobile-watcher + (file-notify-add-watch org-file '(change) #'ap/org-mobile-pull)))))) +#+END_SRC + +**** org-caldav + +I’ve setup CalDAV on my server, it would be nice to use it directly +from org-mode. Previously I had to wait for org-mobile to sync and +write to the Android calendar, and then for DAVDroid to sync with the server. + +#+BEGIN_SRC emacs-lisp +(use-package org-caldav + :defer 30 + :config (progn + (setq org-caldav-url "https://calendar.alanpearce.uk/alan" + org-caldav-calendar-id "caldav" + org-caldav-inbox (concat org-directory "/agenda/caldav.org") + org-caldav-files `(,(concat org-directory "/agenda/organiser.org")) + org-icalendar-timezone "Europe/Berlin" + org-icalendar-use-scheduled '(event-if-todo event-if-not-todo todo-start) + org-icalendar-use-deadline '(event-if-todo event-if-not-todo todo-due) + org-icalendar-alarm-time 60))) +#+END_SRC + +**** org-page + +I would like to convert my website from using hugo to something else +that I can work with nicely from inside Emacs. I wonder if org-page +will do the trick. + +#+BEGIN_SRC emacs-lisp +(use-package org-page + :config (progn + (setq op/site-domain "https://alanpearce.uk/" + op/repository-directory "~/projects/alanpearce/" + op/personal-github-link "https://github.com/alanpearce"))) +#+END_SRC + +* Music +Emacs actually supports playing music via mpd. + +#+BEGIN_SRC emacs-lisp +(use-package mpc + :defer t + :config (progn + (setq mpc-browser-tags '(Genre Albumartist|Composer|Performer Album|Playlist)))) +#+END_SRC +* Programming +** flycheck + +On-the-fly error checking in programming modes? Yes please. + +#+BEGIN_SRC emacs-lisp +(use-package flycheck + :diminish " ✓" + :defer 5 + :config (progn + (global-flycheck-mode) + (setq flycheck-check-syntax-automatically '(save new-line mode-enabled)) + (if (executable-find "eslint_d") + (setq flycheck-javascript-eslint-executable (executable-find "eslint_d"))))) +#+END_SRC + +** golang + +Go has a few packages to inter-operate with other emacs packages. + +#+BEGIN_SRC emacs-lisp +(use-package company-go + :commands company-go + :config (progn + (setq company-go-show-annotation t)) + :init (progn + (defun ap/company-go-setup () + (set (make-local-variable 'company-backends) + '(company-go))) + (add-hook 'go-mode-hook #'ap/company-go-setup))) + +(use-package go-eldoc + :commands go-eldoc-setup + :init (progn + (add-hook 'go-mode-hook #'go-eldoc-setup))) + +(use-package go-projectile + :defer t + :config (progn + (setq go-projectile-switch-gopath 'maybe))) + + +#+END_SRC + +** ggtags + +A nice completion backend for programming modes. + +#+BEGIN_SRC emacs-lisp +(use-package ggtags + :disabled t + :commands turn-on-ggtags-mode + :functions (ggtags-navigation-mode-abort) + :config (progn + (bind-key "q" #'ggtags-navigation-mode-abort ggtags-navigation-mode-map)) + :init (progn + (defun turn-on-ggtags-mode () + (interactive) + (ggtags-mode 1)) + (add-hook 'c-mode-common-hook #'turn-on-ggtags-mode))) +#+END_SRC + +** Lisps + +*** All + +Lisp modes don’t seem to have a common ancestor. So I made a custom +hook which I trigger in every lispy-mode. + +#+BEGIN_SRC emacs-lisp +(defcustom lisp-mode-common-hook nil + "Hook run when entering any Lisp mode." + :type 'hook + :group 'lisp) + +(defun ap/lisp-setup () + (run-hooks 'lisp-mode-common-hook)) +#+END_SRC + +**** Redshank + +Lisp syntax allows for really easy refactoring. Redshank gives some +operations that aren’t part of paredit, like extracting variables into +let bindings. +#+BEGIN_SRC emacs-lisp +(use-package redshank + :diminish " Λ" + :after (paredit) + :config (progn + (add-hook 'lisp-mode-common-hook #'turn-on-redshank-mode))) +#+END_SRC + +*** Emacs Lisp + +Customise the modeline-display of =emacs-lisp-mode=. Then make sure +it runs the common lisp hooks. + +#+BEGIN_SRC emacs-lisp +(add-hook 'emacs-lisp-mode-hook #'ap/lisp-setup) +(add-hook 'emacs-lisp-mode-hook #'eldoc-mode) +#+END_SRC + +Go-to function for elisp. Except it works through the entire Emacs ecosystem. + +#+BEGIN_SRC emacs-lisp +(use-package elisp-slime-nav + :commands elisp-slime-nav-mode + :diminish elisp-slime-nav-mode + :init (progn + (add-hook 'emacs-lisp-mode-hook #'elisp-slime-nav-mode))) +#+END_SRC + +Interactive elisp + +#+BEGIN_SRC emacs-lisp +(use-package ielm + :defer t + :ensure nil + :config (progn + (add-hook 'ielm-mode-hook (lambda () + (run-hooks 'lisp-mode-common-hook))))) +#+END_SRC + +*** Scheme & Lisp + +I don’t work with these as often as I would like + +#+BEGIN_SRC emacs-lisp +(add-hook 'scheme-mode-hook #'ap/lisp-setup) +(add-hook 'lisp-mode-hook #'ap/lisp-setup) +(defun set-common-lisp-indentation () + (set (make-local-variable 'lisp-indent-function) + #'common-lisp-indent-function)) +(add-hook 'lisp-mode-hook #'set-common-lisp-indentation) +#+END_SRC + +**** geiser + +A REPL thing for Scheme. Hopefully I’ll get to use it more in the +future. + +#+BEGIN_SRC emacs-lisp +(use-package geiser + :commands (geiser-mode + geiser + run-geiser + run-racket)) +#+END_SRC + +**** slime + +A REPL thing (and more) for Lisp. + +#+BEGIN_SRC emacs-lisp +(use-package slime + :commands (slime) + :config (progn + (let ((ql-slime-helper (expand-file-name "~/quicklisp/slime-helper.el"))) + (if (file-exists-p ql-slime-helper) + (load ql-slime-helper)) + (slime-setup)) + (setq inferior-lisp-program (executable-find "sbcl")))) +#+END_SRC + +*** Clojure + +#+BEGIN_SRC emacs-lisp +(use-package clojure-mode + :defer t + :init (progn + (add-hook 'cider-repl-mode-hook (lambda () (highlight-changes-mode -1))) + (add-hook 'clojure-mode-hook #'ap/lisp-setup))) + +(use-package clj-refactor + :defer t + :functions (clj-refactor-mode cljr-add-keybindings-with-prefix) + :config (progn + (cljr-add-keybindings-with-prefix "C-c C-m")) + :init (progn + (defun turn-on-clj-refactor-mode () + (clj-refactor-mode 1)) + (add-hook 'clojure-mode-hook #'turn-on-clj-refactor-mode))) +#+END_SRC + +**** cider + +A REPL thing for Clojure + +#+BEGIN_SRC emacs-lisp +(use-package cider + :defer t + :config (progn + (setq nrepl-hide-special-buffers t) + (unbind-key "C-c C-f" cider-mode-map) + (add-hook 'cider-mode-hook #'eldoc-mode))) +#+END_SRC + +** Auto-compile + +Auto-compile emacs lisp when saving. +#+BEGIN_SRC emacs-lisp +(use-package auto-compile + :defer t + :init (add-hook 'emacs-lisp-mode-hook #'auto-compile-on-save-mode)) +#+END_SRC + +** cc-mode + +Although I don’t use C or C++, setting up the mode is helpful because +quite a few other modes are derived from it. + +#+BEGIN_SRC emacs-lisp +(use-package cc-mode + :defer 5 + :init (progn + (add-hook 'c-mode-common-hook #'electric-indent-mode)) + :config (progn + (setq c-default-style '((java-mode . "java") + (awk-mode . "awk") + (other . "k&r")) + c-basic-offset 4) + (c-set-offset 'case-label '+))) +#+END_SRC + +** quickrun + +It’s nice to be able to quickly evaluate some code. Although I don’t +really seem to use it. +#+BEGIN_SRC emacs-lisp +(use-package quickrun + :bind (("C-c C-e" . quickrun))) +#+END_SRC + +** Scala + +Let’s try using Scala. + +#+BEGIN_SRC emacs-lisp +(use-package scala-mode + :pin melpa-stable) +#+END_SRC + +And add ensime, an IDE-style environment. + +#+BEGIN_SRC emacs-lisp +(use-package ensime + :pin melpa-stable) +#+END_SRC + +** Web development + +*** js2-mode + +This mode is really great for editing Javascript. It turns code into +an AST internally, so it can work with it almost like a lisp. I don’t +think there’s anything as good as paredit/redshank for refactoring in +it though + +#+BEGIN_SRC emacs-lisp +(use-package js2-mode + :mode (("\\.js\\'" . js2-mode) + ("\\.jsx\\'" . js2-jsx-mode)) + :interpreter ("node" . js2-mode) + :functions js2-next-error + :config (progn + (define-key js2-mode-map [menu-bar Javascript] nil) + (defun js2--imenu-around (do-it name) + "Don't create a menu from js2-mode" + (if (and (not (string-equal name "IM-Javascript-IDE")) + (fboundp #'do-it)) + (do-it name))) + (advice-add 'imenu-add-to-menubar :around #'js2--imenu-around) + (defun ap/js2-prev-error () + (interactive) + (js2-next-error -1)) + (bind-key "M-g M-n" #'js2-next-error js2-mode-map) + (bind-key "M-g M-p" #'ap/js2-prev-error js2-mode-map) + (setq js2-basic-offset 2 + js2-include-node-externs t))) +#+END_SRC + +**** jade (not pug) + +Javascript with an inferior node.js process and a debugger? Awesome. + +To debug with node, use version 6.9.1 or later of node and run it with +~--inspect~ and, to break on the first line, ~--debug-brk~. + +For Chrom*, it needs to be launched with ~--remote-debugging-port=9222~ + +#+BEGIN_SRC emacs-lisp +(use-package jade + :config (progn + (add-hook 'js2-mode-hook #'jade-interaction-mode))) +#+END_SRC + +*** coffee-mode + +#+BEGIN_SRC emacs-lisp +(use-package coffee-mode + :mode ("\\.coffee\\'" . coffee-mode) + :config (progn + (setq coffee-indent-like-python-mode t))) +#+END_SRC + +*** tern + +Tern understands javascript. It adds really clever documented +completions, besides other IDE-like things. + +#+BEGIN_SRC emacs-lisp +(use-package tern + :commands ap/enable-tern + :if (executable-find "tern") + :defer 5 + :config (progn + (setq tern-command (list (executable-find "tern"))) + (defun ap/enable-tern () + (tern-mode 1)) + (add-hook 'js2-mode-hook #'ap/enable-tern) + (add-hook 'web-mode-hook #'ap/enable-tern))) + +(with-eval-after-load 'tern + (use-package company-tern)) +#+END_SRC + +*** json-mode + +#+BEGIN_SRC emacs-lisp +(use-package json-mode + :mode (("\\.json\\'" . json-mode) + ("\\.sailsrc\\'" . json-mode) + ("composer\\.lock\\'" . json-mode) + ("\\.tern-project\\'" . json-mode))) +#+END_SRC + +*** restclient + +Restclient is really nice. It’s like a scratchpad for HTTP api +calls. Feels a bit like using =org-babel=. I wonder if there’s an +integration between the two yet. + +#+BEGIN_SRC emacs-lisp +(use-package restclient + :mode ("\\.api\\'" . restclient-mode) + :config (progn + (defun imenu-restclient-sections () + (setq imenu-prev-index-position-function nil) + (add-to-list 'imenu-generic-expression '("Services" "^## ?\\(.+\\)$" 1) t) + (add-to-list 'imenu-generic-expression '("Calls" "^# ?\\(.+\\)$" 1) t)) + (add-hook 'restclient-mode-hook #'imenu-restclient-sections))) + +(use-package company-restclient + :after (company restclient) + :init (add-to-list 'company-backends #'company-restclient t)) +#+END_SRC + +*** sgml-mode + +This is for HTML, since old versions of HTML were derived from SGML. +#+BEGIN_SRC emacs-lisp +(use-package sgml-mode + :defer t + :config (setq sgml-basic-offset 2)) +#+END_SRC + +*** emmet-mode + +Emmet is really nice to write HTML quickly. Especially with +frameworks that require multiple nested elements to do anything useful. +#+BEGIN_SRC emacs-lisp +(use-package emmet-mode + :commands (emmet-mode) + :diminish (emmet-mode . " >") + :init (progn + (setq emmet-indentation 2) + (add-hook 'web-mode-hook #'emmet-mode))) +#+END_SRC + +*** web-mode + +This mode handles just about every templating language out ther, which +is really nice, because it handles the HTML part the same way in all +of them as well. + +#+BEGIN_SRC emacs-lisp +(use-package web-mode + :mode (("/views/.*\\.php\\'" . web-mode) + ("\\.html\\'" . web-mode) + ("/templates/.*\\.php\\'" . web-mode) + ("\\.ejs\\'" . web-mode)) + :config (progn + (setq web-mode-code-indent-offset 2 + web-mode-css-indent-offset 2 + web-mode-markup-indent-offset 2 + web-mode-style-padding 0 + web-mode-script-padding 0 + web-mode-comment-style 2 + web-mode-enable-auto-pairing nil + web-mode-enable-auto-quoting nil) + (sp-local-pair '(web-mode) "<%" "%>"))) +#+END_SRC + +I derived a mode for twig, in order to use its =mode-hook=. + +#+BEGIN_SRC emacs-lisp +(define-derived-mode twig-mode web-mode "Twig") +(add-to-list 'auto-mode-alist '("\\.html\\.twig\\'" . twig-mode)) +#+END_SRC + +* Spelling + +#+BEGIN_SRC emacs-lisp +(use-package ispell + :bind (("" . ispell-word)) + :config (progn + (cond + ((executable-find "aspell") (setq ispell-program-name "aspell" + ispell-dictionary "british" + ispell-really-aspell t + ispell-really-hunspell nil)) + ((executable-find "hunspell") (setq ispell-program-name "hunspell" + ispell-really-aspell nil + ispell-really-hunspell t))))) +#+END_SRC + +* Scripting + +Make a shell-script buffer executable after saving it, if it has a shebang. + +#+BEGIN_SRC emacs-lisp +(add-hook 'after-save-hook + #'executable-make-buffer-file-executable-if-script-p) + +(use-package sh-script + :mode (("\\.zsh\\'" . shell-script-mode) + ("zshenv\\'" . shell-script-mode) + ("zshrc\\'" . shell-script-mode)) + :config (setq sh-shell-file "/usr/bin/env zsh" + sh-indentation 2 + sh-basic-offset 2)) +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) +#+END_SRC + +** eshell + +I should try to get into the habit of using this more. It’s really +nice, when I remember to use it. + +#+BEGIN_SRC emacs-lisp +(use-package eshell + :bind ("C-c s" . eshell) + :config (progn + (setq eshell-directory-name "~/.emacs.d/eshell" + eshell-prompt-function (lambda () + (concat + (eshell/pwd) + "\n$ "))) + (add-hook 'eshell-load-hook (lambda () + (bind-key "C-c C-l" #'counsel-esh-history eshell-mode-map))))) + +(use-package em-smart + :ensure nil + :commands eshell-smart-initialize + :init (progn + (add-hook 'eshell-load-hook #'eshell-smart-initialize)) + :config (progn + (setq eshell-where-to-jump 'begin + eshell-review-quick-commands nil + eshell-smart-space-goes-to-end t))) + +(autoload #'eshell/cd "em-dirs") +(defun eshell-goto-current-dir (&optional arg) + (interactive "P") + (let ((dir default-directory)) + (eshell arg) + (eshell/cd dir))) +(bind-key "C-c S" #'eshell-goto-current-dir) + + +#+END_SRC + +*** Shells + +#+BEGIN_SRC emacs-lisp +(use-package shell + :defer t + :ensure nil + :config (define-key shell-mode-map + (kbd "C-d") 'comint-delchar-or-eof-or-kill-buffer)) + +(use-package comint + :defer t + :ensure nil + :config (bind-key "C-c C-l" #'counsel-shell-history comint-mode-map)) + +(defun comint-delchar-or-eof-or-kill-buffer (arg) + (interactive "p") + (if (null (get-buffer-process (current-buffer))) + (kill-buffer) + (comint-delchar-or-maybe-eof arg))) +#+END_SRC + +* Text editing + +Emacs has an editor within. + +#+BEGIN_SRC emacs-lisp +(put 'upcase-region 'disabled nil) +(put 'downcase-region 'disabled nil) +(setq sentence-end-double-space t + line-move-visual nil) +#+END_SRC + +** align + +=Align= is a useful command to line things up, once given some rules. +The most important one for me is JSON property alignment. + +#+BEGIN_SRC emacs-lisp +(use-package align + :defer 10 + :ensure nil + :config (progn + (add-to-list 'align-rules-list + '(colon-key-value + (regexp . ":\\(\\s-*\\)") + (modes . '(js2-mode)))))) +#+END_SRC + +** Clipboard + +I like to use the clipboard more than the primary selection in X11. + +#+BEGIN_SRC emacs-lisp +(setq x-select-enable-clipboard t + save-interprogram-paste-before-kill t) +(if (functionp 'x-cut-buffer-or-selection-value) + (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)) +(when (boundp 'x-select-request-type) + (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))) +#+END_SRC + +*** Copy formatted code + +#+BEGIN_SRC emacs-lisp +(bind-key* "C-c w" (define-prefix-command 'copy-as-map)) +(use-package copy-as-format + :bind (("C-c C-w" . copy-as-format) + :map copy-as-map + ("b" . copy-as-format-bitbucket) + ("g" . copy-as-format-github) + ("h" . copy-as-format-hipchat) + ("w" . copy-as-format-html) + ("j" . copy-as-format-jira) + ("m" . copy-as-format-markdown) + ("s" . copy-as-format-slack))) +#+END_SRC + +** + +** Selection + +I’m quite used to deleting text by selecting it and typing. Emacs has +a mode for that. + +#+BEGIN_SRC emacs-lisp +(delete-selection-mode t) +#+END_SRC + +Sub-word movement is really nice for camel- and Pascal-case + +#+BEGIN_SRC emacs-lisp +(use-package subword + :diminish subword-mode + :init (global-subword-mode t)) +#+END_SRC + +I find that =zap-up-to-char= normally makes more sense to me than +=zap-to-char=. + +#+BEGIN_SRC emacs-lisp +(use-package misc + :ensure nil + :bind (("M-z" . zap-up-to-char) + ("M-Z" . zap-to-char))) +#+END_SRC + +Expanding the region by semantic units was something I quite liked +from Sublime Text. As always, there’s a mode for that. + +#+BEGIN_SRC emacs-lisp +(use-package expand-region + :bind ("C-M-SPC" . er/expand-region) + :config (setq expand-region-fast-keys-enabled nil)) +#+END_SRC + +** avy + +Avy is a really nice way to move around files, like ace-jump-mode, but +somehow I prefer it. + +#+BEGIN_SRC emacs-lisp +(use-package avy + :bind* (("M-g g" . avy-goto-line) + ("M-g M-g" . avy-goto-line) + ("C-|" . avy-goto-line) + ("M-r" . avy-goto-word-1) + ("C-c SPC" . avy-goto-char-timer)) + :config (progn + (avy-setup-default) + (setq avy-all-windows nil + avy-keys '(?a ?r ?s ?t ?d ?h ?n ?e ?i ?\;)))) +#+END_SRC + +*** ace-link + +Visit any link. Despite the name, this works with avy. + +#+BEGIN_SRC emacs-lisp +(use-package ace-link + :after avy + :config (progn + (ace-link-setup-default) + (with-eval-after-load "gnus" + (bind-key "M-o" #'ace-link-gnus gnus-summary-mode-map) + (bind-key "M-o" #'ace-link-gnus gnus-article-mode-map)))) +#+END_SRC + +** goto-chg + +This is like popping the mark, only it filters to only change areas +and doesn’t go back to the same place more than once. + +#+BEGIN_SRC emacs-lisp +(use-package goto-chg + :bind ("C-c C-SPC" . goto-last-change)) +#+END_SRC + +** multiple-cursors + +I mentioned before that I’d used Sublime Text before. Multiple +cursors was one of my favourite features, so I was really happy when I +saw that multiple-cursors was released for Emacs. + +#+BEGIN_SRC emacs-lisp +(use-package multiple-cursors + :defer 1 + :config (progn + (bind-key "C-." #'mc/mark-next-like-this) + (bind-key "C-," #'mc/mark-previous-like-this) + (bind-key "M-" #'mc/mark-all-like-this-dwim) + (bind-key "C-" #'mc/mark-more-like-this-extended) + (bind-key "C-S-L" #'mc/edit-lines))) +#+END_SRC + +** paredit + +Balanced parentheses in lisps are nice, but all the refactoring and +movement commands are much more interesting. + +#+BEGIN_SRC emacs-lisp +(use-package paredit + :diminish "()" + :config (progn + (add-hook 'lisp-mode-common-hook #'enable-paredit-mode) + (put #'paredit-forward-delete 'delete-selection 'supersede) + (put #'paredit-backward-delete 'delete-selection 'supersede) + (add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode))) +#+END_SRC + +** smartparens + +I like to use smartparens where paredit isn’t already useful. Somehow +I didn’t find smartparens’ implementation of paredit style to be as +nice as the real version + +#+BEGIN_SRC emacs-lisp +(eval-when-compile (require 'smartparens nil :noerror)) +(use-package smartparens-config + :ensure smartparens + :config (progn + (sp-use-smartparens-bindings) + (setq sp-highlight-pair-overlay nil) + (fset 'wrap-with-paren "\C-](") ;; `sp-select-next-thing-exchange' + (bind-key "C-(" #'wrap-with-paren smartparens-mode-map) + (bind-key "C-)" #'sp-forward-slurp-sexp smartparens-mode-map) + (bind-key "M-" #'backward-kill-word smartparens-mode-map) + (bind-key "M-?" #'sp-convolute-sexp smartparens-mode-map) + (bind-key "C-M-t" #'sp-transpose-sexp smartparens-mode-map) + (bind-key "M-R" #'sp-raise-sexp smartparens-mode-map) + (bind-key "M-S" #'sp-splice-sexp smartparens-mode-map) + (bind-key "C-M-s" #'sp-split-sexp smartparens-mode-map) + (bind-key "M-J" #'sp-join-sexp smartparens-mode-map) + (bind-key "M-" #'sp-splice-sexp-killing-backward smartparens-mode-map) + (bind-key "M-" #'sp-splice-sexp-killing-forward smartparens-mode-map) + (bind-key "C-M-S-k" #'sp-kill-hybrid-sexp smartparens-mode-map) + (bind-key "C-S-" #'sp-slurp-hybrid-sexp smartparens-mode-map) + (sp-with-modes '(twig-mode) + (sp-local-pair "{%" "%}") + (sp-local-pair "{{" "}}")) + (show-smartparens-global-mode t) + (smartparens-global-strict-mode t) + (add-hook 'lisp-mode-common-hook #'turn-off-smartparens-mode) + (add-hook 'coffee-mode-hook #'turn-off-smartparens-mode))) +#+END_SRC + +** smart-scan + +Move between instances of a symbol + +#+BEGIN_SRC emacs-lisp +(use-package smartscan + :config (progn + (smartscan-mode 1))) +#+END_SRC + +** move-text + +Transposing lines, made easier. + +#+BEGIN_SRC emacs-lisp +(use-package move-text + :config (move-text-default-bindings)) +#+END_SRC + +** undo-tree + +Emacs’ default handling of undo is a bit confusing. Undo-tree makes +it much clearer. It’s especially helpful for protoyping and refactoring. + +#+BEGIN_SRC emacs-lisp +(use-package undo-tree + :config (progn + (global-undo-tree-mode) + ;; Keep region when undoing in region + (defadvice undo-tree-undo (around keep-region activate) + (if (use-region-p) + (let ((m (set-marker (make-marker) (mark))) + (p (set-marker (make-marker) (point)))) + ad-do-it + (goto-char p) + (set-mark m) + (set-marker p nil) + (set-marker m nil)) + ad-do-it))) + :diminish undo-tree-mode) +#+END_SRC + +** replace + +#+BEGIN_SRC emacs-lisp +(use-package replace + :defer t + :config (progn + (setq case-replace nil))) +#+END_SRC + +** visual-regexp + +I don’t always remember exactly how Emacs’ regular expressions work, +so this package is pretty useful because it highlights everything in +the buffer for me. + +#+BEGIN_SRC emacs-lisp +(use-package visual-regexp + :bind (("C-c r" . vr/replace) + ("C-c q" . vr/query-replace) + ("C-c m" . vc/mc-mark))) +#+END_SRC +* Tangling + +Taken from [[https://github.com/larstvei/dot-emacs/blob/master/init.org][larstvei/dot-emacs]]. I changed it so that it would work with +my current dotfiles repository structure and work asynchronously, +thanks to [[https://github.com/jwiegley/emacs-async][jwiegley/emacs-async]]. + +We can use =C-c C-v t= to run =org-babel-tangle=, which extracts the +code blocks from the current file into a source-specific file (in this +case a =.el=-file). + +To avoid doing this each time a change is made we can add a function +to the =after-save-hook= ensuring to always tangle and byte-compile +the =org=-document after changes. + +#+BEGIN_SRC emacs-lisp +(use-package async + :commands (async-start) + :defer 2) + +(defun tangle-if-init () + "If the current buffer is 'init.org' the code-blocks are + tangled, and the tangled file is compiled." + + (when (string-suffix-p "init.org" (buffer-file-name)) + (tangle-init))) + +(defun tangle-init-sync () + (interactive) + (message "Tangling init") + ;; Avoid running hooks when tangling. + (let ((prog-mode-hook nil) + (src (expand-file-name "init.org" user-emacs-directory)) + (dest (expand-file-name "init.el" user-emacs-directory))) + (require 'ob-tangle) + (org-babel-tangle-file src dest) + (if (byte-compile-file dest) + (byte-compile-dest-file dest) + (with-current-buffer byte-compile-log-buffer + (buffer-string))))) + +(defun tangle-init () + "Tangle init.org asynchronously." + + (interactive) + (message "Tangling init") + (async-start + (symbol-function #'tangle-init-sync) + (lambda (result) + (message "Init tangling completed: %s" result)))) +#+END_SRC + +# Local Variables: +# eval: (when (fboundp #'tangle-if-init) (add-hook 'after-save-hook #'tangle-if-init)) +# End: +* End + +Start a server if possible. A daemon is already a server. +#+BEGIN_SRC emacs-lisp +(run-with-idle-timer 2 nil (lambda () + (unless (daemonp) + (require 'server) + (unless (server-running-p server-name) + (server-start))))) +(setq gc-cons-threshold 800000 + file-name-handler-alist file-name-handler-alist-backup) +#+END_SRC diff --git a/fish/.config/fish/config.fish b/fish/.config/fish/config.fish new file mode 100755 index 0000000..34cd22e --- /dev/null +++ b/fish/.config/fish/config.fish @@ -0,0 +1,2 @@ +set PATH $PATH /home/alan/bin +setenv SSH_AUTH_SOCK $XDG_RUNTIME_DIR/ssh-agent.socket diff --git a/git/.config/git/config b/git/.config/git/config new file mode 100644 index 0000000..6228a08 --- /dev/null +++ b/git/.config/git/config @@ -0,0 +1,34 @@ +[user] + email = alan@alanpearce.uk + name = Alan Pearce +[color] + branch = auto + diff = auto + status = auto + ui = true +[push] + default = current +[alias] + up = merge FETCH_HEAD + st = status -sb + ci = commit + br = branch + co = checkout + ready = rebase -i @{u} + lg = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' + standup = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --since yesterday --author Alan + ignored = ls-files --others -i --exclude-standard + pr = pull-request + delete-merged = "!sh -c 'git branch --merged | grep -v "\\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d'" +[github] + user = alan@alanpearce.uk +[diff] + algorithm = patience +[include] + path = config.local +[core] + excludesfile = ~/.config/git/ignore +[rebase] + autosquash = true +[rerere] + enabled = true diff --git a/git/.config/git/gitk b/git/.config/git/gitk new file mode 100644 index 0000000..0eb9a03 --- /dev/null +++ b/git/.config/git/gitk @@ -0,0 +1,61 @@ +set mainfont {{Lucida Grande} 12} +set textfont {Monaco 12} +set uifont {{Lucida Grande} 12 bold} +set tabstop 4 +set findmergefiles 0 +set maxgraphpct 50 +set maxwidth 16 +set cmitmode patch +set wrapcomment none +set autoselect 1 +set autosellen 40 +set showneartags 1 +set maxrefs 20 +set hideremotes 0 +set showlocalchanges 1 +set datetimeformat {%Y-%m-%d %H:%M:%S} +set limitdiffs 1 +set uicolor grey85 +set want_ttk 1 +set bgcolor white +set fgcolor black +set uifgcolor black +set uifgdisabledcolor #999 +set colors {green red blue magenta darkgrey brown orange} +set diffcolors {red "#00a000" blue} +set mergecolors {red blue green purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"} +set markbgcolor #e0e0ff +set diffcontext 3 +set selectbgcolor gray85 +set foundbgcolor yellow +set currentsearchhitbgcolor orange +set extdifftool opendiff +set perfile_attrs 0 +set headbgcolor green +set headfgcolor black +set headoutlinecolor black +set remotebgcolor #ffddaa +set tagbgcolor yellow +set tagfgcolor black +set tagoutlinecolor black +set reflinecolor black +set filesepbgcolor #aaaaaa +set filesepfgcolor black +set linehoverbgcolor #ffff80 +set linehoverfgcolor black +set linehoveroutlinecolor black +set mainheadcirclecolor yellow +set workingfilescirclecolor red +set indexcirclecolor green +set circlecolors {white blue gray blue blue} +set linkfgcolor blue +set circleoutlinecolor black +set geometry(main) 1477x845+26+50 +set geometry(state) normal +set geometry(topwidth) 1477 +set geometry(topheight) 300 +set geometry(pwsash0) "378 1" +set geometry(pwsash1) "569 1" +set geometry(botwidth) 473 +set geometry(botheight) 675 +set permviews {} diff --git a/git/.config/git/ignore b/git/.config/git/ignore new file mode 100644 index 0000000..d7189dc --- /dev/null +++ b/git/.config/git/ignore @@ -0,0 +1,29 @@ +.DS_Store +.AppleDouble +.LSOverride +Icon +Desktop.ini + +# Thumbnails +._* +Thumbs.db + +# Emacs +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +GPATH +GRTAGS +GTAGS + +.tern-port \ No newline at end of file diff --git a/global/.globalrc b/global/.globalrc new file mode 100644 index 0000000..7fd1a0b --- /dev/null +++ b/global/.globalrc @@ -0,0 +1,6 @@ +default:\ + :tc=symfony_global: + +symfony_global:\ + :suffixes=php,yml,yaml,html,twig,xml:\ + :skip=/app/cache,node_modules,bin,/app/logs,GPATH,GTAGS,GRTAGS,GSYMS,HTML/,HTML.pub/,html/,tags,TAGS,ID,y.tab.c,y.tab.h,.notfunction,cscope.out,cscope.po.out,cscope.in.out,.gdbinit,SCCS/,RCS/,CVS/,CVSROOT/,{arch}/,.svn/,.git/,.cvsrc,.cvsignore,.gitignore,.cvspass,.cvswrappers,.deps/,autom4te.cache/,.snprj/: diff --git a/hg/.hgrc b/hg/.hgrc new file mode 100644 index 0000000..2f16f27 --- /dev/null +++ b/hg/.hgrc @@ -0,0 +1,9 @@ +[ui] +username = Alan Pearce + +[extensions] +purge = +progress = +color = +eol = +record = \ No newline at end of file diff --git a/karabiner/.config/karabiner/karabiner.json b/karabiner/.config/karabiner/karabiner.json new file mode 100644 index 0000000..0e866a6 --- /dev/null +++ b/karabiner/.config/karabiner/karabiner.json @@ -0,0 +1,63 @@ +{ + "profiles": [ + { + "devices": [ + { + "identifiers": { + "is_keyboard": true, + "is_pointing_device": false, + "product_id": 602, + "vendor_id": 1452 + }, + "ignore": true, + "keyboard_type": 41 + }, + { + "identifiers": { + "is_keyboard": true, + "is_pointing_device": false, + "product_id": 8209, + "vendor_id": 1241 + }, + "ignore": false, + "keyboard_type": 40 + } + ], + "fn_function_keys": { + "f1": "vk_consumer_brightness_down", + "f10": "mute", + "f11": "volume_down", + "f12": "volume_up", + "f2": "vk_consumer_brightness_up", + "f3": "vk_mission_control", + "f4": "vk_launchpad", + "f5": "vk_consumer_illumination_down", + "f6": "vk_consumer_illumination_up", + "f7": "vk_consumer_previous", + "f8": "vk_consumer_play", + "f9": "vk_consumer_next" + }, + "name": "Default Profile", + "selected": true, + "simple_modifications": { + "caps_lock": "delete_or_backspace", + "left_command": "left_option", + "left_control": "left_command", + "left_option": "left_control", + "right_command": "right_option", + "right_control": "right_command", + "right_option": "right_control" + } + }, + { + "name": "Macbook keyboard", + "simple_modifications": { + "caps_lock": "delete_or_backspace", + "grave_accent_and_tilde": "non_us_backslash", + "left_command": "left_control", + "non_us_backslash": "grave_accent_and_tilde", + "right_command": "right_control" + } + } + ] +} diff --git a/minttyrc/minttyrc b/minttyrc/minttyrc new file mode 100644 index 0000000..2e7f2d8 --- /dev/null +++ b/minttyrc/minttyrc @@ -0,0 +1,33 @@ +BoldAsFont=no +Font=Cousine +FontHeight=12 +FontSmoothing=default +Locale=en_GB +Charset=UTF-8 +Columns=100 +Rows=36 +Scrollbar=none +Transparency=off +OpaqueWhenFocused=no +CursorType=block +CursorBlinks=no +RightClickAction=extend +BoldBlack=0,43,54 +Black=7,54,66 +BoldGreen=88,110,117 +BoldYellow=101,123,131 +BoldBlue=131,148,150 +BoldCyan=147,161,161 +White=238,232,213 +BoldWhite=253,246,227 +Yellow=181,137,0 +BoldRed=203,75,22 +Red=220,50,47 +Magenta=211,54,130 +BoldMagenta=108,113,196 +Blue=38,139,210 +Cyan=42,161,152 +Green=133,153,0 +ForegroundColour=101,123,117 +BackgroundColour=253,246,227 +CursorColour=112,129,131 diff --git a/rcrc b/rcrc deleted file mode 100644 index 112aae6..0000000 --- a/rcrc +++ /dev/null @@ -1,3 +0,0 @@ -EXCLUDES="Brewfile LaunchAgents README.org" -DOTFILES_DIRS="$HOME/projects/dotfiles" -[ -e ~/.rcrc.local ] && . ~/.rcrc.local \ No newline at end of file diff --git a/ssh/.ssh/rc b/ssh/.ssh/rc new file mode 100755 index 0000000..59e4cfd --- /dev/null +++ b/ssh/.ssh/rc @@ -0,0 +1,5 @@ +#!/bin/sh +if [ "$SSH_AUTH_SOCK" ] +then + ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock +fi diff --git a/tag-atop/atoprc b/tag-atop/atoprc deleted file mode 100644 index d03319e..0000000 --- a/tag-atop/atoprc +++ /dev/null @@ -1,2 +0,0 @@ -flags Aa -maxlinecpu 0 \ No newline at end of file diff --git a/tag-clojure/lein/profiles.clj b/tag-clojure/lein/profiles.clj deleted file mode 100644 index 99c0de2..0000000 --- a/tag-clojure/lein/profiles.clj +++ /dev/null @@ -1,11 +0,0 @@ -{:user {:plugins [[org.clojure/tools.namespace "0.2.10"] - [lein-autoexpect "1.6.0"] - [lein-ancient "0.6.7"] - [lein-droid "0.4.0-alpha4"]] - :dependencies [[org.clojure/tools.trace "0.7.8"]] - :repl-options {:init - (do - (require '[clojure.java.javadoc :refer [javadoc]]) - (clojure.java.javadoc/add-local-javadoc - "/usr/share/doc/java8-openjdk/api/"))}} - :repl {:plugins [cider/cider-nrepl "0.9.1"]}} diff --git a/tag-dwm/dwm/config.h b/tag-dwm/dwm/config.h deleted file mode 100644 index ae1d8bb..0000000 --- a/tag-dwm/dwm/config.h +++ /dev/null @@ -1,106 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* appearance */ -static const char font[] = "-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*"; -static const char normbordercolor[] = "#657b83"; -static const char normbgcolor[] = "#002b36"; -static const char normfgcolor[] = "#fdf6e3"; -static const char selbordercolor[] = "#859900"; -static const char selbgcolor[] = "#586e75"; -static const char selfgcolor[] = "#fdf6e3"; -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ -static const Bool showbar = True; /* False means no bar */ -static const Bool topbar = True; /* False means bottom bar */ - -/* tagging */ -static const char *tags[] = { "shell", "code", "web", "misc" }; - -static const Rule rules[] = { - /* class instance title tags mask isfloating monitor */ - { "Firefox", NULL, NULL, 1 << 2, False, -1 }, - { "URxvt", NULL, NULL, 1 << 0, False, -1 }, - { "Emacs", "emacs", NULL, 1 << 1, False, -1 }, - { "KeePass2", NULL, NULL, 1 << 3, False, -1 }, - { "deadbeef", NULL, NULL, 1 << 3, False, -1 }, - { "Emacs", "Ediff", NULL, 0, True, -1 }, -}; - -/* layout(s) */ -static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ -static const int nmaster = 1; /* number of clients in master area */ -static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ - -static const Layout layouts[] = { - /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, -}; - -/* key definitions */ -#define MODKEY Mod4Mask -#define TAGKEYS(KEY,TAG) \ - { MODKEY, KEY, toggleview, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask, KEY, view, {.ui = 1 << TAG} }, \ - { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, - -/* helper for spawning shell commands in the pre dwm-5.0 fashion */ -#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } - -/* commands */ -static const char *termcmd[] = { "urxvt", NULL }; - -static Key keys[] = { - /* modifier key function argument */ - { MODKEY|ShiftMask, XK_b, togglebar, {0} }, - { MODKEY, XK_e, focusstack, {.i = +1 } }, - { MODKEY, XK_i, focusstack, {.i = -1 } }, - { MODKEY, XK_s, incnmaster, {.i = +1 } }, - { MODKEY, XK_r, incnmaster, {.i = -1 } }, - { MODKEY, XK_n, setmfact, {.f = -0.05} }, - { MODKEY, XK_o, setmfact, {.f = +0.05} }, - { MODKEY, XK_Return, zoom, {0} }, - { MODKEY, XK_Tab, view, {0} }, - { MODKEY|ShiftMask, XK_c, killclient, {0} }, - { MODKEY, XK_g, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XK_space, setlayout, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, - { MODKEY, XK_comma, focusmon, {.i = -1 } }, - { MODKEY, XK_period, focusmon, {.i = +1 } }, - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) - TAGKEYS( XK_4, 3) - TAGKEYS( XK_5, 4) - TAGKEYS( XK_6, 5) - TAGKEYS( XK_7, 6) - TAGKEYS( XK_8, 7) - TAGKEYS( XK_9, 8) - { MODKEY|ShiftMask, XK_q, quit, {0} }, - { MODKEY|ShiftMask, XK_r, quit, { .i = 5 } }, -}; - -/* button definitions */ -/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ -static Button buttons[] = { - /* click event mask button function argument */ - { ClkLtSymbol, 0, Button1, setlayout, {0} }, - { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, - { ClkClientWin, MODKEY, Button1, movemouse, {0} }, - { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, - { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, - { ClkTagBar, 0, Button1, toggleview, {0} }, - { ClkTagBar, 0, Button3, view, {0} }, - { ClkTagBar, MODKEY, Button1, tag, {0} }, - { ClkTagBar, MODKEY, Button3, toggletag, {0} }, -}; diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org deleted file mode 100644 index 151efbf..0000000 --- a/tag-emacs/emacs.d/init.org +++ /dev/null @@ -1,2522 +0,0 @@ -#+TITLE: Emacs Configuration for Alan Pearce -#+OPTIONS: ^:nil -#+PROPERTY: results silent -#+PROPERTY: eval no-export -#+PROPERTY: header-args :comments link -* Introduction -This is a living document, detailing my Emacs configuration using org-mode -* Basics -** Startup -Open Emacs with just a plain window. No graphics or messages, please! -#+BEGIN_SRC emacs-lisp -(put 'inhibit-startup-echo-area-message 'saved-value - (setq inhibit-startup-echo-area-message (user-login-name))) -(setq inhibit-startup-screen t) -(setq gc-cons-threshold 100000000) -(defvar file-name-handler-alist-backup file-name-handler-alist) -(setq file-name-handler-alist nil) -(remove-hook 'find-file-hooks #'vc-refresh-state) -#+END_SRC - -** Scratch buffers -I usually use scratch buffers for any sort of text. If I need a -programming mode in one, then I’ll just call it manually. I also like -the buffer to be empty. -#+BEGIN_SRC emacs-lisp -(setq initial-scratch-message "" - initial-major-mode 'text-mode) -#+END_SRC - -** Personal Information -#+BEGIN_SRC emacs-lisp -(setq user-mail-address "alan@alanpearce.co.uk" - user-full-name "Alan Pearce") -#+end_src - -* Packaging - -** Use-package - -#+BEGIN_SRC emacs-lisp -(eval-and-compile - (setq tls-checktrust t - gnutls-verify-error t - package-archives '(("gnu" . "https://elpa.gnu.org/packages/") - ("melpa-stable" . "https://stable.melpa.org/packages/") - ("melpa" . "https://melpa.org/packages/")) - package-user-dir (concat "~/.emacs.d/packages/" emacs-version "/elpa") - package-pinned-packages '(("use-package" . melpa-stable) - ("diminish" . melpa-stable) - ("bind-key" . melpa-stable)) - package-archive-priorities '(("melpa-stable" . 10) - ("gnu" . 10) - ("marmalade" . 5) - ("melpa" . 0)) - package-menu-async t - package-menu-hide-low-priority t) - (package-initialize) - (unless (package-installed-p 'use-package) - (package-refresh-contents) - (package-install 'use-package))) -(eval-when-compile (require 'use-package)) -(unless (featurep 'use-package) - (require 'diminish) - (require 'bind-key) - (use-package use-package - :commands (use-package-autoload-keymap) - :defer 5)) -(setq use-package-verbose t - use-package-always-ensure t - package-enable-at-startup nil) -#+END_SRC - -* Customize -I don’t really like using customize for normal configuration. -Instead, I use it for things that get saved automatically. That’s why -I use a different file, which is ignored by the VCS. It also means -that it’s not important whether the file exists or not, which is why I -pass =:noerror= to =load= - -#+BEGIN_SRC emacs-lisp -(setq custom-file "~/.emacs.d/custom.el") -(load custom-file :noerror :nomessage) -#+END_SRC - -* Styles - -I prefer an always-visible cursor. Feels less distracting. -#+BEGIN_SRC emacs-lisp -(when (fboundp #'blink-cursor-mode) - (blink-cursor-mode -1)) -#+END_SRC - -Disable all the bars, unless on OSX, in which case, keep the menu bar. - -#+BEGIN_SRC emacs-lisp -(when (and menu-bar-mode (not (eq window-system 'ns))) - (menu-bar-mode -1)) -(with-eval-after-load 'scroll-bar - (set-scroll-bar-mode nil)) -(with-eval-after-load 'tooltip - (tooltip-mode -1)) -(with-eval-after-load 'tool-bar - (tool-bar-mode -1)) -#+END_SRC - -Ring the bell sometimes, but not so often -#+BEGIN_SRC emacs-lisp -(setq ring-bell-function - (lambda () - (unless (memq this-command - '(isearch-abort abort-recursive-edit exit-minibuffer keyboard-quit undo-tree-undo)) - (ding)))) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(use-package dash) -#+END_SRC - -** Colours - -Let’s try a more minimal theme. - -#+BEGIN_SRC emacs-lisp -(use-package minimal-theme - :disabled t - :config (progn - (load-theme 'minimal-light t))) -#+END_SRC - -Let’s try a basic theme. - -#+BEGIN_SRC emacs-lisp -(use-package basic-theme - :if (display-graphic-p) - :config (progn - (load-theme 'basic t) - - (set-face-background 'mode-line "#a1b56c") - (set-face-background 'border "#a1b56c") - (set-face-foreground 'border "#a1b56c") - (set-face-background 'vertical-border "#a1b56c") - (set-face-foreground 'vertical-border "#a1b56c") - (set-face-background 'window-divider "#a1b56c") - (set-face-foreground 'window-divider "#a1b56c") - - (defvar mode-line-default-format mode-line-format) - (defvar mode-line-default-hidden nil - "Whether to hide the mode line by default") - - (defun show-mode-line () - (interactive) - (setq mode-line-format mode-line-default-format) - (when (called-interactively-p 'interactive) - (setq-default mode-line-format mode-line-default-format) - (setq mode-line-default-hidden nil))) - (defun hide-mode-line () - (interactive) - (setq mode-line-format nil) - (when (called-interactively-p 'interactive) - (setq-default mode-line-format nil) - (setq mode-line-default-hidden t))) - - (setq-default cursor-type '(bar . 1)) - (setq-default cursor-in-non-selected-windows nil) - - (defun hide-clutter () - (interactive) - (fringe-mode '(0 . 4)) - (hide-mode-line)) - - (defun show-clutter () - (interactive) - (fringe-mode '(8 . 4)) - (show-mode-line)) - (hide-clutter) - - (when mode-line-default-hidden - (call-interactively #'hide-mode-line)) - - (defun hide-mode-line-if-default-hidden () - (if mode-line-default-hidden - (hide-mode-line) - (show-mode-line))) - - (add-to-list 'default-frame-alist '(border-width . 0)) - (add-to-list 'default-frame-alist '(internal-border-width . 0)) - (when (eq window-system 'x) - (setq window-divider-default-bottom-width 1 - window-divider-default-right-width 1 - window-divider-default-places t) - (setq mode-line-default-hidden t) - (window-divider-mode +1)) - - (add-hook 'after-change-major-mode-hook #'hide-mode-line-if-default-hidden) - - (add-hook 'minibuffer-setup-hook #'show-mode-line) - (add-hook 'minibuffer-exit-hook #'hide-mode-line))) -#+END_SRC - -Highlighting quasi-quoted expressions in lisps is quite useful, but I -don't need it all the time. I'll keep it around for a while so that I -can enable it if needed. -#+BEGIN_SRC emacs-lisp -(use-package highlight-stages - :diminish highlight-stages-mode) -#+END_SRC - -** Fonts - -When possible, set up fonts. I don’t have any settings here for X11, -because I manage those in my [[file:~/projects/dotfiles/tag-xresources/xresources/main][XResources file]]. -#+BEGIN_SRC emacs-lisp -(when (or (display-graphic-p) - (daemonp)) - - (defun use-variable-fonts () - (interactive) - (variable-pitch-mode) - (setq cursor-type 'bar)) - - (defun ap/set-fonts (mono-face mono-font-size variable-face variable-font-size antialias) - (if (boundp 'ns-antialias-text) - (setq ns-antialias-text antialias)) - (when mono-face - (let ((default-font (font-spec :family mono-face :size mono-font-size))) - (add-to-list 'default-frame-alist `(font . ,(format "%s %s" mono-face mono-font-size))) - (set-face-font 'fixed-pitch default-font) - (set-frame-font default-font t t))) - (when variable-face - (set-face-font 'variable-pitch (font-spec :name variable-face :size variable-font-size)))) - - (defun ap/set-fonts-according-to-system () - (interactive) - (cond - ((eq window-system 'w32) - (ap/set-fonts "Liberation Mono" 11 "Segoe UI" 11 t)) - ((eq window-system 'ns) - (let ((displays (string-to-number (shell-command-to-string "system_profiler SPDisplaysDataType | grep \"Online: Yes\" | wc -l")))) - (if (eq displays 1) - (ap/set-fonts "Roboto Mono" 13 "Lucida Grande" 13 t) - (ap/set-fonts "Monaco" 10 "Lucida Grande" 12 nil)))) - ((eq window-system 'x) - (set-fontset-font "fontset-default" 'unicode (font-spec :name "Terminus" :size 8)) - (ap/set-fonts "Fixed" 8 "Lucida" 8 nil)))) - - (ap/set-fonts-according-to-system)) -#+END_SRC - -Reduce font decoration. I’m trying to see whether this helps me focus -on the right things. -#+BEGIN_SRC emacs-lisp -(setq font-lock-maximum-decoration '((dired-mode . 1) - (t . 1))) -#+END_SRC - -** Page Breaks - -By default, Emacs displays page breaks as ^L. Lines look much nicer. -On Windows, Emacs incorrectly detects that U+2500 (Box Drawings Light -Horizontal) can only be displayed with a different font, which is not -correct, at least for Liberation Mono. - -#+BEGIN_SRC emacs-lisp -(use-package page-break-lines - :defer 5 - :diminish page-break-lines-mode - :config (progn - (global-page-break-lines-mode) - (unless (eq (char-displayable-p ?─) (char-displayable-p ?a)) - (set-fontset-font "fontset-default" - (cons page-break-lines-char page-break-lines-char) - (face-attribute 'default :family))))) -#+END_SRC -** Modeline - -#+BEGIN_SRC emacs-lisp -(column-number-mode t) -(size-indication-mode t) - -(setq frame-title-format '("%f" (dired-directory dired-directory))) -#+END_SRC - -** Highlight Changes - -Highlight what just changed when I undo, yank, and so on. - -#+BEGIN_SRC emacs-lisp -(use-package volatile-highlights - :diminish volatile-highlights-mode - :config (progn - (volatile-highlights-mode t))) -#+END_SRC - -** Beacon - -I was against the idea of having flashy animations inside Emacs, but -this one is useful. It highlights the cursor when scrolling or -switching windows. - -#+BEGIN_SRC emacs-lisp -(use-package beacon - :diminish beacon-mode - :config (beacon-mode +1)) -#+END_SRC - -** Renaming major modes - -Diminishing major modes does not happen in the same manner as minor -modes. - -#+BEGIN_SRC emacs-lisp -(use-package cyphejor - :defer 2 - :config (progn - (setq cyphejor-rules `(("emacs" "ε") - ("diff" "Δ") - ("js2" "js") - ("magit-status" ,(char-to-string (-find #'char-displayable-p '(11942 5848 177)))) - ("inferior" "i" :prefix) - ("interaction" "i" :prefix) - ("interactive" "i" :prefix) - ("menu" "▤" :postfix) - ("ledger" "Ledger") - ("mode" "") - ("shell" "sh" :postfix))) - (cyphejor-mode 1))) -#+END_SRC - - -* Environment Variables - -MacOS doesn’t have a reasonable way to set environment variables and -read them automatically any more. So, let’s use the -[[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]] package to set up ~exec-path~ and similar -variables from whatever my shell configuration is. - -#+BEGIN_SRC emacs-lisp -(use-package exec-path-from-shell - :if (eq system-type 'darwin) - :config (exec-path-from-shell-initialize)) -#+END_SRC - -* Keybindings - -I think =set-keyboard-coding-system= stops OS X from doing something -annoying to add accents. The modifier setup is to match my -re-arrangement of modifiers on OSX: Cmd on the outside, then -Option/alt, then Control. - -#+BEGIN_SRC emacs-lisp -(when (eq system-type 'darwin) - (set-keyboard-coding-system nil) - (custom-set-variables - '(mac-option-modifier 'meta) - '(mac-right-option-modifier 'none) - '(mac-control-modifier 'control) - '(mac-right-control-modifier 'left) - '(mac-command-modifier 'super) - '(mac-right-command-modifier 'left) - '(mac-function-modifier 'hyper)) - (unbind-key "s-x")) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(unbind-key "") -(bind-key* "" #'compile) -(bind-key* "" #'kmacro-start-macro-or-insert-counter) -(bind-key* "" #'kmacro-end-or-call-macro) - -(bind-key* "" #'execute-extended-command) - -(unbind-key "C-z") -(bind-key* "C-" #'other-window) - -(bind-key* "C-x C-r" #'revert-buffer) -(bind-key* "C-x C-j" #'delete-indentation) -(unbind-key "C-x C-c") - -(bind-key* "C-c i" #'insert-char) -(bind-key* "M-/" #'hippie-expand) - -(unbind-key "s-h") -(unbind-key "s-n") -(unbind-key "s-p") -(unbind-key "s-w") -(bind-key* "s-k" #'kill-or-delete-this-buffer-dwim) - -(bind-key "C-M-a" #'backward-paragraph text-mode-map) -(bind-key "C-M-e" #'forward-paragraph text-mode-map) - -(bind-key* "s-x" (define-prefix-command 'super-x-map)) -(bind-key* "s-," #'switch-to-dotfiles) -(bind-key* "C-M-x" #'execute-extended-command) -(set-register ?z `(file . ,(expand-file-name ".config/zsh/zshrc" "~"))) -#+END_SRC - -** Crux - -I can replace most of the simple helper/wrapper functions in my -configuration with crux.el - -#+BEGIN_SRC emacs-lisp -(use-package crux - :bind (("M-o" . crux-smart-open-line-above) - ("C-o" . crux-smart-open-line) - - ("C-x 4 t" . crux-transpose-windows) - ("C-c e" . crux-eval-and-replace) - ("C-c D" . crux-delete-file-and-buffer) - ("C-c R" . crux-rename-file-and-buffer)) - :init (progn - (defalias 'delete-current-buffer-file #'crux-delete-file-and-buffer) - (defalias 'rename-current-buffer-file #'crux-rename-file-and-buffer))) -#+END_SRC - -* Projects - -#+BEGIN_SRC emacs-lisp -(defvar work-project-directory "~/work") -(defvar home-project-directory "~/projects") -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(defun switch-to-dotfiles () - (interactive) - (projectile-switch-project-by-name (expand-file-name "dotfiles" home-project-directory))) -#+END_SRC - -** The Silver Searcher - -#+BEGIN_SRC emacs-lisp -(use-package ag - :defer 30 - :config (setq ag-project-root-function #'projectile-project-root)) - -(use-package wgrep-ag - :after ag) -#+END_SRC - -** Ripgrep - -Step over Silver Search, here comes a new challenger. - -#+BEGIN_SRC emacs-lisp -(use-package ripgrep - :if (executable-find "rg")) - -(use-package projectile-ripgrep - :after (ripgrep projectile) - :if (executable-find "rg") - :bind (("C-c p s r" . projectile-ripgrep))) -#+END_SRC - -** Projectile - -Projectile is awesome for working in projects, especially VCS-backed -ones. I added a couple of functions to allow me to open new projects -based upon some folder conventions I use. - -#+BEGIN_SRC emacs-lisp -(use-package projectile - :bind (("s-p" . projectile-switch-project) - ("C-c C-f" . projectile-find-file) - ("s-x s-f" . projectile-find-file) - ("C-x g" . projectile-vc) - ("s-G" . projectile-vc)) - :demand t - :diminish projectile-mode - :config (progn - (projectile-global-mode) - (add-to-list 'projectile-globally-ignored-directories ".stversions") - (defun ap/subfolder-projects (dir) - (--map (file-relative-name it dir) - (-filter (lambda (subdir) - (--reduce-from (or acc (funcall it subdir)) nil - projectile-project-root-files-functions)) - (-filter #'file-directory-p (directory-files dir t "\\<"))))) - - (defun ap/open-subfolder-project (from-dir &optional arg) - (let ((project-dir (projectile-completing-read "Open project: " - (ap/subfolder-projects from-dir)))) - (projectile-switch-project-by-name (expand-file-name project-dir from-dir) arg))) - - (defun yarn-install (&optional arg) - (interactive "P") - (projectile-with-default-dir (projectile-project-root) - (cmd-to-echo "yarn" "install"))) - - (defun yarn-add-dev (package) - (interactive "spackage: ") - (projectile-with-default-dir (projectile-project-root) - (cmd-to-echo "yarn" (concat "add --dev " package)))) - - (defun yarn-add (package) - (interactive "spackage: ") - (projectile-with-default-dir (projectile-project-root) - (cmd-to-echo "yarn" (concat "add " package)))) - - (defun ap/open-work-project (&optional arg) - (interactive "P") - (ap/open-subfolder-project work-project-directory arg)) - - (defun ap/open-home-project (&optional arg) - (interactive "P") - (ap/open-subfolder-project home-project-directory arg)) - - (setq projectile-switch-project-action #'projectile-commander - projectile-completion-system 'ivy))) -#+END_SRC - -** vc - -This is nice for some things that magit doesn’t do, and for those rare -occasions that I’m working with something other than git. - -#+BEGIN_SRC emacs-lisp -(use-package vc - :defer t - :bind (("C-x v C" . vc-resolve-conflicts)) - :config (progn - (setq vc-follow-symlinks t) - (setq vc-ignore-dir-regexp (format "\\(%s\\)\\|\\(%s\\)" - vc-ignore-dir-regexp - tramp-file-name-regexp)))) -#+END_SRC - -** git-gutter-fringe - -It’s nice to be able to see at a glance which lines of a file have -changed. This package colours the fringe. I have it set to the right -fringe so it doesn’t interfere with flycheck. - -#+BEGIN_SRC emacs-lisp -(use-package git-gutter-fringe - :defer 2 - :diminish git-gutter-mode - :config (progn - (global-git-gutter-mode 1) - (set-face-foreground 'git-gutter:modified "grey") - (setq git-gutter-fr:side 'right-fringe))) -#+END_SRC - -** magit - -Magit is my favourite way to use git. I use selective staging all the -time. Make sure to set it up with a nice =completing-read-function= - -#+BEGIN_SRC emacs-lisp -(use-package magit - :defer 5 - :commands (magit-status) - :config (progn (setq magit-completing-read-function #'ivy-completing-read - magit-popup-use-prefix-argument 'default - magit-display-buffer-function #'magit-display-buffer-fullcolumn-most-v1 - global-magit-file-mode nil) - (add-to-list 'magit-no-confirm 'safe-with-wip)) - :init (add-hook 'magit-mode-hook #'magit-load-config-extensions)) -#+END_SRC - -** git-timemachine - -This package allow me to go through a file’s history with just a few -keys. It makes it very easy to figure what what exactly was in a file -in the past. I often find it useful when I remember writing something -a particular way, but it changed later. - -#+BEGIN_SRC emacs-lisp -(use-package git-timemachine - :commands git-timemachine) -#+END_SRC - -* Files - -** Auto-saving - -Auto-save everything to a temporary directory, instead of cluttering -the filesystem. I don’t want emacs-specific lockfiles, either. - -#+BEGIN_SRC emacs-lisp -(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)) - create-lockfiles nil) -#+END_SRC -** Backups - -I like to keep my backups out of regular folders. I tell emacs to use -a subfolder of its configuration directory for that. Also, use the -trash for deleting on OS X. -#+BEGIN_SRC emacs-lisp -(let ((backup-dir (expand-file-name "~/.emacs.d/backups/"))) - (unless (file-directory-p backup-dir) - (make-directory backup-dir)) - (setq backup-directory-alist `((".*" . ,backup-dir)) - backup-by-copying-when-linked t - backup-by-copying-when-mismatch t)) -(if (eq system-type 'darwin) - (setq delete-by-moving-to-trash t) - (if (and (executable-find "trash") (not (fboundp #'system-move-file-to-trash))) - (defun system-move-file-to-trash (file) - (call-process (executable-find "trash") - nil 0 nil - file)))) -#+END_SRC - -** autorevert - -#+BEGIN_SRC emacs-lisp -(use-package autorevert - :diminish auto-revert-mode - :init (progn - (global-auto-revert-mode 1) - (setq auto-revert-verbose nil - auto-revert-use-notify (not (eq system-type 'darwin))))) -#+END_SRC - -** Encoding - -UTF-8 is usually appropriate. Note that =prefer-coding-system= expects -only a coding system, not a coding system and line ending combination. - -#+BEGIN_SRC emacs-lisp -(prefer-coding-system 'utf-8) -(setq-default buffer-file-coding-system 'utf-8-auto-unix) -#+END_SRC - -** Buffer-file management - -Ask if I want to create a directory when it doesn’t exist. This is -especially nice when starting new projects. - -#+BEGIN_SRC emacs-lisp -(defun my-create-non-existent-directory () - (let ((parent-directory (file-name-directory buffer-file-name))) - (when (and (not (file-exists-p parent-directory)) - (y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory))) - (make-directory parent-directory t)))) -(add-to-list 'find-file-not-found-functions #'my-create-non-existent-directory) -#+END_SRC - -I often want to rename or delete the file that I’m currently visiting -with a buffer. - -#+BEGIN_SRC emacs-lisp -(defun kill-or-delete-this-buffer-dwim (&optional arg) - "Kills current buffer. With prefix arg, delete it." - (interactive "P") - (if (equal arg '(4)) - (delete-current-buffer-file) - (if server-buffer-clients - (server-edit) - (let ((buf (buffer-name))) - (when (equal buf "*HTTP Response*") - (other-window 1)) - (kill-buffer buf))))) -#+END_SRC - -** Whitespace Butler - -I don’t like it when editors change an entire file’s layout when I -open it. Whitespace butler fixes whitespace only for lines that I’m editing. - -#+BEGIN_SRC emacs-lisp -(use-package ws-butler - :if window-system - :diminish ws-butler-mode - :config (ws-butler-global-mode 1)) -(if (daemonp) - (add-hook 'before-make-frame-hook (lambda () - (use-package ws-butler - :config (ws-butler-global-mode 1))))) -#+END_SRC - -** shrink-whitespace - -DWIM whitespace removal. So I don’t need =M-SPC=, =M-\= and =C-x o= -for similar things any more. - -#+BEGIN_SRC emacs-lisp -(use-package shrink-whitespace - :bind ("M-SPC" . shrink-whitespace)) -#+END_SRC - -** Tramp - -Tramp is awesome. It makes SSH feel Unix-y. The proxy setup is so -that I can sudo on remote machines - -#+BEGIN_SRC emacs-lisp -(use-package tramp - :defer 7 - :config (progn - (unless (getenv "SSH_AUTH_SOCK") - (setenv "SSH_AUTH_SOCK" (format "/run/user/%s/ssh-agent" (user-uid)))) - (setq tramp-default-method "ssh" - tramp-default-user-alist '(("\\`su\\(do\\)?\\'" nil "root")) - tramp-backup-directory-alist backup-directory-alist - tramp-completion-reread-directory-timeout 60 - tramp-ssh-controlmaster-options nil - backup-enable-predicate (lambda (name) - (and (normal-backup-enable-predicate name) - (not (let ((method (file-remote-p name 'method))) - (when (stringp method) - (member method '("su" "sudo"))))))) - tramp-shell-prompt-pattern "\\(?:^\\| \\)[^]#$%>\n]*#?[]#$%>❯›] *\\(\\[\\??[0-9;]*[a-zA-Z] *\\)*") - (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" (concat "/" tramp-default-method ":%h:"))) - (add-to-list 'tramp-default-proxies-alist `(,(regexp-quote (system-name)) nil nil)) - (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)))) - -(use-package tramp-sh - :ensure nil - :defer t - :config (progn - (add-to-list 'tramp-remote-path "/usr/local/sbin") - (add-to-list 'tramp-remote-path "~/bin"))) -#+END_SRC - -** ediff - -I like a horizonal diff setup, with everything in one frame. - -#+BEGIN_SRC emacs-lisp -(use-package ediff - :defer t - :config (progn - (setq ediff-split-window-function 'split-window-horizontally - ediff-window-setup-function 'ediff-setup-windows-plain))) -#+END_SRC - -* Indentation - -Ah, a complicated topic. One day we’ll all be using elastic -tabstops. I’ve recently switched to using two spaces, since elastic -tabstops is probably never going to happen. - -#+BEGIN_SRC emacs-lisp -(setq-default tab-width 2 - indent-tabs-mode nil) -#+END_SRC - - -** smart-tabs-mode - -Not related to [[smart-tab][=smart-tab=]], this mode indents with tabs and aligns -with spaces. Perfect! - -#+BEGIN_SRC emacs-lisp -(use-package smart-tabs-mode - :defer 1 - :config (progn - (smart-tabs-insinuate 'c 'cperl 'python) - (add-hook 'php-mode-hook (lambda () - (smart-tabs-mode indent-tabs-mode))))) -#+END_SRC - -** editorconfig - -#+BEGIN_SRC emacs-lisp -(use-package editorconfig - :config (editorconfig-mode 1)) -#+END_SRC - -** dtrt-indent-mode - -Sometimes people use different indentation settings. [[https://github.com/jscheid/dtrt-indent][dtrt-indent]] -guesses the correct settings for me. - -#+BEGIN_SRC emacs-lisp -(use-package dtrt-indent - :config (progn - (defun ap/dtrt-adapt-if-needed () - (unless editorconfig-mode - (dtrt-indent-adapt))) - (if (fboundp #'editorconfig-mode) - (add-hook 'after-change-major-mode-hook #'ap/dtrt-adapt-if-needed) - (add-hook 'after-change-major-mode-hook #'dtrt-indent-adapt)) - (defadvice dtrt-indent-try-set-offset (after toggle-smart-tabs activate) - (smart-tabs-mode (or indent-tabs-mode -1))))) -#+END_SRC - -* Security - -** password-store - -This is a frontend to the GPG-powered =pass= program. -#+BEGIN_SRC emacs-lisp -(use-package password-store - :defer 15 - :config (progn - (setq password-store-password-length 16))) -#+END_SRC -* Buffers - -** Ibuffer -Ibuffer is quite nice for listing all buffers. - -#+BEGIN_SRC emacs-lisp -(use-package ibuffer - :bind (("C-x C-b" . ibuffer)) - :config (progn - (setq ibuffer-saved-filter-groups - (quote (("default" - ("org" (mode . org-mode)) - ("emacs" (mode . emacs-lisp-mode)) - ("zsh" (filename . "/zsh")) - ("server" (filename . "/su:root@server")))))) - - ;; Human-readable base-2 size column - (define-ibuffer-column size-h - (:name "Size" :inline t) - (cond - ((> (buffer-size) 1024) - (format "%7.2fK" (/ (buffer-size) 1024.0))) - ((> (buffer-size) 1048576) - (format "%7.2fM" (/ (buffer-size) 1048576.0))) - (t - (format "%8d" (buffer-size))))) - - (setq ibuffer-formats - '((mark modified read-only " " - (name 18 18 :left :elide) - " " - (size-h 9 -1 :right) - " " - (mode 16 16 :left :elide) - " " - filename-and-process))))) -#+END_SRC - -** Relative Buffer names - -#+BEGIN_SRC emacs-lisp -(use-package relative-buffers - :defer 15 - :config (progn - (global-relative-buffers-mode))) -#+END_SRC -** Narrowing - -Enable it without prompting - -#+BEGIN_SRC emacs-lisp -(put 'narrow-to-defun 'disabled nil) -(put 'narrow-to-page 'disabled nil) -(put 'narrow-to-region 'disabled nil) -#+END_SRC - -** ace-window - -I don’t often have many windows open at once, but when I do, -=ace-window= is really nice to jump around them in the same way that -=ace-jump= or =avy= work. -#+BEGIN_SRC emacs-lisp -(use-package ace-window - :bind (("s-s" . ace-window)) - :config (progn - (setq aw-dispatch-always t - aw-dispatch-alist '((?k aw-delete-window " Ace - Delete Window") - (?K aw-delete-window) - (?m aw-swap-window " Ace - Swap Window") - (?f aw-flip-window) - (?v aw-split-window-vert " Ace - Split Vert Window") - (?b aw-split-window-horz " Ace - Split Horz Window") - (?m delete-other-windows " Ace - Maximize Window") - (?l delete-other-windows) - (?, winner-undo) - (?. winner-redo)) - aw-keys '(?a ?r ?s ?t ?n ?e ?i ?o)))) -#+END_SRC - -* Windows - -Scrolling is tricky. I use this setup to help me keep track of the -point whilst I’m moving about. - -#+BEGIN_SRC emacs-lisp -(setq scroll-conservatively 100 - scroll-margin 1 - scroll-preserve-screen-position t - mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control))) - split-height-threshold 80 - split-width-threshold 160 - frame-resize-pixelwise nil) -(if (boundp 'ns-pop-up-frames) - (setq ns-pop-up-frames nil)) -#+END_SRC - -** winner - -Undo, for window-based commands. - -#+BEGIN_SRC emacs-lisp -(use-package winner - :config (setq winner-boring-buffers '("*Completions*" "*Help*" "*Apropos*" "*Buffer List*" "*info*" "*Compile-Log*")) - :init (progn - (winner-mode 1))) -#+END_SRC - -** windmove - -Directional window movement - -#+BEGIN_SRC emacs-lisp -(use-package windmove - :bind (("S-" . windmove-left) - ("S-" . windmove-right) - ("S-" . windmove-up) - ("S-" . windmove-down))) -#+END_SRC -* Completion - -Make built-in completion a bit more intelligent, by adding substring -and initial-based completion and ignoring case. - -#+BEGIN_SRC emacs-lisp -(setq completion-styles '(basic initials partial-completion substring) - completion-ignore-case t - tab-always-indent 'complete) -#+END_SRC - -** Company - -The main choices for automatic completion in Emacs are company and -auto-complete-mode. I’ve not tried auto-complete-mode as company -seems to work perfectly well for me. - -#+BEGIN_SRC emacs-lisp -(use-package company - :commands (company-mode) - :diminish "Cmpl" - :bind (("C-" . company-complete) - ("TAB" . company-indent-or-complete-common)) - :init (progn - (add-hook 'prog-mode-hook #'company-mode) - (setq company-backends '(company-bbdb company-web-html company-tern company-nxml company-css company-eclim company-semantic company-elisp - company-clang company-xcode company-cmake company-capf - company-files (company-gtags - company-etags company-keywords) company-oddmuse) - company-frontends '(company-pseudo-tooltip-unless-just-one-frontend - company-preview-frontend - company-echo-metadata-frontend) - company-idle-delay .3 - company-begin-commands '(self-insert-command) - company-auto-complete #'company-explicit-action-p - company-auto-complete-chars '(?\ ?\( ?\) ?.) - company-tooltip-align-annotations t))) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(use-package company-web - :after company) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(use-package company-nixos-options - :if (eq system-type 'gnu/linux) - :config (progn - (add-to-list 'company-backends 'company-nixos-options))) -#+END_SRC - -* Dates & Times - -** Calendar - -Weeks start on Monday for me and I prefer ISO-style dates. -#+BEGIN_SRC emacs-lisp -(use-package calendar - :defer 1 - :config (progn - (setq calendar-week-start-day 1) - (calendar-set-date-style 'iso))) -#+END_SRC - -Sometimes I want to insert a date or time into a buffer. -#+BEGIN_SRC emacs-lisp -(defun insert-date (prefix) - "Insert the current date. With prefix-argument, use British format. With - two prefix arguments, write out the day and month name." - (interactive "P") - (let ((format (cond - ((not prefix) "%Y-%m-%d") - ((equal prefix '(4)) "%d/%m/%Y") - ((equal prefix '(16)) "%A, %d %B %Y")))) - (insert (format-time-string format)))) - -(defun insert-datetime (prefix) - "Insert the current date and time." - (interactive "P") - (let ((format (cond - ((not prefix) "%Y-%m-%d %H:%M:%S") - ((equal prefix '(4)) "%Y-%m-%dT%H:%M:%SZ")))) - (insert (format-time-string format)))) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(defun yesterday-time () - "Provide the date/time 24 hours before the time now in the format of current-time." - (timer-relative-time (current-time) -86400)) -#+END_SRC - -* Directories - -Dired works quite nicely, but not always in the way I want. I don’t -like having so many prompts for recursive operations. Also, when I -have two dired windows open, assume that I’m going to be -copying/moving files between them. - -#+BEGIN_SRC emacs-lisp -(use-package dired - :defer 3 - :ensure nil - :config (progn - (bind-key "" #'dired-find-file dired-mode-map) - (bind-key "^" (lambda () (interactive) (find-alternate-file "..")) dired-mode-map) - (setq dired-dwim-target t - dired-recursive-copies 'top - dired-recursive-deletes 'top - dired-listing-switches "-alh") - (when (and (eq system-type 'darwin) (executable-find "gls")) - (setq insert-directory-program (executable-find "gls"))) - (put 'dired-find-alternate-file 'disabled nil))) -#+END_SRC - -Don’t show uninteresting files in dired listings. - -#+BEGIN_SRC emacs-lisp -(defun turn-on-dired-omit-mode () - (interactive) - (dired-omit-mode 1)) - -(use-package dired-x - :commands (dired-omit-mode - dired-expunge) - :ensure nil - :config (progn - (setq dired-omit-files "#\\|\\.$" - dired-omit-verbose nil - dired-find-subdir t - dired-bind-jump nil)) - :init (progn - (add-hook 'dired-mode-hook #'turn-on-dired-omit-mode))) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(use-package dired+ - :defer 5 - :config (progn - (diredp-toggle-find-file-reuse-dir 1) - (unbind-key "C-h C-m" dired-mode-map))) -#+END_SRC - -Expand subfolders like a tree inside the parent - -#+BEGIN_SRC emacs-lisp -(with-eval-after-load 'dired - (use-package dired-subtree - :functions (dired-subtree--get-ov - dired-subtree-maybe-up) - :init (progn - (setq dired-subtree-use-backgrounds nil) - (defun dired-subtree-maybe-up () - "Jump up one subtree or directory" - (interactive) - (let ((ov (dired-subtree--get-ov))) - (if ov - (progn (goto-char (overlay-start ov)) - (dired-previous-line 1)) - (dired-up-directory)))) - (bind-key "^" #'dired-subtree-maybe-up dired-mode-map) - (bind-key "i" #'dired-subtree-toggle dired-mode-map)))) -#+END_SRC - -** Dired-narrow -One can already use dired with wildcards to browse a filtered -directory listing, but it opens a new buffer. Dired-narrow is a -slightly nicer interface: with a currently-open dired buffer, use =/= -to start filtering, =RET= to complete the filter and =g= to refresh -the buffer, removing the filter. - -#+BEGIN_SRC emacs-lisp -(with-eval-after-load 'dired - (use-package dired-narrow - :bind (:map dired-mode-map - ("/" . dired-narrow)))) -#+END_SRC - -* Documentation - -** ehelp - -ehelp is a less well-known package that’s part of Emacs and slightly -improves the normal help commands, mostly by making quitting them easier. - -#+BEGIN_SRC emacs-lisp -(use-package ehelp - :bind-keymap ("C-h" . ehelp-map)) -#+END_SRC -** counsel-dash - -Emacs’ documentation is great to read from inside Emacs. Counsel-dash -helps to make documentation for other languages easier to access - -#+BEGIN_SRC emacs-lisp -(defmacro ap/create-counsel-dash-hook (mode docsets) - (let* ((mode-s (symbol-name mode)) - (fun (intern (concat "counsel-dash-hook-" mode-s))) - (hook (intern (concat mode-s "-mode-hook")))) - `(progn - (defun ,fun () - (when (require 'counsel-dash nil :noerror) - (-each (-difference ',docsets - (helm-dash-installed-docsets)) - #'counsel-dash-install-docset) - (setq-local counsel-dash-docsets ',docsets))) - (add-hook (quote ,hook) (function ,fun))))) - -(use-package counsel-dash - :defer 20 - :defines counsel-dash-docsets - :config (progn - (setq counsel-dash-browser-func #'eww) - (ap/create-counsel-dash-hook nginx ("Nginx")) - (ap/create-counsel-dash-hook ansible ("Ansible")) - (ap/create-counsel-dash-hook php ("PHP" "Symfony")) - (ap/create-counsel-dash-hook twig ("Twig")) - (ap/create-counsel-dash-hook js2 ("JavaScript" "NodeJS" "jQuery" "Express" "SailsJS" "Lo-Dash")) - (ap/create-counsel-dash-hook markdown ("Markdown")) - (ap/create-counsel-dash-hook saltstack ("SaltStack")) - (ap/create-counsel-dash-hook clojure ("Clojure")) - (ap/create-counsel-dash-hook sql ("PostgreSQL" "MySQL")))) -#+END_SRC - -** discover-my-major - -A nicer way to browse keybindings for major modes. - -#+BEGIN_SRC emacs-lisp -(use-package discover-my-major - :bind ("" . discover-my-major)) -#+END_SRC - -** which-key - -Popup keybindings following a prefix automatically. - -#+BEGIN_SRC emacs-lisp -(use-package which-key - :diminish which-key-mode - :config (progn - (which-key-mode 1) - (which-key-setup-side-window-right-bottom))) -#+END_SRC - -** eldoc - -Documentation in the echo-area (where the minibuffer is displayed) is -rather useful. - -#+BEGIN_SRC emacs-lisp -(use-package eldoc - :commands (eldoc-mode) - :diminish eldoc-mode - :config (progn - (setq eldoc-idle-delay 0.1) - (eldoc-add-command 'paredit-backward-delete 'paredit-close-round))) -#+END_SRC -* Misc - -#+BEGIN_SRC emacs-lisp -(defvar *init-file* - (let ((init-file (or user-init-file - (expand-file-name "init.el" user-emacs-directory)))) - (expand-file-name "init.el" - (file-name-directory (file-truename init-file)))) - "Where the emacs init file really is, passing through symlinks.") -(set-register ?e `(file . ,*init-file*)) - -(defun ap/remove-extra-cr () - "Remove extraneous CR codes from a file" - (interactive) - (save-excursion - (goto-char (point-min)) - (while (search-forward " - " nil t) - (replace-match "")))) - -(use-package rect - :ensure nil - :init (defun copy-rectangle (start end) - "Copy the region-rectangle." - (interactive "r") - (setq killed-rectangle (extract-rectangle start end)))) - -(defun shell-execute (to-current-buffer) - (interactive "P") - (let ((file-buffer (if (buffer-file-name) - (file-name-nondirectory (buffer-file-name)) - "")) - (command (read-shell-command "Shell command: " nil nil nil))) - (shell-command (replace-regexp-in-string "%" file-buffer command) to-current-buffer))) - -(defun process-exit-code (program &rest args) - "Run PROGRAM with ARGS and return the exit code" - (apply 'call-process program nil nil nil args)) - -(defun narrow-to-region-indirect (start end) - "Restrict editing in this buffer to the current region, indirectly." - (interactive "r") - (deactivate-mark) - (let ((buf (clone-indirect-buffer nil nil))) - (with-current-buffer buf - (narrow-to-region start end)) - (switch-to-buffer buf))) - -(bind-key* "M-!" #'shell-execute) -(bind-key* "C-x r M-w" #'copy-rectangle) -#+END_SRC - -** Auxillary Configuration - -#+BEGIN_SRC emacs-lisp -(require 'pinentry) - -(defvar have-private-key - (file-exists-p (expand-file-name "secring.gpg" "~/.gnupg/"))) - -(defvar gpg-agent-ssh-sock - (or (getenv "GPG_AGENT_INFO") - (concat "/run/user/" (number-to-string (user-uid)) "/gnupg/S.gpg-agent.ssh"))) - -(defun read-gpg-file (file) - (let ((file-to-decrypt (expand-file-name file user-emacs-directory)) - (ctx (epg-make-context epa-protocol))) - (if (file-exists-p file-to-decrypt) - (epg-decrypt-file ctx file-to-decrypt nil) - (message "Decrypting %s...failed" file-to-decrypt) - (error "File %s does not exist" file-to-decrypt)))) - -(defun load-gpg (file) - (if have-private-key - (load file) - (message "WARNING: Couldn't load %s (No gpg key found)" file))) - -; load this in a post-frame hook because gpg-agent asks for a password on first -; startup and caches it. Don't want emacs daemon to hang because of gpg-agent. -(defun load-private-data () - (interactive) - (if (not have-private-key) - (message "ERROR: Private GPG key not found") - (unless (or (getenv "GPG_AGENT_INFO") - (getenv "SSH_AUTH_SOCK")) - (start-process "gpg-agent" nil "gpg-agent" "--daemon") - (setenv "SSH_AUTH_SOCK" gpg-agent-ssh-sock)) - (setq password-cache-expiry nil) - (unless (file-exists-p (concat pinentry--socket-dir "pinentry")) - (pinentry-start) - (add-hook 'kill-emacs-hook 'pinentry-stop)) - (add-to-list 'load-suffixes ".el.gpg") - (load-gpg (expand-file-name "private" user-emacs-directory)))) - -(defun first-frame-hook (frame) - (remove-hook 'after-make-frame-functions #'first-frame-hook) - (run-at-time nil nil 'load-private-data)) - -(if (eq 1 (length (frame-list))) - (add-hook 'after-init-hook #'load-private-data) - (add-hook 'after-make-frame-functions #'first-frame-hook)) -#+END_SRC - -* Minibuffer - -Sometimes I want to use the minibuffer, but I’m already inside it. -Fortunately, this is possible. Of course, I need to know how many -minibuffers there are on the stack. - -#+BEGIN_SRC emacs-lisp -(setq enable-recursive-minibuffers t) -(minibuffer-depth-indicate-mode t) -#+END_SRC - -This avoids some issue with the minibuffer and the point being behind -the prompt. I don’t remember what exactly. -#+BEGIN_SRC emacs-lisp -(setq minibuffer-prompt-properties '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)) -#+END_SRC - -Occasionally, I exit emacs. I should probably reduce the frequency of this. -#+BEGIN_SRC emacs-lisp -(if (daemonp) - (defalias 'exit-emacs #'delete-frame) - (defalias 'exit-emacs #'save-buffers-kill-emacs)) -#+END_SRC - -** swiper/ivy - -Ivy is the new kid on the completion block. It seems to be a strong -replacement for helm so far. - -#+BEGIN_SRC emacs-lisp -(use-package swiper - :bind (("C-s" . swiper) - ("C-r" . swiper) - ("C-x i" . ivy-imenu-goto) - ("C-=" . swiper)) - :diminish ivy-mode - :demand t - :config (progn - (ivy-mode 1) - (setq ivy-re-builders-alist '((internal-complete-buffer . ivy--regex-fuzzy) - (t . ivy--regex-plus))) - (defun ivy-imenu-get-candidates-from (alist &optional prefix) - (cl-loop for elm in alist - nconc (if (imenu--subalist-p elm) - (ivy-imenu-get-candidates-from - (cl-loop for (e . v) in (cdr elm) collect - (cons e (if (integerp v) (copy-marker v) v))) - (concat prefix (if prefix ".") (car elm))) - (and (cdr elm) ; bug in imenu, should not be needed. - (setcdr elm (copy-marker (cdr elm))) ; Same as [1]. - (list (cons (concat prefix (if prefix ".") (car elm)) - (copy-marker (cdr elm)))))))) - - (defun ivy-imenu-goto () - "Go to buffer position" - (interactive) - (let ((imenu-auto-rescan t) items) - (unless (featurep 'imenu) - (require 'imenu nil t)) - (setq items (imenu--make-index-alist t)) - (ivy-read "imenu items:" - (ivy-imenu-get-candidates-from (delete (assoc "*Rescan*" items) items)) - :action (lambda (k) (goto-char k))))) - (ivy-set-actions 'ivy-switch-buffer '(("k" (lambda (x) - (kill-buffer x) - (ivy--reset-state ivy-last)) - "kill"))) - (add-to-list 'ivy-initial-inputs-alist '(counsel-M-x . "")))) -#+END_SRC - -** counsel - -#+BEGIN_SRC emacs-lisp -(use-package counsel - :config (progn - (bind-key "M-x" #'counsel-M-x) - (bind-key "" #'counsel-M-x) - (bind-key "" #'counsel-M-x) - (bind-key "C-c M-x" #'execute-extended-command) - (bind-key "C-x C-f" #'counsel-find-file) - (bind-key "M-y" #'counsel-yank-pop) - (bind-key "M-y" #'ivy-next-line ivy-minibuffer-map) - (defadvice counsel-find-file (after find-file-sudo activate) - "Find file as root if necessary." - (when (and buffer-file-name - (not (file-writable-p buffer-file-name))) - (message "File not writable %s" buffer-file-name) - (find-alternate-file (concat "/sudo::" buffer-file-name)))))) -#+END_SRC - - -** smex - -Smex is my favourite way to use =M-x=. Counsel’s =counsel-M-x= -function uses it internally, so I’m keeping it around, even though I -don’t use it directly. - -#+BEGIN_SRC emacs-lisp -(use-package smex - :commands (smex - smex-update - smex-initialize) - :config (progn - (setq smex-key-advice-ignore-menu-bar t - smex-auto-update nil) - (defun smex-update-after-load (_unused) - (if (boundp 'smex-cache) - (smex-update))) - (add-hook 'after-load-functions 'smex-update-after-load)) - :init (progn - (setq smex-history-length 100 - smex-save-file (concat user-emacs-directory - "smex-items")))) -#+END_SRC - -** cmd-to-echo - -I’ve been looking for some way to run programming projects (mostly -node.js) inside emacs. =cmd-to-echo= seems great for this, as new -output pops up in the echo area. - -#+BEGIN_SRC emacs-lisp -(use-package cmd-to-echo - :commands (cmd-to-echo) - :config (setq cmd-to-echo-add-output-to-process-buffers t)) -#+END_SRC -* Modes - -Setup some modes for systemd files -#+BEGIN_SRC emacs-lisp -(add-to-list 'auto-mode-alist '("\\.service\\'" . conf-mode)) -(add-to-list 'auto-mode-alist '("\\.target\\'" . conf-mode)) -(add-to-list 'auto-mode-alist '("\\.socket\\'" . conf-mode)) -#+END_SRC - -=direnv=’s files are basically shell scripts, it’s a nice way to -set environment variables for projects. -#+BEGIN_SRC emacs-lisp -(add-to-list 'auto-mode-alist '("\\.envrc\\'" . sh-mode)) -#+END_SRC - -Some modes that I don’t really customise much, mostly for -configuration files. -#+BEGIN_SRC emacs-lisp -(use-package xrdb-mode - :ensure nil - :mode (("\\.Xdefaults\\'" . xrdb-mode) - ("\\.Xresources\\'" . xrdb-mode))) - -(use-package haskell-mode - :mode (("\\.hs\\'" . haskell-mode))) - -(use-package dockerfile-mode - :mode (("Dockerfile\\'" . dockerfile-mode))) - -(use-package nix-mode - :mode (("\\.nix\\'" . nix-mode))) - -(define-derived-mode xmonad-mode haskell-mode "XM") -(add-to-list 'auto-mode-alist '("xmobarrc\\'" . xmonad-mode)) -(add-to-list 'auto-mode-alist '("xmonad.hs\\'" . xmonad-mode)) - -(use-package nginx-mode - :defer t - :mode (("/nginx/servers/" . nginx-mode) - ("/nginx/.*\\.d/" . nginx-mode))) - -(use-package lua-mode - :defer t) - -(use-package ruby-mode - :mode (("\\.rb\\'" . ruby-mode) - ("\\.cap\\'" . ruby-mode))) - -(use-package go-mode - :mode (("\\.go\\'" . go-mode))) - -(use-package jinja2-mode - :mode (("\\.j2\\'" . jinja2-mode) - ("\\.jinja\\'" . jinja2-mode))) - -(use-package scss-mode - :defer t - :config (progn - (setq scss-compile-at-save nil))) - -(use-package yaml-mode - :mode (("/group_vars/.*" . yaml-mode) - ("/host_vars/.*" . yaml-mode))) - -(define-derived-mode ansible-mode yaml-mode "Ansible") -(add-to-list 'auto-mode-alist '("\\(?:ansible.+\\|roles/.+/\\(?:tasks\\|handlers\\)\\)/.+\\.yml\\'" . ansible-mode)) - -(define-derived-mode saltstack-mode yaml-mode "Salt") -(add-to-list 'auto-mode-alist '("\\.sls\\'" . saltstack-mode)) -#+END_SRC - -** ledger - -I use [[http://ledger-cli.org/][=ledger=]] to manage my finances. It has an Emacs mode, which -works really nicely. - -#+BEGIN_SRC emacs-lisp -(use-package ledger-mode - :mode ("\\.ledger\\'" . ledger-mode) - :init (progn - (defun open-budget () - (interactive) - (projectile-switch-project-by-name "~/Sync/Default") - (find-file (expand-file-name "ledger/my.ledger" (projectile-project-root))) - (ledger-report "Budget (Cumulative)" nil))) - :config (progn - (setq ledger-use-iso-dates t - ledger-post-use-completion-engine :built-in - ledger-reconcile-default-commodity "€" - ledger-clear-whole-transactions t - ledger-narrow-on-reconcile t - ledger-default-date-format "%Y-%m-%d" - ledger-reports '(("Monthly Expenses" "ledger -f %(ledger-file) reg -M Expenses --real -l \"payee != 'Opening Balances'\"") - ("Expenses:This Month" "ledger -f %(ledger-file) bal \\^Expenses -p \"this month\"") - ("On-budget Balances" "ledger -f %(ledger-file) bal --current -R :Budget: Assets:Receivable Liabilities:Personal") - ("All Account Balances" "ledger -f %(ledger-file) bal --current -R \\^Assets \\^Liabilities") - ("Budget Values (Current Month)" "ledger -f %(ledger-file) bal -p \"this month\" --limit \"payee=~/budget/\" \\^Funds") - ("Budget (Cumulative)" "ledger -f %(ledger-file) bal -E \\^Funds \\^Assets:Budget$") - ("Budget Allocation" "ledger -f %(ledger-file) bal -p \"this month\" --limit \"payee=~/budget/\" \\^Funds --format \"\\ - %-17((depth_spacer)+(partial_account))\\ - %10(percent(market(display_total), market(parent.total)))\\ - %16(market(display_total))\n%/\"") - ("bal" "ledger -f %(ledger-file) bal") - ("reg" "ledger -f %(ledger-file) reg") - ("equity" "ledger -f %(ledger-file) equity") - ("payee" "ledger -f %(ledger-file) reg @%(payee)") - ("account" "ledger -f %(ledger-file) reg %(account)"))))) -#+END_SRC - -** Markdown - -#+BEGIN_SRC emacs-lisp -(use-package markdown-mode - :defer t - :config (progn - (add-hook 'markdown-mode-hook #'turn-on-auto-fill))) -#+END_SRC - -** Org - -Org is wünderbar. - -#+BEGIN_SRC emacs-lisp -(use-package org - :bind (("C-c C-a" . org-agenda-list) - ("C-c a" . org-agenda) - ("C-c l" . org-store-link)) - :defer 8 - :init (setq org-replace-disputed-keys t - org-ellipsis "…") - :config (progn - (setq org-directory "~/Sync/org" - org-agenda-files `(,(concat org-directory "/agenda")) - - org-default-notes-file (concat org-directory "/notes") - - ;; ‘Remember’: new items at top - org-reverse-note-order t - - org-modules '(org-protocol) - - ;; Add time done to ‘done’ tasks - org-log-done 'time - - org-list-allow-alphabetical t - - org-adapt-indentation nil - - org-pretty-entities t - - org-table-duration-custom-format 'seconds - - org-src-fontify-natively nil - - org-export-have-math t - - org-blank-before-new-entry '((heading . t) - (plain-list-item . auto)) - org-fontify-done-headline t - - org-todo-keywords '((sequence "BACKLOG(b)" "TODO(t)" "WAIT(w@/!)" "STARTED(s!)" "|" "DONE(d!)") - (sequence "|" "CANCELLED(c@)")) - org-log-into-drawer "LOGBOOK") - (set-register ?o `(file . ,(expand-file-name "organiser.org" org-directory))) - (add-hook 'org-mode-hook #'turn-on-auto-fill) - (org-load-modules-maybe t))) -#+END_SRC - -**** org-babel - -Org’s babel feature is really nice. I use it for this file, and I can -use it to communicate between programming languages. Sometime I hope -to have my =ledger= setup in an org file with some graph processing -with R or something. - -#+BEGIN_SRC emacs-lisp -(use-package ob-core - :defer t - :ensure nil - :config (progn - (org-babel-do-load-languages 'org-babel-load-languages - '((ledger . t) - (sh . t))) - (setq org-src-tab-acts-natively t - org-edit-src-content-indentation 0 - org-src-preserve-indentation t))) -#+END_SRC - -**** org-journal - -I can use this to keep a journal. I should use it. - -#+BEGIN_SRC emacs-lisp -(use-package org-journal - :bind ("s-j" . org-journal-new-entry) - :defer 20 - :config (progn - (setq org-journal-date-format "%A, %d %B %Y") - (defun org-journal-display-entry-yesterday () - "Show org-journal entry for yesterday" - (interactive) - (org-journal-read-or-display-entry (yesterday-time))))) -#+END_SRC - -**** org-mobile - -#+BEGIN_SRC emacs-lisp -(defun ap/org-mobile-pull (descriptor action file) - (org-mobile-pull)) -(use-package org-mobile - :defer 30 - :ensure nil - :disabled t - :config (progn - (setq org-mobile-directory "~/Mobile/Org" - org-mobile-inbox-for-pull "~/Mobile/Org/from-mobile.org") - (defvar org-mobile-push-timer nil - "Timer that `org-mobile-push-timer' used to reschedule itself, or nil.") - - (defun org-mobile-push-with-delay (secs) - (when org-mobile-push-timer - (cancel-timer org-mobile-push-timer)) - (setq org-mobile-push-timer - (run-with-idle-timer - (* 1 secs) nil 'org-mobile-push))) - - (add-hook 'after-save-hook - (lambda () - (when (eq major-mode 'org-mode) - (dolist (file (org-mobile-files-alist)) - (if (string= (file-truename (expand-file-name (car file))) - (file-truename (buffer-file-name))) - (org-mobile-push-with-delay 30)))))) - - (run-at-time "00:05" 86400 '(lambda () (org-mobile-push-with-delay 1))) ;; refreshes agenda file each day - (org-mobile-pull) ;; run org-mobile-pull at startup - - (defvar org-mobile-watcher nil) - (when file-notify--library - (let ((org-file (expand-file-name - (concat - (file-name-as-directory org-mobile-directory) - org-mobile-capture-file)))) - (setq org-mobile-watcher - (file-notify-add-watch org-file '(change) #'ap/org-mobile-pull)))))) -#+END_SRC - -**** org-caldav - -I’ve setup CalDAV on my server, it would be nice to use it directly -from org-mode. Previously I had to wait for org-mobile to sync and -write to the Android calendar, and then for DAVDroid to sync with the server. - -#+BEGIN_SRC emacs-lisp -(use-package org-caldav - :defer 30 - :config (progn - (setq org-caldav-url "https://calendar.alanpearce.uk/alan" - org-caldav-calendar-id "caldav" - org-caldav-inbox (concat org-directory "/agenda/caldav.org") - org-caldav-files `(,(concat org-directory "/agenda/organiser.org")) - org-icalendar-timezone "Europe/Berlin" - org-icalendar-use-scheduled '(event-if-todo event-if-not-todo todo-start) - org-icalendar-use-deadline '(event-if-todo event-if-not-todo todo-due) - org-icalendar-alarm-time 60))) -#+END_SRC - -**** org-page - -I would like to convert my website from using hugo to something else -that I can work with nicely from inside Emacs. I wonder if org-page -will do the trick. - -#+BEGIN_SRC emacs-lisp -(use-package org-page - :config (progn - (setq op/site-domain "https://alanpearce.uk/" - op/repository-directory "~/projects/alanpearce/" - op/personal-github-link "https://github.com/alanpearce"))) -#+END_SRC - -* Music -Emacs actually supports playing music via mpd. - -#+BEGIN_SRC emacs-lisp -(use-package mpc - :defer t - :config (progn - (setq mpc-browser-tags '(Genre Albumartist|Composer|Performer Album|Playlist)))) -#+END_SRC -* Programming -** flycheck - -On-the-fly error checking in programming modes? Yes please. - -#+BEGIN_SRC emacs-lisp -(use-package flycheck - :diminish " ✓" - :defer 5 - :config (progn - (global-flycheck-mode) - (setq flycheck-check-syntax-automatically '(save new-line mode-enabled)) - (if (executable-find "eslint_d") - (setq flycheck-javascript-eslint-executable (executable-find "eslint_d"))))) -#+END_SRC - -** golang - -Go has a few packages to inter-operate with other emacs packages. - -#+BEGIN_SRC emacs-lisp -(use-package company-go - :commands company-go - :config (progn - (setq company-go-show-annotation t)) - :init (progn - (defun ap/company-go-setup () - (set (make-local-variable 'company-backends) - '(company-go))) - (add-hook 'go-mode-hook #'ap/company-go-setup))) - -(use-package go-eldoc - :commands go-eldoc-setup - :init (progn - (add-hook 'go-mode-hook #'go-eldoc-setup))) - -(use-package go-projectile - :defer t - :config (progn - (setq go-projectile-switch-gopath 'maybe))) - - -#+END_SRC - -** ggtags - -A nice completion backend for programming modes. - -#+BEGIN_SRC emacs-lisp -(use-package ggtags - :disabled t - :commands turn-on-ggtags-mode - :functions (ggtags-navigation-mode-abort) - :config (progn - (bind-key "q" #'ggtags-navigation-mode-abort ggtags-navigation-mode-map)) - :init (progn - (defun turn-on-ggtags-mode () - (interactive) - (ggtags-mode 1)) - (add-hook 'c-mode-common-hook #'turn-on-ggtags-mode))) -#+END_SRC - -** Lisps - -*** All - -Lisp modes don’t seem to have a common ancestor. So I made a custom -hook which I trigger in every lispy-mode. - -#+BEGIN_SRC emacs-lisp -(defcustom lisp-mode-common-hook nil - "Hook run when entering any Lisp mode." - :type 'hook - :group 'lisp) - -(defun ap/lisp-setup () - (run-hooks 'lisp-mode-common-hook)) -#+END_SRC - -**** Redshank - -Lisp syntax allows for really easy refactoring. Redshank gives some -operations that aren’t part of paredit, like extracting variables into -let bindings. -#+BEGIN_SRC emacs-lisp -(use-package redshank - :diminish " Λ" - :after (paredit) - :config (progn - (add-hook 'lisp-mode-common-hook #'turn-on-redshank-mode))) -#+END_SRC - -*** Emacs Lisp - -Customise the modeline-display of =emacs-lisp-mode=. Then make sure -it runs the common lisp hooks. - -#+BEGIN_SRC emacs-lisp -(add-hook 'emacs-lisp-mode-hook #'ap/lisp-setup) -(add-hook 'emacs-lisp-mode-hook #'eldoc-mode) -#+END_SRC - -Go-to function for elisp. Except it works through the entire Emacs ecosystem. - -#+BEGIN_SRC emacs-lisp -(use-package elisp-slime-nav - :commands elisp-slime-nav-mode - :diminish elisp-slime-nav-mode - :init (progn - (add-hook 'emacs-lisp-mode-hook #'elisp-slime-nav-mode))) -#+END_SRC - -Interactive elisp - -#+BEGIN_SRC emacs-lisp -(use-package ielm - :defer t - :ensure nil - :config (progn - (add-hook 'ielm-mode-hook (lambda () - (run-hooks 'lisp-mode-common-hook))))) -#+END_SRC - -*** Scheme & Lisp - -I don’t work with these as often as I would like - -#+BEGIN_SRC emacs-lisp -(add-hook 'scheme-mode-hook #'ap/lisp-setup) -(add-hook 'lisp-mode-hook #'ap/lisp-setup) -(defun set-common-lisp-indentation () - (set (make-local-variable 'lisp-indent-function) - #'common-lisp-indent-function)) -(add-hook 'lisp-mode-hook #'set-common-lisp-indentation) -#+END_SRC - -**** geiser - -A REPL thing for Scheme. Hopefully I’ll get to use it more in the -future. - -#+BEGIN_SRC emacs-lisp -(use-package geiser - :commands (geiser-mode - geiser - run-geiser - run-racket)) -#+END_SRC - -**** slime - -A REPL thing (and more) for Lisp. - -#+BEGIN_SRC emacs-lisp -(use-package slime - :commands (slime) - :config (progn - (let ((ql-slime-helper (expand-file-name "~/quicklisp/slime-helper.el"))) - (if (file-exists-p ql-slime-helper) - (load ql-slime-helper)) - (slime-setup)) - (setq inferior-lisp-program (executable-find "sbcl")))) -#+END_SRC - -*** Clojure - -#+BEGIN_SRC emacs-lisp -(use-package clojure-mode - :defer t - :init (progn - (add-hook 'cider-repl-mode-hook (lambda () (highlight-changes-mode -1))) - (add-hook 'clojure-mode-hook #'ap/lisp-setup))) - -(use-package clj-refactor - :defer t - :functions (clj-refactor-mode cljr-add-keybindings-with-prefix) - :config (progn - (cljr-add-keybindings-with-prefix "C-c C-m")) - :init (progn - (defun turn-on-clj-refactor-mode () - (clj-refactor-mode 1)) - (add-hook 'clojure-mode-hook #'turn-on-clj-refactor-mode))) -#+END_SRC - -**** cider - -A REPL thing for Clojure - -#+BEGIN_SRC emacs-lisp -(use-package cider - :defer t - :config (progn - (setq nrepl-hide-special-buffers t) - (unbind-key "C-c C-f" cider-mode-map) - (add-hook 'cider-mode-hook #'eldoc-mode))) -#+END_SRC - -** Auto-compile - -Auto-compile emacs lisp when saving. -#+BEGIN_SRC emacs-lisp -(use-package auto-compile - :defer t - :init (add-hook 'emacs-lisp-mode-hook #'auto-compile-on-save-mode)) -#+END_SRC - -** cc-mode - -Although I don’t use C or C++, setting up the mode is helpful because -quite a few other modes are derived from it. - -#+BEGIN_SRC emacs-lisp -(use-package cc-mode - :defer 5 - :init (progn - (add-hook 'c-mode-common-hook #'electric-indent-mode)) - :config (progn - (setq c-default-style '((java-mode . "java") - (awk-mode . "awk") - (other . "k&r")) - c-basic-offset 4) - (c-set-offset 'case-label '+))) -#+END_SRC - -** quickrun - -It’s nice to be able to quickly evaluate some code. Although I don’t -really seem to use it. -#+BEGIN_SRC emacs-lisp -(use-package quickrun - :bind (("C-c C-e" . quickrun))) -#+END_SRC - -** Scala - -Let’s try using Scala. - -#+BEGIN_SRC emacs-lisp -(use-package scala-mode - :pin melpa-stable) -#+END_SRC - -And add ensime, an IDE-style environment. - -#+BEGIN_SRC emacs-lisp -(use-package ensime - :pin melpa-stable) -#+END_SRC - -** Web development - -*** js2-mode - -This mode is really great for editing Javascript. It turns code into -an AST internally, so it can work with it almost like a lisp. I don’t -think there’s anything as good as paredit/redshank for refactoring in -it though - -#+BEGIN_SRC emacs-lisp -(use-package js2-mode - :mode (("\\.js\\'" . js2-mode) - ("\\.jsx\\'" . js2-jsx-mode)) - :interpreter ("node" . js2-mode) - :functions js2-next-error - :config (progn - (define-key js2-mode-map [menu-bar Javascript] nil) - (defun js2--imenu-around (do-it name) - "Don't create a menu from js2-mode" - (if (and (not (string-equal name "IM-Javascript-IDE")) - (fboundp #'do-it)) - (do-it name))) - (advice-add 'imenu-add-to-menubar :around #'js2--imenu-around) - (defun ap/js2-prev-error () - (interactive) - (js2-next-error -1)) - (bind-key "M-g M-n" #'js2-next-error js2-mode-map) - (bind-key "M-g M-p" #'ap/js2-prev-error js2-mode-map) - (setq js2-basic-offset 2 - js2-include-node-externs t))) -#+END_SRC - -**** jade (not pug) - -Javascript with an inferior node.js process and a debugger? Awesome. - -To debug with node, use version 6.9.1 or later of node and run it with -~--inspect~ and, to break on the first line, ~--debug-brk~. - -For Chrom*, it needs to be launched with ~--remote-debugging-port=9222~ - -#+BEGIN_SRC emacs-lisp -(use-package jade - :config (progn - (add-hook 'js2-mode-hook #'jade-interaction-mode))) -#+END_SRC - -*** coffee-mode - -#+BEGIN_SRC emacs-lisp -(use-package coffee-mode - :mode ("\\.coffee\\'" . coffee-mode) - :config (progn - (setq coffee-indent-like-python-mode t))) -#+END_SRC - -*** tern - -Tern understands javascript. It adds really clever documented -completions, besides other IDE-like things. - -#+BEGIN_SRC emacs-lisp -(use-package tern - :commands ap/enable-tern - :if (executable-find "tern") - :defer 5 - :config (progn - (setq tern-command (list (executable-find "tern"))) - (defun ap/enable-tern () - (tern-mode 1)) - (add-hook 'js2-mode-hook #'ap/enable-tern) - (add-hook 'web-mode-hook #'ap/enable-tern))) - -(with-eval-after-load 'tern - (use-package company-tern)) -#+END_SRC - -*** json-mode - -#+BEGIN_SRC emacs-lisp -(use-package json-mode - :mode (("\\.json\\'" . json-mode) - ("\\.sailsrc\\'" . json-mode) - ("composer\\.lock\\'" . json-mode) - ("\\.tern-project\\'" . json-mode))) -#+END_SRC - -*** restclient - -Restclient is really nice. It’s like a scratchpad for HTTP api -calls. Feels a bit like using =org-babel=. I wonder if there’s an -integration between the two yet. - -#+BEGIN_SRC emacs-lisp -(use-package restclient - :mode ("\\.api\\'" . restclient-mode) - :config (progn - (defun imenu-restclient-sections () - (setq imenu-prev-index-position-function nil) - (add-to-list 'imenu-generic-expression '("Services" "^## ?\\(.+\\)$" 1) t) - (add-to-list 'imenu-generic-expression '("Calls" "^# ?\\(.+\\)$" 1) t)) - (add-hook 'restclient-mode-hook #'imenu-restclient-sections))) - -(use-package company-restclient - :after (company restclient) - :init (add-to-list 'company-backends #'company-restclient t)) -#+END_SRC - -*** sgml-mode - -This is for HTML, since old versions of HTML were derived from SGML. -#+BEGIN_SRC emacs-lisp -(use-package sgml-mode - :defer t - :config (setq sgml-basic-offset 2)) -#+END_SRC - -*** emmet-mode - -Emmet is really nice to write HTML quickly. Especially with -frameworks that require multiple nested elements to do anything useful. -#+BEGIN_SRC emacs-lisp -(use-package emmet-mode - :commands (emmet-mode) - :diminish (emmet-mode . " >") - :init (progn - (setq emmet-indentation 2) - (add-hook 'web-mode-hook #'emmet-mode))) -#+END_SRC - -*** web-mode - -This mode handles just about every templating language out ther, which -is really nice, because it handles the HTML part the same way in all -of them as well. - -#+BEGIN_SRC emacs-lisp -(use-package web-mode - :mode (("/views/.*\\.php\\'" . web-mode) - ("\\.html\\'" . web-mode) - ("/templates/.*\\.php\\'" . web-mode) - ("\\.ejs\\'" . web-mode)) - :config (progn - (setq web-mode-code-indent-offset 2 - web-mode-css-indent-offset 2 - web-mode-markup-indent-offset 2 - web-mode-style-padding 0 - web-mode-script-padding 0 - web-mode-comment-style 2 - web-mode-enable-auto-pairing nil - web-mode-enable-auto-quoting nil) - (sp-local-pair '(web-mode) "<%" "%>"))) -#+END_SRC - -I derived a mode for twig, in order to use its =mode-hook=. - -#+BEGIN_SRC emacs-lisp -(define-derived-mode twig-mode web-mode "Twig") -(add-to-list 'auto-mode-alist '("\\.html\\.twig\\'" . twig-mode)) -#+END_SRC - -* Spelling - -#+BEGIN_SRC emacs-lisp -(use-package ispell - :bind (("" . ispell-word)) - :config (progn - (cond - ((executable-find "aspell") (setq ispell-program-name "aspell" - ispell-dictionary "british" - ispell-really-aspell t - ispell-really-hunspell nil)) - ((executable-find "hunspell") (setq ispell-program-name "hunspell" - ispell-really-aspell nil - ispell-really-hunspell t))))) -#+END_SRC - -* Scripting - -Make a shell-script buffer executable after saving it, if it has a shebang. - -#+BEGIN_SRC emacs-lisp -(add-hook 'after-save-hook - #'executable-make-buffer-file-executable-if-script-p) - -(use-package sh-script - :mode (("\\.zsh\\'" . shell-script-mode) - ("zshenv\\'" . shell-script-mode) - ("zshrc\\'" . shell-script-mode)) - :config (setq sh-shell-file "/usr/bin/env zsh" - sh-indentation 2 - sh-basic-offset 2)) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) -#+END_SRC - -** eshell - -I should try to get into the habit of using this more. It’s really -nice, when I remember to use it. - -#+BEGIN_SRC emacs-lisp -(use-package eshell - :bind ("C-c s" . eshell) - :config (progn - (setq eshell-directory-name "~/.emacs.d/eshell" - eshell-prompt-function (lambda () - (concat - (eshell/pwd) - "\n$ "))) - (add-hook 'eshell-load-hook (lambda () - (bind-key "C-c C-l" #'counsel-esh-history eshell-mode-map))))) - -(use-package em-smart - :ensure nil - :commands eshell-smart-initialize - :init (progn - (add-hook 'eshell-load-hook #'eshell-smart-initialize)) - :config (progn - (setq eshell-where-to-jump 'begin - eshell-review-quick-commands nil - eshell-smart-space-goes-to-end t))) - -(autoload #'eshell/cd "em-dirs") -(defun eshell-goto-current-dir (&optional arg) - (interactive "P") - (let ((dir default-directory)) - (eshell arg) - (eshell/cd dir))) -(bind-key "C-c S" #'eshell-goto-current-dir) - - -#+END_SRC - -*** Shells - -#+BEGIN_SRC emacs-lisp -(use-package shell - :defer t - :ensure nil - :config (define-key shell-mode-map - (kbd "C-d") 'comint-delchar-or-eof-or-kill-buffer)) - -(use-package comint - :defer t - :ensure nil - :config (bind-key "C-c C-l" #'counsel-shell-history comint-mode-map)) - -(defun comint-delchar-or-eof-or-kill-buffer (arg) - (interactive "p") - (if (null (get-buffer-process (current-buffer))) - (kill-buffer) - (comint-delchar-or-maybe-eof arg))) -#+END_SRC - -* Text editing - -Emacs has an editor within. - -#+BEGIN_SRC emacs-lisp -(put 'upcase-region 'disabled nil) -(put 'downcase-region 'disabled nil) -(setq sentence-end-double-space t - line-move-visual nil) -#+END_SRC - -** align - -=Align= is a useful command to line things up, once given some rules. -The most important one for me is JSON property alignment. - -#+BEGIN_SRC emacs-lisp -(use-package align - :defer 10 - :ensure nil - :config (progn - (add-to-list 'align-rules-list - '(colon-key-value - (regexp . ":\\(\\s-*\\)") - (modes . '(js2-mode)))))) -#+END_SRC - -** Clipboard - -I like to use the clipboard more than the primary selection in X11. - -#+BEGIN_SRC emacs-lisp -(setq x-select-enable-clipboard t - save-interprogram-paste-before-kill t) -(if (functionp 'x-cut-buffer-or-selection-value) - (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)) -(when (boundp 'x-select-request-type) - (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))) -#+END_SRC - -*** Copy formatted code - -#+BEGIN_SRC emacs-lisp -(bind-key* "C-c w" (define-prefix-command 'copy-as-map)) -(use-package copy-as-format - :bind (("C-c C-w" . copy-as-format) - :map copy-as-map - ("b" . copy-as-format-bitbucket) - ("g" . copy-as-format-github) - ("h" . copy-as-format-hipchat) - ("w" . copy-as-format-html) - ("j" . copy-as-format-jira) - ("m" . copy-as-format-markdown) - ("s" . copy-as-format-slack))) -#+END_SRC - -** - -** Selection - -I’m quite used to deleting text by selecting it and typing. Emacs has -a mode for that. - -#+BEGIN_SRC emacs-lisp -(delete-selection-mode t) -#+END_SRC - -Sub-word movement is really nice for camel- and Pascal-case - -#+BEGIN_SRC emacs-lisp -(use-package subword - :diminish subword-mode - :init (global-subword-mode t)) -#+END_SRC - -I find that =zap-up-to-char= normally makes more sense to me than -=zap-to-char=. - -#+BEGIN_SRC emacs-lisp -(use-package misc - :ensure nil - :bind (("M-z" . zap-up-to-char) - ("M-Z" . zap-to-char))) -#+END_SRC - -Expanding the region by semantic units was something I quite liked -from Sublime Text. As always, there’s a mode for that. - -#+BEGIN_SRC emacs-lisp -(use-package expand-region - :bind ("C-M-SPC" . er/expand-region) - :config (setq expand-region-fast-keys-enabled nil)) -#+END_SRC - -** avy - -Avy is a really nice way to move around files, like ace-jump-mode, but -somehow I prefer it. - -#+BEGIN_SRC emacs-lisp -(use-package avy - :bind* (("M-g g" . avy-goto-line) - ("M-g M-g" . avy-goto-line) - ("C-|" . avy-goto-line) - ("M-r" . avy-goto-word-1) - ("C-c SPC" . avy-goto-char-timer)) - :config (progn - (avy-setup-default) - (setq avy-all-windows nil - avy-keys '(?a ?r ?s ?t ?d ?h ?n ?e ?i ?\;)))) -#+END_SRC - -*** ace-link - -Visit any link. Despite the name, this works with avy. - -#+BEGIN_SRC emacs-lisp -(use-package ace-link - :after avy - :config (progn - (ace-link-setup-default) - (with-eval-after-load "gnus" - (bind-key "M-o" #'ace-link-gnus gnus-summary-mode-map) - (bind-key "M-o" #'ace-link-gnus gnus-article-mode-map)))) -#+END_SRC - -** goto-chg - -This is like popping the mark, only it filters to only change areas -and doesn’t go back to the same place more than once. - -#+BEGIN_SRC emacs-lisp -(use-package goto-chg - :bind ("C-c C-SPC" . goto-last-change)) -#+END_SRC - -** multiple-cursors - -I mentioned before that I’d used Sublime Text before. Multiple -cursors was one of my favourite features, so I was really happy when I -saw that multiple-cursors was released for Emacs. - -#+BEGIN_SRC emacs-lisp -(use-package multiple-cursors - :defer 1 - :config (progn - (bind-key "C-." #'mc/mark-next-like-this) - (bind-key "C-," #'mc/mark-previous-like-this) - (bind-key "M-" #'mc/mark-all-like-this-dwim) - (bind-key "C-" #'mc/mark-more-like-this-extended) - (bind-key "C-S-L" #'mc/edit-lines))) -#+END_SRC - -** paredit - -Balanced parentheses in lisps are nice, but all the refactoring and -movement commands are much more interesting. - -#+BEGIN_SRC emacs-lisp -(use-package paredit - :diminish "()" - :config (progn - (add-hook 'lisp-mode-common-hook #'enable-paredit-mode) - (put #'paredit-forward-delete 'delete-selection 'supersede) - (put #'paredit-backward-delete 'delete-selection 'supersede) - (add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode))) -#+END_SRC - -** smartparens - -I like to use smartparens where paredit isn’t already useful. Somehow -I didn’t find smartparens’ implementation of paredit style to be as -nice as the real version - -#+BEGIN_SRC emacs-lisp -(eval-when-compile (require 'smartparens nil :noerror)) -(use-package smartparens-config - :ensure smartparens - :config (progn - (sp-use-smartparens-bindings) - (setq sp-highlight-pair-overlay nil) - (fset 'wrap-with-paren "\C-](") ;; `sp-select-next-thing-exchange' - (bind-key "C-(" #'wrap-with-paren smartparens-mode-map) - (bind-key "C-)" #'sp-forward-slurp-sexp smartparens-mode-map) - (bind-key "M-" #'backward-kill-word smartparens-mode-map) - (bind-key "M-?" #'sp-convolute-sexp smartparens-mode-map) - (bind-key "C-M-t" #'sp-transpose-sexp smartparens-mode-map) - (bind-key "M-R" #'sp-raise-sexp smartparens-mode-map) - (bind-key "M-S" #'sp-splice-sexp smartparens-mode-map) - (bind-key "C-M-s" #'sp-split-sexp smartparens-mode-map) - (bind-key "M-J" #'sp-join-sexp smartparens-mode-map) - (bind-key "M-" #'sp-splice-sexp-killing-backward smartparens-mode-map) - (bind-key "M-" #'sp-splice-sexp-killing-forward smartparens-mode-map) - (bind-key "C-M-S-k" #'sp-kill-hybrid-sexp smartparens-mode-map) - (bind-key "C-S-" #'sp-slurp-hybrid-sexp smartparens-mode-map) - (sp-with-modes '(twig-mode) - (sp-local-pair "{%" "%}") - (sp-local-pair "{{" "}}")) - (show-smartparens-global-mode t) - (smartparens-global-strict-mode t) - (add-hook 'lisp-mode-common-hook #'turn-off-smartparens-mode) - (add-hook 'coffee-mode-hook #'turn-off-smartparens-mode))) -#+END_SRC - -** smart-scan - -Move between instances of a symbol - -#+BEGIN_SRC emacs-lisp -(use-package smartscan - :config (progn - (smartscan-mode 1))) -#+END_SRC - -** move-text - -Transposing lines, made easier. - -#+BEGIN_SRC emacs-lisp -(use-package move-text - :config (move-text-default-bindings)) -#+END_SRC - -** undo-tree - -Emacs’ default handling of undo is a bit confusing. Undo-tree makes -it much clearer. It’s especially helpful for protoyping and refactoring. - -#+BEGIN_SRC emacs-lisp -(use-package undo-tree - :config (progn - (global-undo-tree-mode) - ;; Keep region when undoing in region - (defadvice undo-tree-undo (around keep-region activate) - (if (use-region-p) - (let ((m (set-marker (make-marker) (mark))) - (p (set-marker (make-marker) (point)))) - ad-do-it - (goto-char p) - (set-mark m) - (set-marker p nil) - (set-marker m nil)) - ad-do-it))) - :diminish undo-tree-mode) -#+END_SRC - -** replace - -#+BEGIN_SRC emacs-lisp -(use-package replace - :defer t - :config (progn - (setq case-replace nil))) -#+END_SRC - -** visual-regexp - -I don’t always remember exactly how Emacs’ regular expressions work, -so this package is pretty useful because it highlights everything in -the buffer for me. - -#+BEGIN_SRC emacs-lisp -(use-package visual-regexp - :bind (("C-c r" . vr/replace) - ("C-c q" . vr/query-replace) - ("C-c m" . vc/mc-mark))) -#+END_SRC -* Tangling - -Taken from [[https://github.com/larstvei/dot-emacs/blob/master/init.org][larstvei/dot-emacs]]. I changed it so that it would work with -my current dotfiles repository structure and work asynchronously, -thanks to [[https://github.com/jwiegley/emacs-async][jwiegley/emacs-async]]. - -We can use =C-c C-v t= to run =org-babel-tangle=, which extracts the -code blocks from the current file into a source-specific file (in this -case a =.el=-file). - -To avoid doing this each time a change is made we can add a function -to the =after-save-hook= ensuring to always tangle and byte-compile -the =org=-document after changes. - -#+BEGIN_SRC emacs-lisp -(use-package async - :commands (async-start) - :defer 2) - -(defun tangle-if-init () - "If the current buffer is 'init.org' the code-blocks are - tangled, and the tangled file is compiled." - - (when (string-suffix-p "init.org" (buffer-file-name)) - (tangle-init))) - -(defun tangle-init-sync () - (interactive) - (message "Tangling init") - ;; Avoid running hooks when tangling. - (let ((prog-mode-hook nil) - (src (expand-file-name "init.org" user-emacs-directory)) - (dest (expand-file-name "init.el" user-emacs-directory))) - (require 'ob-tangle) - (org-babel-tangle-file src dest) - (if (byte-compile-file dest) - (byte-compile-dest-file dest) - (with-current-buffer byte-compile-log-buffer - (buffer-string))))) - -(defun tangle-init () - "Tangle init.org asynchronously." - - (interactive) - (message "Tangling init") - (async-start - (symbol-function #'tangle-init-sync) - (lambda (result) - (message "Init tangling completed: %s" result)))) -#+END_SRC - -# Local Variables: -# eval: (when (fboundp #'tangle-if-init) (add-hook 'after-save-hook #'tangle-if-init)) -# End: -* End - -Start a server if possible. A daemon is already a server. -#+BEGIN_SRC emacs-lisp -(run-with-idle-timer 2 nil (lambda () - (unless (daemonp) - (require 'server) - (unless (server-running-p server-name) - (server-start))))) -(setq gc-cons-threshold 800000 - file-name-handler-alist file-name-handler-alist-backup) -#+END_SRC diff --git a/tag-fish/config/fish/config.fish b/tag-fish/config/fish/config.fish deleted file mode 100755 index 34cd22e..0000000 --- a/tag-fish/config/fish/config.fish +++ /dev/null @@ -1,2 +0,0 @@ -set PATH $PATH /home/alan/bin -setenv SSH_AUTH_SOCK $XDG_RUNTIME_DIR/ssh-agent.socket diff --git a/tag-git/config/git/config b/tag-git/config/git/config deleted file mode 100644 index 6228a08..0000000 --- a/tag-git/config/git/config +++ /dev/null @@ -1,34 +0,0 @@ -[user] - email = alan@alanpearce.uk - name = Alan Pearce -[color] - branch = auto - diff = auto - status = auto - ui = true -[push] - default = current -[alias] - up = merge FETCH_HEAD - st = status -sb - ci = commit - br = branch - co = checkout - ready = rebase -i @{u} - lg = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' - standup = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --since yesterday --author Alan - ignored = ls-files --others -i --exclude-standard - pr = pull-request - delete-merged = "!sh -c 'git branch --merged | grep -v "\\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d'" -[github] - user = alan@alanpearce.uk -[diff] - algorithm = patience -[include] - path = config.local -[core] - excludesfile = ~/.config/git/ignore -[rebase] - autosquash = true -[rerere] - enabled = true diff --git a/tag-git/config/git/gitk b/tag-git/config/git/gitk deleted file mode 100644 index 0eb9a03..0000000 --- a/tag-git/config/git/gitk +++ /dev/null @@ -1,61 +0,0 @@ -set mainfont {{Lucida Grande} 12} -set textfont {Monaco 12} -set uifont {{Lucida Grande} 12 bold} -set tabstop 4 -set findmergefiles 0 -set maxgraphpct 50 -set maxwidth 16 -set cmitmode patch -set wrapcomment none -set autoselect 1 -set autosellen 40 -set showneartags 1 -set maxrefs 20 -set hideremotes 0 -set showlocalchanges 1 -set datetimeformat {%Y-%m-%d %H:%M:%S} -set limitdiffs 1 -set uicolor grey85 -set want_ttk 1 -set bgcolor white -set fgcolor black -set uifgcolor black -set uifgdisabledcolor #999 -set colors {green red blue magenta darkgrey brown orange} -set diffcolors {red "#00a000" blue} -set mergecolors {red blue green purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"} -set markbgcolor #e0e0ff -set diffcontext 3 -set selectbgcolor gray85 -set foundbgcolor yellow -set currentsearchhitbgcolor orange -set extdifftool opendiff -set perfile_attrs 0 -set headbgcolor green -set headfgcolor black -set headoutlinecolor black -set remotebgcolor #ffddaa -set tagbgcolor yellow -set tagfgcolor black -set tagoutlinecolor black -set reflinecolor black -set filesepbgcolor #aaaaaa -set filesepfgcolor black -set linehoverbgcolor #ffff80 -set linehoverfgcolor black -set linehoveroutlinecolor black -set mainheadcirclecolor yellow -set workingfilescirclecolor red -set indexcirclecolor green -set circlecolors {white blue gray blue blue} -set linkfgcolor blue -set circleoutlinecolor black -set geometry(main) 1477x845+26+50 -set geometry(state) normal -set geometry(topwidth) 1477 -set geometry(topheight) 300 -set geometry(pwsash0) "378 1" -set geometry(pwsash1) "569 1" -set geometry(botwidth) 473 -set geometry(botheight) 675 -set permviews {} diff --git a/tag-git/config/git/ignore b/tag-git/config/git/ignore deleted file mode 100644 index d7189dc..0000000 --- a/tag-git/config/git/ignore +++ /dev/null @@ -1,29 +0,0 @@ -.DS_Store -.AppleDouble -.LSOverride -Icon -Desktop.ini - -# Thumbnails -._* -Thumbs.db - -# Emacs -*~ -\#*\# -/.emacs.desktop -/.emacs.desktop.lock -.elc -auto-save-list -tramp -.\#* - -# Org-mode -.org-id-locations -*_archive - -GPATH -GRTAGS -GTAGS - -.tern-port \ No newline at end of file diff --git a/tag-global/globalrc b/tag-global/globalrc deleted file mode 100644 index 7fd1a0b..0000000 --- a/tag-global/globalrc +++ /dev/null @@ -1,6 +0,0 @@ -default:\ - :tc=symfony_global: - -symfony_global:\ - :suffixes=php,yml,yaml,html,twig,xml:\ - :skip=/app/cache,node_modules,bin,/app/logs,GPATH,GTAGS,GRTAGS,GSYMS,HTML/,HTML.pub/,html/,tags,TAGS,ID,y.tab.c,y.tab.h,.notfunction,cscope.out,cscope.po.out,cscope.in.out,.gdbinit,SCCS/,RCS/,CVS/,CVSROOT/,{arch}/,.svn/,.git/,.cvsrc,.cvsignore,.gitignore,.cvspass,.cvswrappers,.deps/,autom4te.cache/,.snprj/: diff --git a/tag-hg/hgrc b/tag-hg/hgrc deleted file mode 100644 index 2f16f27..0000000 --- a/tag-hg/hgrc +++ /dev/null @@ -1,9 +0,0 @@ -[ui] -username = Alan Pearce - -[extensions] -purge = -progress = -color = -eol = -record = \ No newline at end of file diff --git a/tag-karabiner/config/karabiner/karabiner.json b/tag-karabiner/config/karabiner/karabiner.json deleted file mode 100644 index 0e866a6..0000000 --- a/tag-karabiner/config/karabiner/karabiner.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "profiles": [ - { - "devices": [ - { - "identifiers": { - "is_keyboard": true, - "is_pointing_device": false, - "product_id": 602, - "vendor_id": 1452 - }, - "ignore": true, - "keyboard_type": 41 - }, - { - "identifiers": { - "is_keyboard": true, - "is_pointing_device": false, - "product_id": 8209, - "vendor_id": 1241 - }, - "ignore": false, - "keyboard_type": 40 - } - ], - "fn_function_keys": { - "f1": "vk_consumer_brightness_down", - "f10": "mute", - "f11": "volume_down", - "f12": "volume_up", - "f2": "vk_consumer_brightness_up", - "f3": "vk_mission_control", - "f4": "vk_launchpad", - "f5": "vk_consumer_illumination_down", - "f6": "vk_consumer_illumination_up", - "f7": "vk_consumer_previous", - "f8": "vk_consumer_play", - "f9": "vk_consumer_next" - }, - "name": "Default Profile", - "selected": true, - "simple_modifications": { - "caps_lock": "delete_or_backspace", - "left_command": "left_option", - "left_control": "left_command", - "left_option": "left_control", - "right_command": "right_option", - "right_control": "right_command", - "right_option": "right_control" - } - }, - { - "name": "Macbook keyboard", - "simple_modifications": { - "caps_lock": "delete_or_backspace", - "grave_accent_and_tilde": "non_us_backslash", - "left_command": "left_control", - "non_us_backslash": "grave_accent_and_tilde", - "right_command": "right_control" - } - } - ] -} diff --git a/tag-minttyrc/minttyrc b/tag-minttyrc/minttyrc deleted file mode 100644 index 2e7f2d8..0000000 --- a/tag-minttyrc/minttyrc +++ /dev/null @@ -1,33 +0,0 @@ -BoldAsFont=no -Font=Cousine -FontHeight=12 -FontSmoothing=default -Locale=en_GB -Charset=UTF-8 -Columns=100 -Rows=36 -Scrollbar=none -Transparency=off -OpaqueWhenFocused=no -CursorType=block -CursorBlinks=no -RightClickAction=extend -BoldBlack=0,43,54 -Black=7,54,66 -BoldGreen=88,110,117 -BoldYellow=101,123,131 -BoldBlue=131,148,150 -BoldCyan=147,161,161 -White=238,232,213 -BoldWhite=253,246,227 -Yellow=181,137,0 -BoldRed=203,75,22 -Red=220,50,47 -Magenta=211,54,130 -BoldMagenta=108,113,196 -Blue=38,139,210 -Cyan=42,161,152 -Green=133,153,0 -ForegroundColour=101,123,117 -BackgroundColour=253,246,227 -CursorColour=112,129,131 diff --git a/tag-ssh/ssh/rc b/tag-ssh/ssh/rc deleted file mode 100755 index 59e4cfd..0000000 --- a/tag-ssh/ssh/rc +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -if [ "$SSH_AUTH_SOCK" ] -then - ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock -fi diff --git a/tag-tmux/tmux.conf b/tag-tmux/tmux.conf deleted file mode 100644 index 697e123..0000000 --- a/tag-tmux/tmux.conf +++ /dev/null @@ -1,19 +0,0 @@ -#setw -g xterm-keys on -#set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@" - -set-window-option -g utf8 on -set-option -g status-utf8 on -set-option -g prefix C-z - -bind C-n send-prefix -unbind-key C-b - -set -g default-terminal "screen-256color" - -# Colemak style -bind-key C-i next-window - -set -g base-index 1 - -set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_GIT SSH_CONNECTION WINDOWID XAUTHORITY" -set-environment -g 'SSH_AUTH_SOCK' '/home/alan/.ssh/ssh_auth_sock' \ No newline at end of file diff --git a/tag-vagrant/vagrant.d/Vagrantfile b/tag-vagrant/vagrant.d/Vagrantfile deleted file mode 100644 index 4c69c88..0000000 --- a/tag-vagrant/vagrant.d/Vagrantfile +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: ruby -*- -Vagrant.configure(2) do |config| - config.vm.provision "ansible" do |ansible| - ansible.playbook = "#{File.dirname(__FILE__)}/ansible/site.yml" - ansible.limit = "all" - end -end diff --git a/tag-vagrant/vagrant.d/ansible/centos.yml b/tag-vagrant/vagrant.d/ansible/centos.yml deleted file mode 100644 index 1a6759a..0000000 --- a/tag-vagrant/vagrant.d/ansible/centos.yml +++ /dev/null @@ -1,31 +0,0 @@ -- name: Ensure EPEL repository package is present - register: centos_repos - get_url: - url: "{{ item.url }}" - dest: "/root/{{ item.dest }}" - with_items: - - url: http://lon.mirror.rackspace.com/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm - dest: epel-repo.rpm - - url: http://lon.mirror.rackspace.com/ius/stable/CentOS/6/x86_64/ius-release-1.0-11.ius.centos6.noarch.rpm - dest: ius-repo.rpm - -- name: Fetch utilities repo - get_url: - url: http://download.opensuse.org/repositories/utilities/CentOS_6/utilities.repo - dest: /etc/yum.repos.d/utilities.repo - -- name: Ensure IUS and EPEL repositories are installed - when: centos_repos.changed - yum: - name: "{{ item }}" - state: installed - with_items: - - /root/epel-repo.rpm - - /root/ius-repo.rpm - - -- name: Ensure that tools are installed - with_items: packages - yum: - name: "{{ item }}" - state: present diff --git a/tag-vagrant/vagrant.d/ansible/debian.yml b/tag-vagrant/vagrant.d/ansible/debian.yml deleted file mode 100644 index 9e06af6..0000000 --- a/tag-vagrant/vagrant.d/ansible/debian.yml +++ /dev/null @@ -1,15 +0,0 @@ -- get_url: - url: https://thoughtbot.github.io/rcm/debs/rcm_1.2.2-2_all.deb - dest: /tmp/rcm.deb - -- command: dpkg --skip-same-version -i /tmp/rcm.deb - register: dpkg - changed_when: "dpkg.stdout.startswith('Selecting')" - -- name: Ensure that tools are installed - with_items: packages - apt: - pkg: "{{ item }}" - state: present - cache_valid_time: 86400 - update_cache: yes \ No newline at end of file diff --git a/tag-vagrant/vagrant.d/ansible/site.yml b/tag-vagrant/vagrant.d/ansible/site.yml deleted file mode 100644 index 1338455..0000000 --- a/tag-vagrant/vagrant.d/ansible/site.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- hosts: all - sudo: yes - vars: - packages: - - zsh - - htop - - lsof - - git - - rcm - tasks: - - include: centos.yml - when: ansible_distribution == "CentOS" - - - include: debian.yml - when: ansible_distribution == "Debian" - - - name: Ensure that dotfiles are checked out - sudo: no - git: - repo: git://github.com/alanpearce/dotfiles - dest: ~/dotfiles - update: yes - - - name: Change shell to zsh - user: - name: vagrant - shell: /bin/zsh - - - name: Install dotfiles - sudo: no - command: /usr/bin/rcup -d dotfiles -t zsh -t git -x README.org -x Brewfile -x LaunchAgents chdir=/home/vagrant \ No newline at end of file diff --git a/tag-xbindkeys/xbindkeysrc.scm b/tag-xbindkeys/xbindkeysrc.scm deleted file mode 100644 index 7b00c38..0000000 --- a/tag-xbindkeys/xbindkeysrc.scm +++ /dev/null @@ -1,57 +0,0 @@ -;; To specify a key, you can use 'xbindkeys --key' or -;; 'xbindkeys --multikey' and put one of the two lines in this file. - -;; A list of keys is in /usr/include/X11/keysym.h and in -;; /usr/include/X11/keysymdef.h -;; The XK_ is not needed. - -;; List of modifier: -;; Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock), -;; Mod3 (CapsLock), Mod4, Mod5 (Scroll). - - -;; The release modifier is not a standard X modifier, but you can -;; use it if you want to catch release instead of press events - -;; By defaults, xbindkeys does not pay attention to modifiers -;; NumLock, CapsLock and ScrollLock. -;; Uncomment the lines below if you want to use them. -;; To dissable them, call the functions with #f - - -;;;;EXTRA FUNCTIONS: Enable numlock, scrolllock or capslock usage -;;(set-numlock! #t) -;;(set-scrolllock! #t) -;;(set-capslock! #t) - -;;;;; Scheme API reference -;;;; -;; Optional modifier state: -;; (set-numlock! #f or #t) -;; (set-scrolllock! #f or #t) -;; (set-capslock! #f or #t) -;; -;; Shell command key: -;; (xbindkey key "foo-bar-command [args]") -;; (xbindkey '(modifier* key) "foo-bar-command [args]") -;; -;; Scheme function key: -;; (xbindkey-function key function-name-or-lambda-function) -;; (xbindkey-function '(modifier* key) function-name-or-lambda-function) -;; -;; Other functions: -;; (remove-xbindkey key) -;; (run-command "foo-bar-command [args]") -;; (grab-all-keys) -;; (ungrab-all-keys) -;; (remove-all-keys) -;; (debug) - -(xbindkey '(mod4 F9) "mpc toggle") -(xbindkey '(mod4 F10) "mpc prev") -(xbindkey '(mod4 F11) "mpc next") -(xbindkey '(mod4 F12) "mpc stop") - -(xbindkey '(mod4 p) "dmenu_run -fn '-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*' -nb '#002b36' -nf '#fdf6e3' -sb '#586e75' -sf '#fdf6e3' -hist '/home/alan/.cache/dmenu_run_history'") -(xbindkey '(mod4 shift T) "urxvtc") -(xbindkey '(mod4 shift E) "emacsclient -c") diff --git a/tag-xmobar/xmobarrc b/tag-xmobar/xmobarrc deleted file mode 100644 index dd54a92..0000000 --- a/tag-xmobar/xmobarrc +++ /dev/null @@ -1,40 +0,0 @@ -Config { font = "-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*" - , borderColor = "#657b83" - , border = TopB - , bgColor = "#fdf6e3" - , fgColor = "#657b83" - , position = BottomW L 90 - , lowerOnStart = False - , hideOnStart = False - , persistent = True - , commands = [ Run Weather "EGNX" ["-t", "ºC" - ,"-L", "12" - ,"-H", "22" - ,"--low", "#268bd2" - ,"--normal", "#859900" - ,"--high", "#dc322f" - ] 36000 - , Run DynNetwork ["-t", "Net: ¦KB" - ,"-L", "512" - ,"-H", "10240" - ,"--low", "#859900" - ,"--normal", "#b58900" - ,"--high", "#dc322f" - ,"-m", "5" - ] 10 - , Run Cpu ["-p", "3" - ,"-L", "3" - ,"-H", "50" - ,"--normal", "#859900" - ,"--high", "#dc322f" - ] 10 - , Run Memory ["-p", "3" - ,"-t", "Mem: %" - ] 20 - , Run StdinReader - , Run Date "%a %b %_d %Y %H:%M" "date" 100 - ] - , sepChar = "%" - , alignSep = "}{" - , template = "%StdinReader% }{ %cpu% | %memory% | %dynnetwork% | %EGNX% | %date%" - } diff --git a/tag-xmonad/xmonad/xmonad.hs b/tag-xmonad/xmonad/xmonad.hs deleted file mode 100644 index 21e197d..0000000 --- a/tag-xmonad/xmonad/xmonad.hs +++ /dev/null @@ -1,92 +0,0 @@ -import XMonad -import qualified XMonad.StackSet as W -import XMonad.Hooks.DynamicLog -import XMonad.Hooks.EwmhDesktops -import XMonad.Hooks.ManageDocks -import XMonad.Hooks.ManageHelpers -import XMonad.Layout.NoBorders -import XMonad.Layout.WindowNavigation -import XMonad.Util.EZConfig -import XMonad.Util.Run(spawnPipe) -import System.Exit -import System.IO -import Data.List(isPrefixOf) - -myManageHook :: ManageHook -myManageHook = composeOne - [ className =? "Firefox" -?> doShift "2" - , className =? "Pidgin" -?> doShift "3" - , className =? "nuvolaplayer" -?> doShift "8" - , className =? "Transmission-gtk" -?> doShift "9" - , isFullscreen -?> doFullFloat - , fmap ("mpv" `isPrefixOf`) title -?> doFullFloat - ] - -myKeys c = mkKeymap c $ - [ ("M-S-", spawn $ XMonad.terminal c) - , ("M-k", kill) - - , ("M-", spawn "exec $(dmenu_path | dmenu)") - , ("M-x M-e", spawn "emacsclient -c") - - , ("M-t", withFocused $ windows . W.sink) - , ("M-m", windows W.focusMaster) - , ("M-S-m", windows W.swapMaster) - - , ("M-", sendMessage $ Go R) - , ("M-", sendMessage $ Go L) - , ("M-", sendMessage $ Go U) - , ("M-", sendMessage $ Go D) - , ("M-M1-", sendMessage $ Swap R) - , ("M-M1-", sendMessage $ Swap L) - , ("M-M1-", sendMessage $ Swap U) - , ("M-M1-", sendMessage $ Swap D) - , ("M-C-", sendMessage $ Move R) - , ("M-C-", sendMessage $ Move L) - , ("M-C-", sendMessage $ Move U) - , ("M-C-", sendMessage $ Move D) - - , ("M-n", windows W.focusDown) - , ("M-p", windows W.focusUp) - , ("M-S-n", windows W.swapDown) - , ("M-S-p", windows W.swapUp) - - , ("M-,", sendMessage (IncMasterN 1)) - , ("M-.", sendMessage (IncMasterN (-1))) - - , ("M-\\", sendMessage NextLayout) - , ("M-S-\\", setLayout $ XMonad.layoutHook c) - - , ("M-+", sendMessage Shrink) - , ("M--", sendMessage Expand) - - , ("M-q", broadcastMessage ReleaseResources - >> restart "xmonad" True) - , ("C-M-q", io (exitWith ExitSuccess)) - ] ++ - - -- mod-[1..9], Switch to workspace N - -- mod-shift-[1..9], Move client to workspace N - [(m ++ k, windows $ f w) - | (w, k) <- zip (XMonad.workspaces c) (map show [1..9]) - , (m, f) <- [("M-",W.greedyView), ("M-S-",W.shift)]] - - -main :: IO () -main = do - xmproc <-spawnPipe "/usr/bin/xmobar /home/alan/.xmobarrc" - xmonad $ defaultConfig - { manageHook = myManageHook <+> manageDocks <+> manageHook defaultConfig - , layoutHook = smartBorders . avoidStruts $ layoutHook defaultConfig - , logHook = dynamicLogWithPP xmobarPP - { ppOutput = hPutStrLn xmproc - , ppTitle = xmobarColor "#859900" "" . shorten 200 - , ppCurrent = xmobarColor "#b58900" "". wrap "[" "]" - , ppHiddenNoWindows = xmobarColor "#93a1a1" "" - , ppUrgent = xmobarColor "#dc322f" "#b58900" - } - , terminal = "urxvt" - , modMask = mod4Mask - , handleEventHook = fullscreenEventHook - , keys = myKeys - } diff --git a/tag-xprofile/xprofile b/tag-xprofile/xprofile deleted file mode 100755 index f0a0523..0000000 --- a/tag-xprofile/xprofile +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -envoy -t gpg-agent -eval $(envoy -p) -xrdb -I$HOME/.xresources .Xresources -xsetroot -cursor_name left_ptr -redshift-gtk & -dropboxd & -trayer --edge bottom --align right --SetDockType true --SetPartialStrut true --expand true --width 10 --transparent true --alpha 0 --tint 0xfdf6e3 --height 12 & -emacsclient --alternate-editor="" --eval '"Starting Emacs"' & diff --git a/tag-xresources/xresources/main b/tag-xresources/xresources/main deleted file mode 100644 index 73f8096..0000000 --- a/tag-xresources/xresources/main +++ /dev/null @@ -1,13 +0,0 @@ -#include "solarized-light" - -Xcursor.theme: Neutral -Xcursor.size: 22 - -Emacs.ToolBar: off -Emacs.MenuBar: off -Emacs.ScrollBars: off -Emacs.CursorBlink: off - -Emacs.Font: -*-Input Mono Narrow-normal-*-*-*-16-*-*-*-*-*-*-* -Emacs.fixed-pitch.attributeFont: -*-Input Mono Narrow-normal-*-*-*-16-*-*-*-*-*-*-* -Emacs.variable-pitch.attributeFont: -*-Input Sans-medium-r-*-*-16-*-*-*-*-*-*-* diff --git a/tag-xresources/xresources/solarized-light b/tag-xresources/xresources/solarized-light deleted file mode 100644 index 3906b7b..0000000 --- a/tag-xresources/xresources/solarized-light +++ /dev/null @@ -1,70 +0,0 @@ -! Solarized color scheme for the X Window System -! -! http://ethanschoonover.com/solarized - - -! Common - -#define S_yellow #b58900 -#define S_orange #cb4b16 -#define S_red #dc322f -#define S_magenta #d33682 -#define S_violet #6c71c4 -#define S_blue #268bd2 -#define S_cyan #2aa198 -#define S_green #859900 - - -! Dark - -! #define S_base03 #002b36 -! #define S_base02 #073642 -! #define S_base01 #586e75 -! #define S_base00 #657b83 -! #define S_base0 #839496 -! #define S_base1 #93a1a1 -! #define S_base2 #eee8d5 -! #define S_base3 #fdf6e3 - - -! Light - -#define S_base03 #fdf6e3 -#define S_base02 #eee8d5 -#define S_base01 #93a1a1 -#define S_base00 #839496 -#define S_base0 #657b83 -#define S_base1 #586e75 -#define S_base2 #073642 -#define S_base3 #002b36 - - -! To only apply colors to your terminal, for example, prefix -! the color assignment statement with its name. Example: -! -! URxvt*background: S_base03 - -*background: S_base03 -*foreground: S_base0 -*fading: 40 -*fadeColor: S_base03 -*cursorColor: S_base1 -*pointerColorBackground: S_base01 -*pointerColorForeground: S_base1 - -*color0: S_base02 -*color1: S_red -*color2: S_green -*color3: S_yellow -*color4: S_blue -*color5: S_magenta -*color6: S_cyan -*color7: S_base2 -*color8: S_base03 -*color9: S_orange -*color10: S_base01 -*color11: S_base00 -*color12: S_base0 -*color13: S_violet -*color14: S_base1 -*color15: S_base3 diff --git a/tag-zsh/config/zsh/zshenv b/tag-zsh/config/zsh/zshenv deleted file mode 100644 index f1cad02..0000000 --- a/tag-zsh/config/zsh/zshenv +++ /dev/null @@ -1,43 +0,0 @@ -if [[ $SHLVL -eq 1 || -n $DISPLAY ]] -then - if [[ -f $ZDOTDIR/zshenv.local ]] - then - . $ZDOTDIR/zshenv.local - fi - - if [[ -f $ZDOTDIR/zshenv.private ]] - then - . $ZDOTDIR/zshenv.private - fi - - ZPLUG_HOME=${ZPLUG_HOME:-~/projects/zplug} - - if [[ -z $SSH_AUTH_SOCK ]] - then - export SSH_AUTH_SOCK=${XDG_RUNTIME_DIR:-/run/user/$UID}/ssh-agent - fi - - case $OSTYPE in - darwin*) - os=darwin - ;; - linux-gnu) - os=linux - ;; - freebsd*) - os=freebsd - ;; - *) - os=unknown - ;; - esac - - case $MACHTYPE in - *64) - arch=amd64 - ;; - *) - arch=386 - ;; - esac -fi diff --git a/tag-zsh/config/zsh/zshrc b/tag-zsh/config/zsh/zshrc deleted file mode 100644 index f2102b3..0000000 --- a/tag-zsh/config/zsh/zshrc +++ /dev/null @@ -1,241 +0,0 @@ -# -*- mode: sh; -*- -source $ZPLUG_HOME/init.zsh - -zplug "zsh-users/zsh-completions", depth:1, defer:0 -zplug "junegunn/fzf-bin", from:gh-r, as:command, rename-to:fzf -zplug "junegunn/fzf", as:plugin, use:"shell/*.zsh", defer:2 -zplug "junegunn/fzf", as:command, use:"bin/*" -zplug "caarlos0/zsh-open-pr", as:plugin -zplug "unixorn/tumult.plugin.zsh", as:plugin, if:"[[ $os -eq darwin ]]" -if [[ -n $commands[nix-env] ]] -then - zplug "spwhitt/nix-zsh-completions", as:plugin - fpath=($fpath $ZPLUG_REPOS/spwhitt/nix-zsh-completions) -fi - -zplug "gerges/oh-my-zsh-jira-plus", as:plugin, if:"[[ ${(SN)HOST%spotcap} ]]" -zplug "plugins/yarn", from:oh-my-zsh, defer:2, if:"[[ -n $commands[yarn] ]]", defer:2 -zplug "lukechilds/zsh-better-npm-completion", if:"[[ -n $commands[npm] ]]", defer:2 -zplug "hlissner/zsh-autopair", defer:2 - -HISTSIZE=3000 -SAVEHIST=10000 -HISTFILE=${XDG_CACHE_HOME:=$HOME/.cache}/zsh/history - -WORDCHARS=${${WORDCHARS//[-.]}//[\/]} - -if [[ ${path[(I)$HOME/bin ]} ]] -then - path+=($HOME/bin) -fi - -if [[ ${path[(I)$HOME/.local/bin ]} ]] -then - path+=($HOME/.local/bin) -fi - -if [[ -d /opt/local/share/zsh/site-functions ]] -then - fpath+=(/opt/local/share/zsh/site-functions) -fi - -export EDITOR=emacsclient -alias ec=emacsclient -alias open-project=projectile -_emacs_function () { - emacsclient -e "($1 \"$2\")" > /dev/null -} -projectile () { - _emacs_function projectile-switch-project-by-name ${1:-$PWD} -} -yarn () { - PREFIX=$HOME/.local command yarn "$@" -} - -ls='\ls' -gnu_ls_options="-v --group-directories-first --color=auto" -gnu_ls_isodate="--time-style=long-iso" -bsd_ls_options="-p" -bsd_ls_isodate="-D '%F %k:%M'" - -case $os in - darwin) - if [[ -n $commands[gls] ]] - then - ls='\gls' - ls_options=$gnu_ls_options - ls_isodate=$gnu_ls_isodate - else - ls_options=$bsd_ls_options - ls_isodate=$bsd_ls_isodate - fi - ;; - freebsd) - ls_options=$bsd_ls_options - ls_isodate=$bsd_ls_isodate - ;; - linux) - ls_options=$gnu_ls_options - ls_isodate=$gnu_ls_isodate - ;; -esac -alias l="${ls} ${ls_options} -Bp" -alias l1="${ls} ${ls_options} -1" -alias ls="${ls} ${ls_options} -hF" -alias la="${ls} ${ls_options} -hA" -alias ll="${ls} ${ls_options} ${ls_isodate} -hl" -alias lal="ll -A" -alias lla="lal" -alias llr="ll -t" - -zmodload zsh/terminfo - -bindkey '\e[3~' delete-char - -bindkey '\C-hd' describe-key-briefly - -backward-argument () { - local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\"" - zle backward-word -} - -forward-argument () { - local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\"" - zle forward-word -} - -kill-argument () { - local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\"" - zle backward-argument - zle kill-word -} - -zle -N backward-argument -zle -N forward-argument -zle -N kill-argument -bindkey '\e^b' backward-argument -bindkey '\e^f' forward-argument -bindkey '\e^k' kill-argument - -ds () { - du -hd1 $1 | sort -h -} - -zle -C hist-complete complete-word _generic -zstyle ':completion:hist-complete:*' completer _history -bindkey '\e ' hist-complete - -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}' -zstyle ':completion:*' completer _expand _complete _match - -if [[ -z $SSH_AUTH_SOCK && $commands[ssh-agent] ]] -then - eval $(ssh-agent) -fi - -# Then, source plugins and add commands to $PATH -zplug load - -# General configuration - -if [[ -n $commands[hub] ]] -then - alias git=hub - alias gh=hub -fi - -if [[ -n $commands[lunchy] ]] -then - LUNCHY_DIR=$(dirname $(gem which lunchy))/../extras - if [ -f $LUNCHY_DIR/lunchy-completion.zsh ]; then - . $LUNCHY_DIR/lunchy-completion.zsh - fi -fi - -if [[ $TERM == "dumb" ]] -then - unsetopt zle - PROMPT="> " -else - unset RPROMPT - # show username@host if logged in through SSH - [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username=' %F{242}%n@%m%f' - - # show username@host if root, with username in white - [[ $UID -eq 0 ]] && prompt_pure_username=' %F{white}%n%f%F{242}@%m%f' - - setopt prompt_subst - setopt prompt_cr - PROMPT='%F{blue}%~%f${prompt_pure_username} -%(?.%F{magenta}.%F{red})>%f ' - - ## From https://github.com/robbyrussell/oh-my-zsh/blob/71deb74552d54630d99ae1db3647ebed7b3bc735/lib/termsupport.zsh - - # Keep Apple Terminal.app's current working directory updated - # Based on this answer: http://superuser.com/a/315029 - # With extra fixes to handle multibyte chars and non-UTF-8 locales - - if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then - # Emits the control sequence to notify Terminal.app of the cwd - # Identifies the directory using a file: URI scheme, including - # the host name to disambiguate local vs. remote paths. - function update_terminalapp_cwd() { - emulate -L zsh - - # Percent-encode the pathname. - # Percent-encode the pathname. - local URL_PATH='' - { - # Use LC_CTYPE=C to process text byte-by-byte. - local i ch hexch LC_CTYPE=C - for ((i = 1; i <= ${#PWD}; ++i)); do - ch="$PWD[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - URL_PATH+="$ch" - else - hexch=$(printf "%02X" "'$ch") - URL_PATH+="%$hexch" - fi - done - } - [[ $? != 0 ]] && return 1 - - printf '\e]7;%s\a' "file://$HOST$URL_PATH" - } - - # Use a precmd hook instead of a chpwd hook to avoid contaminating output - precmd_functions+=(update_terminalapp_cwd) - # Run once to get initial cwd set - update_terminalapp_cwd - fi - - function set_window_title { printf '\e]2;%s\a' "$1" } - - function update_window_title { - if [[ -n "$SSH_CONNECTION" || $UID -eq 0 ]] - then - set_window_title "$USER@$HOST" - else - set_window_title "" - fi - } - precmd_functions+=(update_window_title) -fi - -if zplug check junegunn/fzf -then - _fzf_compgen_path() { - echo "$1" - command find -L "$1" \ - -name .git -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \ - -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' - } - - _fzf_compgen_dir() { - command find -L "$1" \ - -name .git -prune -o -name .svn -prune -o -type d \ - -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' - } -fi - -unsetopt flow_control # Let me use ^S and ^Q diff --git a/tag-zsh/zshenv b/tag-zsh/zshenv deleted file mode 100644 index 354c54d..0000000 --- a/tag-zsh/zshenv +++ /dev/null @@ -1,3 +0,0 @@ -ZDOTDIR="${XDG_CONFIG_HOME:=$HOME/.config}/zsh" - -source "$ZDOTDIR"/.zshenv diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf new file mode 100644 index 0000000..697e123 --- /dev/null +++ b/tmux/.tmux.conf @@ -0,0 +1,19 @@ +#setw -g xterm-keys on +#set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@" + +set-window-option -g utf8 on +set-option -g status-utf8 on +set-option -g prefix C-z + +bind C-n send-prefix +unbind-key C-b + +set -g default-terminal "screen-256color" + +# Colemak style +bind-key C-i next-window + +set -g base-index 1 + +set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_GIT SSH_CONNECTION WINDOWID XAUTHORITY" +set-environment -g 'SSH_AUTH_SOCK' '/home/alan/.ssh/ssh_auth_sock' \ No newline at end of file diff --git a/vagrant/.vagrant.d/Vagrantfile b/vagrant/.vagrant.d/Vagrantfile new file mode 100644 index 0000000..4c69c88 --- /dev/null +++ b/vagrant/.vagrant.d/Vagrantfile @@ -0,0 +1,7 @@ +# -*- mode: ruby -*- +Vagrant.configure(2) do |config| + config.vm.provision "ansible" do |ansible| + ansible.playbook = "#{File.dirname(__FILE__)}/ansible/site.yml" + ansible.limit = "all" + end +end diff --git a/vagrant/.vagrant.d/ansible/centos.yml b/vagrant/.vagrant.d/ansible/centos.yml new file mode 100644 index 0000000..1a6759a --- /dev/null +++ b/vagrant/.vagrant.d/ansible/centos.yml @@ -0,0 +1,31 @@ +- name: Ensure EPEL repository package is present + register: centos_repos + get_url: + url: "{{ item.url }}" + dest: "/root/{{ item.dest }}" + with_items: + - url: http://lon.mirror.rackspace.com/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm + dest: epel-repo.rpm + - url: http://lon.mirror.rackspace.com/ius/stable/CentOS/6/x86_64/ius-release-1.0-11.ius.centos6.noarch.rpm + dest: ius-repo.rpm + +- name: Fetch utilities repo + get_url: + url: http://download.opensuse.org/repositories/utilities/CentOS_6/utilities.repo + dest: /etc/yum.repos.d/utilities.repo + +- name: Ensure IUS and EPEL repositories are installed + when: centos_repos.changed + yum: + name: "{{ item }}" + state: installed + with_items: + - /root/epel-repo.rpm + - /root/ius-repo.rpm + + +- name: Ensure that tools are installed + with_items: packages + yum: + name: "{{ item }}" + state: present diff --git a/vagrant/.vagrant.d/ansible/debian.yml b/vagrant/.vagrant.d/ansible/debian.yml new file mode 100644 index 0000000..9e06af6 --- /dev/null +++ b/vagrant/.vagrant.d/ansible/debian.yml @@ -0,0 +1,15 @@ +- get_url: + url: https://thoughtbot.github.io/rcm/debs/rcm_1.2.2-2_all.deb + dest: /tmp/rcm.deb + +- command: dpkg --skip-same-version -i /tmp/rcm.deb + register: dpkg + changed_when: "dpkg.stdout.startswith('Selecting')" + +- name: Ensure that tools are installed + with_items: packages + apt: + pkg: "{{ item }}" + state: present + cache_valid_time: 86400 + update_cache: yes \ No newline at end of file diff --git a/vagrant/.vagrant.d/ansible/site.yml b/vagrant/.vagrant.d/ansible/site.yml new file mode 100644 index 0000000..1338455 --- /dev/null +++ b/vagrant/.vagrant.d/ansible/site.yml @@ -0,0 +1,32 @@ +--- +- hosts: all + sudo: yes + vars: + packages: + - zsh + - htop + - lsof + - git + - rcm + tasks: + - include: centos.yml + when: ansible_distribution == "CentOS" + + - include: debian.yml + when: ansible_distribution == "Debian" + + - name: Ensure that dotfiles are checked out + sudo: no + git: + repo: git://github.com/alanpearce/dotfiles + dest: ~/dotfiles + update: yes + + - name: Change shell to zsh + user: + name: vagrant + shell: /bin/zsh + + - name: Install dotfiles + sudo: no + command: /usr/bin/rcup -d dotfiles -t zsh -t git -x README.org -x Brewfile -x LaunchAgents chdir=/home/vagrant \ No newline at end of file diff --git a/xbindkeys/xbindkeysrc.scm b/xbindkeys/xbindkeysrc.scm new file mode 100644 index 0000000..7b00c38 --- /dev/null +++ b/xbindkeys/xbindkeysrc.scm @@ -0,0 +1,57 @@ +;; To specify a key, you can use 'xbindkeys --key' or +;; 'xbindkeys --multikey' and put one of the two lines in this file. + +;; A list of keys is in /usr/include/X11/keysym.h and in +;; /usr/include/X11/keysymdef.h +;; The XK_ is not needed. + +;; List of modifier: +;; Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock), +;; Mod3 (CapsLock), Mod4, Mod5 (Scroll). + + +;; The release modifier is not a standard X modifier, but you can +;; use it if you want to catch release instead of press events + +;; By defaults, xbindkeys does not pay attention to modifiers +;; NumLock, CapsLock and ScrollLock. +;; Uncomment the lines below if you want to use them. +;; To dissable them, call the functions with #f + + +;;;;EXTRA FUNCTIONS: Enable numlock, scrolllock or capslock usage +;;(set-numlock! #t) +;;(set-scrolllock! #t) +;;(set-capslock! #t) + +;;;;; Scheme API reference +;;;; +;; Optional modifier state: +;; (set-numlock! #f or #t) +;; (set-scrolllock! #f or #t) +;; (set-capslock! #f or #t) +;; +;; Shell command key: +;; (xbindkey key "foo-bar-command [args]") +;; (xbindkey '(modifier* key) "foo-bar-command [args]") +;; +;; Scheme function key: +;; (xbindkey-function key function-name-or-lambda-function) +;; (xbindkey-function '(modifier* key) function-name-or-lambda-function) +;; +;; Other functions: +;; (remove-xbindkey key) +;; (run-command "foo-bar-command [args]") +;; (grab-all-keys) +;; (ungrab-all-keys) +;; (remove-all-keys) +;; (debug) + +(xbindkey '(mod4 F9) "mpc toggle") +(xbindkey '(mod4 F10) "mpc prev") +(xbindkey '(mod4 F11) "mpc next") +(xbindkey '(mod4 F12) "mpc stop") + +(xbindkey '(mod4 p) "dmenu_run -fn '-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*' -nb '#002b36' -nf '#fdf6e3' -sb '#586e75' -sf '#fdf6e3' -hist '/home/alan/.cache/dmenu_run_history'") +(xbindkey '(mod4 shift T) "urxvtc") +(xbindkey '(mod4 shift E) "emacsclient -c") diff --git a/xmobar/.xmobarrc b/xmobar/.xmobarrc new file mode 100644 index 0000000..dd54a92 --- /dev/null +++ b/xmobar/.xmobarrc @@ -0,0 +1,40 @@ +Config { font = "-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*" + , borderColor = "#657b83" + , border = TopB + , bgColor = "#fdf6e3" + , fgColor = "#657b83" + , position = BottomW L 90 + , lowerOnStart = False + , hideOnStart = False + , persistent = True + , commands = [ Run Weather "EGNX" ["-t", "ºC" + ,"-L", "12" + ,"-H", "22" + ,"--low", "#268bd2" + ,"--normal", "#859900" + ,"--high", "#dc322f" + ] 36000 + , Run DynNetwork ["-t", "Net: ¦KB" + ,"-L", "512" + ,"-H", "10240" + ,"--low", "#859900" + ,"--normal", "#b58900" + ,"--high", "#dc322f" + ,"-m", "5" + ] 10 + , Run Cpu ["-p", "3" + ,"-L", "3" + ,"-H", "50" + ,"--normal", "#859900" + ,"--high", "#dc322f" + ] 10 + , Run Memory ["-p", "3" + ,"-t", "Mem: %" + ] 20 + , Run StdinReader + , Run Date "%a %b %_d %Y %H:%M" "date" 100 + ] + , sepChar = "%" + , alignSep = "}{" + , template = "%StdinReader% }{ %cpu% | %memory% | %dynnetwork% | %EGNX% | %date%" + } diff --git a/xmonad/xmonad/xmonad.hs b/xmonad/xmonad/xmonad.hs new file mode 100644 index 0000000..21e197d --- /dev/null +++ b/xmonad/xmonad/xmonad.hs @@ -0,0 +1,92 @@ +import XMonad +import qualified XMonad.StackSet as W +import XMonad.Hooks.DynamicLog +import XMonad.Hooks.EwmhDesktops +import XMonad.Hooks.ManageDocks +import XMonad.Hooks.ManageHelpers +import XMonad.Layout.NoBorders +import XMonad.Layout.WindowNavigation +import XMonad.Util.EZConfig +import XMonad.Util.Run(spawnPipe) +import System.Exit +import System.IO +import Data.List(isPrefixOf) + +myManageHook :: ManageHook +myManageHook = composeOne + [ className =? "Firefox" -?> doShift "2" + , className =? "Pidgin" -?> doShift "3" + , className =? "nuvolaplayer" -?> doShift "8" + , className =? "Transmission-gtk" -?> doShift "9" + , isFullscreen -?> doFullFloat + , fmap ("mpv" `isPrefixOf`) title -?> doFullFloat + ] + +myKeys c = mkKeymap c $ + [ ("M-S-", spawn $ XMonad.terminal c) + , ("M-k", kill) + + , ("M-", spawn "exec $(dmenu_path | dmenu)") + , ("M-x M-e", spawn "emacsclient -c") + + , ("M-t", withFocused $ windows . W.sink) + , ("M-m", windows W.focusMaster) + , ("M-S-m", windows W.swapMaster) + + , ("M-", sendMessage $ Go R) + , ("M-", sendMessage $ Go L) + , ("M-", sendMessage $ Go U) + , ("M-", sendMessage $ Go D) + , ("M-M1-", sendMessage $ Swap R) + , ("M-M1-", sendMessage $ Swap L) + , ("M-M1-", sendMessage $ Swap U) + , ("M-M1-", sendMessage $ Swap D) + , ("M-C-", sendMessage $ Move R) + , ("M-C-", sendMessage $ Move L) + , ("M-C-", sendMessage $ Move U) + , ("M-C-", sendMessage $ Move D) + + , ("M-n", windows W.focusDown) + , ("M-p", windows W.focusUp) + , ("M-S-n", windows W.swapDown) + , ("M-S-p", windows W.swapUp) + + , ("M-,", sendMessage (IncMasterN 1)) + , ("M-.", sendMessage (IncMasterN (-1))) + + , ("M-\\", sendMessage NextLayout) + , ("M-S-\\", setLayout $ XMonad.layoutHook c) + + , ("M-+", sendMessage Shrink) + , ("M--", sendMessage Expand) + + , ("M-q", broadcastMessage ReleaseResources + >> restart "xmonad" True) + , ("C-M-q", io (exitWith ExitSuccess)) + ] ++ + + -- mod-[1..9], Switch to workspace N + -- mod-shift-[1..9], Move client to workspace N + [(m ++ k, windows $ f w) + | (w, k) <- zip (XMonad.workspaces c) (map show [1..9]) + , (m, f) <- [("M-",W.greedyView), ("M-S-",W.shift)]] + + +main :: IO () +main = do + xmproc <-spawnPipe "/usr/bin/xmobar /home/alan/.xmobarrc" + xmonad $ defaultConfig + { manageHook = myManageHook <+> manageDocks <+> manageHook defaultConfig + , layoutHook = smartBorders . avoidStruts $ layoutHook defaultConfig + , logHook = dynamicLogWithPP xmobarPP + { ppOutput = hPutStrLn xmproc + , ppTitle = xmobarColor "#859900" "" . shorten 200 + , ppCurrent = xmobarColor "#b58900" "". wrap "[" "]" + , ppHiddenNoWindows = xmobarColor "#93a1a1" "" + , ppUrgent = xmobarColor "#dc322f" "#b58900" + } + , terminal = "urxvt" + , modMask = mod4Mask + , handleEventHook = fullscreenEventHook + , keys = myKeys + } diff --git a/xprofile/.xprofile b/xprofile/.xprofile new file mode 100755 index 0000000..f0a0523 --- /dev/null +++ b/xprofile/.xprofile @@ -0,0 +1,9 @@ +#!/bin/sh +envoy -t gpg-agent +eval $(envoy -p) +xrdb -I$HOME/.xresources .Xresources +xsetroot -cursor_name left_ptr +redshift-gtk & +dropboxd & +trayer --edge bottom --align right --SetDockType true --SetPartialStrut true --expand true --width 10 --transparent true --alpha 0 --tint 0xfdf6e3 --height 12 & +emacsclient --alternate-editor="" --eval '"Starting Emacs"' & diff --git a/xresources/.xresources/main b/xresources/.xresources/main new file mode 100644 index 0000000..73f8096 --- /dev/null +++ b/xresources/.xresources/main @@ -0,0 +1,13 @@ +#include "solarized-light" + +Xcursor.theme: Neutral +Xcursor.size: 22 + +Emacs.ToolBar: off +Emacs.MenuBar: off +Emacs.ScrollBars: off +Emacs.CursorBlink: off + +Emacs.Font: -*-Input Mono Narrow-normal-*-*-*-16-*-*-*-*-*-*-* +Emacs.fixed-pitch.attributeFont: -*-Input Mono Narrow-normal-*-*-*-16-*-*-*-*-*-*-* +Emacs.variable-pitch.attributeFont: -*-Input Sans-medium-r-*-*-16-*-*-*-*-*-*-* diff --git a/xresources/.xresources/solarized-light b/xresources/.xresources/solarized-light new file mode 100644 index 0000000..3906b7b --- /dev/null +++ b/xresources/.xresources/solarized-light @@ -0,0 +1,70 @@ +! Solarized color scheme for the X Window System +! +! http://ethanschoonover.com/solarized + + +! Common + +#define S_yellow #b58900 +#define S_orange #cb4b16 +#define S_red #dc322f +#define S_magenta #d33682 +#define S_violet #6c71c4 +#define S_blue #268bd2 +#define S_cyan #2aa198 +#define S_green #859900 + + +! Dark + +! #define S_base03 #002b36 +! #define S_base02 #073642 +! #define S_base01 #586e75 +! #define S_base00 #657b83 +! #define S_base0 #839496 +! #define S_base1 #93a1a1 +! #define S_base2 #eee8d5 +! #define S_base3 #fdf6e3 + + +! Light + +#define S_base03 #fdf6e3 +#define S_base02 #eee8d5 +#define S_base01 #93a1a1 +#define S_base00 #839496 +#define S_base0 #657b83 +#define S_base1 #586e75 +#define S_base2 #073642 +#define S_base3 #002b36 + + +! To only apply colors to your terminal, for example, prefix +! the color assignment statement with its name. Example: +! +! URxvt*background: S_base03 + +*background: S_base03 +*foreground: S_base0 +*fading: 40 +*fadeColor: S_base03 +*cursorColor: S_base1 +*pointerColorBackground: S_base01 +*pointerColorForeground: S_base1 + +*color0: S_base02 +*color1: S_red +*color2: S_green +*color3: S_yellow +*color4: S_blue +*color5: S_magenta +*color6: S_cyan +*color7: S_base2 +*color8: S_base03 +*color9: S_orange +*color10: S_base01 +*color11: S_base00 +*color12: S_base0 +*color13: S_violet +*color14: S_base1 +*color15: S_base3 diff --git a/zsh/.config/zsh/.zshenv b/zsh/.config/zsh/.zshenv new file mode 100644 index 0000000..f1cad02 --- /dev/null +++ b/zsh/.config/zsh/.zshenv @@ -0,0 +1,43 @@ +if [[ $SHLVL -eq 1 || -n $DISPLAY ]] +then + if [[ -f $ZDOTDIR/zshenv.local ]] + then + . $ZDOTDIR/zshenv.local + fi + + if [[ -f $ZDOTDIR/zshenv.private ]] + then + . $ZDOTDIR/zshenv.private + fi + + ZPLUG_HOME=${ZPLUG_HOME:-~/projects/zplug} + + if [[ -z $SSH_AUTH_SOCK ]] + then + export SSH_AUTH_SOCK=${XDG_RUNTIME_DIR:-/run/user/$UID}/ssh-agent + fi + + case $OSTYPE in + darwin*) + os=darwin + ;; + linux-gnu) + os=linux + ;; + freebsd*) + os=freebsd + ;; + *) + os=unknown + ;; + esac + + case $MACHTYPE in + *64) + arch=amd64 + ;; + *) + arch=386 + ;; + esac +fi diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc new file mode 100644 index 0000000..f2102b3 --- /dev/null +++ b/zsh/.config/zsh/.zshrc @@ -0,0 +1,241 @@ +# -*- mode: sh; -*- +source $ZPLUG_HOME/init.zsh + +zplug "zsh-users/zsh-completions", depth:1, defer:0 +zplug "junegunn/fzf-bin", from:gh-r, as:command, rename-to:fzf +zplug "junegunn/fzf", as:plugin, use:"shell/*.zsh", defer:2 +zplug "junegunn/fzf", as:command, use:"bin/*" +zplug "caarlos0/zsh-open-pr", as:plugin +zplug "unixorn/tumult.plugin.zsh", as:plugin, if:"[[ $os -eq darwin ]]" +if [[ -n $commands[nix-env] ]] +then + zplug "spwhitt/nix-zsh-completions", as:plugin + fpath=($fpath $ZPLUG_REPOS/spwhitt/nix-zsh-completions) +fi + +zplug "gerges/oh-my-zsh-jira-plus", as:plugin, if:"[[ ${(SN)HOST%spotcap} ]]" +zplug "plugins/yarn", from:oh-my-zsh, defer:2, if:"[[ -n $commands[yarn] ]]", defer:2 +zplug "lukechilds/zsh-better-npm-completion", if:"[[ -n $commands[npm] ]]", defer:2 +zplug "hlissner/zsh-autopair", defer:2 + +HISTSIZE=3000 +SAVEHIST=10000 +HISTFILE=${XDG_CACHE_HOME:=$HOME/.cache}/zsh/history + +WORDCHARS=${${WORDCHARS//[-.]}//[\/]} + +if [[ ${path[(I)$HOME/bin ]} ]] +then + path+=($HOME/bin) +fi + +if [[ ${path[(I)$HOME/.local/bin ]} ]] +then + path+=($HOME/.local/bin) +fi + +if [[ -d /opt/local/share/zsh/site-functions ]] +then + fpath+=(/opt/local/share/zsh/site-functions) +fi + +export EDITOR=emacsclient +alias ec=emacsclient +alias open-project=projectile +_emacs_function () { + emacsclient -e "($1 \"$2\")" > /dev/null +} +projectile () { + _emacs_function projectile-switch-project-by-name ${1:-$PWD} +} +yarn () { + PREFIX=$HOME/.local command yarn "$@" +} + +ls='\ls' +gnu_ls_options="-v --group-directories-first --color=auto" +gnu_ls_isodate="--time-style=long-iso" +bsd_ls_options="-p" +bsd_ls_isodate="-D '%F %k:%M'" + +case $os in + darwin) + if [[ -n $commands[gls] ]] + then + ls='\gls' + ls_options=$gnu_ls_options + ls_isodate=$gnu_ls_isodate + else + ls_options=$bsd_ls_options + ls_isodate=$bsd_ls_isodate + fi + ;; + freebsd) + ls_options=$bsd_ls_options + ls_isodate=$bsd_ls_isodate + ;; + linux) + ls_options=$gnu_ls_options + ls_isodate=$gnu_ls_isodate + ;; +esac +alias l="${ls} ${ls_options} -Bp" +alias l1="${ls} ${ls_options} -1" +alias ls="${ls} ${ls_options} -hF" +alias la="${ls} ${ls_options} -hA" +alias ll="${ls} ${ls_options} ${ls_isodate} -hl" +alias lal="ll -A" +alias lla="lal" +alias llr="ll -t" + +zmodload zsh/terminfo + +bindkey '\e[3~' delete-char + +bindkey '\C-hd' describe-key-briefly + +backward-argument () { + local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\"" + zle backward-word +} + +forward-argument () { + local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\"" + zle forward-word +} + +kill-argument () { + local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\"" + zle backward-argument + zle kill-word +} + +zle -N backward-argument +zle -N forward-argument +zle -N kill-argument +bindkey '\e^b' backward-argument +bindkey '\e^f' forward-argument +bindkey '\e^k' kill-argument + +ds () { + du -hd1 $1 | sort -h +} + +zle -C hist-complete complete-word _generic +zstyle ':completion:hist-complete:*' completer _history +bindkey '\e ' hist-complete + +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}' +zstyle ':completion:*' completer _expand _complete _match + +if [[ -z $SSH_AUTH_SOCK && $commands[ssh-agent] ]] +then + eval $(ssh-agent) +fi + +# Then, source plugins and add commands to $PATH +zplug load + +# General configuration + +if [[ -n $commands[hub] ]] +then + alias git=hub + alias gh=hub +fi + +if [[ -n $commands[lunchy] ]] +then + LUNCHY_DIR=$(dirname $(gem which lunchy))/../extras + if [ -f $LUNCHY_DIR/lunchy-completion.zsh ]; then + . $LUNCHY_DIR/lunchy-completion.zsh + fi +fi + +if [[ $TERM == "dumb" ]] +then + unsetopt zle + PROMPT="> " +else + unset RPROMPT + # show username@host if logged in through SSH + [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username=' %F{242}%n@%m%f' + + # show username@host if root, with username in white + [[ $UID -eq 0 ]] && prompt_pure_username=' %F{white}%n%f%F{242}@%m%f' + + setopt prompt_subst + setopt prompt_cr + PROMPT='%F{blue}%~%f${prompt_pure_username} +%(?.%F{magenta}.%F{red})>%f ' + + ## From https://github.com/robbyrussell/oh-my-zsh/blob/71deb74552d54630d99ae1db3647ebed7b3bc735/lib/termsupport.zsh + + # Keep Apple Terminal.app's current working directory updated + # Based on this answer: http://superuser.com/a/315029 + # With extra fixes to handle multibyte chars and non-UTF-8 locales + + if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then + # Emits the control sequence to notify Terminal.app of the cwd + # Identifies the directory using a file: URI scheme, including + # the host name to disambiguate local vs. remote paths. + function update_terminalapp_cwd() { + emulate -L zsh + + # Percent-encode the pathname. + # Percent-encode the pathname. + local URL_PATH='' + { + # Use LC_CTYPE=C to process text byte-by-byte. + local i ch hexch LC_CTYPE=C + for ((i = 1; i <= ${#PWD}; ++i)); do + ch="$PWD[i]" + if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then + URL_PATH+="$ch" + else + hexch=$(printf "%02X" "'$ch") + URL_PATH+="%$hexch" + fi + done + } + [[ $? != 0 ]] && return 1 + + printf '\e]7;%s\a' "file://$HOST$URL_PATH" + } + + # Use a precmd hook instead of a chpwd hook to avoid contaminating output + precmd_functions+=(update_terminalapp_cwd) + # Run once to get initial cwd set + update_terminalapp_cwd + fi + + function set_window_title { printf '\e]2;%s\a' "$1" } + + function update_window_title { + if [[ -n "$SSH_CONNECTION" || $UID -eq 0 ]] + then + set_window_title "$USER@$HOST" + else + set_window_title "" + fi + } + precmd_functions+=(update_window_title) +fi + +if zplug check junegunn/fzf +then + _fzf_compgen_path() { + echo "$1" + command find -L "$1" \ + -name .git -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } + + _fzf_compgen_dir() { + command find -L "$1" \ + -name .git -prune -o -name .svn -prune -o -type d \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } +fi + +unsetopt flow_control # Let me use ^S and ^Q diff --git a/zsh/.zshenv b/zsh/.zshenv new file mode 100644 index 0000000..354c54d --- /dev/null +++ b/zsh/.zshenv @@ -0,0 +1,3 @@ +ZDOTDIR="${XDG_CONFIG_HOME:=$HOME/.config}/zsh" + +source "$ZDOTDIR"/.zshenv -- cgit 1.4.1 From 9fee193c12d92ab503f1ba334345f7e56c10f217 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 17 Mar 2017 10:01:23 +0100 Subject: Merge host-specific configuration to tags --- emacs/.emacs.d/private.el.gpg | Bin 0 -> 2288 bytes host-ap-spotcap.local/config/mpv/config | 11 ------- host-ap-spotcap.local/config/zsh/zshenv.local | 9 ------ host-ap-spotcap.local/emacs.d/private.el.gpg | Bin 2288 -> 0 bytes host-ap-spotcap.local/rcrc.local | 2 -- host-ap-spotcap.local/slate | 45 -------------------------- host-marvin/xmodmaprc | 20 ------------ host-prefect/Xresources | 4 --- host-prefect/rcrc.local | 2 -- mpv/.config/config | 11 +++++++ slate/.slate | 45 ++++++++++++++++++++++++++ xmodmap/xmodmaprc | 20 ++++++++++++ zsh/.config/zsh/.zshenv | 5 +++ zsh/.config/zsh/.zshrc | 6 ++++ 14 files changed, 87 insertions(+), 93 deletions(-) create mode 100644 emacs/.emacs.d/private.el.gpg delete mode 100644 host-ap-spotcap.local/config/mpv/config delete mode 100644 host-ap-spotcap.local/config/zsh/zshenv.local delete mode 100644 host-ap-spotcap.local/emacs.d/private.el.gpg delete mode 100644 host-ap-spotcap.local/rcrc.local delete mode 100644 host-ap-spotcap.local/slate delete mode 100644 host-marvin/xmodmaprc delete mode 100644 host-prefect/Xresources delete mode 100644 host-prefect/rcrc.local create mode 100644 mpv/.config/config create mode 100644 slate/.slate create mode 100644 xmodmap/xmodmaprc diff --git a/emacs/.emacs.d/private.el.gpg b/emacs/.emacs.d/private.el.gpg new file mode 100644 index 0000000..784a023 Binary files /dev/null and b/emacs/.emacs.d/private.el.gpg differ diff --git a/host-ap-spotcap.local/config/mpv/config b/host-ap-spotcap.local/config/mpv/config deleted file mode 100644 index 56c6d99..0000000 --- a/host-ap-spotcap.local/config/mpv/config +++ /dev/null @@ -1,11 +0,0 @@ -[default] - -vo=opengl-hq:backend=cocoa -ao=coreaudio - -hwdec=videotoolbox - -alang=en,eng,de,ger - -ytdl -ytdl-format=best diff --git a/host-ap-spotcap.local/config/zsh/zshenv.local b/host-ap-spotcap.local/config/zsh/zshenv.local deleted file mode 100644 index af63e1b..0000000 --- a/host-ap-spotcap.local/config/zsh/zshenv.local +++ /dev/null @@ -1,9 +0,0 @@ -# -*- mode: sh; -*- -if [[ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]] -then - . $HOME/.nix-profile/etc/profile.d/nix.sh; -fi - -JIRA_RAPID_BOARD=true -JIRA_URL=https://spotcap.atlassian.net -EMAIL=alan.pearce@spotcap.com diff --git a/host-ap-spotcap.local/emacs.d/private.el.gpg b/host-ap-spotcap.local/emacs.d/private.el.gpg deleted file mode 100644 index 784a023..0000000 Binary files a/host-ap-spotcap.local/emacs.d/private.el.gpg and /dev/null differ diff --git a/host-ap-spotcap.local/rcrc.local b/host-ap-spotcap.local/rcrc.local deleted file mode 100644 index 4639c9e..0000000 --- a/host-ap-spotcap.local/rcrc.local +++ /dev/null @@ -1,2 +0,0 @@ -DOTFILES_DIRS="$HOME/projects/dotfiles" -TAGS="emacs git global tmux zsh" \ No newline at end of file diff --git a/host-ap-spotcap.local/slate b/host-ap-spotcap.local/slate deleted file mode 100644 index e8c675d..0000000 --- a/host-ap-spotcap.local/slate +++ /dev/null @@ -1,45 +0,0 @@ -config keyboardLayout colemak - -config defaultToCurrentScreen true -config nudgePercentOf screenSize -config resizePercentOf screenSize - -config windowHintsSpread true - -alias mon-laptop 1680x1050 -alias mon-work 1920x1200 -alias mon-home 2560x1440 - -alias 1-full throw 0 resize -alias 1-left push left bar-resize:screenSizeX/2 0 -alias 1-right push right bar-resize:screenSizeX/2 0 -alias 2-left push left bar-resize:screenSizeX/2 1 -alias 2-right push right bar-resize:screenSizeX/2 1 - -# Push Bindings -bind right:alt;cmd push right bar-resize:screenSizeX/2 -bind left:alt;cmd push left bar-resize:screenSizeX/2 -bind up:alt;cmd push up bar-resize:screenSizeY/2 -bind down:alt;cmd push down bar-resize:screenSizeY/2 - -# Throw Bindings -bind 1:ctrl;alt throw 0 resize -bind 2:ctrl;alt throw 1 resize -bind 3:ctrl;alt throw 2 resize -bind right:ctrl;alt;cmd throw right resize -bind left:ctrl;alt;cmd throw left resize -bind up:ctrl;alt;cmd throw up resize -bind down:ctrl;alt;cmd throw down resize - -bind f:cmd;shift move screenOriginX;screenOriginY screenSizeX;screenSizeY - -# Focus Bindings -bind right:cmd;shift focus right -bind left:cmd;shift focus left -# bind up:cmd;shift focus up -# bind down:cmd;shift focus down -bind up:cmd;shift focus behind -bind down:cmd;shift focus behind - -# Window Hints -bind esc:cmd hint setnriao diff --git a/host-marvin/xmodmaprc b/host-marvin/xmodmaprc deleted file mode 100644 index 82a8674..0000000 --- a/host-marvin/xmodmaprc +++ /dev/null @@ -1,20 +0,0 @@ -keycode 37 = Super_L NoSymbol Super_L -keycode 133 = Alt_L Meta_L Alt_L Meta_L -keycode 64 = Control_L NoSymbol Control_L - -! Thinkpad has PrtSc next to Alt_R -keycode 108 = Control_R NoSymbol Control_R -keycode 107 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift -keycode 105 = Super_R NoSymbol Super_R -! For external keyboards -keycode 134 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift - -clear Control -clear Mod1 -clear Mod3 -clear Mod4 - -add Control = Control_L Control_R -add Mod1 = Alt_L Meta_L -add Mod4 = Super_L Super_R Super_L Hyper_L -add Mod5 = ISO_Level3_Shift Mode_switch \ No newline at end of file diff --git a/host-prefect/Xresources b/host-prefect/Xresources deleted file mode 100644 index c89d486..0000000 --- a/host-prefect/Xresources +++ /dev/null @@ -1,4 +0,0 @@ -#include "main" - -Emacs.Font: -xos4-Terminus-normal-normal-normal-*-14-*-*-*-*-*-*-* -Emacs.fixed-pitch.attributeFont: -xos4-Terminus-normal-normal-normal-*-14-*-*-*-*-*-*-* diff --git a/host-prefect/rcrc.local b/host-prefect/rcrc.local deleted file mode 100644 index 3b80dd6..0000000 --- a/host-prefect/rcrc.local +++ /dev/null @@ -1,2 +0,0 @@ -DOTFILES_DIRS="$HOME/projects/dotfiles" -TAGS="emacs git hg clojure ssh zsh" diff --git a/mpv/.config/config b/mpv/.config/config new file mode 100644 index 0000000..56c6d99 --- /dev/null +++ b/mpv/.config/config @@ -0,0 +1,11 @@ +[default] + +vo=opengl-hq:backend=cocoa +ao=coreaudio + +hwdec=videotoolbox + +alang=en,eng,de,ger + +ytdl +ytdl-format=best diff --git a/slate/.slate b/slate/.slate new file mode 100644 index 0000000..e8c675d --- /dev/null +++ b/slate/.slate @@ -0,0 +1,45 @@ +config keyboardLayout colemak + +config defaultToCurrentScreen true +config nudgePercentOf screenSize +config resizePercentOf screenSize + +config windowHintsSpread true + +alias mon-laptop 1680x1050 +alias mon-work 1920x1200 +alias mon-home 2560x1440 + +alias 1-full throw 0 resize +alias 1-left push left bar-resize:screenSizeX/2 0 +alias 1-right push right bar-resize:screenSizeX/2 0 +alias 2-left push left bar-resize:screenSizeX/2 1 +alias 2-right push right bar-resize:screenSizeX/2 1 + +# Push Bindings +bind right:alt;cmd push right bar-resize:screenSizeX/2 +bind left:alt;cmd push left bar-resize:screenSizeX/2 +bind up:alt;cmd push up bar-resize:screenSizeY/2 +bind down:alt;cmd push down bar-resize:screenSizeY/2 + +# Throw Bindings +bind 1:ctrl;alt throw 0 resize +bind 2:ctrl;alt throw 1 resize +bind 3:ctrl;alt throw 2 resize +bind right:ctrl;alt;cmd throw right resize +bind left:ctrl;alt;cmd throw left resize +bind up:ctrl;alt;cmd throw up resize +bind down:ctrl;alt;cmd throw down resize + +bind f:cmd;shift move screenOriginX;screenOriginY screenSizeX;screenSizeY + +# Focus Bindings +bind right:cmd;shift focus right +bind left:cmd;shift focus left +# bind up:cmd;shift focus up +# bind down:cmd;shift focus down +bind up:cmd;shift focus behind +bind down:cmd;shift focus behind + +# Window Hints +bind esc:cmd hint setnriao diff --git a/xmodmap/xmodmaprc b/xmodmap/xmodmaprc new file mode 100644 index 0000000..82a8674 --- /dev/null +++ b/xmodmap/xmodmaprc @@ -0,0 +1,20 @@ +keycode 37 = Super_L NoSymbol Super_L +keycode 133 = Alt_L Meta_L Alt_L Meta_L +keycode 64 = Control_L NoSymbol Control_L + +! Thinkpad has PrtSc next to Alt_R +keycode 108 = Control_R NoSymbol Control_R +keycode 107 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift +keycode 105 = Super_R NoSymbol Super_R +! For external keyboards +keycode 134 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift + +clear Control +clear Mod1 +clear Mod3 +clear Mod4 + +add Control = Control_L Control_R +add Mod1 = Alt_L Meta_L +add Mod4 = Super_L Super_R Super_L Hyper_L +add Mod5 = ISO_Level3_Shift Mode_switch \ No newline at end of file diff --git a/zsh/.config/zsh/.zshenv b/zsh/.config/zsh/.zshenv index f1cad02..0be5a7a 100644 --- a/zsh/.config/zsh/.zshenv +++ b/zsh/.config/zsh/.zshenv @@ -17,6 +17,11 @@ then export SSH_AUTH_SOCK=${XDG_RUNTIME_DIR:-/run/user/$UID}/ssh-agent fi + if [[ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]] + then + . $HOME/.nix-profile/etc/profile.d/nix.sh; + fi + case $OSTYPE in darwin*) os=darwin diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index f2102b3..8a9c806 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -133,6 +133,12 @@ then eval $(ssh-agent) fi +if zplug check gerges/oh-my-zsh-jira-plus +then + JIRA_RAPID_BOARD=true + JIRA_URL=https://spotcap.atlassian.net +fi + # Then, source plugins and add commands to $PATH zplug load -- cgit 1.4.1 From 9595844538a4bcf53bec628874605f8c49d589c5 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 17 Mar 2017 10:04:07 +0100 Subject: Move top-level dotfiles to tags --- gemrc | 1 - javascript/.npmrc | 1 + npmrc | 1 - ruby/.gemrc | 1 + 4 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 gemrc create mode 100644 javascript/.npmrc delete mode 100644 npmrc create mode 100644 ruby/.gemrc diff --git a/gemrc b/gemrc deleted file mode 100644 index ab4f784..0000000 --- a/gemrc +++ /dev/null @@ -1 +0,0 @@ -gem: --user-install -n~/.local/bin \ No newline at end of file diff --git a/javascript/.npmrc b/javascript/.npmrc new file mode 100644 index 0000000..6804f65 --- /dev/null +++ b/javascript/.npmrc @@ -0,0 +1 @@ +prefix = ${HOME}/.local/ \ No newline at end of file diff --git a/npmrc b/npmrc deleted file mode 100644 index 6804f65..0000000 --- a/npmrc +++ /dev/null @@ -1 +0,0 @@ -prefix = ${HOME}/.local/ \ No newline at end of file diff --git a/ruby/.gemrc b/ruby/.gemrc new file mode 100644 index 0000000..ab4f784 --- /dev/null +++ b/ruby/.gemrc @@ -0,0 +1 @@ +gem: --user-install -n~/.local/bin \ No newline at end of file -- cgit 1.4.1 From e23229baf851e14630889b21d956e23f13aae870 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 17 Mar 2017 10:39:59 +0100 Subject: Replace emacs hook with makefile --- emacs/.emacs.d/Makefile | 19 +++++++++++++++++++ hooks/post-up/emacs | 17 ----------------- 2 files changed, 19 insertions(+), 17 deletions(-) create mode 100644 emacs/.emacs.d/Makefile delete mode 100755 hooks/post-up/emacs diff --git a/emacs/.emacs.d/Makefile b/emacs/.emacs.d/Makefile new file mode 100644 index 0000000..fd51e39 --- /dev/null +++ b/emacs/.emacs.d/Makefile @@ -0,0 +1,19 @@ +define EMACS_TANGLE +(progn\ + (setq vc-follow-symlinks nil)\ + (find-file \"init.org\")\ + (require 'ob-tangle)\ + (org-babel-tangle nil \"init.el\")) +endef + +all: init.elc +.PHONY: all + +init.el: + @emacs --batch --no-init-file --eval "$(EMACS_TANGLE)" --kill + +init.elc: init.el + @emacs --batch --no-init-file --funcall batch-byte-compile init.el + +clean: + rm init.el init.elc diff --git a/hooks/post-up/emacs b/hooks/post-up/emacs deleted file mode 100755 index 05a5c9d..0000000 --- a/hooks/post-up/emacs +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -EMACS_COMMAND=$(command -v Emacs || command -v emacs) - -if [[ -s $EMACS_COMMAND ]] -then - pushd ~/.emacs.d - emacs --batch --eval "(progn -(setq vc-follow-symlinks nil) -(find-file \"init.org\") -(require 'ob-tangle) -(org-babel-tangle nil \"init.el\") -(byte-compile-file \"init.el\") -(load-file \"init.el\") -)" - popd -fi -- cgit 1.4.1 From 612bf6ce1be2b10ec47f7ac14460059e5b791160 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 17 Mar 2017 22:03:09 +0100 Subject: Emacs: Fix replace load issue --- emacs/.emacs.d/init.org | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index 151efbf..4d9e5fa 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -2436,10 +2436,8 @@ it much clearer. It’s especially helpful for protoyping and refactoring. ** replace #+BEGIN_SRC emacs-lisp -(use-package replace - :defer t - :config (progn - (setq case-replace nil))) +(with-eval-after-load "replace.el" + (setq case-replace nil)) #+END_SRC ** visual-regexp -- cgit 1.4.1 From d8c083931789acd8cdb7f952f5915c84a9a4e78f Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 08:46:04 +0100 Subject: Emacs: Point switch-to-dotfiles to new dotfiles folder --- emacs/.emacs.d/init.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index 151efbf..dd67357 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -423,7 +423,7 @@ configuration with crux.el #+BEGIN_SRC emacs-lisp (defun switch-to-dotfiles () (interactive) - (projectile-switch-project-by-name (expand-file-name "dotfiles" home-project-directory))) + (projectile-switch-project-by-name (expand-file-name "~/dotfiles"))) #+END_SRC ** The Silver Searcher -- cgit 1.4.1 From 4e43d4e467c1163789e2dc7ce61774bd8771c869 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 08:58:52 +0100 Subject: Update README --- README.org | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/README.org b/README.org index b6c5c09..e1fb43b 100644 --- a/README.org +++ b/README.org @@ -1,8 +1,14 @@ * Dotfiles -I've organised this repository with [[https://github.com/thoughtbot/rcm][rcm]], using tag- and -host-specific directories. It focuses on zsh and emacs, with some -functions to go from zsh to emacs (and directly to dired and magit). -It doesn't use any configuration frameworks. +I've organised this repository with [[https://www.gnu.org/software/stow/][GNU Stow]]. It focuses on [[http://zsh.sourceforge.net][Z Shell]] and +[[http://emacs.sexy][Emacs]]. -Most likely to work on Linux, OSX and FreeBSD. +It doesn't use any configuration frameworks, just packages installed +via package managers. For Z shell I use [[https://zplug.sh/][zplug]] and for Emacs I use the +built-in package.el via [[https://github.com/jwiegley/use-package][use-package]]. + +It should work on: +- Linux +- OSX +- FreeBSD +- Windows/Ubuntu -- cgit 1.4.1 From 47f9ac570ddfac0700237c66e4d96fa6fa2cb4aa Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 12:23:04 +0100 Subject: Emacs: Update private configuration --- emacs/.emacs.d/private.el.gpg | Bin 2288 -> 2339 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/emacs/.emacs.d/private.el.gpg b/emacs/.emacs.d/private.el.gpg index 784a023..04290b7 100644 Binary files a/emacs/.emacs.d/private.el.gpg and b/emacs/.emacs.d/private.el.gpg differ -- cgit 1.4.1 From d8364fdf028b6578ee3136d8cc17a36a4c0fbf3d Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 12:23:13 +0100 Subject: Emacs: Reconfigure beacon-mode --- emacs/.emacs.d/init.org | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index 54b1de6..369da20 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -300,7 +300,12 @@ switching windows. #+BEGIN_SRC emacs-lisp (use-package beacon :diminish beacon-mode - :config (beacon-mode +1)) + :config (progn + (beacon-mode +1) + (setq beacon-blink-delay 0.25 + beacon-blink-duration 0.25 + beacon-size 20 + beacon-color "#a1b56c"))) #+END_SRC ** Renaming major modes -- cgit 1.4.1 From f8ec71a117760f22e2573f1a6d072547d6410f21 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 12:38:16 +0100 Subject: Add installation section to readme --- README.org | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.org b/README.org index e1fb43b..b22c80b 100644 --- a/README.org +++ b/README.org @@ -12,3 +12,18 @@ It should work on: - OSX - FreeBSD - Windows/Ubuntu + +** Installation + +Installing a set of dotfiles with stow is simple. For example, with +Emacs: + +#+BEGIN_SRC sh :exports code +stow -S emacs +#+END_SRC + +And then to uninstall + +#+BEGIN_SRC sh :exports code +stow -D emacs +#+END_SRC -- cgit 1.4.1 From 061b7a0149c62f53a75f7f0e8ad63836acf4e334 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 12:42:46 +0100 Subject: Move zsh install commands to readme --- README.org | 17 +++++++++++++++++ hooks/post-up/zsh | 29 ----------------------------- 2 files changed, 17 insertions(+), 29 deletions(-) delete mode 100755 hooks/post-up/zsh diff --git a/README.org b/README.org index b22c80b..68aaef4 100644 --- a/README.org +++ b/README.org @@ -27,3 +27,20 @@ And then to uninstall #+BEGIN_SRC sh :exports code stow -D emacs #+END_SRC + +*** Z Shell + +My zsh configuration uses [[https://zplug.sh/][zplug]], so that will need to be installed: + +#+BEGIN_SRC sh :exports code +git clone git://github.com/zplug/zplug ~/projects/zplug/ +#+END_SRC + +To install the packages: + +#+BEGIN_SRC sh :exports code +zsh -ic "zplug install" +#+END_SRC + +Note that this will log some errors about a pipe, but that's okay. +zplug is meant to be used in a real interactive shell. diff --git a/hooks/post-up/zsh b/hooks/post-up/zsh deleted file mode 100755 index 3eef6e5..0000000 --- a/hooks/post-up/zsh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env zsh -ZDOTDIR="${XDG_CONFIG_HOME:=~/.config}/zsh" - -pushd $ZDOTDIR -for f in z*(-.) -do - if [[ -e .$f ]] - then - if [[ ! -h .$f ]] - then - echo ".$f already exists as a regular file, ignoring" - fi - else - ln -s $f .$f - fi -done -popd - -if [[ ! -d ~/.cache/zsh ]] -then - mkdir -p ~/.cache/zsh -fi - -if [[ -z $commands[zplug] && ! -d ~/projects/zplug/ ]] -then - git clone git://github.com/zplug/zplug ~/projects/zplug/ -fi - -zsh -ic "zplug install" -- cgit 1.4.1 From ea6dafe072ff4f2c2d2483f2906780889e272811 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 14:18:32 +0100 Subject: Add comments to Makefile --- emacs/.emacs.d/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/emacs/.emacs.d/Makefile b/emacs/.emacs.d/Makefile index fd51e39..3d965e4 100644 --- a/emacs/.emacs.d/Makefile +++ b/emacs/.emacs.d/Makefile @@ -6,8 +6,11 @@ define EMACS_TANGLE (org-babel-tangle nil \"init.el\")) endef +# The first target is the default. `all` is typically defined here. all: init.elc -.PHONY: all + +# These targets don't pertain to files +.PHONY: all clean init.el: @emacs --batch --no-init-file --eval "$(EMACS_TANGLE)" --kill -- cgit 1.4.1 From 05f574baa9e43499a13460bdfbb5140fcf957d6d Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 14:19:04 +0100 Subject: Add Emacs section to readme --- README.org | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.org b/README.org index 68aaef4..7333ed3 100644 --- a/README.org +++ b/README.org @@ -44,3 +44,13 @@ zsh -ic "zplug install" Note that this will log some errors about a pipe, but that's okay. zplug is meant to be used in a real interactive shell. + +*** Emacs + +I use org-mode for my Emacs init file. To simplify setup, I created a +[[file:emacs/.emacs.d/Makefile][Makefile]]. + +#+BEGIN_SRC sh :exports code +cd ~/.emacs.d/ +make +#+END_SRC -- cgit 1.4.1 From 3936dc527affdf9dfc6a3089f5e8c2dd57385a65 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 15:10:43 +0100 Subject: Emacs: Install dumb-jump for simple goto-definition --- emacs/.emacs.d/init.org | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index 369da20..880e4bc 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -1748,6 +1748,21 @@ A nice completion backend for programming modes. (add-hook 'c-mode-common-hook #'turn-on-ggtags-mode))) #+END_SRC +** dumb-jump + +A "clever" way of implementing go-to-definition across languages: use +a project-wide text search and apply heuristics to the results to +guess a definition. + +#+BEGIN_SRC emacs-lisp +(use-package dumb-jump + :bind (("M-g o" . dumb-jump-go-other-window) + ("M-g j" . dumb-jump-go) + ("M-g x" . dumb-jump-go-prefer-external) + ("M-g z" . dumb-jump-go-prefer-external-other-window)) + :config (setq dumb-jump-selector 'ivy)) +#+END_SRC + ** Lisps *** All -- cgit 1.4.1 From 53f50286e177abb9d1ac4a7c239dcbcc3fed63b7 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 Mar 2017 15:11:06 +0100 Subject: Emacs/zsh: Enable GNU Global if available --- emacs/.emacs.d/init.org | 2 +- zsh/.config/zsh/.zshenv | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index 880e4bc..7578c72 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -1736,7 +1736,7 @@ A nice completion backend for programming modes. #+BEGIN_SRC emacs-lisp (use-package ggtags - :disabled t + :if (executable-find "gtags") :commands turn-on-ggtags-mode :functions (ggtags-navigation-mode-abort) :config (progn diff --git a/zsh/.config/zsh/.zshenv b/zsh/.config/zsh/.zshenv index 0be5a7a..512dc56 100644 --- a/zsh/.config/zsh/.zshenv +++ b/zsh/.config/zsh/.zshenv @@ -45,4 +45,7 @@ then arch=386 ;; esac + + export GTAGSCONF=~/.globalrc + export GTAGSLABEL=ctags fi -- cgit 1.4.1