#+auto_tangle: t
#+OPTIONS: html-style:nil
* init.el
This section generates the init.el file in the .emacs.d
directory. Emacs reads this file on startup.
Because init.el is generated afresh whenever =org-babel-tangle= is
called, and because the default behavior of emacs is to
programmatically place customizations at the end of the init.el
file, it is prudent to set a =custom-file= location explicitly.
After setting custom file, emacs is configured. Because many other
configuration options depend on properly configured packages, the
packages are setup first. After that, the order of the setup
operations is more or less insignificant.
#+begin_src elisp :tangle ~/.emacs.d/init.el :noweb no-export :results none
;;;; init.el
;;;; DO NOT EDIT: This file has been generated by org-babel-tangle
;;;; from a source file called init-el.org.
(setq custom-file (concat user-emacs-directory "custom.el"))
(load custom-file 'noerror)
(setq warning-minimum-level :emergency)
<>
;;; utilities
(defun read-file-into-string (f)
(with-temp-buffer
(insert-file-contents f)
(buffer-string)))
<>
<>
<>
<>
<>
<>
<>
<>
<>
#+end_src
** Native Compilation
New in emacs 28, native compilation can be enabled:
#+name: native-comp
#+begin_src elisp :results none
;; Native compilation setup
(when (and (fboundp 'native-comp-available-p)
(native-comp-available-p))
(setq package-native-compile t
native-comp-always-compile t))
#+end_src
** Packages Setup Config
#+name: packages-setup-config
#+begin_src elisp :results none
;; PACKAGES SETUP
(require 'cl)
(defun my-package-install (package &optional archive dont-select)
"archive is a string naming the archive. Will attempt"
(let* ((pkg-descs
(cdr (assoc package package-archive-contents)))
(desc
(if archive
(find archive pkg-descs :test 'equalp :key 'package-desc-archive))))
(when desc
(package-install desc dont-select))))
(require 'package)
(add-to-list 'package-archives
'("elpa" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)
(package-install 'use-package)
#+end_src
* Leader Keys
#+name: my-leader-keys-config
#+begin_src elisp :noweb no-export :results none
<>
<>
<>
<>
#+end_src
I have written a custom leader key system called "my-leader-keys". A
leader key system emulates menus. An initial key (M-m for me) opens
the top level menu. The menu presents a key to press that either leads
to the next menu or run a specific interative function.
It all starts with the =def-my-command= macro, which associates a key
to a menu of commands. Each 'command' is just an interactive function.
** My Leader Keys Definition
#+name: my-leader-key-system
#+begin_src elisp :results none
;; Leader Keys System
(setq lexical-binding t)
(defmacro def-my-command (name forms)
`(defun ,name (ch)
(interactive (let ((input (read-char (my-prompt-string ,forms))))
(list input)))
(let ((command (assoc ch ,forms)))
(when command
(call-interactively (caddr command))))))
;; a helper function for navigating command menus
(defun my-prompt-string (&optional forms)
(concat "Options: "
(mapconcat 'identity
(mapcar #'cadr
(if forms forms *my-leader-command-forms*))
", ")))
#+end_src
** My Leader Key Toplevel Menu
The leader key system wouldn't be much good without a top-level leader
key. Here the inital leader key menu is defined and bound to M-m.
#+name: my-leader-key-toplevel-menu
#+begin_src elisp :results none
;; Leader Key Entry Point
(setq imenu-auto-rescan t)
(def-my-command my-leader-command
'((?/ "[/] search buffer" swiper)
(?q "[q]uery replace" query-replace)
(?i "[i]menu" imenu)
(?' "['] shell" persp-shell--jump-to-persp-shell)
(?b "[b]uffers" my-buffer-command)
(?c "[c]apture" org-capture)
(?a "[a]applications" my-utilities-command)
(?t "[t]hemes" my-theme-cycler)
(?T "toggle [T]heme set" toggle-theme-set)
(?l "[l]ayouts" my-perspective-command)
(?w "[w]indows" my-window-comand)
(?p "[p]rojectile" my-projectile-command)
(?m "[m]ajor mode" my-major-mode-command)
(?f "[f]ind file" find-file)
(?d "[d]irvish" dirvish)
(?s "[s]lime selection" my-lisp-switch-command)
(?h "[h]elp" helpful-at-point)))
(global-set-key (kbd "M-m") 'my-leader-command)
#+end_src
** My leader Key Major Mode Menu
#+name: my-leader-key-major-mode-menu
#+begin_src elisp :results none
(defvar my-major-mode-list nil "subcommands by major-mode")
(setf my-major-mode-list
'(;(haxe-mode my-haxe-mode-command)
(org-mode my-org-command)
;(zettel-mode my-zettel-mode-command)
(slime-repl-mode my-lisp-mode-command)
(pdf-view-mode my-pdf-view-mod-command)
(lisp-mode my-lisp-mode-command)))
(defun my-major-mode-command ()
(interactive)
(let ((mode-command (assoc major-mode my-major-mode-list)))
(when mode-command
(call-interactively (cadr mode-command)))))
#+end_src
** My leader key utilities and applications menu
#+name: my-leader-key-applications-menu
#+begin_src elisp :results none
(def-my-command my-utilities-command
'((?o "org clock [o]ut" org-clock-out)
(?r "org [r]esume last" org-clock-in-last)
(?c "[c]alendar" cfw:open-org-calendar)
(?a "[a]genda" org-agenda)
(?b "[b]ooks" calibredb)
(?d "[d]eft" toggle-deft)
(?f "el[f]eed" elfeed)
(?j "[j]ournal" toggle-journal)
(?s "[s]ecrets" toggle-secrets)
(?p "[p]omodoro" pomidor)
(?w "[w]eb browser (eww)" eww)
(?C "[C]RDT" my-crdt-commands)))
#+end_src
* Org Mode Configs
#+name: org-mode-config
#+begin_src elisp :noweb no-export
<>
<>
<>
#+end_src
** Org Mode Main Config
#+name: org-mode-main-config
#+begin_src elisp :noweb no-export :results none
(package-install 'org)
(require 'org)
(setq org-duration-format 'h:mm)
(setq org-edit-src-content-indentation 0)
(setq org-goto-interface 'outline-path-completion
org-goto-max-level 10
org-outline-path-complete-in-steps nil)
(setq org-imenu-depth 10)
(setq org-startup-folded t)
(defun my-org-up-heading ()
(interactive)
(org-up-heading-safe))
(defun my-org-down-heading ()
(interactive)
(org-down-element))
(defun personal-log-insert ()
(interactive)
(org-insert-heading)
(delete-backward-char 1)
(insert "* ")
(insert (current-time-string)))
(defun org-insert-internal-link (title)
(interactive "sHeading: ")
(insert "[[*")
(call-interactively 'complete-symbol)
(insert (format "][%s]]" title)))
(defun org-insert-named-code-block (name lang)
(interactive "sName: \nsLanguage: ")
(insert "#+name: ")
(insert name)
(insert "\n")
(insert (format "#+begin_src %s :noweb no-export\n\n#+end_src" lang)))
(defvar +cicadas-surf-task-status-file+ "/ssh:colin@cicadas.surf:~/.task")
(defun clock-in-external-log-advice (&rest args)
"to be added as advice to org-clock-in"
(when +cicadas-surf-task-status-file+
(with-temp-buffer
(insert "👷 ")
(insert
(first
(split-string
(buffer-name (marker-buffer org-clock-marker))
"\\.")))
(insert " -- ")
(insert org-clock-heading)
(insert " 👷")
(write-file +cicadas-surf-task-status-file+))))
(defun clock-out-external-log-advice (&rest args)
(when +cicadas-surf-task-status-file+
(with-temp-buffer
(write-file +cicadas-surf-task-status-file+))))
(advice-add 'org-clock-in :after #'clock-in-external-log-advice)
(advice-add 'org-clock-out :after #'clock-out-external-log-advice)
#+end_src
#+RESULTS: org-mode-main-config
** Org Mode and Babel Configuration
#+name: org-mode-babel-config
#+begin_src elisp :results none
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(python . t)
(lisp . t)
(C . t)
(shell . t)))
#+end_src
** My-Leader Key for Org Major Mode
#+name: org-mode-leader-key-menu
#+begin_src elisp :results none :noweb no-export
(def-my-command my-org-command
'((?/ "[/] sparse tree" org-sparse-tree)
(?g "[g]oto" org-goto)
(?u "[u]p heading" my-org-up-heading)
(?d "[d]own heading" my-org-down-heading)
(?p "[p]revious heading" org-previous-visible-heading)
(?n "[n]next heading" org-next-visible-heading)
(?r "Org [r]efile" org-refile)
(?k "Org [k]ut" org-cut-special)
(?s "Org [s]ort" org-sort)
(?A "Org [A]rchive" org-archive-subtree)
(?i "[i]insertion" my-org-insertion-subcommand)
(?x "e[x]port" my-org-export-subcommand)
(?e "[e]dit a code block" org-edit-src-code)
(?N "[N]arrow" org-narrow-to-subtree)
(?W "[W]iden" widen)
(?I "[I]mages toggle" org-toggle-inline-images)
(?c "table re[c]alculate" org-table-recalculate)
(?C "[C]lock" org-clock-in)))
(def-my-command my-org-export-subcommand
'((?t "[t]angle file" org-babel-tangle)
(?w "[w]ritefreely" writefreely-publish-or-update)
(?x "e[x]port options" org-export-dispatch)))
(def-my-command my-org-insertion-subcommand
'((?l "internal [l]ink" org-insert-internal-link)
(?L "external [L]ink" org-insert-link)
(?r "insert d[r]awe[r]" org-insert-drawer)
(?d "[d]ated log entry" personal-log-insert)
(?D "[D]eadline" org-deadline)
(?T "[T]imestamp" org-time-stamp)
(?f "[f]ootnote" org-footnote-new)
(?b "named code [b]lock" org-insert-named-code-block)
(?s "[s]tructure template" org-insert-structure-template)))
#+end_src
* UI
#+name: ui-config
#+begin_src elisp :noweb no-export :results none
;;; UI
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
#+end_src
** Fonts
#+name: ui-fonts
#+begin_src elisp :noweb no-export
(add-to-list 'default-frame-alist
'(font . "Victor Mono-10"))
#+end_src
#+RESULTS: ui-fonts
: ((font . Victor Mono-10) (vertical-scroll-bars))
** UI Chrome
I like for my emacs to have as little UI chrome as possible, and to
have a consistent UI experience. So I disable the blinking cursor, I
set cursor type to 'box by default, and I disable menu, tool, and
scroll bars.
#+name: ui-chrome-config
#+begin_src elisp :results none
;; UI Chrome
(blink-cursor-mode 0)
(setq-default cursor-type 'box)
(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode -1)
(toggle-frame-maximized)
; (toggle-frame-fullscreen)
(defun transparency (value)
"Sets the transparency of the frame window. 0=transparent/100=opaque"
(interactive (let* ((prompt (concat "Transparency Value 0 - 100 opaque ["
(prin1-to-string (frame-parameter (selected-frame) 'alpha))
"]:"))
(input (read-number prompt)))
(list input)))
(set-frame-parameter (selected-frame) 'alpha value))
#+end_src
** Modeline Config
#+name: ui-modeline-config
#+begin_src elisp :results none
;; (package-install 'doom-modeline)
;; (require 'doom-modeline)
;; (doom-modeline-mode 1)
#+end_src
** Tweaks
Bits and bobs.
I globally unset the C-z keybinding because it is easy to hit by
accident and causes the window to suddenly close.
In addition, for some programming langauges, tabs should not be used
to perform indtentation of source code. To ensure that no indentation
does not, by default, use tabs, I set indent-tabs-mode to nil.
#+name: ui-tweaks-config
#+begin_src elisp :results none
(global-unset-key (kbd ""))
(global-unset-key "\C-z")
(setq-default indent-tabs-mode nil)
;(global-hl-line-mode 1)
;(global-linum-mode 1)
#+end_src
** Bells and Whistles
#+name: ui-bells-and-wistles
#+begin_src elisp :results none
(package-install 'org-superstar)
(require 'org-superstar)
(add-hook 'org-mode-hook (lambda ()
(org-superstar-mode 1)
(visual-line-mode)))
#+end_src
** My Leader Keys
** Completions Engine
#+name: ui-completion-engine
#+begin_src elisp :results none
(package-install 'ivy)
(package-install 'smex)
(package-install 'swiper)
(ivy-mode 1)
(setq ivy-use-selectable-prompt t)
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
#+end_src
** Buffers, Windows, and Perspectives
#+name: ui-windows-and-perspectives
#+begin_src elisp :noweb no-export :results none
<>
<>
<>
<>
#+end_src
*** Packages
#+name: ui-windows-and-perspectives-packages
#+begin_src elisp :results none
(package-install 'perspective)
(setq persp-suppress-no-prefix-key-warning t)
(persp-mode)
(package-install 'rotate)
(package-install 'window-numbering)
(window-numbering-mode)
(package-install 'resize-window)
(require 'resize-window)
#+end_src
*** Window Leader Key Menu
#+name: ui-window-leader-key-menu
#+begin_src elisp :results none
(setq fit-window-to-buffer-horizontally t)
(defun my-fit-window-to-buffer ()
(interactive)
(fit-window-to-buffer)
(resize-window--enlarge-horizontally))
(setq *auto-light-mode* nil)
(defun toggle-auto-light-mode ()
(interactive)
(set-frame-parameter
nil 'screen-gamma
(if *auto-light-mode*
2.2
3.1))
(setq *auto-light-mode* (not *auto-light-mode*)))
(def-my-command my-window-comand
'((?/ "[/] vertical splitter" split-window-horizontally)
(?- "[-] horoziontal splitter" split-window-vertically)
(?b "[b]alance windows" balance-windows)
(?t "[t]ransparency" transparency)
(?l "[l]ightmode toggle" toggle-auto-light-mode)
(?k "[k]ill window" delete-window)
(?m "[m]aximise window" delete-other-windows)
(?R "[R]otate window" rotate-window)
(?r "[r]esize widnows" resize-window)
(?f "[f]it window" my-fit-window-to-buffer)
(?p "font [p]itch shift" variable-pitch-mode)
(?v "[v]isual line mode" visual-line-mode)
(?w "[w]riteroom mode" writeroom-mode)))
#+end_src
*** Buffer Leader Key Menu
#+name: ui-buffer-leader-key-menu
#+begin_src elisp :results none
(def-my-command my-buffer-command
'((?b "switch [b]uffers" ivy-switch-buffer)
(?s "[s]ave buffer" save-buffer)
(?S "[S]ave all buffers" save-some-buffers)
(?k "[k]ill buffer" kill-buffer)))
#+end_src
*** Perspectives Leader Key Menu
#+name: ui-perspectives-leader-key-menu
#+begin_src elisp :results none
(def-my-command my-perspective-command
'((?s "[s]witch perspective" persp-switch)
(?k "[k]ill perspective" persp-kill)
(?d "[d]rop buffer" persp-remove-buffer)
(?n "re[n]ame perspective" persp-rename)
(?a "[a]dd buffer" persp-add-buffer)))
#+end_src
** Themes
#+name: ui-themes
#+begin_src elisp :noweb no-export :results none
<>
<>
<>
#+end_src
*** Installed Themes
#+name: ui-themes-installed
#+begin_src elisp :results none
(package-install 'autothemer) ;; for custom themes
(setq my-installed-themes
'(modus-themes
sweet-theme
poet-theme
solarized-theme))
(dolist (package my-installed-themes)
(when (not (package-installed-p package))
(package-install package)))
#+end_src
*** Theme Switcher
#+name: ui-themes-theme-switcher
#+begin_src elisp :results none
(setq *coding-themes*
'(modus-operandi-tritanopia
solarized-selenized-dark
sweet
modus-vivendi-tritanopia))
(setq *writing-themes*
'(poet-monochrome
poet
poet-dark-monochrome
poet-dark))
(setq *current-theme-set* *coding-themes*)
(defun toggle-theme-set ()
(interactive)
(if (equalp *current-theme-set* *coding-themes*)
(setq *current-theme-set* *writing-themes*)
(setq *current-theme-set* *coding-themes*))
(my-theme-command-next))
(when (car custom-enabled-themes)
(disable-theme (car custom-enabled-themes)))
(load-theme (first *current-theme-set*) t)
(defun my-theme-string ()
(if (car custom-enabled-themes)
(format "%s is current" (car custom-enabled-themes))
""))
(defun my-theme-cycler ()
(interactive)
(let ((still-cycling t))
(message (format "%s [n]ext or [p]evious. Anything else to quit."
(my-theme-string)))
(while still-cycling
(let ((char (read-key)))
(cond
((eq char ?n) (my-theme-command-next))
((eq char ?p) (my-theme-command-previous))
(t (setq still-cycling nil))))
(message (format "%s [n]ext or [p]evious. Anything else to quit."
(my-theme-string))))))
(defun my-theme-command-next ()
(interactive)
(let* ((active-theme (car custom-enabled-themes))
(next-theme (cadr (cl-member active-theme *current-theme-set*))))
(when active-theme (disable-theme active-theme))
(if next-theme (load-theme next-theme t)
(load-theme (car *current-theme-set*) t))
(setq cursor-type 'box)
(setq-default cursor-type 'box)))
(defun my-theme-command-previous ()
(interactive)
(let* ((active-theme (car custom-enabled-themes))
(themes (reverse *current-theme-set*))
(next-theme (cadr (cl-member active-theme themes))))
(when active-theme (disable-theme active-theme))
(if next-theme (load-theme next-theme t)
(load-theme (car themes) t))
(setq cursor-type 'box)
(setq-default cursor-type 'box)))
#+end_src
*** COMMENT Halloweenie
#+name: halloweenie
#+begin_src elisp
;; halloweenie - a Halloween emacs color theme.
;; Copyright (C) 2021 Colin Okay
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see .
;; Spooky times all.
(require 'autothemer)
(autothemer-deftheme
halloweenie "Ghost, Ghouls, and worst of all: Pumpkin Spice"
((((class color) (min-colors #xFFFFFF)))
(halloweenie-pitch "#1c1c1c")
(halloweenie-night "#1f213a")
(halloweenie-blood "#a2270d")
(halloweenie-potion "#832ea1")
(halloweenie-slime "#15ed0a")
(halloweenie-jackolantern "#FF9430")
(halloweenie-spellglow "#d478e0")
(halloweenie-bone "#E8E7D5")
(halloweenie-rot "#6Bc980")
(halloweenie-ghost "#C1CAE8")
(halloweenie-shine "#70c2ca")
(halloweenie-cateyes "#ffde38")
(halloweenie-evileyes "#FF1F1F"))
((default (:foreground halloweenie-bone :background halloweenie-pitch) :weight 'semi-bold)
(error (:foreground halloweenie-evileyes :weight 'semi-bold))
(cursor (:background halloweenie-slime))
(region (:background "black"))
(hl-line (:background halloweenie-night))
(link (:background halloweenie-potion))
(mode-line (:background halloweenie-jackolantern :foreground halloweenie-pitch))
(mode-line-emphasis (:foreground halloweenie-pitch :weight 'bold))
(font-lock-comment-face (:foreground halloweenie-slime))
(font-lock-string-face (:foreground halloweenie-rot))
(font-lock-type-face (:foreground halloweenie-cateyes :weight 'ultra-bold))
(font-lock-constant-face (:foreground halloweenie-evileyes :weight 'extra-bold))
(font-lock-variable-name-face ( :weight 'bold :foreground halloweenie-spellglow))
(font-lock-function-name-face (:foreground halloweenie-spellglow :weight 'bold :slant 'italic))
(font-lock-builtin-face (:foreground halloweenie-jackolantern :weight 'semi-bold))
(font-lock-keyword-face (:foreground halloweenie-jackolantern :weight 'extra-bold))
;; org
(org-todo (:weight 'bold :foreground halloweenie-evileyes))
(org-done (:weight 'bold :foreground halloweenie-rot ))
;; doom modeline
(doom-modeline-project-dir
(:foreground halloweenie-pitch :weight 'bold ))
(doom-modeline-project-root-dir
(:foreground halloweenie-blood :weight 'bold))
;; persp
(persp-selected-face
(:foreground halloweenie-blood :weight 'bold :slant 'italic))))
(provide-theme 'halloweenie)
#+end_src
* Time Managment
#+name: time-management-config
#+begin_src elisp :noweb no-export :results none
;;; TIME MANAGMENT
(setq org-enforce-todo-dependencies t
org-enforce-todo-checkbox-dependencies t)
(setq org-edit-src-content-indentation 0)
<>
<>
<>
<>
<>
#+end_src
** Pomidor
Pomidor is a neat pomidoro system that I started using recently. I
don't care about the productity aspect, but I like the reminders to
stand up and move around.
#:name: pomidor
#+begin_src elisp :noweb no-export :results none
(package-install 'pomidor)
(setq pomidor-seconds (* 60 60)
pomidor-break-seconds (* 15 60)
pomidor-breaks-before-long 1000
pomidor-sound-tick nil
pomidor-sound-tack nil)
#+end_src
** CALFW calendar
#+name: calfw-org-config
#+begin_src elisp :noweb no-export :results none
(package-install 'calfw)
(package-install 'calfw-org)
(require 'calfw)
(require 'calfw-org)
#+end_src
** Org Refile
#+name: org-refile-config
#+begin_src elisp :results none
(setq my-org-refile-directory "~/notes/deft/")
(defun my-org-refile-targets ()
(loop for fname in (directory-files my-org-refile-directory)
when (string-match "\.org$" fname)
collect (concat my-org-refile-directory fname)))
(setq org-refile-targets
'((my-org-refile-targets :maxlevel . 5)))
#+end_src
** Org Capture
#+name:org-capture-config
#+begin_src elisp :results none
(setq org-capture-templates
(quote
(("i" "Inbox" entry
(file+headline "~/notes/deft/project-Planner.org" "INBOX")
"")
("j" "Journal" entry
(file+olp+datetree "~/notes/circadian.org.cpt")
"")
("c" "Calendar" entry
(file+headline "~/notes/deft/project-Planner.org" "CALENDAR")
"* %?\n %(cfw:org-capture-day)"))))
;; ("i" "Inbox" entry
;; (file "~/notes/deft/project-Inbox.org")
;; "")
#+end_src
** Org Agenda
#+name: org-agenda-config
#+begin_src elisp :noweb no-export :results none
(custom-set-variables
'(org-directory "~/notes/deft")
'(org-agenda-files "~/notes/org-agenda-files"))
(add-hook 'org-agenda-mode-hook
(lambda ()
(local-set-key (kbd "M-m") 'my-leader-command)))
#+end_src
* Communication
#+name: communications-config
#+begin_src elisp :noweb no-export :results none
<>
<>
#+end_src
** ERC
#+name: erc-config
#+begin_src elisp :noweb no-export :results none
(setq erc-hide-list '("JOIN" "QUIT" "PART"))
#+end_src
** CRDT
#+name: crdt-config
#+begin_src elisp :noweb no-export :results none
(def-my-command my-crdt-commands
'((?s "[s]hare this buffer" crdt-share-buffer)
(?f "[f]ollow a user" crdt-follow-user)
(?u "[u]nfollow a user" crdt-stop-follow)
(?C "[C]lose connection" crdt-disconnect)
(?c "[c]onnect" crdt-connect)
(?l "[l]ist buffers" crdt-list-buffers)))
#+end_src
* Reading, Notes, and Writing
#+name: reading-notes-and-writing-config
#+begin_src elisp :noweb no-export :results none
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
#+end_src
** Calibre db
#+name: calibre-config
#+begin_src elisp :results none
(package-install 'calibredb)
(require 'calibredb)
(setq calibredb-root-dir "~/Calibre")
(setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
#+end_src
** PDF tools for Reading and Annotating PDFS
*** PDF Tools
#+name: pdf-tools
#+begin_src elisp :results none
(package-install 'pdf-tools)
(pdf-tools-install)
#+end_src
*** Some functions to quickly annotate
#+name: pdf-mode-config
#+begin_src elisp :results none
(defun my-pdf-annot-at-position (pos)
"Return annotation at POS in the selected window.
POS should be an absolute image position as a cons \(X . Y\).
Alternatively POS may also be an event position, in which case
`posn-window' and `posn-object-x-y' is used to find the image
position.
Return nil, if no annotation was found."
(let (window)
(when (posnp pos)
(setq window (posn-window pos)
pos (posn-object-x-y pos)))
(save-selected-window
(when window (select-window window 'norecord))
(let* ((annots (pdf-annot-getannots (pdf-view-current-page)))
(size (pdf-view-image-size))
(rx (/ (car pos) (float (car size))))
(ry (/ (cdr pos) (float (cdr size))))
(rpos (cons rx ry)))
(cl-some (lambda (a)
(and (cl-some
(lambda (e)
(pdf-util-edges-inside-p e rpos))
(pdf-annot-get-display-edges a))
a))
annots)))))
(defun my-pdf-annot-add-text-annotation ()
(interactive)
(let ((annot
(or (my-pdf-annot-at-position '(0 . 0))
(pdf-annot-add-text-annotation '(0 . 0)))))
(pdf-annot-edit-contents annot)))
(def-my-command my-pdf-view-mod-command
'((?/ "[/] search pdf" pdf-occur)
(?l "[l]ist annotations" pdf-annot-list-annotations)
(?m "[m]idnight mode" pdf-view-midnight-minor-mode)
(?n "add [n]ote" my-pdf-annot-add-text-annotation)))
#+end_src
** Nov
#+name: nov
#+begin_src elisp :noweb no-export
(package-install 'nov)
(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
#+end_src
#+RESULTS: nov
: ((\.epub\' . nov-mode) (\.odc\' . archive-mode) (\.odf\' . archive-mode) (\.odi\' . archive-mode) (\.otp\' . archive-mode) (\.odp\' . archive-mode) (\.otg\' . archive-mode) (\.odg\' . archive-mode) (\.ots\' . archive-mode) (\.ods\' . archive-mode) (\.odm\' . archive-mode) (\.ott\' . archive-mode) (\.odt\' . archive-mode) (\.cpt\(\#\|~\|\.~[0-9]+~\)?\' nil ps-ccrypt) (\.[pP][dD][fF]\' . pdf-view-mode) (\.desktop\(\.in\)?$ . desktop-entry-mode) (CMakeLists\.txt\' . cmake-mode) (\.cmake\' . cmake-mode) (.at' . autotest-mode) (\.tsv\' . tsv-mode) (\.[Cc][Ss][Vv]\' . csv-mode) (\.gv\' . graphviz-dot-mode) (\.dot\' . graphviz-dot-mode) (/git-rebase-todo\' . git-rebase-mode) (\.\(?:md\|markdown\|mkd\|mdown\|mkdn\|mdwn\)\' . markdown-mode) (\.\(plantuml\|pum\|plu\)\' . plantuml-mode) ([./]opam_?\' . tuareg-opam-mode) (\.mly\' . tuareg-menhir-mode) (\.eliomi?\' . tuareg-mode) (\.ml[ip]?\' . tuareg-mode) (\.gpg\(~\|\.~[0-9]+~\)?\' nil epa-file) (\.elc\' . elisp-byte-code-mode) (\.zst\' nil jka-compr) (\.dz\' nil jka-compr) (\.xz\' nil jka-compr) (\.lzma\' nil jka-compr) (\.lz\' nil jka-compr) (\.g?z\' nil jka-compr) (\.bz2\' nil jka-compr) (\.Z\' nil jka-compr) (\.vr[hi]?\' . vera-mode) (\(?:\.\(?:rbw?\|ru\|rake\|thor\|jbuilder\|rabl\|gemspec\|podspec\)\|/\(?:Gem\|Rake\|Cap\|Thor\|Puppet\|Berks\|Brew\|Vagrant\|Guard\|Pod\)file\)\' . ruby-mode) (\.re?st\' . rst-mode) (\.py[iw]?\' . python-mode) (\.m\' . octave-maybe-mode) (\.less\' . less-css-mode) (\.scss\' . scss-mode) (\.awk\' . awk-mode) (\.\(u?lpc\|pike\|pmod\(\.in\)?\)\' . pike-mode) (\.idl\' . idl-mode) (\.java\' . java-mode) (\.m\' . objc-mode) (\.ii\' . c++-mode) (\.i\' . c-mode) (\.lex\' . c-mode) (\.y\(acc\)?\' . c-mode) (\.h\' . c-or-c++-mode) (\.c\' . c-mode) (\.\(CC?\|HH?\)\' . c++-mode) (\.[ch]\(pp\|xx\|\+\+\)\' . c++-mode) (\.\(cc\|hh\)\' . c++-mode) (\.\(bat\|cmd\)\' . bat-mode) (\.[sx]?html?\(\.[a-zA-Z_]+\)?\' . mhtml-mode) (\.svgz?\' . image-mode) (\.svgz?\' . xml-mode) (\.x[bp]m\' . image-mode) (\.x[bp]m\' . c-mode) (\.p[bpgn]m\' . image-mode) (\.tiff?\' . image-mode) (\.gif\' . image-mode) (\.png\' . image-mode) (\.jpe?g\' . image-mode) (\.te?xt\' . text-mode) (\.[tT]e[xX]\' . tex-mode) (\.ins\' . tex-mode) (\.ltx\' . latex-mode) (\.dtx\' . doctex-mode) (\.org\' . org-mode) (\.dir-locals\(?:-2\)?\.el\' . lisp-data-mode) (eww-bookmarks\' . lisp-data-mode) (tramp\' . lisp-data-mode) (/archive-contents\' . lisp-data-mode) (places\' . lisp-data-mode) (\.emacs-places\' . lisp-data-mode) (\.el\' . emacs-lisp-mode) (Project\.ede\' . emacs-lisp-mode) (\.\(scm\|stk\|ss\|sch\)\' . scheme-mode) (\.l\' . lisp-mode) (\.li?sp\' . lisp-mode) (\.[fF]\' . fortran-mode) (\.for\' . fortran-mode) (\.p\' . pascal-mode) (\.pas\' . pascal-mode) (\.\(dpr\|DPR\)\' . delphi-mode) (\.\([pP]\([Llm]\|erl\|od\)\|al\)\' . perl-mode) (Imakefile\' . makefile-imake-mode) (Makeppfile\(?:\.mk\)?\' . makefile-makepp-mode) (\.makepp\' . makefile-makepp-mode) (\.mk\' . makefile-gmake-mode) (\.make\' . makefile-gmake-mode) ([Mm]akefile\' . makefile-gmake-mode) (\.am\' . makefile-automake-mode) (\.texinfo\' . texinfo-mode) (\.te?xi\' . texinfo-mode) (\.[sS]\' . asm-mode) (\.asm\' . asm-mode) (\.css\' . css-mode) (\.mixal\' . mixal-mode) (\.gcov\' . compilation-mode) (/\.[a-z0-9-]*gdbinit . gdb-script-mode) (-gdb\.gdb . gdb-script-mode) ([cC]hange\.?[lL]og?\' . change-log-mode) ([cC]hange[lL]og[-.][0-9]+\' . change-log-mode) (\$CHANGE_LOG\$\.TXT . change-log-mode) (\.scm\.[0-9]*\' . scheme-mode) (\.[ckz]?sh\'\|\.shar\'\|/\.z?profile\' . sh-mode) (\.bash\' . sh-mode) (/PKGBUILD\' . sh-mode) (\(/\|\`\)\.\(bash_\(profile\|history\|log\(in\|out\)\)\|z?log\(in\|out\)\)\' . sh-mode) (\(/\|\`\)\.\(shrc\|zshrc\|m?kshrc\|bashrc\|t?cshrc\|esrc\)\' . sh-mode) (\(/\|\`\)\.\([kz]shenv\|xinitrc\|startxrc\|xsession\)\' . sh-mode) (\.m?spec\' . sh-mode) (\.m[mes]\' . nroff-mode) (\.man\' . nroff-mode) (\.sty\' . latex-mode) (\.cl[so]\' . latex-mode) (\.bbl\' . latex-mode) (\.bib\' . bibtex-mode) (\.bst\' . bibtex-style-mode) (\.sql\' . sql-mode) (\(acinclude\|aclocal\|acsite\)\.m4\' . autoconf-mode) (\.m[4c]\' . m4-mode) (\.mf\' . metafont-mode) (\.mp\' . metapost-mode) (\.vhdl?\' . vhdl-mode) (\.article\' . text-mode) (\.letter\' . text-mode) (\.i?tcl\' . tcl-mode) (\.exp\' . tcl-mode) (\.itk\' . tcl-mode) (\.icn\' . icon-mode) (\.sim\' . simula-mode) (\.mss\' . scribe-mode) (\.f9[05]\' . f90-mode) (\.f0[38]\' . f90-mode) (\.indent\.pro\' . fundamental-mode) (\.\(pro\|PRO\)\' . idlwave-mode) (\.srt\' . srecode-template-mode) (\.prolog\' . prolog-mode) (\.tar\' . tar-mode) (\.\(arc\|zip\|lzh\|lha\|zoo\|[jew]ar\|xpi\|rar\|cbr\|7z\|squashfs\|ARC\|ZIP\|LZH\|LHA\|ZOO\|[JEW]AR\|XPI\|RAR\|CBR\|7Z\|SQUASHFS\)\' . archive-mode) (\.oxt\' . archive-mode) (\.\(deb\|[oi]pk\)\' . archive-mode) (\`/tmp/Re . text-mode) (/Message[0-9]*\' . text-mode) (\`/tmp/fol/ . text-mode) (\.oak\' . scheme-mode) (\.sgml?\' . sgml-mode) (\.x[ms]l\' . xml-mode) (\.dbk\' . xml-mode) (\.dtd\' . sgml-mode) (\.ds\(ss\)?l\' . dsssl-mode) (\.js[mx]?\' . javascript-mode) (\.har\' . javascript-mode) (\.json\' . javascript-mode) (\.[ds]?va?h?\' . verilog-mode) (\.by\' . bovine-grammar-mode) (\.wy\' . wisent-grammar-mode) ([:/\]\..*\(emacs\|gnus\|viper\)\' . emacs-lisp-mode) (\`\..*emacs\' . emacs-lisp-mode) ([:/]_emacs\' . emacs-lisp-mode) (/crontab\.X*[0-9]+\' . shell-script-mode) (\.ml\' . lisp-mode) (\.ld[si]?\' . ld-script-mode) (ld\.?script\' . ld-script-mode) (\.xs\' . c-mode) (\.x[abdsru]?[cnw]?\' . ld-script-mode) (\.zone\' . dns-mode) (\.soa\' . dns-mode) (\.asd\' . lisp-mode) (\.\(asn\|mib\|smi\)\' . snmp-mode) (\.\(as\|mi\|sm\)2\' . snmpv2-mode) (\.\(diffs?\|patch\|rej\)\' . diff-mode) (\.\(dif\|pat\)\' . diff-mode) (\.[eE]?[pP][sS]\' . ps-mode) (\.\(?:PDF\|DVI\|OD[FGPST]\|DOCX\|XLSX?\|PPTX?\|pdf\|djvu\|dvi\|od[fgpst]\|docx\|xlsx?\|pptx?\)\' . doc-view-mode-maybe) (configure\.\(ac\|in\)\' . autoconf-mode) (\.s\(v\|iv\|ieve\)\' . sieve-mode) (BROWSE\' . ebrowse-tree-mode) (\.ebrowse\' . ebrowse-tree-mode) (#\*mail\* . mail-mode) (\.g\' . antlr-mode) (\.mod\' . m2-mode) (\.ses\' . ses-mode) (\.docbook\' . sgml-mode) (\.com\' . dcl-mode) (/config\.\(?:bat\|log\)\' . fundamental-mode) (/\.\(authinfo\|netrc\)\' . authinfo-mode) (\.\(?:[iI][nN][iI]\|[lL][sS][tT]\|[rR][eE][gG]\|[sS][yY][sS]\)\' . conf-mode) (\.la\' . conf-unix-mode) (\.ppd\' . conf-ppd-mode) (java.+\.conf\' . conf-javaprop-mode) (\.properties\(?:\.[a-zA-Z0-9._-]+\)?\' . conf-javaprop-mode) (\.toml\' . conf-toml-mode) (\.desktop\' . conf-desktop-mode) (/\.redshift\.conf\' . conf-windows-mode) (\`/etc/\(?:DIR_COLORS\|ethers\|.?fstab\|.*hosts\|lesskey\|login\.?de\(?:fs\|vperm\)\|magic\|mtab\|pam\.d/.*\|permissions\(?:\.d/.+\)?\|protocols\|rpc\|services\)\' . conf-space-mode) (\`/etc/\(?:acpid?/.+\|aliases\(?:\.d/.+\)?\|default/.+\|group-?\|hosts\..+\|inittab\|ksysguarddrc\|opera6rc\|passwd-?\|shadow-?\|sysconfig/.+\)\' . conf-mode) ([cC]hange[lL]og[-.][-0-9a-z]+\' . change-log-mode) (/\.?\(?:gitconfig\|gnokiirc\|hgrc\|kde.*rc\|mime\.types\|wgetrc\)\' . conf-mode) (/\.\(?:asound\|enigma\|fetchmail\|gltron\|gtk\|hxplayer\|mairix\|mbsync\|msmtp\|net\|neverball\|nvidia-settings-\|offlineimap\|qt/.+\|realplayer\|reportbug\|rtorrent\.\|screen\|scummvm\|sversion\|sylpheed/.+\|xmp\)rc\' . conf-mode) (/\.\(?:gdbtkinit\|grip\|mpdconf\|notmuch-config\|orbital/.+txt\|rhosts\|tuxracer/options\)\' . conf-mode) (/\.?X\(?:default\|resource\|re\)s\> . conf-xdefaults-mode) (/X11.+app-defaults/\|\.ad\' . conf-xdefaults-mode) (/X11.+locale/.+/Compose\' . conf-colon-mode) (/X11.+locale/compose\.dir\' . conf-javaprop-mode) (\.~?[0-9]+\.[0-9][-.0-9]*~?\' nil t) (\.\(?:orig\|in\|[bB][aA][kK]\)\' nil t) ([/.]c\(?:on\)?f\(?:i?g\)?\(?:\.[a-zA-Z0-9._-]+\)?\' . conf-mode-maybe) (\.[1-9]\' . nroff-mode) (\.art\' . image-mode) (\.avs\' . image-mode) (\.bmp\' . image-mode) (\.cmyk\' . image-mode) (\.cmyka\' . image-mode) (\.crw\' . image-mode) (\.dcr\' . image-mode) (\.dcx\' . image-mode) (\.dng\' . image-mode) (\.dpx\' . image-mode) (\.fax\' . image-mode) (\.hrz\' . image-mode) (\.icb\' . image-mode) (\.icc\' . image-mode) (\.icm\' . image-mode) (\.ico\' . image-mode) (\.icon\' . image-mode) (\.jbg\' . image-mode) (\.jbig\' . image-mode) (\.jng\' . image-mode) (\.jnx\' . image-mode) (\.miff\' . image-mode) (\.mng\' . image-mode) (\.mvg\' . image-mode) (\.otb\' . image-mode) (\.p7\' . image-mode) (\.pcx\' . image-mode) (\.pdb\' . image-mode) (\.pfa\' . image-mode) (\.pfb\' . image-mode) (\.picon\' . image-mode) (\.pict\' . image-mode) (\.rgb\' . image-mode) (\.rgba\' . image-mode) (\.tga\' . image-mode) (\.wbmp\' . image-mode) (\.webp\' . image-mode) (\.wmf\' . image-mode) (\.wpg\' . image-mode) (\.xcf\' . image-mode) (\.xmp\' . image-mode) (\.xwd\' . image-mode) (\.yuv\' . image-mode) (\.tgz\' . tar-mode) (\.tbz2?\' . tar-mode) (\.txz\' . tar-mode) (\.tzst\' . tar-mode) (\.tgz\' . tar-mode))
** Elfeed for Reading RSS Feeds
#+name: elfeed-config
#+begin_src elisp :results none
(package-install 'elfeed)
(require 'elfeed)
(setq elfeed-feeds
'(("https://harpers.org/feed" culture politics news)
("https://theconvivialsociety.substack.com/feed" technology culture philosophy)
("https://daily.jstor.org/feed" news)
("https://www.viruscomix.com/rss.xml" comics)
("https://smbc-comics.com/rss.php" comics)
("https://existentialcomics.com/rss.xml" comics)))
(setq-default elfeed-search-filter "@1-weeks-ago +unread")
#+end_src
** CCRYPT
ccrypt is a standard unix encryption tool. It ships with emacs
bindings that allow users to encrypt and ecrypt files just by
opening and saving them. Such files have a .cpt extension.
#+name: ccrypt
#+begin_src elisp :results none
(load "~/notes/ps-ccrypt.el")
#+end_src
** Toggler
Toggler.el is some code I wrote ages ago. Its sole purpose is to
toggle some file/buffers for easy access.
for now all of the toggling happens in toggler.el, but it shoul be facotred a bit.
#+name: toggler
#+begin_src elisp :results none
(load "~/notes/elisp/toggler.el")
#+end_src
** Deft
#+name: deft
#+begin_src elisp :results none
(package-install 'deft)
(require 'subr-x) ;; what i this?
(setq deft-directory "~/notes/deft/")
(setq deft-use-filename-as-title nil)
(setq deft-use-filter-string-for-filename t)
(setq deft-extensions '("org"))
#+end_src
** Writeroom
#+name: writeroom
#+begin_src elisp :results none
(package-install 'writeroom-mode)
;; (setq my-writeroom-theme 'poet-dark)
;; (setq my-writeroom-cached-theme nil)
;; (add-hook 'writeroom-mode-enable-hook
;; (lambda ()
;; (when my-writeroom-theme
;; (setf my-writeroom-cached-theme
;; (car custom-enabled-themes))
;; (disable-theme (car custom-enabled-themes))
;; (load-theme my-writeroom-theme))
;; (variable-pitch-mode)))
;; (add-hook 'writeroom-mode-disable-hook
;; (lambda ()
;; (variable-pitch-mode 0)
;; (disable-theme (car custom-enabled-themes))
;; (when my-writeroom-cached-theme
;; (enable-theme my-writeroom-cached-theme))
;; (setf my-writeroom-cached-theme nil)))
#+end_src
** EWW config
#+name: eww-config
#+begin_src elisp :noweb no-export :results none
(setq browse-url-browser-function 'eww-browse-url)
;; (add-hook 'eww-mode-hook
;; (lambda ()
;; (writeroom-mode t)))
#+end_src
** Markdown Editing
#+name: markdown-editing
#+begin_src elisp :noweb no-export
(package-install 'markdown-mode)
#+end_src
#+RESULTS: markdown-editing
* Software Development
#+name: software-development-config
#+begin_src elisp :noweb no-export :results none
(show-paren-mode 1)
<>
<>
<>
<>
<>
<>
#+end_src
** Literate Programming
Hacks and tweaks for literate programming. Org auto tangle will tangle
a file whenever it is saved.
#+name: literate-programming
#+begin_src elisp :noweb no-export :results none
(package-install 'org-auto-tangle)
(require 'org-auto-tangle)
(add-hook 'org-mode-hook 'org-auto-tangle-mode)
#+end_src
** Pair-Programming
#+name: pair-programming
#+begin_src elisp :noweb no-export :results none
<>
#+end_src
*** CRDT for pair programming
#+name: crdt-config
#+begin_src elisp :results none
(package-install 'crdt)
#+end_src
** Tools Essential To Development
#+name: software-dev-essentials
#+begin_src elisp :noweb no-export :results none
(package-install 'flycheck)
(package-install 'magit)
(package-install 'paredit)
(package-install 'ag)
(package-install 'lice)
<>
<>
#+end_src
*** Projectile
#+name: projectile
#+begin_src elisp :results none
(require 'cl-lib)
(package-install 'projectile)
(projectile-mode +1)
(setq projectile-project-search-path '("~/projects/"))
(setq projectile-indexing-method 'native)
(setq org-duration-format 'h:mm)
(def-my-command my-projectile-command
'((?/ "[/] search project" projectile-ag)
(?r "[r]eplace in project" projectile-replace)
(?b "project [b]uffers" projectile-ibuffer)
(?o "[o]pen a project" projectile-switch-project)
(?g "ma[g]it" magit-status)
(?j "[j]ump to file" projectile-find-file-dwim)))
#+end_src
*** Company
#+name: company
#+begin_src elisp :results none
(package-install 'company)
(add-hook 'after-init-hook 'global-company-mode)
#+end_src
** Shell Config
The following defines commands used by my [[*My Leader Keys][leader key system]] to
association one shell with each [[*Perspectives Leader Key Menu][perspective aka layout]]
#+name: shell-config
#+begin_src elisp :noweb no-export :results none
(defun persp-shell--shell-name ()
(format "*shell %s*" (persp-current-name)))
(defun persp-shell--shell-buffer-p (buffer)
(string-equal (buffer-name buffer)
(persp-shell--shell-name)))
(defun persp-shell--shell ()
(cl-find-if 'persp-shell--shell-buffer-p
(persp-buffers (persp-curr))))
(defun persp-shell--jump-to-persp-shell ()
(interactive)
(let ((buff (persp-shell--shell)))
(if buff (switch-to-buffer-other-window buff)
(shell (persp-shell--shell-name)))))
#+end_src
** Common Lisp
#+name: common-lisp-config
#+begin_src elisp :noweb no-export :results none
<>
<>
<>
<>
<>
#+end_src
*** Packages
#+name: common-lisp-packages
#+begin_src elisp :results none
(package-install 'paredit)
(package-install 'slime)
(package-install 'slime-company)
(setq slime-contribs
'(slime-fancy slime-company slime-fuzzy slime-asdf))
#+end_src
*** Starting SLIME with different Lisps
#+name: common-lisp-switch-commands
#+begin_src elisp :results none
(defvar my-current-slime-name "sbcl")
(setq sbcl-command "/home/colin/bin/sbcl --dynamic-space-size 4096")
(setq inferior-lisp-program sbcl-command)
(defmacro start-slime-with (str name)
`(lambda ()
(interactive)
(setq inferior-lisp-program ,str)
(setq my-current-slime-name ,name)
(my-switch-to-slime)))
(defun slime-in-this-layout-p (name)
(cl-find-if (lambda (buffer)
(string-search (format "slime-repl %s" name)
(or (buffer-name buffer) "")))
(persp-buffers (persp-curr))))
(defun my-switch-to-slime ()
(interactive)
(let ((buff (slime-in-this-layout-p my-current-slime-name)))
(if buff (switch-to-buffer-other-window buff)
(slime))))
(def-my-command my-lisp-switch-command
`((?' "['] repl" my-switch-to-slime)
(?s "[s]bcl" ,(start-slime-with sbcl-command "sbcl"))
(?e "[e]cl" ,(start-slime-with "ecl" "ecl"))
(?a "[a]bcl" ,(start-slime-with "abcl" "abcl"))
;(?c "[c]cl" ,(start-slime-with "~/lisp/ccl/lx86cl64" "ccl"))
))
#+end_src
*** Lisp Mode Leader Key command
Requires installation of the hyperspec and cltl packages on debain
from debian contrib
: sudo apt install cltl hyperspec
#+name: common-lisp-mode-command
#+begin_src elisp :results none
(def-my-command my-lisp-mode-command
'((?' "['] open slime repl" my-switch-to-slime)
(?c "[c]ompile form" slime-compile-defun)
(?l "[l]oad file" slime-load-file)
(?< "[<] list callers" slime-list-callers)
(?> "[>] list callees" slime-list-callees)
(?s "[s]ymbol describe" slime-describe-symbol)
(?S "[S]ync package" slime-sync-package-and-default-directory)
(?d "[d]ocumentation" slime-documentation)
(?\t "[TAB] inspect-presentation" slime-inspect-presentation-at-point)
(?B "Open CLTL2 [B]ook" open-cltl2)
(?b "[b]rows system" slime-browse-system)
(?h "[h]yperspec lookup" hyperspec-lookup)))
(defun open-cltl2 ()
(interactive)
(eww "file:///usr/share/doc/cltl/clm/clm.html"))
(with-eval-after-load 'lisp-mode
(progn
(setq common-lisp-hyperspec-root "file:///home/colin/HyperSpec/")))
#+end_src
*** Editing Config
#+name: common-lisp-editing-config
#+begin_src elisp :results none
(slime-setup '(slime-fancy slime-company))
(setq slime-company-completion 'fuzzy
slime-company-after-completion 'slime-company-just-one-space)
(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
(add-hook 'lisp-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
(add-hook 'scheme-mode-hook #'enable-paredit-mode)
(add-hook 'clojure-mode-hook #'paredit-mode)
(defun space-for-delimiter-after-$-p (delimiter endp)
(not (char-equal ?$ (char-before (point)))))
(defun space-for-delimiter-after-@-p (delimiter endp)
(not (char-equal ?@ (char-before (point)))))
(defun space-for-delimiter-after-p-p (delimiter endp)
(not (char-equal ?P (char-before (point)))))
(setq paredit-space-for-delimiter-predicates
(list 'space-for-delimiter-after-$-p
'space-for-delimiter-after-@-p
'space-for-delimiter-after-p-p))
(add-hook 'lisp-mode-hook 'linum-mode)
#+end_src
*** Coalton
#+name: coalton-config
#+begin_src elisp :noweb no-export
(setq +coalton-package-template+
"
(defpackage #:%s
(:import-from
#:common-lisp
#:describe
#:disassemble)
(:use
#:coalton
#:coalton-prelude)
(:local-nicknames
(#:types #:coalton-library/types)
(#:hash #:coalton-library/hash)
(#:bits #:coalton-library/bits)
(#:math #:coalton-library/math)
(#:char #:coalton-library/char)
(#:string #:coalton-library/string)
(#:tuple #:coalton-library/tuple)
(#:optional #:coalton-library/optional)
(#:list #:coalton-library/list)
(#:result #:coalton-library/result)
(#:cell #:coalton-library/cell)
(#:vector #:coalton-library/vector)
(#:slice #:coalton-library/slice)
(#:hashtable #:coalton-library/hashtable)
(#:st #:coalton-library/monad/state)
(#:free #:coalton-library/monad/free)
(#:iter #:coalton-library/iterator)
(#:sys #:coalton-library/system)))
(named-readtables:in-readtable coalton:coalton)
(in-package #:%s)
(coalton-toplevel
)
")
(defun insert-coalton-defpackage (name)
(interactive "sName: ")
(insert
(format +coalton-package-template+ name name)))
(message "HERE HERE HERE")
#+end_src
#+RESULTS: coalton
: insert-coalton-defpackage
** Haxe
#+name: haxe-config
#+begin_src elisp :noweb no-export
(package-install 'haxe-mode)
#+end_src
#+RESULTS: haxe-config
: Package ‘haxe-mode’ installed.
* Tools
#+name: tools-config
#+begin_src elis :noweb no-export
<>xs
<>
<>
#+end_src
** Dirvish
Dirvish is a slicker dired - i.e it's a file manager.
#+name: dirvish-config
#+begin_src elisp :noweb no-export
(package-install 'dirvish)
(dirvish-override-dired-mode)
#+end_src
#+RESULTS: dirvish-config
: t
** Export Emacs Buffer
#+name: buffer-export-config
#+begin_src emacs-lisp
(defun screenshot-svg (filename)
"Save a screenshot of the current frame as an SVG image.
Saves to a temp file and puts the filename in the kill ring."
(interactive "sfilename:")
(let* ((tmpfile (make-temp-file "Emacs" nil ".svg"))
(data (x-export-frames nil 'svg)))
(with-temp-file tmpfile
(insert data))
(copy-file tmpfile filename t)
(message filename)))
#+end_src
#+RESULTS: buffer-export-config
: screenshot-svg
** Helpful
#+name: helpful
#+begin_src elisp :noweb no-export
(package-install 'helpful)
#+end_src
#+RESULTS: helpful
: Package ‘helpful’ installed.