;; Code:
-(org-babel-load-file (concat user-emacs-directory "config.org"))
+;; Startup options
+(setq inhibit-startup-screen t
+ inhibit-startup-buffer-menu t
+ server-client-instructions nil
+ frame-resize-pixelwise t
+ initial-scratch-message (message ";;; Emacs loaded in %s.\n\n" (emacs-init-time)))
+
+;; Load External Libraries
+(add-to-list 'load-path (concat user-emacs-directory "re/"))
+(add-to-list 'load-path (concat user-emacs-directory "acme-mouse/"))
+(require 're-c-style)
+(require 're-editing-defuns)
+(require 're-packages)
+(require 're-os-specific)
+(require 're-bindings)
+
+;; Loaded Later
+(add-hook 'after-init-hook (lambda ()
+ (require 'acme-mouse)
+ (require 're-repl-defuns)
+ (require 're-math-defuns)
+ (require 're-electronics-defuns)
+ (require 're-plc-defuns)
+ (require 're-refrigeration-defuns)
+ (require 're-skeletons)))
+
+;; Don't do anything with org until I call it
+(add-hook 'org-mode-hook (lambda ()
+ #'abbrev-mode
+ (require 're-org)))
+
+
+;; Buffer customizations
+(setq-default indicate-empty-lines t
+ fill-column 80
+ cursor-type 'bar
+ cursor-in-non-selected-windows 'hollow)
+
+(blink-cursor-mode -1)
+(column-number-mode t)
+(size-indication-mode t)
+
+;; Buffer interaction
+(delete-selection-mode t)
+(setq disabled-command-function nil
+ save-interprogram-paste-before-kill t
+ confirm-kill-processes nil
+ mouse-1-click-follows-link nil)
+
+;; Buffer navigation
+(windmove-default-keybindings 'control)
+(setq windmove-wrap-around t
+ windmove-create-window t)
+
+;; Recent files/buffers
+(midnight-mode t)
+(recentf-mode 1)
+(setq recentf-max-menu-items 20)
+
+;; Dired
+(setq dired-listing-switches "-al"
+ dired-vc-rename-file t
+ dired-auto-revert-buffer t
+ dired-hide-details-hide-symlink-targets nil)
+
+(add-hook 'dired-mode-hook
+ (lambda ()
+ (dired-hide-details-mode t)
+ (keymap-set dired-mode-map
+ "RET" 'dired-find-alternate-file)))
+
+;; Bookmarks
+(setq bookmark-save-flag 1)
+
+;; Minibuffer Customizations
+(setq ring-bell-function 'ignore
+ use-short-answers t
+ use-file-dialog nil
+ echo-keystrokes 0.1
+ eldoc-idle-delay 0
+ eldoc-echo-area-use-multiline-p nil
+ read-buffer-completion-ignore-case t
+ history-delete-duplicates t)
+
+;; GUI customizations
+(menu-bar-mode -1)
+(tool-bar-mode -1)
+(set-scroll-bar-mode 'left)
+(setq frame-title-format "Poor Man's LispM")
+
+;; Pretty-Printing
+(setq prettify-symbols-alist '(("lambda" . 955)
+ ("delta" . 120517)
+ ("epsilon" . 120518)
+ ("->" . 8594)
+ ("<=" . 8804)
+ (">=" . 8805)))
+
+(global-prettify-symbols-mode t)
+
+;; Paren-matching
+(setq show-paren-delay 0
+ show-paren-style 'expression)
+
+(set-face-attribute 'show-paren-match nil
+ :foreground 'unspecified
+ :background 'unspecified
+ :underline t)
+;; Help
+(setq apropos-do-all t)
+
+;; UTF-8
+(set-language-environment 'utf-8)
+(set-default-coding-systems 'utf-8)
+(set-keyboard-coding-system 'utf-8-unix)
+(set-terminal-coding-system 'utf-8-unix)
+
+;; Cleanup on save
+(setq require-final-newline t)
+(add-hook 'before-save-hook 'whitespace-cleanup)
+(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
+
+;; Version Control
+(setq vc-make-backup-files t
+ backup-by-copying t
+ backup-directory-alist `((".*" . "~/emacs-backups/")))
+
+;; Backups
+(setq delete-old-versions t
+ kept-new-versions 5
+ kept-old-versions 5)
+
+;; Auto-revert
+(global-auto-revert-mode t)
+(setq global-auto-revert-non-file-buffers t)
+
+;; Crash handling
+(setq attempt-stack-overflow-recovery nil
+ attempt-orderly-shutdown-on-fatal-signal nil)
+
+;; Abbrev-mode
+(setq abbrev-file-name (expand-file-name "abbrev_defs" user-emacs-directory)
+ save-abbrevs 'silently)
+
+;; Customize System
+(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
+(when (not (file-exists-p custom-file))
+ (make-empty-file custom-file))
+
+(load custom-file)
;;; hic terminatur init.el
--- /dev/null
+;;; re-bindings.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+;; Editing Bindings
+(keymap-global-set "<insert>" nil)
+(keymap-global-set "C-\\" 'undo-redo)
+(keymap-global-set "C-S-K" 'kill-whole-line)
+(keymap-global-set "C-w" 're/kill-bword-or-region)
+(keymap-global-set "C-u" '(lambda () (interactive) (kill-line 0)))
+(keymap-set key-translation-map "C-h" "<DEL>") ; Prefer F1 for help
+(keymap-global-set "C-o" 're/open-line-below)
+(keymap-global-set "M-o" 're/open-line-above)
+(keymap-global-set "M-j" (lambda ()
+ (interactive)
+ (join-line 0))) ; join-line other way
+(keymap-global-set "C-z" 'zap-up-to-char)
+(keymap-global-set "C-c s" 'sort-lines)
+(keymap-global-set "M-;" 're/comment-dwim)
+(keymap-global-set "<remap> <capitalize-word>" 'capitalize-dwim)
+(keymap-global-set "<remap> <downcase-word>" 'downcase-dwim)
+(keymap-global-set "<remap> <upcase-word>" 'upcase-dwim)
+(keymap-global-set "M-'" 'universal-argument)
+
+;; Motion
+(keymap-global-set "<home>" 'beginning-of-buffer)
+(keymap-global-set "<end>" 'end-of-buffer)
+(keymap-global-set "M-n" 'next-buffer)
+(keymap-global-set "M-p" 'previous-buffer)
+(keymap-global-set "<mouse-4>" 'previous-buffer)
+(keymap-global-set "C-M-o" 're/other-window-or-split-window)
+(keymap-global-set "<remap> <move-beginning-of-line>" 're/smart-beginning-of-line)
+(keymap-global-set "<remap> <move-end-of-line>" 're/smart-end-of-line)
+(keymap-set visual-line-mode-map "C-a" 're/smart-beginning-of-line)
+(keymap-set visual-line-mode-map "C-e" 're/smart-end-of-line)
+(keymap-global-set "<remap> <goto-line>" 're/goto-line)
+
+;; Search
+(keymap-global-set "M-s ." 'isearch-forward-thing-at-point)
+(keymap-global-set "M-s M-." 'isearch-forward-symbol-at-point)
+(keymap-global-set "M-%" 'replace-regexp)
+(keymap-global-set "C-%" 'replace-string)
+(keymap-global-set "C-s" 're/isearch-forward-use-region)
+(keymap-global-set "C-r" 're/isearch-backward-use-region)
+(keymap-global-set "C-S-S" 'isearch-forward-regexp)
+(keymap-global-set "C-S-R" 'isearch-backward-regexp)
+
+;; Buffer/Window Management
+(keymap-global-set "C-x C-r" 're/rename-current-buffer-file)
+(keymap-global-set "<f5>" 'scratch-buffer)
+(keymap-global-set "S-<f5>" 're/scratch-only)
+(keymap-global-set "C-x M-f" 'find-file-at-point)
+(keymap-global-set "C-x C-b" 'buffer-menu)
+(keymap-global-set "C-x M-b" 'buffer-menu-other-window)
+
+;; Recents and Bookmarks
+(keymap-global-set "C-c r" 'recentf-open-files)
+(keymap-global-set "C-x r B" 'bookmark-jump-other-window)
+
+;; Eval/REPL
+(keymap-global-set "C-M-z" 'eval-region)
+(keymap-global-set "C-c i" 'ielm)
+(add-hook 'ielm-mode-hook
+ (lambda ()
+ (keymap-set inferior-emacs-lisp-mode-map "C-l" 'comint-clear-buffer)
+ (keymap-set inferior-emacs-lisp-mode-map ")" '(re/send-on-close-paren 'ielm-send-input))))
+(keymap-global-set "C-c e" 'eshell)
+(add-hook 'eshell-mode-hook
+ (lambda ()
+ (keymap-set eshell-mode-map ")" '(re/send-on-close-paren 'eshell-send-input))
+ (keymap-set eshell-mode-map "C-d" 'eshell-quit-or-delete-char)))
+
+
+;; Org Starters
+(keymap-global-set "C-c l" 'org-store-link)
+(keymap-global-set "C-c a" 'org-agenda)
+(keymap-global-set "C-c c" 'org-capture)
+(keymap-global-set "C-c b" 'org-switchb)
+(keymap-global-set "<f8>" 're/org-agenda-show-custom)
+(keymap-global-set "<f6>" 're/org-show-agenda)
+
+(provide 're-bindings)
+;;; hic terminatur re-bindings.el
--- /dev/null
+;;; re-c-style.el --- My C style -*- lexical-binding: t; -*-
+;; This file is not part of emacs
+;; Fix emacs' refusal to use tabs in c files
+;; Code:
+
+(defun re/c-lineup-arglist-tabs-only (ignored)
+ "Line up argument lists by tabs, not spaces. Stolen from https://kernel.org/doc/html/v4.10/process/coding-style.html"
+ (let* ((anchor (c-langelem-pos c-syntactic-element))
+ (column (c-langelem-2nd-pos c-syntactic-element))
+ (offset (- (1+ column) anchor))
+ (steps (floor offset c-basic-offset)))
+ (* (max steps 1)
+ c-basic-offset)))
+
+(add-hook 'c-mode-common-hook
+ (lambda ()
+ ;; Add kernel style
+ (c-add-style
+ "linux-tabs-only"
+ '("linux"
+ (c-offsets-alist
+ (arglist-cont-nonempty
+ c-lineup-gcc-asm-reg
+ re/c-lineup-arglist-tabs-only))))))
+
+(add-hook 'c-mode-hook
+ (lambda ()
+ (setq indent-tabs-mode t)
+ (setq show-trailing-whitespace t)
+ (setq c-backspace-function 'backward-delete-char) ;; don't expand my tabs, just delete them.
+ (c-set-style "linux-tabs-only")))
+
+(provide 're-c-style)
+;;; hic terminatur re-c-style.el
--- /dev/null
+;;; re-editing-defuns.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+(defun re/rename-current-buffer-file ()
+ "Renames the current buffer and the file it is visiting."
+ (interactive)
+ (let ((name (buffer-name))
+ (filename (buffer-file-name)))
+ (if (not (and filename (file-exists-p filename)))
+ (error "Buffer '%s' is not visiting a file!" name)
+ (let ((new-name (read-file-name "New name: " filename)))
+ (if (get-buffer new-name)
+ (error "A buffer named '%s' already exists!" new-name)
+ (rename-file filename new-name 1)
+ (rename-buffer new-name)
+ (set-visited-file-name new-name)
+ (set-buffer-modified-p nil)
+ (message "File '%s' successfully renamed to '%s'"
+ name (file-name-nondirectory new-name)))))))
+
+(defun re/scratch-only ()
+ "Bring up the scratch buffer as the only visible buffer."
+ (interactive)
+ (scratch-buffer)
+ (delete-other-windows))
+
+(defun re/open-line-below (n)
+ "Creates a new empty line below the current line and moves to it."
+ (interactive "*p")
+ (end-of-line)
+ (open-line n)
+ (call-interactively (next-line))
+ (indent-for-tab-command))
+
+(defun re/open-line-above (n)
+ "Creates a new empty line above the current line."
+ (interactive "*p")
+ (beginning-of-line)
+ (open-line n)
+ (indent-for-tab-command))
+
+(defun re/comment-dwim ()
+ "Comment region if active, otherwise comment line.
+Stolen from https://depp.brause.cc/dotemacs"
+ (interactive)
+ (if (use-region-p)
+ (comment-or-uncomment-region (region-beginning) (region-end))
+ (comment-or-uncomment-region (line-beginning-position)
+ (line-end-position))))
+(defun re/kill-bword-or-region ()
+ "Kill region if active, otherwise kill back one word."
+ (interactive)
+ (if (use-region-p)
+ (call-interactively 'kill-region)
+ (call-interactively 'backward-kill-word)))
+
+(defun re/smart-beginning-of-line ()
+ "Move point to first non-whitespace character or `beginning-of-visual-line'.
+If point was already at that position, call `back-to-indentation'.
+Called a third time, move point to `beginning-of-line'.
+If in org-mode, call `org-beginning-of-line' first."
+ (interactive "^")
+ (let ((oldpos (point)))
+ (if (equal major-mode 'org-mode)
+ (org-beginning-of-line)
+ (progn
+ (beginning-of-visual-line 1)
+ (skip-syntax-forward " " (line-end-position))
+ (backward-prefix-chars)))
+ (and (= oldpos (point))
+ (let ((newpos (point)))
+ (back-to-indentation)
+ (and (= newpos (point))
+ (beginning-of-line))))))
+
+(defun re/smart-end-of-line ()
+ "Move point to the end of the visual line. If point was already at that position, call `move-end-of-line'.
+If in org-mode, call `org-end-of-line' first."
+ (interactive "^")
+ (let ((oldpos (point)))
+ (if (equal major-mode 'org-mode)
+ (org-end-of-line)
+ (end-of-visual-line 1))
+ (and (= oldpos (point))
+ (move-end-of-line nil))))
+
+(defun re/goto-line ()
+ "Show line numbers before going to line, then hide them again."
+ (interactive)
+ (display-line-numbers-mode 1)
+ (call-interactively 'goto-line)
+ (display-line-numbers-mode -1))
+(defun re/other-window-or-split-window (&optional window)
+ (interactive)
+ (if (= (count-windows) 1)
+ (funcall split-window-preferred-function window)
+ (other-window 1)))
+
+(defun re/isearch-forward-use-region ()
+ (interactive)
+ (when (use-region-p)
+ (add-to-history 'search-ring (buffer-substring (region-beginning)
+ (region-end)))
+ (deactivate-mark))
+ (call-interactively 'isearch-forward))
+
+(defun re/isearch-backward-use-region ()
+ (interactive)
+ (when (use-region-p)
+ (add-to-history 'search-ring (buffer-substring (region-beginning)
+ (region-end)))
+ (deactivate-mark))
+ (call-interactively 'isearch-backward))
+
+(provide 're-editing-defuns)
+;;; hic terminatur re-editing-defuns.el
--- /dev/null
+;;; re-electronics-defuns.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+(defun eff-imp (r1 &optional r2)
+ "Calculate the effective input impedance, given two resistances.
+For use in `amps->volts' and related. The handling of only one
+resistance given is done here, instead of doing it in every
+function that uses this."
+ (if (eq nil r2)
+ r1
+ (inv (+ (inv r1) (inv r2)))))
+
+(defun amps->volts (amps r1 &optional r2)
+ "Calculate the voltage, given amperage and impedance.
+Multiplies the amperage by the effective impedance calculated
+with `eff-imp'."
+ (* amps (eff-imp r1 r2)))
+
+(defun volts->amps (volts r1 &optional r2)
+ "Calculate the amperage, given voltage and impedance.
+Divides the voltage by the effective impedance calculated with
+`eff-imp'."
+ (/ volts (eff-imp r1 r2)))
+
+(provide 're-electronics-defuns)
+;;; hic terminatur re-electronics-defuns.el
--- /dev/null
+;;; re-math-defuns.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+(defalias '^ 'expt)
+
+(defmacro square (x)
+ "Calculate the square of a value."
+ `(^ ,x 2))
+
+(defmacro cube (x)
+ "Calculate the cube of a value."
+ `(^ ,x 3))
+
+(defmacro inv (x)
+ "Calculate the inverse of a value."
+ `(/ 1 (float ,x)))
+
+(defmacro E (number exponent)
+ "Pseudo Engineering notation.
+i.e. (E 5 3) == 5E3 == 5000"
+ `(* ,number (^ 10 ,exponent)))
+
+(provide 're-math-defuns)
+;;; hic terminatur re-math-defuns.el
--- /dev/null
+;;; re-org.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+(setq org-startup-folded t
+ org-startup-indented t)
+
+(setq org-M-RET-may-split-line nil
+ org-return-follows-link t
+ org-table-export-default-format "orgtbl-to-csv"
+ org-export-backends '(ascii html latex md)
+ org-link-file-path-type 'absolute)
+
+(setq org-use-fast-todo-selection 'expert
+ org-fast-tag-selection-single-key 'expert
+ org-enforce-todo-dependencies t
+ org-enforce-todo-checkbox-dependencies t
+ org-fontify-done-headline nil
+ org-fontify-todo-headline nil)
+
+(setq org-goto-interface 'outline-path-completion
+ org-outline-path-complete-in-steps nil
+ org-goto-max-level 20)
+
+(setq org-special-ctrl-a/e t
+ org-special-ctrl-k t
+ org-yank-adjusted-subtrees t)
+
+(setq org-link-frame-setup '((file . find-file)))
+
+(setq org-directory "~/org"
+ org-agenda-files '("~/org")
+ org-default-notes-file "~/org/refile.org"
+ org-journal-file "~/org/journal.org")
+
+(setq org-refile-targets '((nil :maxlevel . 9)
+ (org-agenda-files :maxlevel . 9))
+ org-refile-use-outline-path 'file
+ org-refile-allow-creating-parent-nodes 'confirm)
+
+(setq org-todo-keywords '((sequence "TODO(t)"
+ "WAITING(w@/!)"
+ "IN-PROGRESS(i!)"
+ "APPT(a!)"
+ "|"
+ "DELEGATED(l@)"
+ "DONE(d!/@)"
+ "CANCELLED(c@)")))
+
+(setq org-tag-alist '((:startgroup . nil)
+ ("need" . ?n)
+ ("standard" . ?s)
+ ("wisdom" . ?w)
+ (:endgroup . nil)))
+
+(setq org-agenda-restore-windows-after-quit t
+ org-agenda-start-on-weekday 0
+ org-agenda-span 14
+ org-deadline-warning-days 30
+ org-agenda-window-setup 'current-window
+ org-agenda-remove-tags t
+ org-agenda-prefix-format '((agenda . " %:c %b %?-12t% s")
+ (todo . " %:c % b")
+ (tags . " %:c % b")
+ (search . " %:c % b")))
+
+(setq org-agenda-custom-commands '((" " "Agenda"
+ (;(agenda "" nil)
+ (tags "need"
+ ((org-agenda-overriding-header "Needed Items")))
+ (tags-todo "-REFILE+TODO=\"IN-PROGRESS\""
+ ((org-agenda-overriding-header "In Progress")))
+ (tags "REFILE"
+ ((org-agenda-overriding-header "Tasks to Refile")))
+ (tags-todo "-TODO=\"WAITING\"-TODO=\"IN-PROGRESS\"-standard-REFILE"
+ ((org-agenda-overriding-header "Filed Tasks")))
+ (tags-todo "TODO=\"WAITING\"-REFILE"
+ ((org-agenda-overriding-header "Holding")))
+ (tags-todo "standard"
+ ((org-agenda-overriding-header "Changes to Standard")))))))
+
+(setq org-columns-default-format "%50ITEM(Task) %10CLOCKSUM %16TIMESTAMP_IA"
+ org-agenda-start-with-log-mode t)
+
+(org-clock-persistence-insinuate)
+
+(setq org-clock-persist t
+ org-clock-in-resume t
+ org-clock-persist-query-resume nil
+ org-clock-report-include-clocking-task t
+ org-pretty-entities t)
+
+(setq org-capture-templates '(("n" "Note" entry (file org-default-notes-file)
+ "* %?"
+ :clock-in t
+ :clock-resume t)
+ ("t" "TODO" entry (file org-default-notes-file)
+ "* TODO %?\n%U\n"
+ :clock-in t
+ :clock-resume t)
+ ("m" "Meeting" entry (file+olp+datetree org-journal-file)
+ "* %? :meeting:\n%t\n** Notes\n** Action Items"
+ :time-prompt t)
+ ("s" "Semi-Weekly PLC Meeting" entry (file+olp+datetree org-journal-file)
+ "* Semi-Weekly PLC Meeting :plc:semiweekly:meeting:%^g \n%t\n** Notes\n** Action Items"
+ :clock-in t
+ :clock-resume t)
+ ("a" "Appointment" entry (file+olp+datetree org-journal-file)
+ "* %? :appt:\n%t"
+ :time-prompt t)
+ ("j" "Journal" entry (file+olp+datetree org-journal-file)
+ "* %?\n%U\n")))
+
+(setq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
+
+(setq org-src-window-setup 'current-window
+ org-src-preserve-indentation t
+ org-src-fontify-natively t)
+
+(defun re/org-agenda-show-custom (&optional arg)
+ "Show my custom agenda."
+ (interactive "P")
+ (org-agenda arg " "))
+
+(defun re/org-show-agenda (&optional arg)
+ "Show the main agenda"
+ (interactive "P")
+ (org-agenda arg "a"))
+
+(defun re/org-auto-generate-ids-in-file ()
+ "Add ID properties to all headlines in the current
+ file which do not already have one."
+ (interactive)
+ (org-map-entries 'org-id-get-create))
+
+(defun re/tangle-init ()
+ "Tangle and compile init.org.
+Stolen from https://github.com/larstvei/dot-emacs."
+ (when (equal (buffer-file-name)
+ (expand-file-name (concat user-emacs-directory "config.org")))
+ (let ((prog-mode-hook nil))
+ (org-babel-tangle))))
+
+(keymap-set org-mode-map "M-<right>" 'org-shiftmetaright)
+(keymap-set org-mode-map "M-<left>" 'org-shiftmetaleft)
+(keymap-set org-mode-map "M-S-<right>" 'org-metaright)
+(keymap-set org-mode-map "M-S-<left>" 'org-metaleft)
+
+(provide 're-org)
+;;; hic terminatur re-org.el
--- /dev/null
+;;; re-os-specific.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+;; Windows Specific
+(when (equal system-type 'windows-nt)
+ (setq delete-by-moving-to-trash t
+ ediff-diff-program "\"c:/Program Files/Git/usr/bin/diff.exe\""
+ ediff-diff3-program "\"c:/Program Files/Git/usr/bin/diff3.exe\""
+ diff-command "\"c:/Program Files/Git/usr/bin/diff.exe\""
+ w32-recognize-altgr 'nil)
+ (defun re/unfuck-aveva-license ()
+ "Remove the offending xml files.
+Use this when aveva can't find ass with both hands."
+ (interactive)
+ (let ((xml1 "c:/ProgramData/AVEVA/Licensing/License API2/Data/LocalAcquireInfo.xml")
+ (xml2 "c:/ProgramData/AVEVA/Licensing/License API2/Data/LocalBackEndAcquireInfo.xml"))
+ (when (file-exists-p xml1) (delete-file xml1))
+ (when (file-exists-p xml2) (delete-file xml2)))))
+
+;; Linux/BSD Specific
+(unless (equal system-type 'windows-nt)
+ (if(equal system-type 'berkeley-unix)
+ (defun doas ()
+ "Use TRAMP to reopen the current buffer as root using doas."
+ (interactive)
+ (when buffer-file-name
+ (find-alternate-file
+ (concat "/doas:root@localhost:"
+ buffer-file-name))))
+ (defun sudo ()
+ "Use TRAMP to reopen the current buffer as root using sudo."
+ (interactive)
+ (when buffer-file-name
+ (find-alternate-file
+ (concat "/doas:root@localhost:"
+ buffer-file-name))))))
+
+(provide 're-os-specific)
+;;; hic terminatur re-os-specific.el
--- /dev/null
+;;; re-packages.el --- Load Packages -*- lexical-binding: t; -*-
+;; This file is not part of Emacs.
+;; Code:
+
+(require 'package)
+(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
+
+(use-package ledger-mode
+ :ensure t
+ :bind
+ ((:map ledger-mode-map ("C-c s" . ledger-sort-buffer))))
+
+(use-package visual-fill-column
+ :ensure t
+ :config
+ (global-visual-line-mode 1)
+ :custom
+ (word-wrap t)
+ (visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow))
+ (visual-fill-column-enable-sensible-window-split t))
+
+(keymap-global-set "C-c v" (lambda ()
+ (interactive)
+ (visual-fill-column-mode 'toggle)))
+
+(use-package corfu
+ :ensure t
+ :custom
+ (corfu-auto t)
+ (corfu-auto-delay 0)
+ (corfu-auto-prefix 1)
+ :config
+ (global-corfu-mode))
+
+(use-package corfu-popupinfo
+ :ensure nil ; Part of corfu
+ :after corfu
+ :hook (corfu-mode . corfu-popupinfo-mode)
+ :custom
+ (corfu-popupinfo-delay '(nil . 0.01))
+ (corfu-popupinfo-hide nil)
+ :config
+ (corfu-popupinfo-mode))
+(use-package expand-region
+ :ensure t
+ :bind
+ (("C-=" . 'er/expand-region)))
+
+(use-package magit
+ :ensure t
+ :config
+ (message "Magit Loaded")
+ :bind
+ ((:map ctl-x-map ("g" . magit-status))))
+
+(use-package openwith
+ :ensure t
+ :defer t
+ :config
+ (openwith-mode t)
+ (setq openwith-associations (list ; Set these up for linux - windows falls back to system default
+ (list (openwith-make-extension-regexp
+ '("xls" "xlsx"
+ "doc" "docx"
+ "ppt" "pptx"
+ "odt" "ods"
+ "odg" "odp"))
+ "libreoffice" ; Windows falls back to system default
+ '(file))
+ (list (openwith-make-extension-regexp
+ '("adpro"))
+ "ProductivitySuite"
+ '(file))
+ (list (openwith-make-extension-regexp
+ '("pdf"))
+ "zathura" ; Windows falls back to ms-office
+ '(file)))))
+(use-package auctex
+ :ensure t
+ :defer t)
+
+(let ((slime-help "~/quicklisp/slime-helper.el"))
+ (when (file-exists-p slime-help)
+ (use-package slime
+ :ensure t
+ :defer t
+ :init
+ (load (expand-file-name slime-help))
+ :config
+ (setq inferior-lisp-program "sbcl")
+ :custom
+ (slime-net-coding-system 'utf-8-unix))
+ (when (file-exists-p "~/lisp/sbcl.core-for-slime")
+ (setq slime-lisp-implementations
+ '((sbcl ("sbcl" "--core" "sbcl.core-for-slime")
+ :directory "~/lisp"))))
+ (add-hook 'slime-mode-hook
+ (lambda ()
+ (unless (slime-connected-p)
+ (save-excursion (slime)))))))
+
+(provide 're-packages)
+;;; Hic terminatur re-packages.el
--- /dev/null
+;;; re-plc-defuns.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+(defun max-counts (resolution)
+ "Calculate the max count for a PLC analog, given card's bit-resolution."
+ (1- (^ 2 resolution)))
+
+(defun volts->counts (vmax vin resolution)
+ "Convert a voltage signal to a PLC count.
+Calculates a ratio of vin/vmax, then scales by `max-counts'."
+ (* (/ (float vin) vmax) (max-counts resolution)))
+
+(defun counts->volts (vmax cin resolution)
+ "Convert a PLC count to a voltage.
+Calculates a ratio of cin/`max-counts', then multiplies by vmax."
+ (* (/ (float cin) (max-counts resolution)) vmax))
+
+(defun amps->counts (vmax amps resolution r1 &optional r2)
+ "Convert a current signal to PLC Counts.
+Converts the amperage to a voltage using `amps->volts' (with r1
+and optional r2), then applies `volts->counts' to the resulting
+voltage, vmax, and resolution."
+ (volts->counts vmax (amps->volts amps r1 r2) resolution))
+
+(defun count-range (upper lower vmax resolution &optional r1 r2)
+ "Given an upper and lower signal, return the list of upper and lower PLC counts.
+With a current signal, use r1 and maybe r2 to
+calculate `amps->counts'. Otherwise ignore r1/r2 and calculate
+`volts->counts'."
+ (if (eq nil r1)
+ (list (volts->counts vmax upper resolution)
+ (volts->counts vmax lower resolution))
+ (list (amps->counts vmax upper resolution r1 r2)
+ (amps->counts vmax lower resolution r1 r2))))
+
+(defun divisor (raw-max raw-min scaled-max scaled-min)
+ "Calculate 1/slope given PLC Max/Min and Eng. Max/Min."
+ (/ (float (- raw-max raw-min)) (- scaled-max scaled-min)))
+
+(defun offset (raw-max raw-min scaled-max scaled-min)
+ "Calculate offset given PLC Max/Min and Eng. Max/Min."
+ (- scaled-min (/ raw-min (divisor raw-max raw-min scaled-max scaled-min))))
+
+(defun final (analog-input divisor offset)
+ "Calculate the scaled value of an input."
+ (+ (/ analog-input divisor) offset))
+
+(defun scale (raw-max raw-min scaled-max scaled-min &optional analog-input)
+ "Calculate the divisor, offset, and maybe final value, given the parameters."
+ (let* ((div (divisor raw-max raw-min scaled-max scaled-min))
+ (os (offset raw-max raw-min scaled-max scaled-min)))
+ (if (eq nil analog-input)
+ (list div os)
+ (list div os (final analog-input div os)))))
+
+(provide 're-plc-defuns)
+;;; hic terminatur re-plc-defuns.el
--- /dev/null
+;;; re-refrigeration-defuns.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+;; Unit Conversions
+(defun mm->in (mm)
+ "Convert milimeters to inches."
+ (/ mm 25.4))
+
+(defun in->mm (in)
+ "Convert inches to milimeters."
+ (* in 25.4))
+
+(defun k->c (tempk)
+ "Convert degrees Kelvin to degrees Celsius."
+ (- tempk 273.15))
+
+(defun c->k (tempc)
+ "Convert degrees Celsius to degrees Kelvin."
+ (+ tempc 273.15))
+
+(defun c->f (tempc)
+ "Convert degrees Celsius to degrees Fahrenheit."
+ (+ (* tempc 1.8) 32.0))
+
+(defun f->c (tempf)
+ "Convert degrees Fahrenheit to degrees Celsius."
+ (/ (- tempf 32.0) 1.8))
+
+(defun k->f (tempk)
+ "Convert degrees Kelvin to degrees Fahrenheit.
+Applies `c->f' to `k->c'."
+ (c->f (k->c tempk)))
+
+(defun f->k (tempf)
+ "Convert degrees Fahrenheit to degrees Kelvin.
+Applies `c->k' to `f->c'."
+ (c->k (f->c tempf)))
+
+;; Refrigeration
+(defun cfm-circ (fpm radius)
+ "Calculate the CFM of a circular duct.
+Inputs are feet/minute and radius (in)."
+ (list (* float-pi fpm (square (/ radius 12.0)))))
+
+(defun cfm-rect (fpm width height)
+ "Calculate the CFM of a rectangular duct.
+Inputs are feet/minute, width (in) and height (in)."
+ (list (* fpm (/ width 12.0) (/ height 12.0))))
+
+(defun sat-water-press (temp)
+ "Calculate the saturated water pressure at a temp (F)."
+ (+ .0182795
+ (* temp .001029904)
+ (* (square temp) 0.00002579408)
+ (* (cube temp) (E 2.400493 -7))
+ (* (^ temp 4) (E 8.100939 -10))
+ (* (^ temp 5) (E 3.256805 -11))
+ (* (^ temp 6) (E -1.001922 -13))
+ (* (^ temp 7) (E 2.44161 -16))))
+
+(defun hum-ratio (humidity swp)
+ "Calulate the humidity ratio.
+Takes humidity in %RH, and a Saturated Water Pressure."
+ (let ((hum-press (* (/ humidity 100.0) swp)))
+ (/ (* hum-press 0.62198) (- 14.7 hum-press))))
+
+(defun gn-water-per-lb (humidity temp)
+ "Calculate the grains of water per lb of air.
+Takes humidity in %RH, and temp in F."
+ (* 7000 (hum-ratio humidity (sat-water-press temp))))
+
+(provide 're-refrigeration-defuns)
+;;; hic terminatur re-refrigeration-defuns.el
--- /dev/null
+;;; re-repl-defuns.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+;; Any Repl
+(defmacro re/send-on-close-paren (executor)
+ "Generalizes sending an execute on close paren.
+When a sexp is complete - that is when parens balance as you type - execute it.
+Use this macro as a direct binding"
+ `(lambda ()
+ (insert-char 41)
+ (when (= 0 (car (syntax-ppss)))
+ (call-interactively ,executor))))
+;; Eshell
+(defun eshell-quit-or-delete-char (arg)
+ "Delete char if at one, quit eshell if on empty prompt.
+Stolen from https://depp.brause.cc/dotemacs"
+ (interactive "p")
+ (if (and (eolp) (looking-back eshell-prompt-regexp 0 t))
+ (eshell-life-is-too-much) ; https://emacshorrors.com/post/life-is-too-much
+ (delete-char arg)))
+
+;; IELM
+(defun re/ielm-init-history ()
+ "Stolen from https://n16f.net/blog/making-ielm-more-comfortable."
+ (let ((path (expand-file-name "ielm/history" user-emacs-directory)))
+ (make-directory (file-name-directory path) t)
+ (setq-local comint-input-ring-file-name path))
+ (setq-local comint-input-ring-size 10000
+ comint-input-ignoredups t)
+ (comint-read-input-ring))
+
+(defun re/ielm-write-history (&rest _args)
+ "Stolen from https://n16f.net/blog/making-ielm-more-comfortable."
+ (with-file-modes #o600
+ (comint-write-input-ring)))
+
+(add-hook 'ielm-mode-hook 're/ielm-init-history)
+(advice-add 'ielm-send-input :after 're/ielm-write-history)
+
+(provide 're-repl-defuns)
+;;; hic terminatur re-repl-defuns.el
--- /dev/null
+;;; re-skeletons.el --- Quae configurare -*- lexical-binding: t; -*-
+;; Haec pars Emacs non est.
+;; Code:
+
+(define-skeleton skel-org-block
+ "Insert an org source code block"
+ ""
+ "#+BEGIN_SRC "
+ _ - "\n\n"
+ "#+END_SRC\n")
+
+(define-skeleton skel-org-block-elisp
+ "Insert an org emacs lisp block"
+ ""
+ "#+BEGIN_SRC emacs-lisp\n"
+ _ - \n
+ "#+END_SRC\n")
+
+(define-skeleton skel-facility-properties
+ "Insert the org title and filetags for a new facility."
+ ""
+ "#+TITLE: "
+ _ - \n
+ "#+FILETAGS: customer city state pm sm ee ce aka c#\n\n"
+ "* System Notes\n"
+ "* PLC [/]\n"
+ "* Wonderware [/]\n"
+ "* Commissioning [/]\n")
+
+(define-skeleton skel-person-properties
+ "Insert the org title and filetags for a person."
+ ""
+ "#+TITLE: @"
+ _ - \n
+ "#+FILETAGS: company position\n"
+ "#+EMAIL:\n"
+ "#+OFFICE:\n"
+ "#+CELL:\n")
+
+(define-skeleton skel-workorder-properties
+ "Insert the org title and filetags for a workorder"
+ ""
+ "#+TITLE: Workorder "
+ _ - \n
+ "#+FILETAGS: wo# workorder customer city state topics\n")
+
+(provide 're-skeletons)
+;;; hic terminatur re-skeletons.el