summaryrefslogtreecommitdiff
path: root/emacs/inits
diff options
context:
space:
mode:
authortslil clingman <>2019-09-11 19:18:14 -0400
committertslil clingman <>2019-09-11 19:18:14 -0400
commitac1a4884d03fc0495c773500d8a13f84b695fa43 (patch)
tree29e5ec49e0ce957d80d8f11a155b47840c74f488 /emacs/inits
Init
Diffstat (limited to 'emacs/inits')
-rw-r--r--emacs/inits/00-exwm.el153
-rw-r--r--emacs/inits/01-basic.el126
-rw-r--r--emacs/inits/02-modeline.el96
-rw-r--r--emacs/inits/03-miscload.el17
-rw-r--r--emacs/inits/04-input_method.el14
-rw-r--r--emacs/inits/05-helpful.el17
-rw-r--r--emacs/inits/06-dashboard.el30
-rw-r--r--emacs/inits/10-ivy.el117
-rw-r--r--emacs/inits/12-company.el17
-rw-r--r--emacs/inits/13-ibuffer.el70
-rw-r--r--emacs/inits/14-movement.el170
-rw-r--r--emacs/inits/15-project-mgmt.el18
-rw-r--r--emacs/inits/20-programming.el121
-rw-r--r--emacs/inits/21-functional.el75
-rw-r--r--emacs/inits/22-lisp.el132
-rw-r--r--emacs/inits/23-text-related.el133
-rw-r--r--emacs/inits/24-latex.el146
-rw-r--r--emacs/inits/25-theorems.el124
-rw-r--r--emacs/inits/30-irc.el45
-rw-r--r--emacs/inits/50-file-assocs.el20
-rw-r--r--emacs/inits/60-misc-configs.el22
-rw-r--r--emacs/inits/70-global-keybinds.el32
-rw-r--r--emacs/inits/99-last.el7
23 files changed, 1702 insertions, 0 deletions
diff --git a/emacs/inits/00-exwm.el b/emacs/inits/00-exwm.el
new file mode 100644
index 0000000..381f54e
--- /dev/null
+++ b/emacs/inits/00-exwm.el
@@ -0,0 +1,153 @@
+;; Time-stamp: <2019-09-11 14:35:00 (tslil@basingstoke)>
+
+(defun adjust-volume (mixer adjust)
+ (let ((tail " | tail -n 1")
+ (sed (concat " | sed 's/.*\\[\\([0-9]*.\\)\\] "
+ "\\[.*dB\\] \\[\\(.*\\)\\]$/"
+ mixer
+ " \\1 \\2/'")))
+ (shell-command
+ (concat
+ (cond ((string-equal "+" adjust) (concat "amixer set " mixer " 2%+"))
+ ((string-equal "-" adjust) (concat "amixer set " mixer " 2%-"))
+ (t (concat "amixer set " mixer " toggle")))
+ tail
+ sed))))
+
+(defun banish-rat ()
+ (interactive)
+ (shell-command "xdotool mousemove 1366 768")
+ (message "Rat banished."))
+
+(use-package exwm
+ :if (window-system)
+ :ensure t
+ :demand
+ :config
+
+ (setq exwm-workspace-number 1
+ exwm-workspace-switch-create-limit 5
+ exwm-workspace-show-all-buffers nil)
+
+ (add-hook 'exwm-update-class-hook
+ (lambda ()
+ (exwm-workspace-rename-buffer exwm-class-name)))
+
+ ;; -------------------------------------------------------------------
+ ;; Global key binds
+
+ (setq exwm-input-simulation-keys
+ '(([?\C-b] . [left])
+ ([?\C-f] . [right])
+ ([?\C-p] . [up])
+ ([?\C-n] . [down])
+ ([?\C-a] . [home])
+ ([?\C-e] . [end])
+ ([?\M-v] . [prior])
+ ([?\C-v] . [next])
+ ([?\C-s] . [C-f])
+ ;;([?\C-d] . [delete])
+ ;;([?\C-k] . [S-end delete])
+ ))
+
+ ;; reset
+ (exwm-input-set-key (kbd "s-r") 'exwm-reset)
+
+ ;; workspaces
+ (exwm-input-set-key (kbd "s-e") 'exwm-workspace-switch)
+
+ (dotimes (i 10)
+ (exwm-input-set-key (kbd (format "s-%d" i))
+ `(lambda ()
+ (interactive)
+ (exwm-workspace-switch-create ,i))))
+
+ ;; buffer and window management
+ (exwm-input-set-key (kbd "s-<tab>") 'next-buffer)
+
+ (defvar exwm-last-workspace-index 0)
+ (defun exwm-last-workspace ()
+ (interactive)
+ (let ((temp exwm-workspace-current-index))
+ (exwm-workspace-switch exwm-last-workspace-index)
+ (setq exwm-last-workspace-index temp)))
+
+ (exwm-input-set-key (kbd "s-n") 'ivy-switch-buffer)
+ (exwm-input-set-key (kbd "s-o") 'switch-window)
+ (exwm-input-set-key (kbd "s-\\") 'exwm-last-workspace)
+
+ (exwm-input-set-key (kbd "s-b") 'banish-rat)
+
+ ;; run command
+ (exwm-input-set-key (kbd "s-c") (lambda ()
+ (interactive)
+ (start-process "" nil "st")))
+ (exwm-input-set-key (kbd "s-q") (lambda ()
+ (interactive)
+ (start-process "" nil "firefox-esr")))
+ (exwm-input-set-key (kbd "s-<f2>") (lambda ()
+ (interactive)
+ (start-process "" nil "lock")))
+ (exwm-input-set-key (kbd "s-p") (lambda (command)
+ (interactive (list (read-shell-command "$ ")))
+ (start-process-shell-command command nil command)))
+ ;; Volume
+ (exwm-input-set-key (kbd "s-<f10>")
+ (lambda ()
+ (interactive)
+ (adjust-volume "Speaker" "+")))
+
+ (exwm-input-set-key (kbd "s-<f9>")
+ (lambda ()
+ (interactive)
+ (adjust-volume "Speaker" "-")))
+
+ (exwm-input-set-key (kbd "s-<f8>")
+ (lambda ()
+ (interactive)
+ (adjust-volume "Speaker" "toggle")))
+
+ (exwm-input-set-key (kbd "C-s-<f10>")
+ (lambda ()
+ (interactive)
+ (adjust-volume "Headphone" "+")))
+
+ (exwm-input-set-key (kbd "C-s-<f9>")
+ (lambda ()
+ (interactive)
+ (adjust-volume "Headphone" "-")))
+
+ (exwm-input-set-key (kbd "C-s-<f8>")
+ (lambda ()
+ (interactive)
+ (adjust-volume "Headphone" "toggle")))
+
+ (exwm-input-set-key (kbd "s-<f7>") (lambda ()
+ (interactive)
+ (shell-command "$HOME/bin/backlight_up.sh")
+ (message "Backlight up.")))
+
+ (exwm-input-set-key (kbd "s-<f6>") (lambda ()
+ (interactive)
+ (shell-command "$HOME/bin/backlight_down.sh")
+ (message "Backlight down.")))
+
+ ;; -------------------------------------------------------------------
+ ;; RandR
+
+ (require 'exwm-randr)
+ (exwm-randr-enable)
+
+ (setq exwm-randr-workspace-monitor-plist
+ '(1 "HDMI-1" 0 "eDP-1"))
+
+ (exwm-enable))
+
+;; -----------------------------------------------------------------------------
+;; EXWM-edit
+
+(use-package exwm-edit
+ :ensure t
+ :config
+ (add-hook 'exwm-edit-compose-hook (lambda ()
+ (text-mode))))
diff --git a/emacs/inits/01-basic.el b/emacs/inits/01-basic.el
new file mode 100644
index 0000000..5c66367
--- /dev/null
+++ b/emacs/inits/01-basic.el
@@ -0,0 +1,126 @@
+;; Time-stamp: <2019-09-11 10:19:29 (tslil@basingstoke)>
+
+;; -----------------------------------------------------------------------------
+;; Interface
+
+(tool-bar-mode -1)
+(menu-bar-mode -1)
+(scroll-bar-mode -1)
+(fset 'yes-or-no-p 'y-or-n-p)
+
+(setq select-enable-clipboard t
+ select-enable-primary t
+ save-interprogram-paste-before-kill t
+ require-final-newline t
+ visible-bell nil)
+
+(setq echo-keystrokes 0.1
+ confirm-kill-emacs 'y-or-n-p
+ disabled-command-function nil
+ ring-bell-function 'ignore)
+
+(size-indication-mode t)
+
+(defun enlarge-to-fill ()
+ "Stretch the buffer to accomodate `fill-column` many columns."
+ (interactive)
+ (let ((ww (window-width)))
+ (when (< ww (+ 1 fill-column))
+ (enlarge-window-horizontally (- (+ 1 fill-column) ww)))))
+
+(global-set-key (kbd "C-c 3") (lambda ()
+ (interactive)
+ (split-window-horizontally)
+ (enlarge-to-fill)))
+
+(blink-cursor-mode 0)
+(setq cursor-type 'box)
+(set-cursor-color "black")
+
+(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
+(when (eq 'x (window-system))
+ (load-theme 'zenburn t)
+ (set-face-attribute 'default nil :font "Fira Code-14"))
+
+(set-fringe-style 0)
+;; (set-fringe-mode 128)
+
+;; -----------------------------------------------------------------------------
+;; Backups
+
+(setq backup-by-copying t
+ backup-directory-alist '((".*" . "~/store/backups/"))
+ delete-old-versions t
+ kept-new-versions 6
+ kept-old-versions 2
+ version-control t)
+
+(setq create-lockfiles nil)
+
+;; -----------------------------------------------------------------------------
+;; Defaults
+
+(setq fill-column 80)
+
+(setq standard-indent 2)
+(setq-default tab-width 2
+ indent-tabs-mode nil)
+(add-hook 'before-save-hook #'whitespace-cleanup)
+
+(show-paren-mode t)
+
+(setq-default truncate-lines t
+ truncate-partial-width-windows nil)
+(setq scroll-step 1)
+
+(setq next-line-add-newlines nil)
+
+(setq enable-dir-local-variables nil)
+
+;; -----------------------------------------------------------------------------
+;; Packages
+
+(use-package recentf
+ :demand t
+ :config
+ (setq recentf-max-saved-items 42)
+ (recentf-mode))
+
+(use-package uniquify
+ :config
+ (setq uniquify-buffer-name-style 'forward))
+
+(require 'saveplace)
+(save-place-mode)
+
+(use-package undo-tree
+ :ensure t
+ :config (setq undo-tree-visualizer-timestamps t)
+ (global-undo-tree-mode 1))
+
+(use-package keyfreq
+ :ensure t
+ :config
+ (setq keyfreq-file "~/.emacs.d/keyfreq"
+ keyfreq-file-lock "~/.emacs.d/keyfreq.lock")
+ (keyfreq-mode 1)
+ (keyfreq-autosave-mode 1))
+
+;; -----------------------------------------------------------------------------
+;; Scratch buffer
+
+(defun immortal-scratch ()
+ (if (eq (current-buffer) (get-buffer "*scratch*"))
+ (progn (bury-buffer) nil) t))
+
+(add-hook 'kill-buffer-query-functions 'immortal-scratch)
+
+;; I couldn't figure the config options out, so this is the next best thing
+(defun display-startup-echo-area-message () nil)
+
+(setq initial-scratch-message nil
+ initial-buffer-choice t)
+
+(add-hook 'after-init-hook
+ (lambda ()
+ (setq default-directory "~/")))
diff --git a/emacs/inits/02-modeline.el b/emacs/inits/02-modeline.el
new file mode 100644
index 0000000..58b2cd1
--- /dev/null
+++ b/emacs/inits/02-modeline.el
@@ -0,0 +1,96 @@
+;; Time-stamp: <2019-08-13 14:43:24 (tslil@basingstoke)>
+
+;; -----------------------------------------------------------------------------
+;; Battery status and CPU temperature
+
+(defvar sys-status "")
+(defvar sys-status-cpu-temp-threshold "45")
+
+(defun linux-sys-status ()
+ (let ((bat-s (if (not (file-exists-p "/sys/class/power_supply/sbs-20-000b/uevent")) ""
+ (with-temp-buffer
+ (insert-file-contents "/sys/class/power_supply/sbs-20-000b/uevent")
+ (re-search-forward "POWER_SUPPLY_STATUS=\\(Discharging\\|Charging\\|Full\\)")
+ (let ((status (match-string 1)))
+ (if (string-equal "Full" status) "Full"
+ (let* ((perc (progn
+ (re-search-forward "POWER_SUPPLY_CAPACITY=\\([0-9]+\\)")
+ (match-string 1)))
+ (field (concat "POWER_SUPPLY_TIME_TO_"
+ (if (string-equal "Discharging" status)
+ "EMPTY" "FULL")
+ "_AVG=\\([0-9]+\\)"))
+ (seconds (progn
+ (re-search-forward field)
+ (string-to-number (match-string 1))))
+ (hours (/ seconds 3600))
+ (minutes (/ (- seconds (* hours 3600)) 60)))
+ (format "%s%s%% %dh%dm"
+ (substring status 0 1)
+ perc hours minutes)))))))
+ (temp-s (if (not (file-exists-p "/sys/class/thermal/thermal_zone1/temp")) ""
+ (with-temp-buffer
+ (insert-file-contents "/sys/class/thermal/thermal_zone1/temp")
+ (let ((temp (substring-no-properties (buffer-string) 0 -4)))
+ (if (string-greaterp temp sys-status-cpu-temp-threshold)
+ (concat " " temp "C") ""))))))
+ (if (and (string-blank-p bat-s) (string-blank-p temp-s))
+ "" (format " [%s%s]" bat-s temp-s))))
+
+(defun sys-status-update ()
+ (setq sys-status (linux-sys-status)))
+
+(defvar sys-status-update-timer (run-at-time nil 60 'sys-status-update))
+
+;; -----------------------------------------------------------------------------
+;; Remind me of my mortality
+
+(defun mortality ()
+ (format " %.4f"
+ (/ (float-time
+ (time-subtract (current-time)
+ (encode-time 0 0 0 DAY MONTH YEAR)))
+ (* 60 60 24 364.25))))
+
+;; -----------------------------------------------------------------------------
+;; Mode-line and minibuffer defaults
+
+(use-package minibuffer-line
+ :ensure t
+ :config
+ (setq minibuffer-line-refresh-interval 60
+ minibuffer-line-format
+ '("" (:eval (format-time-string "%d/%H.%M"))
+ display-time-string
+ (sys-status sys-status)
+ (:eval (mortality))
+ " " (:eval (abbreviate-file-name default-directory))))
+ ;; We redefine this function to centre the text
+ ;; Is there a better way?
+ (defun minibuffer-line--update ()
+ (with-current-buffer minibuffer-line--buffer
+ (erase-buffer)
+ (insert (format-mode-line minibuffer-line-format 'minibuffer-line))
+ (setq fill-column (frame-width))
+ (center-line)))
+ (minibuffer-line-mode 1))
+
+;; really want to hook buffer changes at all, and focus
+(add-hook 'minibuffer-exit-hook #'minibuffer-line--update)
+
+(setq global-mode-string nil)
+(setq-default mode-line-format
+ '("" mode-line-front-space
+ mode-line-modified "%@"
+ " %l:%c %[" mode-line-buffer-identification "%] %I"
+ " " mode-line-modes ;; (vc-mode vc-mode)
+ mode-line-misc-info mode-line-end-spaces))
+
+;; -----------------------------------------------------------------------------
+;; Minions to clean mode-line
+
+(use-package minions
+ :ensure t
+ :config
+ (setq minions-mode-line-lighter ":")
+ (minions-mode 1))
diff --git a/emacs/inits/03-miscload.el b/emacs/inits/03-miscload.el
new file mode 100644
index 0000000..2ac2f54
--- /dev/null
+++ b/emacs/inits/03-miscload.el
@@ -0,0 +1,17 @@
+;; Time-stamp: <2019-01-26 12:49:48 (tslil@winslow)>
+
+;;(add-to-list 'load-path (expand-file-name "~/.emacs.d/scripts/"))
+
+(add-to-list 'load-path (expand-file-name "~/.emacs.d/scripts/siege-mode"))
+(autoload 'siege-mode "siege-mode" nil t)
+
+;; (use-package siege-mode
+;; :defer t
+;; :load-path "/home/tslil/.emacs.d/scripts/siege-mode/siege-mode.el")
+
+(use-package imaxima
+ :defer t
+ :config (setq imaxima-use-maxima-mode-flag t))
+
+(use-package notmuch
+ :defer t)
diff --git a/emacs/inits/04-input_method.el b/emacs/inits/04-input_method.el
new file mode 100644
index 0000000..b463ff6
--- /dev/null
+++ b/emacs/inits/04-input_method.el
@@ -0,0 +1,14 @@
+;; Time-stamp: <2019-09-11 11:26:28 (tslil@basingstoke)>
+
+(use-package agda-input
+ :load-path "~/.emacs.d/scripts/"
+ :config
+ (dolist (sym '(("chimney" "╝")
+ ("==>" "⟹")
+ ("amalg" "⨿")
+ ("bG" "𝔾")
+ ("bU" "𝕌")))
+ (add-to-list 'agda-input-user-translations sym))
+ (agda-input-setup))
+
+(setq-default default-input-method "Agda")
diff --git a/emacs/inits/05-helpful.el b/emacs/inits/05-helpful.el
new file mode 100644
index 0000000..f8ac203
--- /dev/null
+++ b/emacs/inits/05-helpful.el
@@ -0,0 +1,17 @@
+;; Time-stamp: <2019-01-26 12:49:57 (tslil@winslow)>
+
+(use-package helpful
+ :ensure t
+ :bind (("C-h f" . helpful-callable)
+ ("C-h v" . helpful-variable)
+ ("C-h k" . helpful-key)
+ ("C-h F" . helpful-function)
+ ("C-c h" . heplful-at-point))
+ :config
+ (advice-add #'describe-key :override #'helpful-key)
+ (advice-add #'describe-function :override #'helpful-callable)
+ (advice-add #'describe-variable :override #'helpful-variable)
+ (advice-add #'describe-symbol :override #'helpful-symbol))
+
+(use-package apropos
+ :config (setq apropos-do-all t))
diff --git a/emacs/inits/06-dashboard.el b/emacs/inits/06-dashboard.el
new file mode 100644
index 0000000..7aae2a0
--- /dev/null
+++ b/emacs/inits/06-dashboard.el
@@ -0,0 +1,30 @@
+;; Time-stamp: <2019-09-11 10:42:40 (tslil@basingstoke)>
+
+(use-package fortune
+ :config
+ (setq fortune-dir "/usr/share/games/fortunes/"
+ fortune-program "fortune"
+ fortune-file "/usr/share/games/fortunes/cookie"
+ fortune-program-options '("-s"))
+ (defun dashboard-fortune (n)
+ (insert
+ (with-temp-buffer
+ (let ((fortune-buffer-name (current-buffer)))
+ (fortune-in-buffer t)
+ (buffer-string))))))
+
+(use-package dashboard
+ :ensure t
+ :config
+ (add-to-list 'dashboard-item-generators '(fortune . dashboard-fortune))
+
+ (setq dashboard-center-content t
+ dashboard-set-init-info t
+ dashboard-set-footer nil
+ dashboard-startup-banner 1
+ dashboard-items '((recents . 5)
+ (projects . 5)
+ (fortune . 0))
+ dashboard-init-info (format "Welcome ~%s!" (user-login-name)))
+
+ (dashboard-setup-startup-hook))
diff --git a/emacs/inits/10-ivy.el b/emacs/inits/10-ivy.el
new file mode 100644
index 0000000..8867bb8
--- /dev/null
+++ b/emacs/inits/10-ivy.el
@@ -0,0 +1,117 @@
+;; Time-stamp: <2019-09-09 22:10:08 (tslil@basingstoke)>
+
+(use-package amx :ensure t)
+
+(use-package counsel :ensure t
+ :after amx
+ :demand
+ :defines (counsel-for-files)
+ :bind (("C-s" . counsel-grep-or-swiper)
+ ("C-x f" . counsel-recentf)
+ ("C-x l" . counsel-locate)
+ ("C-c C-r" . ivy-resume)
+ ("C-c g" . counsel-rg)
+ ("M-x" . counsel-M-x)
+ ("C-s" . swiper-isearch)
+ :map ivy-minibuffer-map
+ ("C-m" . ivy-alt-done)
+ :map swiper-map
+ ("M-%" . swiper-query-replace))
+ :config
+ (setq ivy-use-virtual-buffers nil
+ ivy-display-style 'fancy
+ ivy-initial-inputs-alist nil
+ ivy-format-function 'ivy-format-function-line
+ ivy-count-format "")
+
+ (setq swiper-use-visual-line t)
+
+ (setq counsel-find-file-at-point t
+ counsel-grep-base-command
+ "rg -i -M 120 --no-heading --line-number --color never '%s' %s"
+ counsel-describe-function-function 'helpful-function
+ counsel-describe-variable-function 'helpful-variable)
+
+ (ivy-mode t)
+ (counsel-mode t))
+
+
+(use-package ivy-rich :ensure t
+ :config
+ (setq ivy-rich-path-style 'abbrev
+ ivy-rich-display-transformers-list
+ '(ivy-switch-buffer
+ (:columns
+ ((ivy-rich-candidate (:width 20))
+ (ivy-rich-switch-buffer-size (:width 7 :align right))
+ (ivy-rich-switch-buffer-indicators
+ (:width 2 :face error :align right))
+ (ivy-rich-switch-buffer-major-mode (:width 12 :face warning))
+ (ivy-rich-switch-buffer-project (:width 8 :face success))
+ (ivy-rich-switch-buffer-path
+ (:width (lambda (x)
+ (ivy-rich-switch-buffer-shorten-path
+ x (ivy-rich-minibuffer-width 0.3))))))
+ :predicate (lambda (cand) (get-buffer cand)))
+ counsel-M-x
+ (:columns
+ ((counsel-M-x-transformer (:width 40))
+ (ivy-rich-counsel-function-docstring
+ (:face font-lock-doc-face))))
+ counsel-describe-function
+ (:columns
+ ((counsel-describe-function-transformer (:width 40))
+ (ivy-rich-counsel-function-docstring
+ (:face font-lock-doc-face))))
+ counsel-describe-variable
+ (:columns
+ ((counsel-describe-variable-transformer (:width 40))
+ (ivy-rich-counsel-variable-docstring
+ (:face font-lock-doc-face))))
+ counsel-recentf
+ (:columns
+ ((ivy-rich-candidate (:width 0.8))
+ (ivy-rich-file-last-modified-time
+ (:face font-lock-comment-face))))))
+
+ (ivy-rich-mode 1))
+
+;; (defun limited-counsel-locate-cmd (input)
+;; "Return a shell command based on INPUT."
+;; (counsel-require-program "locate")
+;; (format "locate -l 10 -i --regex '%s'"
+;; (counsel-unquote-regex-parens
+;; (ivy--regex input))))
+
+;; (defun bad ()
+;; (interactive)
+;; (let (process buffer)
+;; (ivy-read "File: "
+;; #'(lambda (input)
+;; (append
+;; '("Recent Files\n" . "")
+;; (recentf-elements 10)
+;; (directory-files default-directory "")
+;; (mapcar (lambda (b) (buffer-name b)) (buffer-list))
+;; (if (< (length input) 3) (counsel-more-chars 3)
+;; ;; (counsel--async-command
+;; ;; (funcall #'limited-counsel-locate-cmd input))
+;; (when process (kill-process process))
+;; (setq process (start-file-process-shell-command
+;; "*locate*"
+;; "*locate*"
+;; (funcall #'limited-counsel-locate-cmd input))))
+;; ))
+;; :dynamic-collection t
+;; :unwind #'(progn (kill-buffer))
+;; :sort nil
+;; :action #'(lambda (x)
+;; (with-ivy-window
+;; (if (file-exists-p x) (find-file x)
+;; (switch-to-buffer x)))))))
+
+;; '(helm-source-recentf
+;; helm-source-file-cache
+;; helm-source-files-in-current-dir
+;; helm-source-buffers-list
+;; helm-source-locate)
diff --git a/emacs/inits/12-company.el b/emacs/inits/12-company.el
new file mode 100644
index 0000000..d514496
--- /dev/null
+++ b/emacs/inits/12-company.el
@@ -0,0 +1,17 @@
+;; Time-stamp: <2019-01-26 12:50:26 (tslil@winslow)>
+
+(use-package company :ensure t
+ :bind (("M-<tab>" . company-complete)
+ :map company-active-map
+ ("C-n" . company-select-next)
+ ("C-p" . company-select-previous))
+
+ :config
+ (setq company-begin-commands '(self-insert-command)
+ company-idle-delay 1
+ company-require-match nil
+ company-show-numbers t
+ company-auto-complete 'company-explicit-action-p
+ company-tooltip-align-annotations t)
+
+ (global-company-mode))
diff --git a/emacs/inits/13-ibuffer.el b/emacs/inits/13-ibuffer.el
new file mode 100644
index 0000000..c46babe
--- /dev/null
+++ b/emacs/inits/13-ibuffer.el
@@ -0,0 +1,70 @@
+;; Time-stamp: <2019-05-26 18:21:05 (tslil@basingstoke)>
+
+(use-package ibuffer
+ :bind (("C-x C-b" . ibuffer))
+ :hook (ibuffer-mode . (lambda ()
+ (ibuffer-switch-to-saved-filter-groups "default")))
+ :config
+ (setq ibuffer-display-summary nil
+ ibuffer-saved-filter-groups
+ '(("default"
+ ("agda" (or (mode . agda2-mode)
+ (name . "^\\*[aA]gda")))
+ ("coq" (or (mode . coq-mode)
+ (mode . coq-goals-mode)
+ (mode . coq-response-mode)
+ (mode . coq-shell-mode)))
+ ("dired" (mode . dired-mode))
+ ("elisp" (or (mode . emacs-lisp-mode)
+ (name . "^\\*Backtrace\\*")))
+ ("emacs" (or (name . "^\\*scratch\\*$")
+ (name . "^\\*Messages\\*$")
+ (name . "^\\*init log\\*$")
+ (name . "^\\*Compile-Log\\*$")))
+ ("exwm" (mode . exwm-mode))
+ ("help" (or (mode . helpful-mode)
+ (name . "^\\*Help\\*$")))
+ ("irc" (mode . rcirc-mode))
+ ("magit" (name . "^magit[:-]"))
+ ("media" (or (mode . image-mode)
+ (mode . doc-view-mode)))
+ ("org" (mode . org-mode))
+ ("REPL" (name . "^\\*.*REPL.*\\*$"))
+ ("slime" (name . "^\\*slime-[^*]*\\*$"))
+ ("tex" (mode . latex-mode))
+ ("web" (or (mode . js2-mode)
+ (mode . js-mode)
+ (mode . html-mode)
+ (mode . css-mode)
+ (mode . mhtml-mode))))))
+
+ (defadvice ibuffer-update-title-and-summary (after remove-column-titles)
+ (with-current-buffer "*Ibuffer*"
+ (read-only-mode -1)
+ (goto-char 1)
+ (search-forward "-\n" nil t)
+ (delete-region 1 (point))
+ (let ((window-min-height 1))
+ ;; save a little screen estate
+ (shrink-window-if-larger-than-buffer))
+ (read-only-mode 1)))
+
+ (ad-activate 'ibuffer-update-title-and-summary)
+
+ (define-ibuffer-column size-h
+ (:name "Size" :inline t)
+ (cond
+ ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
+ ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
+ ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
+ (t (format "%8d" (buffer-size)))))
+
+ (setq ibuffer-formats
+ '((mark modified read-only locked " "
+ (name 18 18 :left :elide)
+ " "
+ (size-h 9 -1 :right)
+ " "
+ (mode 16 16 :left :elide)
+ " "
+ filename-and-process))))
diff --git a/emacs/inits/14-movement.el b/emacs/inits/14-movement.el
new file mode 100644
index 0000000..a1b27f6
--- /dev/null
+++ b/emacs/inits/14-movement.el
@@ -0,0 +1,170 @@
+;; Time-stamp: <2019-08-14 11:59:46 (tslil@basingstoke)>
+
+;; (eval-after-load "tiny-menu"
+;; (progn
+;; (defun hexl-input-smart ()
+;; (hexl-insert-char (0xc-string-to-number (read-string "Input: ")) 1))
+
+;; (setq tiny-menu-forever t
+;; tiny-menu-items '(("hexl-menu"
+;; ("hexl"
+;; ((?i "Insert" hexl-input-smart)
+;; (?b "Byte" hexl-forward-char)
+;; (?e "bytE" hexl-backward-char)
+;; (?s "Short" hexl-forward-short)
+;; (?t "shorT" hexl-backward-short))))
+;; ))))
+
+;; (add-hook 'hexl-mode-hook
+;; (lambda ()
+;; (require '0xc)
+;; (require 'tiny-menu)
+;; (define-key hexl-mode-map (kbd "M-l")
+;; (lambda () (interactive) (tiny-menu "hexl-menu")))))
+
+;; -------------------------------------------------------------------
+;; Repeated key presses for region, deletion, and movement
+
+(use-package expand-region :ensure t
+ :bind ("C-r" . er/expand-region)
+ :config
+ (setq expand-region-fast-keys-enabled t
+ expand-region-contract-fast-key "c"
+ expand-region-reset-fast-key "e"
+ expand-region-autocopy-register "i"))
+
+(use-package viking-mode
+ :disabled
+ :after expand-region
+ :bind (:map viking-mode-map
+ ("C-d" . nil)
+ ("C-c d" . viking-kill-thing-at-point))
+ :config
+ (setq viking-use-expand-region-when-loaded t
+ viking-really-delete nil)
+ (viking-global-mode))
+
+;; (defun goto-begin-dwim ()
+;; "Read the source."
+;; (interactive)
+;; (let ((iter (viking-last-key-repeats))
+;; (lisp (memq major-mode '(emacs-lisp-mode
+;; lisp-mode
+;; scheme-mode
+;; slime-repl-mode))))
+;; (if lisp
+;; (cond
+;; ((= iter 1) (back-to-indentation))
+;; ((= iter 2) (backward-sexp))
+;; ((= iter 3) (beginning-of-defun))
+;; (t (beginning-of-defun 1)))
+;; (cond
+;; ((= iter 1) (back-to-indentation))
+;; ((= iter 2) (beginning-of-line))
+;; ((= iter 3) (backward-paragraph))
+;; (t (goto-char (point-min)))))))
+
+;; (defun goto-end-dwim ()
+;; "Read the source."
+;; (interactive)
+;; (let ((iter (viking-last-key-repeats))
+;; (lisp (memq major-mode '(emacs-lisp-mode lisp-mode scheme-mode slime-repl-mode))))
+;; (if lisp
+;; (cond
+;; ((= iter 1) (end-of-line))
+;; ((= iter 2) (end-of-defun))
+;; (t (end-of-defun 1)))
+;; (if (< (point) (point-at-eol)) (end-of-line)
+;; (forward-paragraph)))))
+
+;; (global-set-key (kbd "C-a") 'goto-begin-dwim)
+;; (global-set-key (kbd "C-e") 'goto-end-dwim)
+
+;; -------------------------------------------------------------------
+;; Window switching
+(use-package switch-window :ensure t
+ :bind (("C-x o" . switch-window)
+ ("C-x C-o" . other-frame)
+ ("C-c o" . switch-window)
+ ("C-c n" . switch-window-then-maximize)
+ :map switch-window-extra-map
+ ("u" . switch-window-mvborder-up)
+ ("e" . switch-window-mvborder-down)
+ ("n" . switch-window-mvborder-left)
+ ("o" . switch-window-mvborder-right)
+ ("i" . nil)
+ ("j" . nil)
+ ("k" . nil)
+ ("l" . nil))
+ :config
+ (setq switch-window-input-style 'minibuffer
+ switch-window-shortcut-style 'qwerty
+ switch-window-multiple-frames nil
+ switch-window-qwerty-shortcuts
+ '("a" "s" "t" "h" "n" "e" "o" "i" "d" "r" "w" "f" "u" "p")))
+
+;; -------------------------------------------------------------------
+;; Character jumping
+(use-package avy
+ :ensure t
+ :demand
+ :bind (("C-," . avy-goto-char-timer)
+ ("C-." . avy-goto-char-in-line)
+ ("M-g s" . avy-goto-word-or-subword-1)
+ ("M-g w" . avy-goto-word-1)
+ ("M-g a" . avy-goto-word-0)
+ ("M-g M-g" . avy-goto-line))
+ :config
+ (setq avy-keys '(?a ?s ?t ?h ?n ?e ?o ?i ?d ?r ?u ?p)
+ avy-dispatch-alist '((?w . avy-action-kill-move)
+ (?W . avy-action-kill-stay)
+ (?j . avy-action-teleport)
+ (?m . avy-action-mark)
+ (?c . avy-action-copy)
+ (?y . avy-action-yank)
+ (?i . avy-action-ispell)
+ (?z . avy-action-zap-to-char))))
+
+;; -------------------------------------------------------------------
+;; General stuff
+
+(global-set-key (kbd "C-M-e") 'end-of-buffer)
+(global-set-key (kbd "C-M-a") 'beginning-of-buffer)
+
+(global-set-key (kbd "M-h") 'backward-kill-word)
+
+(global-set-key (kbd "M-z") 'zap-up-to-char)
+
+;; Fast movement
+(global-set-key (kbd "M-n") 'scroll-up-command)
+(global-set-key (kbd "M-p") 'scroll-down-command)
+
+(global-set-key (kbd "C-S-n")
+ (lambda () (interactive) (ignore-errors (forward-line 5))))
+
+(global-set-key (kbd "C-S-p")
+ (lambda () (interactive) (ignore-errors (forward-line -5))))
+
+(global-set-key (kbd "C-S-f")
+ (lambda () (interactive) (ignore-errors (forward-char 5))))
+
+(global-set-key (kbd "C-S-b")
+ (lambda () (interactive) (ignore-errors (backward-char 5))))
+
+;; Hardcore mode
+(defconst hardcore-nav-mode t)
+(when hardcore-nav-mode
+ (global-set-key (kbd "<right>") nil)
+ (global-set-key (kbd "<left>") nil)
+ (global-set-key (kbd "<up>") nil)
+ (global-set-key (kbd "<down>") nil)
+ (global-set-key (kbd "S-<right>") nil)
+ (global-set-key (kbd "S-<left>") nil)
+ (global-set-key (kbd "S-<up>") nil)
+ (global-set-key (kbd "C-<down>") nil)
+ (global-set-key (kbd "C-<right>") nil)
+ (global-set-key (kbd "C-<left>") nil)
+ (global-set-key (kbd "C-<up>") nil)
+ (global-set-key (kbd "C-<down>") nil)
+ (global-set-key (kbd "<Home>") nil)
+ (global-set-key (kbd "<End>") nil))
diff --git a/emacs/inits/15-project-mgmt.el b/emacs/inits/15-project-mgmt.el
new file mode 100644
index 0000000..8197f99
--- /dev/null
+++ b/emacs/inits/15-project-mgmt.el
@@ -0,0 +1,18 @@
+;; Time-stamp: <2019-04-09 23:20:17 (tslil@bison)>
+
+(use-package projectile
+ :ensure t
+ :bind (("C-c p" . projectile-switch-project)
+ ("C-c f" . projectile-find-file-dwim))
+ :config
+ (projectile-mode 1)
+
+ (setq projectile-completion-system 'ivy
+ projectile-mode-line-prefix ""
+ projectile-mode-line-function '(lambda ()
+ (format " ¶[%s]"
+ (projectile-project-name)))))
+
+(use-package magit
+ :ensure t
+ :bind (("C-x g" . magit-status)))
diff --git a/emacs/inits/20-programming.el b/emacs/inits/20-programming.el
new file mode 100644
index 0000000..e2e0494
--- /dev/null
+++ b/emacs/inits/20-programming.el
@@ -0,0 +1,121 @@
+;; Time-stamp: <2019-09-11 11:30:39 (tslil@basingstoke)>
+
+;; -----------------------------------------------------------------------------
+;; General setup
+
+(defadvice compile (around split-horizontally activate)
+ (let ((split-width-threshold 0)
+ (split-height-threshold nil))
+ ad-do-it))
+
+(defadvice compile (after resize-window-properly activate)
+ (let ((ww (window-width)))
+ (when (< ww (+ 5 fill-column))
+ (enlarge-window-horizontally (- (+ 5 fill-column) ww)))))
+
+(defun programming-setup ()
+ (subword-mode 1)
+ (electric-pair-local-mode)
+ ;; Emacs25 compat
+ (if (fboundp 'display-line-numbers-mode)
+ (display-line-numbers-mode)
+ (linum-mode))
+ (setq auto-hscroll-mode t))
+
+(add-hook 'prog-mode-hook #'programming-setup)
+
+;; -----------------------------------------------------------------------------
+;; Specific packages
+
+(use-package shift-number
+ :ensure t
+ :bind (("C-c S-i" . shift-number-up)
+ ("C-c S-d" . shift-number-down)))
+
+(use-package comment-dwim-2
+ :ensure t
+ :bind (("M-;" . comment-dwim-2)))
+
+(use-package aggressive-indent
+ :ensure t
+ :defer t)
+
+(use-package yasnippet
+ :ensure t
+ :defer t)
+
+(use-package elec-pair
+ :defer t
+ :config
+ (setq electric-pair-delete-adjacent-pairs t
+ electric-pair-skip-self t
+ electric-pair-preserve-balance t
+ electric-pair-skip-whitespace t))
+
+(use-package js-comint
+ :ensure t
+ :defer t
+ :config
+ (setq js-comint-program-command "node"
+ js-comint-program-arguments nil))
+
+(use-package js2-mode
+ :ensure t
+ :defer t
+ :after js-comint
+ :mode "\\.js$"
+ :bind (:map js2-mode-map
+ ("TAB" . js2-indent-line)
+ ("C-x C-e" . js-send-last-sexp)
+ ("C-c C-b" . js-send-buffer)
+ ("C-c C-l" . js-load-file))
+ :hook (js2-mode . (lambda ()
+ (auto-revert-mode -1)
+ (yas-minor-mode-on))))
+
+;; What are these?
+;; (setq gdb-show-threads-by-default nil
+;; gdb-many-windows nil
+;; gdb-show-main nil)
+
+
+(use-package flycheck
+ :defer t
+ :ensure t)
+
+(use-package irony
+ :ensure t
+ :defer t
+ :hook (lambda ()
+ (irony-cdb-autosetup-compile-options)
+ (company-irony-setup-begin-commands)))
+
+(use-package cc-mode
+ :defer t
+ :config
+ (c-set-offset 'case-label '+)
+ (setq-default c-basic-offset 2))
+
+(add-hook 'c-mode-hook
+ (lambda ()
+ (irony-mode)
+ (abbrev-mode 0)
+ (flycheck-mode)
+ (flycheck-irony-setup)
+ (c-toggle-hungry-state 1)
+ (c-toggle-electric-state 1)
+ (c-toggle-syntactic-indentation 1)))
+
+(use-package flycheck-rust
+ :after flycheck
+ :ensure t
+ :defer t)
+
+(use-package rust-mode
+ :ensure t
+ :defer t
+ :bind (:map rust-mode-map
+ ("C-c C-c" . rust-compile))
+ :hook (rust-mode . (lambda ()
+ (flycheck-mode)
+ (flycheck-rust-setup))))
diff --git a/emacs/inits/21-functional.el b/emacs/inits/21-functional.el
new file mode 100644
index 0000000..90d0fba
--- /dev/null
+++ b/emacs/inits/21-functional.el
@@ -0,0 +1,75 @@
+;; Time-stamp: <2019-06-03 17:36:44 (tslil@basingstoke)>
+
+;; -----------------------------------------------------------------------------
+;; Haskell
+
+(use-package haskell-mode
+ :ensure t
+ :defer t)
+
+(use-package intero
+ :ensure t
+ :defer t
+ :hook (haskell-mode . (lambda ()
+ (intero-mode)
+ (flycheck-mode -1)))
+ )
+
+;; (use-package ghc :ensure t :defer t)
+
+;; (use-package company-ghc :ensure t :defer t)
+
+;; (use-package company-ghci :ensure t :defer t)
+
+;; (use-package shm :ensure t
+;; :functions structured-haskell-mode
+;; :bind (:map shm-map
+;; ("C-c C-s" . shm/case-split)))
+
+;; (use-package haskell-mode
+;; :ensure t
+;; :after (company-ghc company-ghci shm)
+;; :bind (:map haskell-mode-map
+;; ("[f8]". haskell-navigate-imports)
+;; ("C-c C-c" . haskell-compile)
+;; ("C-c C-z" . haskell-interactive-switch)
+;; ("C-c C-l" . haskell-process-load-file)
+;; ("C-c C-b" . haskell-interactive-switch)
+;; ("C-c C-t" . haskell-process-do-type)
+;; ("C-c C-i" . haskell-process-do-info)
+;; ("C-x C-d" . nil)
+;; ("C-c M-." . nil)
+;; ("C-c C-d" . nil))
+;; :hook ((haskell-interactive-mode . visual-line-mode)
+;; (haskell-mode . (lambda ()
+;; (subword-mode 1)
+;; (aggressive-indent-mode -1)
+;; (require 'shm)
+;; (require 'shm-case-split)
+;; (require 'ghc)
+;; (ghc-init)
+;; (structured-haskell-mode)
+;; ;; (haskell-indentation-mode)
+;; (interactive-haskell-mode)
+;; (turn-on-haskell-doc-mode)
+;; (turn-on-haskell-decl-scan)
+;; (add-to-list 'company-backends 'company-ghc)
+;; (add-to-list 'company-backends 'company-ghci)
+;; ;; (turn-on-haskell-unicode-input-method)
+;; ;; (haskell-mode-stylish-buffer)
+;; )))
+;; :config
+;; (setq haskell-doc-show-global-types t
+;; haskell-doc-show-prelude t
+;; haskell-doc-show-user-defined t
+;; haskell-doc-show-reserved t
+;; haskell-interactive-mode-eval-pretty t
+;; haskell-process-type 'cabal-repl
+;; company-ghc-show-info t
+;; company-ghc-autoscan t
+;; company-ghc-show-module t
+;; haskell-stylish-on-save t
+;; haskell-process-use-presentation-mode t
+;; haskell-process-suggest-imports t
+;; haskell-process-suggest-hoogle-imports t
+;; haskell-process-show-debug-tips nil))
diff --git a/emacs/inits/22-lisp.el b/emacs/inits/22-lisp.el
new file mode 100644
index 0000000..872fe9a
--- /dev/null
+++ b/emacs/inits/22-lisp.el
@@ -0,0 +1,132 @@
+;; Time-stamp: <2019-03-20 17:11:15 (tslil@basingstoke)>
+
+;; ----------------------------------------------------------------------------
+;; Lisp helpers
+
+(defvar lh-pairs '(("(" . ")")
+ ("[" . "]")
+ ("{" . "}")
+ ("<" . ">")
+ ("\"" . "\"")))
+
+(defun lh-forward-delim ()
+ (interactive)
+ (save-match-data
+ (re-search-forward
+ (regexp-opt (mapcar #'cdr lh-pairs)))))
+
+(defun lh-backward-delim ()
+ (interactive)
+ (save-match-data
+ (re-search-backward
+ (regexp-opt (mapcar #'car lh-pairs)))))
+
+(defun lh-matching-delim ()
+ (interactive)
+ (cond
+ ((looking-at (regexp-opt (mapcar #'car lh-pairs)))
+ (forward-sexp))
+ ((looking-back (regexp-opt (mapcar #'cdr lh-pairs)) nil)
+ (backward-sexp))
+ (t (backward-up-list 1 t t))))
+
+(defun lh-slurp-forward ()
+ (interactive)
+ (corral-shift-backward ?\( ?\)))
+
+(defun lh-slurp-backward ()
+ (interactive)
+ (corral-shift-forward ?\( ?\)))
+
+(defun lh-open-parentheses-dwim (arg)
+ (interactive "P")
+ (if (or (= (line-beginning-position) (point))
+ (looking-at "\\Sw")) (insert-parentheses arg)
+ (backward-sexp)
+ (insert-parentheses 1)))
+
+(defun lh-end-of-defun (arg)
+ (interactive "P")
+ (end-of-defun arg)
+ (re-search-backward ")")
+ (forward-char))
+
+(defun lh-avy-open-paren ()
+ (interactive)
+ (avy-goto-char ?\( ))
+
+(defun lh-avy-close-paren ()
+ (interactive)
+ (avy-goto-char ?\) ))
+
+(use-package corral :ensure t)
+(defun make-lisp-bindings ()
+ (let ((map (eval (read (format "%s-map" major-mode)))))
+ (progn
+ (require 'corral)
+ (define-key map (kbd "M-e") 'forward-sexp)
+ (define-key map (kbd "M-a") 'backward-sexp)
+ (define-key map (kbd "M-,") 'lh-backward-delim)
+ (define-key map (kbd "M-.") 'lh-forward-delim)
+ (define-key map (kbd "M-/") 'lh-matching-delim)
+ (define-key map (kbd "C-c (") 'lh-avy-open-paren)
+ (define-key map (kbd "C-c )") 'lh-avy-close-paren)
+ (define-key map (kbd "(") 'lh-open-parentheses-dwim)
+ (define-key map (kbd "C-c r") 'raise-sexp)
+ (define-key map (kbd "C-k") 'kill-sexp)
+ (define-key map (kbd "M-(") 'corral-parentheses-forward)
+ (define-key map (kbd "M-)") 'corral-parentheses-backward)
+ (define-key map (kbd "M-{") 'corral-braces-forward)
+ (define-key map (kbd "M-}") 'corral-braces-backward)
+ (define-key map (kbd "M-[") 'corral-brackets-forward)
+ (define-key map (kbd "M-]") 'corral-brackets-backward)
+ (define-key map (kbd "C-(") 'lh-slurp-forward)
+ (define-key map (kbd "C-)") 'lh-slurp-backward)
+ (define-key map (kbd "M-p") 'beginning-of-defun)
+ (define-key map (kbd "M-n") 'lh-end-of-defun)
+ t)))
+
+;; ----------------------------------------------------------------------------
+;; Mode configurations
+
+(add-hook 'emacs-lisp-mode-hook
+ (lambda ()
+ (eldoc-mode)
+ (aggressive-indent-mode)
+ (make-lisp-bindings)))
+
+(use-package caps-lock-mode
+ :load-path "~/.emacs.d/scripts/")
+
+(use-package slime-company
+ :ensure t :defer t)
+
+(use-package slime
+ :ensure t
+ :after caps-lock-mode
+ :hook ((lisp-mode . (lambda ()
+ (aggressive-indent-mode)
+ (slime-setup '(slime-fancy
+ slime-asdf
+ slime-banner
+ slime-scratch
+ slime-autodoc
+ slime-company))
+ (slime-mode)
+ (require 'caps-lock-mode)
+ (caps-lock-mode)
+ (make-lisp-bindings)))
+ (inferior-lisp-mode-hook . make-lisp-bindings))
+ :config
+ (setq inferior-lisp-program "sbcl")
+
+ (require 'slime-banner)
+ (setq slime-header-line-p nil
+ slime-kill-without-query-p t))
+
+(use-package geiser
+ :ensure t
+ :hook (scheme-mode . (lambda ()
+ (geiser-mode)
+ (aggressive-indent-mode)
+ (make-lisp-bindings))))
diff --git a/emacs/inits/23-text-related.el b/emacs/inits/23-text-related.el
new file mode 100644
index 0000000..8d48795
--- /dev/null
+++ b/emacs/inits/23-text-related.el
@@ -0,0 +1,133 @@
+;; Time-stamp: <2019-07-17 18:18:58 (tslil@basingstoke)>
+
+;; -----------------------------------------------------------------------------
+;; Spelling
+
+(use-package flyspell-correct-ivy
+ :ensure t :defer t)
+
+(use-package flyspell
+ :ensure t
+ :bind (:map flyspell-mode-map
+ ("M-$" . flyspell-correct-wrapper)
+ ("C-," . nil)
+ ("C-." . nil)
+ ("C-\"" . nil))
+ :init
+ (setq ispell-dictionary "british"
+ flyspell-default-dictionary "british"
+ flyspell-correct-interface #'flyspell-correct-ivy))
+
+(setq sentence-end-double-space nil)
+
+(add-hook 'mail-mode-hook (lambda ()
+ (electric-pair-local-mode 1)
+ (turn-on-auto-fill)
+ (flyspell-mode 1)
+ (company-mode 1)))
+
+(add-hook 'text-mode-hook (lambda ()
+ ;; (set-input-method "Adga")
+ (subword-mode 1)
+ (electric-pair-local-mode 1)
+ (turn-on-auto-fill)
+ (siege-mode 1)
+ (flyspell-mode 1)))
+
+(use-package dictionary :ensure t :defer t)
+
+;; -----------------------------------------------------------------------------
+;; Org
+
+(use-package org
+ :defer t
+ :bind (:map org-mode-map
+ ("M-h" . nil))
+ ;; :hook (org-mode . (lambda ()
+ ;; (activate-input-method default-input-method)))
+ :config
+ (setq org-use-sub-superscripts (quote {})
+ org-modules nil))
+
+
+;; -----------------------------------------------------------------------------
+;; Deft
+
+(use-package deft
+ :ensure t
+ :defer t
+ :commands (deft)
+ :bind (("C-z" . deft-take-note)
+ ("C-c C-z" . deft))
+ :config
+ (setq deft-default-extension "org"
+ deft-directory "~/store/notes"
+ deft-use-filename-as-title nil
+ deft-use-filter-string-for-filename t
+ deft-file-naming-rules '((noslash . "_")
+ (nospace . "_")
+ (case-fn . downcase))
+ deft-org-mode-title-prefix t)
+
+ (defvar deft-take-note-pre-grab
+ '((region-thing . (let ((r (if (region-active-p)
+ (buffer-substring (region-beginning) (region-end))
+ (thing-at-point 'line))))
+ (if r (concat r "\n") "")))
+ (bfn . (let ((f (buffer-file-name))
+ (b (buffer-name))) (if f f (concat b " (no file associated)")))))
+ "List of pairs of symbol names and (functions evaluating to)
+ strings evaluated before the buffer is created, and made
+ available for deft-take-note-default-contents.")
+
+ (defvar deft-take-note-post-grab '()
+ "List of pairs of symbol names and (functions evaluating to)
+ strings evaluated after the buffer is created, and made
+ available for deft-take-note-default-contents.")
+
+ (defvar deft-take-note-default-contents '(region-thing bfn "\n")
+ "List with string literals and symbols defined in the pre and
+ post grab lists to be inserted into the buffer.")
+
+ (defun deft-take-note ()
+ (interactive)
+ (let ((pre-alist (mapcar #'(lambda (elt) `(,(car elt) . ,(eval (cdr elt))))
+ deft-take-note-pre-grab)))
+ (let ((bn (concat (format-time-string "%Y%m%d-%H:%M:%S.%N-%Z") "."
+ deft-default-extension)))
+ (switch-to-buffer bn)
+ (set-visited-file-name (expand-file-name
+ (concat deft-directory "/" bn)))
+ (let ((complete-alist
+ (append pre-alist
+ (mapcar #'(lambda (elt) `(,(car elt) . ,(eval (cdr elt))))
+ deft-take-note-post-grab))))
+ (mapc #'(lambda (elt) (if (eq (type-of elt) 'string)
+ (insert elt)
+ (insert (cdr (assoc elt complete-alist)))))
+ deft-take-note-default-contents))))))
+
+;; -----------------------------------------------------------------------------
+;; Useful keybinds
+
+(defun vi-open-line-above ()
+ "Insert a newline above the current line and put point at beginning."
+ (interactive)
+ (unless (bolp)
+ (beginning-of-line))
+ (newline)
+ (forward-line -1)
+ (indent-according-to-mode))
+
+(defun vi-open-line-below ()
+ "Insert a newline below the current line and put point at beginning."
+ (interactive)
+ (unless (eolp)
+ (end-of-line))
+ (newline-and-indent))
+
+(global-set-key (kbd "M-o") 'vi-open-line-below)
+(global-set-key (kbd "C-o") 'vi-open-line-above)
+
+(global-set-key (kbd "M-C-+") 'text-scale-increase)
+(global-set-key (kbd "M-C--") 'text-scale-decrease)
diff --git a/emacs/inits/24-latex.el b/emacs/inits/24-latex.el
new file mode 100644
index 0000000..98eb70c
--- /dev/null
+++ b/emacs/inits/24-latex.el
@@ -0,0 +1,146 @@
+;; Time-stamp: <2019-05-27 11:22:10 (tslil@basingstoke)>
+
+(defvar latex-template-dir (expand-file-name "~/academic/typeset/latex-templates"))
+(defun prompt-latex-file-template ()
+ "Check if tex file does not exist or the command was called
+interactively. If neither, prompt to insert from a template
+populated from the directory *latex-template-dir*"
+ (interactive)
+ (when (and (if (file-exists-p (buffer-file-name))
+ (called-interactively-p 'interactive)
+ t)
+ (yes-or-no-p "Insert template?"))
+ (let* ((tfiles (directory-files latex-template-dir nil "\\.tex"))
+ (template (ivy-read "Select template: " tfiles)))
+ (when template
+ (goto-char (point-min))
+ (insert-file-contents (concat latex-template-dir "/" template))
+ (search-forward "begin{document}")
+ (forward-line)
+ (save-buffer)))))
+
+;; Why does this not work?
+;; (use-package cdm-mode
+;; :functions cdm-mode
+;; :defer t
+;; :load-path "~/.emacs.d/scripts/")
+(autoload 'cdm-mode "cdm-mode" nil t)
+
+(use-package company-auctex :ensure t :defer t)
+
+(use-package latex
+ :ensure auctex
+ :bind (:map LaTeX-mode-map
+ ("'" . better-TeX-insert-single-quote)
+ ("TAB" . LaTeX-indent-line))
+ :hook (LaTeX-mode . (lambda ()
+ (require 'company-auctex)
+ (electric-pair-local-mode -1)
+ (flyspell-mode)
+ (turn-on-auto-fill)
+ (cdlatex-mode t)
+ (company-auctex-init)
+ (siege-mode 1)
+ (cdm-mode)
+ (prompt-latex-file-template)))
+ :init
+ (defun better-TeX-insert-single-quote ()
+ (interactive)
+ (let ((old-open TeX-open-quote)
+ (old-close TeX-close-quote))
+ (unwind-protect (progn
+ (setq TeX-open-quote "`"
+ TeX-close-quote "'")
+ (call-interactively 'TeX-insert-quote))
+ (setq TeX-open-quote old-open
+ TeX-close-quote old-close))))
+
+ :config
+ (add-to-list 'LaTeX-indent-environment-list
+ '("diagram"))
+ (add-to-list 'LaTeX-indent-environment-list
+ '("diagram*"))
+
+
+ (add-to-list 'TeX-command-list '("XeLaTeX" "xelatex %t" TeX-run-TeX nil
+ (latex-mode doctex-mode)
+ :help "Run XeLaTeX"))
+
+ (setq TeX-electric-sub-and-superscript t
+ TeX-electric-math '("$" . "$")
+ TeX-electric-escape nil
+ LaTeX-electric-left-right-brace t)
+
+ (setq-default TeX-master nil)
+ (setq TeX-auto-save t
+ TeX-parse-self t
+ TeX-PDF-mode t
+ TeX-source-correlate-mode nil
+ TeX-view-program-selection '( ((output-dvi style-pstricks) "dvips and gv")
+ (output-dvi "xdvi")
+ (output-pdf "Zathura")
+ (output-html "xdg-open"))))
+
+
+(use-package cdlatex
+ :ensure t
+ :bind (:map cdlatex-mode-map
+ ("(" . nil)
+ ("{" . nil)
+ ("[" . nil)
+ ("|" . nil)
+ ("<" . nil)
+ ("$" . nil)
+ ("'" . nil)
+ ("TAB" . nil)
+ ;; ("TAB" . cdlatex-tab)
+ ("C-c e" . cdlatex-environment)
+ ("~" . cdlatex-math-modify)
+ ("`" . cdlatex-math-symbol))
+ :init
+ (setq cdlatex-math-modify-prefix ?~
+ cdlatex-math-symbol-prefix ?`
+ cdlatex-math-modify-alist '((?a "\\mathbb" nil t nil nil)
+ (?c "\\mathcal" "\\textsc" t nil nil)
+ (?t "\\trm" "\\trm" t nil nil)
+ (?y "\\ty" "\\ty" t nil nil)
+ (?v "\\texttt" "\\texttt" t nil nil)
+ (?u "\\tyu" "\\tyu" t nil nil)
+ (?k "\\mathfrak" nil t nil nil)
+ (?` nil "`'" t nil nil)
+ (?- "\\overline" nil t nil nil)
+ (?_ "\\underline" nil t nil nil))
+ cdlatex-math-symbol-alist '((?% ("\\widehat{?}" "\\hat{?}"))
+ (?' ("^{\\prime}" "\\prime"))
+ (?* ("\\times" "\\otimes" "\\star"))
+ (?+ ("+" "\\oplus"))
+ (?- ("\\vdash" "\\setminus" "\\triangle"))
+ (?. ("\\sq" "\\circ" "\\cdot"))
+ (?0 ("\\emptyset" "\\circ"))
+ (?\; ("\\col"))
+ (?< ("\\leftarrow" "\\leftharpoonup" "\\xleftarrow"))
+ (?> ("\\to" "\\rightharpoonup" "\\xrightarrow"))
+ (?B ("\\bullet"))
+ (?C ("\\widecheck{?}" "\\check{?}"))
+ (?F ("\\Phi" "\\Varphi"))
+ (?M ("\\begin{bsmallmatrix}?\\end{bsmallmatrix}"))
+ (?P ("\\Prod{?}" "\\Pi" "\\partial"))
+ (?S ("\\Sum{?}" "\\Sigma" "\\arcsin"))
+ (?\"("^{\\prime\\prime}" "\\prime\\prime"))
+ (?a ("\\alpha" "\\cap" "\\sqcap"))
+ (?c ("\\cat{?}" "\\catn{?}"))
+ (?e ("\\varepsilon" "\\epsilon" "\\exp{?}"))
+ (?i ("\\iota" "\\in"))
+ (?j ("{\\id^{h}}_{?}" "{\\id^{v}}_{?}"))
+ (?r ("\\rho" "\\varrho" "\\restrict{?}"))
+ (?u ("\\upsilon" "\\cup" "\\sqcup"))
+ (?{ ("\\subseteq" "\\subsetneq"))
+ (?} ("\\supseteq" "\\supsetneq"))
+ )))
+
+(use-package doc-view
+ :defer t
+ :functions doc-view-mode
+ :hook (doc-view-mode . auto-revert-mode)
+ :config (setq doc-view-resolution 300
+ doc-view-continuous t))
diff --git a/emacs/inits/25-theorems.el b/emacs/inits/25-theorems.el
new file mode 100644
index 0000000..ed3619d
--- /dev/null
+++ b/emacs/inits/25-theorems.el
@@ -0,0 +1,124 @@
+;; Time-stamp: <2019-09-11 13:59:30 (tslil@basingstoke)>
+
+;; -----------------------------------------------------------------------------
+;; Coq
+
+;; (defvar pg-inserted-newline nil)
+;; (defconst pg-whitespace-match "[ \\t]")
+;; (defconst pg-subgoal-match "[*+\\-]")
+
+;; (defun pg-move-point-dwim ()
+;; (interactive)
+;; ;; Did we move to a blank new line?
+;; (when (= (point) (point-at-bol))
+;; ;; If there's nothing here, lets add another line below
+;; (when (looking-at-p (concat pg-whitespace-match "*$"))
+;; (save-excursion (newline))
+;; (setq pg-inserted-newline t))
+;; ;; Now let's work out where the point should go
+;; (previous-line)
+;; (beginning-of-line)
+;; ;; Is the previous line essentially a subgoal marker?
+;; (if (looking-at-p (concat pg-whitespace-match "*"
+;; pg-subgoal-match "+"
+;; pg-whitespace-match "*$"))
+;; ;; If so, trim the line and put the point in after the subgoal marker
+;; (progn
+;; (delete-trailing-whitespace (point-at-bol) (point-at-eol))
+;; (end-of-line)
+;; (insert-char ? ))
+;; ;; If not, go back to where we were and indent
+;; (next-line)
+;; (indent-for-tab-command))))
+
+(defconst coq-env '(("UniMath"
+ :topdir "~/theorems/coq/UniMath/"
+ :binary "sub/coq/bin/coqtop"
+ :args ("-coqlib" "/home/tslil/theorems/coq/UniMath/sub/coq/"
+ "-emacs" "-noinit"
+ "-indices-matter"
+ "-type-in-type" "-w" "-notation-overridden"
+ "-Q" "/home/tslil/theorems/coq/UniMath/UniMath" "UniMath"
+ "-Q" "/home/tslil/academic/proof_relevant_cats/formalisation" "wCats"))
+ ("HoTT"
+ :topdir "~/theorems/coq/HoTT/"
+ :binary "hoqtop"
+ :args nil)))
+
+(defvar use-coq-env "UniMath")
+
+(use-package proof-general
+ :ensure t
+ :defer t
+ :functions coq-local-environment
+ :init (setq proof-splash-enable nil
+ proof-follow-mode 'followdown)
+ ;; It's really annoying to have the code truncated due to equal
+ ;; division ratios of the windows. The 5 is to accomodate line
+ ;; numbers and the like
+ (defadvice proof-layout-windows (after resize-window-properly activate)
+ (let ((ww (window-width)))
+ (when (< ww (+ 5 fill-column))
+ (enlarge-window-horizontally (- (+ 5 fill-column) ww)))))
+ (defun coq-local-environment ()
+ (bind-key "C-s" #'isearch-forward proof-mode-map)
+ (let* ((data (alist-get use-coq-env coq-env nil nil #'string-equal))
+ (topdir (expand-file-name (plist-get data :topdir)))
+ (binary (plist-get data :binary))
+ (args (plist-get data :args)))
+ ;; TAGS
+ (visit-tags-table (concat topdir "TAGS"))
+ ;; Formatting
+ (setq fill-column 70)
+ (set-fringe-mode 0)
+ (make-local-variable 'before-save-hook)
+ (add-hook 'before-save-hook 'delete-trailing-whitespace)
+ (setq proof-three-window-mode-policy 'hybrid
+ proof-layout-windows-on-visit-file t
+ proof-shrink-windows-tofit t
+ proof-script-fly-past-comments t)
+ ;; Tweak syntax table
+ ;; (modify-syntax-entry ?' "w")
+ ;; Coq binary related
+ (dolist (var '(coq-use-project-file coq-prog-args coq-prog-name))
+ (make-local-variable var))
+ (setq coq-use-project-file nil
+ coq-prog-args args
+ coq-prog-name (concat topdir binary))
+ (agda-input-setup)
+ (activate-input-method "Agda")))
+ :mode ("\\.v$" . coq-mode)
+ :hook (coq-mode . (lambda ()
+ (programming-setup)
+ (coq-local-environment)
+ (auto-fill-mode)
+ (company-coq-mode))))
+
+(use-package company-coq
+ :after proof-general
+ :ensure t
+ :bind (:map company-coq-map
+ ("M-." . xref-find-references)
+ ("M-*" . pop-tag-mark))
+ :init
+ (setq company-coq-disabled-features '(hello)))
+
+;; -----------------------------------------------------------------------------
+;; Agda
+
+(load-file (let ((coding-system-for-read 'utf-8))
+ (shell-command-to-string "agda-mode locate")))
+
+(add-hook 'agda2-mode
+ (lambda ()
+ (subword-mode 1)
+ (auto-fill-mode)
+ (aggressive-indent-mode -1)))
+
+;; -----------------------------------------------------------------------------
+;; Lean
+
+;; (use-package lean-mode
+;; :ensure t
+;; :defer t
+;; :mode ("\\.lean$" . lean-mode))
diff --git a/emacs/inits/30-irc.el b/emacs/inits/30-irc.el
new file mode 100644
index 0000000..7d3566f
--- /dev/null
+++ b/emacs/inits/30-irc.el
@@ -0,0 +1,45 @@
+;; Time-stamp: <2019-01-26 12:55:41 (tslil@winslow)>
+
+(use-package rcirc
+ :ensure t
+ :defer
+ :hook (rcirc-mode . (lambda ()
+ (rcirc-track-minor-mode)
+ (flyspell-mode-on)
+ (set (make-local-variable 'scroll-conservatively) 8192)))
+ :config
+ (use-package rcirc-color
+ :ensure t
+ :if (window-system))
+
+ (require 'auth-source)
+
+ (defadvice rcirc (before rcirc-read-from-authinfo activate)
+ (unless arg
+ (dolist (p (auth-source-search :port '("nickserv"
+ "bitlbee"
+ "quakenet")
+ :require '(:port :user :secret)))
+ (let ((secret (plist-get p :secret))
+ (method (intern (plist-get p :port))))
+ (add-to-list 'rcirc-authinfo
+ (list (plist-get p :host)
+ method
+ (plist-get p :user)
+ (if (functionp secret)
+ (funcall secret)
+ secret)))))))
+
+ (setq rcirc-default-full-name "tslil"
+ rcirc-default-nick "maximum_yellow"
+ rcirc-default-user-name "maximum_yellow"
+ rcirc-time-format "%Y-%m-%d %H:%M "
+ rcirc-log-directory "~/irc/"
+ rcirc-fill-column 80
+ rcirc-log-flag t
+ rcirc-server-alist
+ '(("irc.freenode.net"
+ :port 6697
+ :encryption tls
+ :channels ("#emacs" "#guix")
+ ))))
diff --git a/emacs/inits/50-file-assocs.el b/emacs/inits/50-file-assocs.el
new file mode 100644
index 0000000..0024f1a
--- /dev/null
+++ b/emacs/inits/50-file-assocs.el
@@ -0,0 +1,20 @@
+;; Time-stamp: <2019-09-11 11:29:16 (tslil@basingstoke)>
+
+(use-package gnuplot-mode
+ :ensure t
+ :mode "\\.gnp$")
+
+(use-package scad-mode
+ :ensure t
+ :mode "\\.scad$")
+
+(setq auto-mode-alist
+ (append
+ '(("\\.emacs$" . emacs-lisp-mode)
+ ("\\.scm$" . scheme-mode)
+ ("\\.sch$" . scheme-mode)
+ ("\\.sc$" . scheme-mode)
+ ("\\.cl$" . lisp-mode)
+ ("\\.py$" . python-mode)
+ ("\\.pg$" . perl-mode)
+ ) auto-mode-alist))
diff --git a/emacs/inits/60-misc-configs.el b/emacs/inits/60-misc-configs.el
new file mode 100644
index 0000000..dd51a20
--- /dev/null
+++ b/emacs/inits/60-misc-configs.el
@@ -0,0 +1,22 @@
+;; Time-stamp: <2019-03-11 11:02:27 (tslil@basingstoke)>
+
+(use-package dired
+ :defer t
+ :config
+ (setq dired-listing-switches "--group-directories-first -alh"
+ dired-auto-revert-buffer t
+ dired-dwim-target t
+ ;; ???
+ ;; dired-guess-shell-alist-user '(("\\.djvu\\'" "zathura")
+ ;; ("\\.pdf\\'" "zathura")
+ ;; ("\\.ps\\'" "zathura"))
+ ))
+
+(use-package browse-url
+ :defer t
+ :config
+ (setq browse-url-generic-program "firefox-esr"
+ browse-url-browser-function '(("." . browse-url-generic))))
+
+(setq backup-directory-alist `((".*" . ,temporary-file-directory))
+ auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
diff --git a/emacs/inits/70-global-keybinds.el b/emacs/inits/70-global-keybinds.el
new file mode 100644
index 0000000..92ae2fe
--- /dev/null
+++ b/emacs/inits/70-global-keybinds.el
@@ -0,0 +1,32 @@
+;; Time-stamp: <2019-08-25 21:44:55 (tslil@basingstoke)>
+
+(setq time-stamp-active t
+ time-stamp-line-limit 3
+ time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u@%s)")
+
+(add-hook 'before-save-hook #'time-stamp)
+
+(defun insert-timestamp ()
+ (interactive)
+ (save-excursion
+ (goto-char (point-min))
+ (unless (search-forward "Time-stamp: "
+ (line-beginning-position (1+ time-stamp-line-limit))
+ t)
+ (goto-char (point-min))
+ (newline)
+ (beginning-of-line 0)
+ (comment-dwim nil)
+ (insert (concat "Time-stamp: " "<>"))
+ (newline))
+ (time-stamp)))
+(global-set-key (kbd "C-x t") 'insert-timestamp)
+
+(global-set-key (kbd "<f11>") 'notmuch)
+(global-set-key (kbd "C-x m") 'eshell)
+(global-set-key (kbd "C-c c") 'shell)
+(global-set-key (kbd "C-x e") 'eval-expression)
+
+(global-set-key (kbd "M-i") 'indent-region)
+
+(global-set-key (kbd "C-v") 'delete-indentation)
diff --git a/emacs/inits/99-last.el b/emacs/inits/99-last.el
new file mode 100644
index 0000000..dc6db7d
--- /dev/null
+++ b/emacs/inits/99-last.el
@@ -0,0 +1,7 @@
+;; Time-stamp: <2019-01-26 12:56:04 (tslil@winslow)>
+
+(add-hook 'after-init-hook
+ (lambda ()
+ (run-with-idle-timer 20 nil (lambda () (setq gc-cons-threshold 8000000)))))
+
+(setq file-name-handler-alist old-file-name-handler-alist)