#+END_SRC
** Basic UI preferences
-I want no menus, no tool-bars, no scroll-bars, no blinking cursor, and no messages when starting up. I just want the scratch buffer with a report on =emacs-init-time=. Make resizing work properly as well.
+I want no menus, no tool-bars, left-side scroll-bars, no blinking cursor, and no messages when starting up. I just want the scratch buffer with a report on =emacs-init-time=. Make resizing work properly as well.
#+BEGIN_SRC emacs-lisp :tangle ./early-init.el
(menu-bar-mode -1)
(tool-bar-mode -1)
-(scroll-bar-mode -1)
+(scroll-bar-mode 'left)
+(set-scroll-bar-mode 'left)
(blink-cursor-mode -1)
(setq inhibit-startup-screen t
I am no longer using the default theme, so that config is no longer here, but [[*eink-emacs][here]]. Make every frame open full-screen, and re-emphasize the desire for no scroll-bars.
#+BEGIN_SRC emacs-lisp :tangle ./early-init.el
-(setq default-frame-alist '((fullscreen . maximized)
- (vertical-scroll-bars . nil)))
+(setq default-frame-alist '(;;(background-color . "#d8f2b0")
+ (fullscreen . maximized)))
#+END_SRC
** Misc/odd issues
*** eink-emacs
I want a minimal (mostly b+w) theme.
#+BEGIN_SRC emacs-lisp
-(use-package eink-theme
- :ensure t
- :init
- (load-theme 'eink t))
+;; (use-package eink-theme
+;; :ensure t
+;; :init
+;; (load-theme 'eink t))
#+END_SRC
*** 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.
:defer t)
#+END_SRC
-*** centered-cursor-mode
-Trying out the (veritcally) centered cursor, heard about it on [[gemini://gem.librehacker.com/gemlog/starlog/20240228-0.gmi][gemini]]
-#+BEGIN_SRC emacs-lisp
-(use-package centered-cursor-mode
- :ensure t
- :custom
- (ccm-recenter-at-end-of-file t)
- (ccm-step-delay 0)
- :config
- (global-centered-cursor-mode t))
-
-#+END_SRC
-
-
** Non-Package customization
This section has '/base/' emacs customization. All the general stuff.
Highlight current line in all buffers, even if inactive.
#+BEGIN_SRC emacs-lisp
(setq global-hl-line-sticky-flag t)
-(global-hl-line-mode t)
+;; (global-hl-line-mode t)
#+END_SRC
I want nice symbols to look at
#+END_SRC
**** 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 and C-u
=C-w= is very much engrained for killing back one word, as is =C-u= for killing back to the beginning of the line. [[http://unix-kb.cat-v.org/][These have been standard bindings since TENEX...]]
I didn't want to re-bind =C-w= away from =kill-region=, so I made it do both.
#+END_SRC
**** Moving
+***** Home/End
I want =Home= and =End= to take me to the top and bottom of the file.
#+BEGIN_SRC emacs-lisp
(keymap-global-set "<home>" 'beginning-of-buffer)
(keymap-global-set "<end>" 'end-of-buffer)
#+END_SRC
-
+***** Beginning of line
I have the infamous =smart-beginning-of-line= command here.
#+BEGIN_SRC emacs-lisp
(defun smart-beginning-of-line ()
(lambda ()
(keymap-global-set "C-a" 'smart-beginning-of-visual-line)))
#+END_SRC
-
+***** Line Numbers on move only
I don't want line numbers in the margin unless I am actively trying to go to a line. I override =goto-line= with this function, which shows line numbers, asks me where I want to go, and then hides line numbers.
#+BEGIN_SRC emacs-lisp
(defun my-goto-line ()
(global-set-key [remap goto-line] 'my-goto-line)
#+END_SRC
-
+***** Other window or split window
I ripped this defun and binding from [[https://github.com/lem-project/lem][lem]]. Can't live without it now.
#+BEGIN_SRC emacs-lisp
(defun other-window-or-split-window (&optional window)
*** 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."
function that uses this."
(if (eq nil r2)
r1
- (inv (+ (inv (float r1)) (inv (float r2))))))
+ (inv (+ (inv r1) (inv r2)))))
(defun amps->volts (amps r1 &optional r2)
"Calculate the voltage, given amperage and impedance.
"Calculate the max count for a PLC analog, given card's bit-resolution."
(- (^ 2 resolution) 1))
-(defun volts->counts (vin vmax 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 (cin vmax 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 (amps vmax resolution r1 &optional r2)
+(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 (amps->volts amps r1 r2) vmax resolution))
+ (volts->counts vmax (amps->volts amps r1 r2) resolution))
-(defun count-range (type upper lower vmax resolution &optional r1 r2)
+(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.
-Type takes either a v or an i, corresponding to a voltage or
-current signal. With a current signal, use r1 and maybe r2 to
+With a current signal, use r1 and maybe r2 to
calculate `amps->counts'. Otherwise ignore r1/r2 and calculate
`volts->counts'."
- (cond ((or (equal 'v type)
- (equal 'V type))
- (list (volts->counts upper vmax resolution)
- (volts->counts lower vmax resolution)))
- ((or (equal 'i type)
- (equal 'I type))
- (list (amps->counts upper vmax resolution r1 r2)
- (amps->counts lower vmax resolution r1 r2)))))
-
-(defun scaleval (pmax pmin emax emin &optional ai)
- "Calculate the slope and offset given PLC Max/Min and Eng. Max/Min.
-With optional argument `ai', also calculate a final scaled value from an input."
- (let* ((div (/ (- pmax pmin) (- (float emax) (float emin))))
- (ofst (- emin (/ pmin div))))
- (if (eq nil ai)
- (list div ofst)
- (list div ofst (+ ofst (/ ai div))))))
+ (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 div-ofst (raw-max raw-min scaled-max scaled-min)
+ "Calculate 1/slope and offset given PLC Max/Min and Eng. Max/Min."
+ (let* ((divisor (/ (float (- raw-max raw-min)) (- scaled-max scaled-min)))
+ (offset (- scaled-min (/ raw-min divisor))))
+ (list divisor offset)))
+
+(defun fincalc (analog-input divisor offset)
+ "Calculate the scaled value of an input."
+ (+ (/ analog-input divisor) offset))
+
+(defun final (analog-input divisor &optional offset)
+ "Calculate the scaled value of an input, by calling `fincalc'.
+Get values of divisor and offset if from a list, as returned by `div-ofst',
+otherwise take two separate values"
+ (if (listp divisor)
+ (let ((div (car divisor))
+ (os (car (cdr divisor))))
+ (fincalc analog-input div os))
+ (fincalc analog-input divisor offset)))
+
+(defun scale (analog-input raw-max raw-min scaled-max scaled-min)
+ "Calculate the divisor, offset, and final value, given the parameters."
+ (list (div-ofst raw-max raw-min scaled-max scaled-min)
+ (final analog-input (div-ofst raw-max raw-min scaled-max scaled-min))))
#+END_SRC
*** Refrigeration