]> git.earman.xyz Git - emacsinit.git/commitdiff
Cleanup & Organize
authorrearman <rearman@r717.net>
Wed, 12 Jun 2024 19:37:26 +0000 (15:37 -0400)
committerrearman <rearman@r717.net>
Wed, 12 Jun 2024 19:37:26 +0000 (15:37 -0400)
init.org

index 20102c38d35c923e7dd380c35d5158a5b8d22537..f5b919dc7af239a6c9b47bbf9b4de224860738dc 100644 (file)
--- a/init.org
+++ b/init.org
@@ -68,7 +68,7 @@ Set the GC threshold to max during startup, then set it back to a value that is
 #+END_SRC
 
 ** Basic UI preferences
-I want no menus, no tool-bars, left-side scroll-bars, no blinking cursor, no messages when starting up, and to make resizing work properly.  I just want the scratch buffer with a report on =emacs-init-time=.
+I want no menus, no tool-bars, no blinking cursor, no messages when starting up, and to make resizing work properly.  I just want the scratch buffer with a report on =emacs-init-time=.
 #+BEGIN_SRC emacs-lisp :tangle ./early-init.el
 (menu-bar-mode -1)
 (tool-bar-mode -1)
@@ -136,7 +136,6 @@ I don't need these on a windows PC.
 
 *** visual-fill-column
 A godsend.  Finally, I can have visual-line-mode without having to read lines that are 1980 pixels wide!  Also set word wrap, and make the split for help do what I want on big screens.
-
 #+BEGIN_SRC emacs-lisp
 (use-package visual-fill-column
   :ensure t
@@ -199,7 +198,6 @@ Seldom used, but nothing else does it.
 
 *** magit
 I use magit occasionally.  I put this sparse configuration here mostly for a speed boost, by making magit only load when I explicitly call for it.
-
 #+BEGIN_SRC emacs-lisp
 (use-package magit
   :ensure t
@@ -221,7 +219,6 @@ I use magit occasionally.  I put this sparse configuration here mostly for a spe
 
 *** openwith
 I need to open binary files with their own editor.  Disgusting.
-
 #+BEGIN_SRC emacs-lisp
 (use-package openwith
   :ensure t
@@ -280,7 +277,6 @@ Lisp me...sometimes.
 This section has '/base/' emacs customization.  All the general stuff.
 *** Defaults
 I want these things every time, or at least setting them this way worked when a regular =setq= didn't.
-
 #+BEGIN_SRC emacs-lisp
 (setq-default indicate-empty-lines t
               fill-column 80
@@ -288,13 +284,13 @@ I want these things every time, or at least setting them this way worked when a
               cursor-in-non-selected-windows 'hollow)
 #+END_SRC
 *** Help
-Set up apropos to be more useful
+Set up apropos to be more useful.
 #+BEGIN_SRC emacs-lisp
 (setq apropos-do-all t)
 #+END_SRC
 
 *** UTF-8
-Force emacs to use UTF-8 so I avoid prompts on save
+Force emacs to use UTF-8 so I avoid prompts on save.
 #+BEGIN_SRC emacs-lisp
 (set-language-environment 'utf-8)
 (set-default-coding-systems 'utf-8)
@@ -350,7 +346,6 @@ I want to strip all trailing whitespace on save, and I want to make all shell sc
 
 *** Minibuffer interaction
 I don't want emacs to beep or blink at me, I want y/n instead of the default yes/no, I don't care for clicking on things in the minibuffer, I like seeing things echoed almost immediately, for keystrokes and eldoc.  I want eldoc to stick to one line.  I want history to only show me unique commands, and I want case-insensitive buffer switching.
-
 #+BEGIN_SRC emacs-lisp
 (setq ring-bell-function 'ignore
       use-short-answers t
@@ -364,21 +359,24 @@ I don't want emacs to beep or blink at me, I want y/n instead of the default yes
 
 *** Buffer interaction
 **** General
+***** midnight-mode
 Close unused buffers after 3 days.
 #+BEGIN_SRC emacs-lisp
 (midnight-mode t)
 #+END_SRC
 
+***** delete-selection-mode
 Overwrite selection when active, like every other editor since Sam.
 #+BEGIN_SRC emacs-lisp
 (delete-selection-mode t)
 #+END_SRC
 
-Don't disable any functions.
+***** Don't disable any functions.
 #+BEGIN_SRC emacs-lisp
 (setq  disabled-command-function nil)
 #+END_SRC
 
+***** Inter-program kill-ring
 Save pastes from elsewhere into the kill-ring, and don't ask me about killing processes when I kill a buffer.
 #+BEGIN_SRC emacs-lisp
 (setq save-interprogram-paste-before-kill t
@@ -503,10 +501,8 @@ Use =recycle bin=, DON'T use =AltGr=, and tell emacs where =diff= is.
 
 ** Defuns and Bindings
 I have quite a few math and work-related defuns, and fewer editing ones.  Inversely, I have more editing related bindings than work-related ones.  This makes sense, considering my usage patterns.
-
 *** Editing
 Most of these are to re-create something from vim/readline/sam/acme.  Some are just helper functions or wrappers.
-
 **** Visiting Files
 Bind ~find-file-at-point~ and ~bookmark-jump-other-window~.
 #+BEGIN_SRC emacs-lisp
@@ -624,21 +620,20 @@ Stolen from https://depp.brause.cc/dotemacs"
 **** Killing
 ***** Kill Whole Line
 Bind =kill-whole-line= to =C-S-K= for something somewhat pnemonic.
-
 #+BEGIN_SRC emacs-lisp
 (keymap-global-set "C-S-K" 'kill-whole-line)
 #+END_SRC
+
 ***** Zap up to char
 Bind =C-z= to zap-up-to-char, sice zap-to-char is on =M-z=.
-
 #+BEGIN_SRC emacs-lisp
 (keymap-global-set "C-z" 'zap-up-to-char)
 #+END_SRC
+
 ***** UNIX C-w, C-u, and C-h
 =C-w= is very much engrained for killing back one word, as is =C-u= for killing back to the beginning of the line, and =C-h= for one character back.  [[http://unix-kb.cat-v.org/][These have been standard bindings since TENEX...]]
 ****** =C-w=
 I didn't want to re-bind =C-w= away from =kill-region=, so I made it do both.
-
 #+BEGIN_SRC emacs-lisp
 (defun re/kill-bword-or-region ()
   "Kill region if active, otherwise kill back one word."
@@ -652,7 +647,6 @@ I didn't want to re-bind =C-w= away from =kill-region=, so I made it do both.
 
 ****** =C-u=
 There is no pre-made function to kill backward to the beginning of line from point, so I made one that passes the correct argument to =kill-line=, and bound it to =C-u=.
-
 #+BEGIN_SRC emacs-lisp
 (defun re/backward-kill-line ()
   "Kill back to beginning of line from point."
@@ -669,7 +663,7 @@ Since =C-u= is =universal-argument=, I put that functionality on =M-'=.
 #+END_SRC
 
 ****** =C-h=
-We already have =F1= for help. Use this setup instead of ~key-translate~ because that doesn't work whun running the daemon.
+We already have =F1= for help. Use this setup instead of ~key-translate~ because that doesn't work when running the daemon.
 #+BEGIN_SRC emacs-lisp
 (keymap-set key-translation-map "C-h" "<DEL>")
 #+END_SRC
@@ -762,8 +756,6 @@ I ripped this defun and binding from [[https://github.com/lem-project/lem][lem]]
                                                    (region-end)))
     (deactivate-mark))
   (call-interactively 'isearch-backward))
-
-
 #+END_SRC
 
 ***** Bindings
@@ -795,7 +787,7 @@ Some old Emacs-like editor (Edwin?) used this binding, so I put it in here.  Les
 :PROPERTIES:
 :ID:       325c01c5-b877-4281-adff-ea956bdb5f2c
 :END:
-I wanted something like what the Genera environment has, where putting in a final close-paren will send the command, without having to hit enter.  This is a general command, used by [[id:325c01c5-b877-4281-adff-ea956bdb5f2c][Eshell]], [[id:664ba0e7-0826-4868-9480-e1338a6e9f63][Ielm]], and
+I wanted something like what the Genera environment has, where putting in a final close-paren will send the command, without having to hit enter.  This is a general command, used by [[id:325c01c5-b877-4281-adff-ea956bdb5f2c][Eshell]] and [[id:664ba0e7-0826-4868-9480-e1338a6e9f63][Ielm]].
 #+BEGIN_SRC emacs-lisp
 (defun re/send-on-close-paren (executor)
   "Generalizes sending an execute on close paren.
@@ -848,6 +840,7 @@ I'm tired of writing out ='expt=, and I want to use the same notation every othe
 #+BEGIN_SRC emacs-lisp
 (defalias '^ 'expt)
 #+END_SRC
+
 **** Square, Cube, and Inv
 Define square, cube, and inv for brevity of common usages.
 #+BEGIN_SRC emacs-lisp
@@ -866,7 +859,6 @@ Define square, cube, and inv for brevity of common usages.
 
 *** Unit Conversions
 The rest of the world decided to self-castrate because some French guys told them things Definitely Made More Sense if everything was divisible by 10.  I'm convinced the average Frenchman simply couldn't grasp fractions, and that's why he came up with this crap.  What's 1/3 of a meter?  What's 1/3 of a yard?  And 1/3 of a foot?  How likely are you to need to divide a measurement by 3 when you're building something?  Maybe the [[https://dozenal.org/][Dozenal]] people were right all along.  Anyway, I'm now forced to convert into proper units daily because of this grave error.
-
 #+BEGIN_SRC emacs-lisp
 (defun mm->in (mm)
   "Convert milimeters to inches."
@@ -905,6 +897,7 @@ Applies `c->k' to `f->c'."
 
 *** Electrical
 These defuns are all about electronics.  Effective impedance, amps to volts, and back again.
+**** Effective-impedance
 #+BEGIN_SRC emacs-lisp
 (defun eff-imp (r1 &optional r2)
   "Calculate the effective input impedance, given two resistances.
@@ -914,13 +907,19 @@ function that uses this."
   (if (eq nil r2)
       r1
     (inv (+ (inv r1) (inv r2)))))
+#+END_SRC
 
+**** Amps to volts
+#+BEGIN_SRC emacs-lisp
 (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)))
+#+END_SRC
 
+**** Volts to amps
+#+BEGIN_SRC emacs-lisp
 (defun volts->amps (volts r1 &optional r2)
   "Calculate the amperage, given voltage and impedance.
 Divides the voltage by the effective impedance calculated with
@@ -930,28 +929,41 @@ Divides the voltage by the effective impedance calculated with
 
 *** PLC
 The nitty-gritty.  These defuns build on the previous ones to help me do various calculations related to analog signals and how they interact with [[https://en.wikipedia.org/wiki/Programmable_logic_controller][PLCs]], also called PACs.  Counts, volts, amps, bit-resolutions, and relating them to each other.
+**** Max counts
 #+BEGIN_SRC emacs-lisp
 (defun max-counts (resolution)
   "Calculate the max count for a PLC analog, given card's bit-resolution."
   (- (^ 2 resolution) 1))
+#+END_SRC
 
+**** Volts to counts
+#+BEGIN_SRC emacs-lisp
 (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)))
+#+END_SRC
 
+**** Counts to volts
+#+BEGIN_SRC emacs-lisp
 (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))
+#+END_SRC
 
+**** Amps to counts
+#+BEGIN_SRC emacs-lisp
 (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))
+#+END_SRC
 
+**** Count range
+#+BEGIN_SRC emacs-lisp
 (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
@@ -962,7 +974,10 @@ calculate `amps->counts'.  Otherwise ignore r1/r2 and calculate
             (volts->counts vmax lower resolution))
     (list (amps->counts vmax upper resolution r1 r2)
           (amps->counts vmax lower resolution r1 r2))))
+#+END_SRC
 
+**** Scaling
+#+BEGIN_SRC emacs-lisp
 (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)))
@@ -986,6 +1001,7 @@ calculate `amps->counts'.  Otherwise ignore r1/r2 and calculate
 
 *** Refrigeration
 More nitty-gritty.  These are for calculating specific refrigeration-related things.  Somewhat specialized.
+**** CFM
 #+BEGIN_SRC emacs-lisp
 (defun cfm-circ (fpm radius)
   "Calculate the CFM of a circular duct.
@@ -996,24 +1012,37 @@ Inputs are feet/minute and radius (in)."
   "Calculate the CFM of a rectangular duct.
 Inputs are feet/minute, width (in) and height (in)."
   (list (* fpm (/ width 12.0) (/ height 12.0))))
+#+END_SRC
 
-(defun gn-water-per-lb (temp humidity)
+**** Saturated Water Pressure
+#+BEGIN_SRC emacs-lisp
+(defun sat-water-press (temp)
+  "Calculate the saturated water pressure at a temp (F)."
+  (+ .0182795
+     (* temp .001029904)
+     (* (square temp) 0.00002579408)
+     (* (cube temp) (* 2.400493 (^ 10 -7)))
+     (* (^ temp 4) (* 8.100939 (^ 10 -10)))
+     (* (^ temp 5) (* 3.256805 (^ 10 -11)))
+     (* (^ temp 6) (* -1.001922 (^ 10 -13)))
+     (* (^ temp 7) (* 2.44161 (^ 10 -16)))))
+#+END_SRC
+
+**** Humidity Ratio
+#+BEGIN_SRC emacs-lisp
+(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))))
+#+END_SRC
+
+**** Grains of water per lb of air
+#+BEGIN_SRC emacs-lisp
+(defun gn-water-per-lb (humidity temp)
   "Calculate the grains of water per lb of air.
-Inputs are temp (F) and humidity (%).  Returns a list of
-Saturated Water Pressure, Humidity Ratio, and Grains of water per
-lb of air."
-  (let* ((sat-water-press (+ .0182795
-                             (* temp .001029904)
-                             (* (square temp) 0.00002579408)
-                             (* (cube temp) (* 2.400493 (^ 10 -7)))
-                             (* (^ temp 4) (* 8.100939 (^ 10 -10)))
-                             (* (^ temp 5) (* 3.256805 (^ 10 -11)))
-                             (* (^ temp 6) (* -1.001922 (^ 10 -13)))
-                             (* (^ temp 7) (* 2.44161 (^ 10 -16)))))
-         (hum-press (* (/ humidity 100.0) sat-water-press))
-         (hum-ratio (/ (* hum-press 0.62198) (- 14.7 hum-press)))
-         (gns-water-lb-air (* hum-ratio 7000)))
-    (list sat-water-press hum-ratio gns-water-lb-air)))
+Takes humidity in %RH, and temp in F."
+  (* 7000 (hum-ratio humidity (sat-water-press temp))))
 #+END_SRC
 
 ** org configuration
@@ -1047,7 +1076,7 @@ Select with single key, enforce sub-tasks, only change the color of the keyword.
 #+END_SRC
 
 *** Navigation
-Make the =C-c C-j= binding more useful
+Make the =C-c C-j= binding more useful.
 #+BEGIN_SRC emacs-lisp
 (setq org-goto-interface 'outline-path-completion
       org-outline-path-complete-in-steps nil
@@ -1067,6 +1096,7 @@ Don't open links in another window, just use the current one.
 #+BEGIN_SRC emacs-lisp
 (setq org-link-frame-setup '((file . find-file)))
 #+END_SRC
+
 *** Directories
 Tell org where everything is
 #+BEGIN_SRC emacs-lisp
@@ -1075,6 +1105,7 @@ Tell org where everything is
       org-default-notes-file "~/org/refile.org"
       org-journal-file "~/org/journal.org")
 #+END_SRC
+
 *** Refile
 Let me refile anywhere, use outline paths, confirm when creating parent nodes.
 #+BEGIN_SRC emacs-lisp
@@ -1235,6 +1266,7 @@ Start up =abbrev-mode= for org
   _ - \n
   "#+END_SRC\n")
 #+END_SRC
+
 ***** Facility properties block
 #+BEGIN_SRC emacs-lisp
 (define-skeleton skel-facility-properties
@@ -1325,7 +1357,7 @@ Automatically generate unique IDs if not already created.  Stolen from [[https:/
   (org-map-entries 'org-id-get-create))
 #+END_SRC
 
-Run this on save of any org-mode file
+Don't run this on save of any org-mode file like we used to. (no longer tangling this block).
 #+BEGIN_SRC emacs-lisp :tangle no
 (add-hook 'org-mode-hook
           (lambda ()
@@ -1412,7 +1444,6 @@ Here are the various customizations I have for eshell.
 
 *** Send on Close-Paren
 I wanted something like what the Genera environment has, where putting in a final close-paren will send the command, without having to hit enter. See [[id:325c01c5-b877-4281-adff-ea956bdb5f2c][Send on Close-Paren]].
-
 #+BEGIN_SRC emacs-lisp
 (defun re/eshell-send-on-close-paren ()
   "Makes eshell act somewhat like genera.
@@ -1423,7 +1454,6 @@ Makes a closing paren execute the sexp."
 
 *** Quit or delete-char
 I want =C-d= to end the shell if it is on an empty line, otherwise act normally.
-
 #+BEGIN_SRC emacs-lisp
 (defun eshell-quit-or-delete-char (arg)
   "Delete char if at one, quit eshell if on empty prompt.
@@ -1436,13 +1466,13 @@ Stolen from https://depp.brause.cc/dotemacs"
 
 *** Bind the defuns
 I have only been able to get these to work when they are within an add-hook lambda.
-
 #+BEGIN_SRC emacs-lisp
 (add-hook 'eshell-mode-hook
           (lambda ()
             (keymap-set eshell-mode-map ")" 're/eshell-send-on-close-paren)
             (keymap-set eshell-mode-map "C-d" 'eshell-quit-or-delete-char)))
 #+END_SRC
+
 ** ielm configuration
 :PROPERTIES:
 :ID:       e7a7b861-8f63-4036-9f68-59fb954a7561
@@ -1450,7 +1480,6 @@ I have only been able to get these to work when they are within an add-hook lamb
 I wanted something more like a standard lisp REPL in emacs.  Found =ielm=.
 *** Send on Close-Paren
 I wanted something like what the Genera environment has, where putting in a final close-paren will send the command, without having to hit enter. See [[id:325c01c5-b877-4281-adff-ea956bdb5f2c][Send on Close-Paren]].
-
 #+BEGIN_SRC emacs-lisp
 (defun re/ielm-send-on-close-paren ()
   "Makes ielm act somewhat like genera.
@@ -1458,6 +1487,7 @@ Makes a closing paren execute the sexp."
   (interactive)
   (re/send-on-close-paren 'ielm-send-input))
 #+END_SRC
+
 *** Persistent command history
 **** Read History
 #+BEGIN_SRC emacs-lisp
@@ -1472,6 +1502,7 @@ Makes a closing paren execute the sexp."
 
 (add-hook 'ielm-mode-hook 're/ielm-init-history)
 #+END_SRC
+
 **** Write History
 #+BEGIN_SRC emacs-lisp
 (defun re/ielm-write-history (&rest _args)
@@ -1481,6 +1512,7 @@ Makes a closing paren execute the sexp."
 
 (advice-add 'ielm-send-input :after 're/ielm-write-history)
 #+END_SRC
+
 *** Bindings
 ~C-l~ to clear buffer, send on close paren.
 #+BEGIN_SRC emacs-lisp
@@ -1490,6 +1522,7 @@ Makes a closing paren execute the sexp."
             (keymap-set inferior-emacs-lisp-mode-map "C-l" 'comint-clear-buffer)
             (keymap-set inferior-emacs-lisp-mode-map ")" 're/ielm-send-on-close-paren)))
 #+END_SRC
+
 ** Customize system
 I do not use the customize system.  I don't want to see it if I don't have to.
 #+BEGIN_SRC emacs-lisp