From bb8fee1be0c30ebf5d58fe6ff27ca4cd638de46f Mon Sep 17 00:00:00 2001 From: rearman Date: Tue, 24 Jan 2023 15:25:24 -0500 Subject: [PATCH] Cleanup various if/when/unless/cond statements --- defuns.el | 12 ++++++------ init.el | 10 +++++----- package-config.el | 2 +- work-eqs.el | 31 +++++++++++++++---------------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/defuns.el b/defuns.el index c1bdcdb..ec5f2a8 100644 --- a/defuns.el +++ b/defuns.el @@ -37,7 +37,7 @@ Can't go prev line first, edge case of beginning of buffer." "If two windows are open, toggle their split layout between vert. and horiz. Stolen from http://whattheemacsd.com" (interactive) - (if (= (count-windows) 2) + (when (= (count-windows) 2) (let* ((this-win-buffer (window-buffer)) (next-win-buffer (window-buffer (next-window))) (this-win-edges (window-edges (selected-window))) @@ -54,11 +54,11 @@ Stolen from http://whattheemacsd.com" (delete-other-windows) (let ((first-win (selected-window))) (funcall splitter) - (if this-win-2nd (other-window 1)) + (when this-win-2nd (other-window 1)) (set-window-buffer (selected-window) this-win-buffer) (set-window-buffer (next-window) next-win-buffer) (select-window first-win) - (if this-win-2nd (other-window 1)))))) + (when this-win-2nd (other-window 1)))))) (defun rotate-windows () "Rotate your windows. @@ -175,10 +175,10 @@ Stolen from https://tony-zorman.com/posts/query-replace/2022-08-06-query-replace (interactive (let ((common (slot/get-queries))) (list (nth 0 common) (nth 1 common) - (if (use-region-p) (region-beginning)) - (if (use-region-p) (region-end)) + (when (use-region-p) (region-beginning)) + (when (use-region-p) (region-end)) (nth 2 common) - (if (use-region-p) (region-noncontiguous-p))))) + (when (use-region-p) (region-noncontiguous-p))))) (perform-replace (concat "\\(?:" (mapconcat #'car pairs "\\|") "\\)") ; build query (cons (lambda (pairs _count) diff --git a/init.el b/init.el index d8bab1d..a972fc6 100644 --- a/init.el +++ b/init.el @@ -18,11 +18,11 @@ ("\\.docx\\'" "word" (file)) ("\\.adpro\\'" "PoductivitySuite" (file)))) (load (expand-file-name "win-defuns.el" user-emacs-directory))) - (progn (setq openwith-associations '(("\\.pdf\\'" "zathura" (file)) - ("\\.xls\\'" "libreoffice" (file)) - ("\\.xlsx\\'" "libreoffice" (file)) - ("\\.doc\\'" "libreoffice" (file)) - ("\\.docx\\'" "libreoffice" (file)))))) + (setq openwith-associations '(("\\.pdf\\'" "zathura" (file)) + ("\\.xls\\'" "libreoffice" (file)) + ("\\.xlsx\\'" "libreoffice" (file)) + ("\\.doc\\'" "libreoffice" (file)) + ("\\.docx\\'" "libreoffice" (file))))) (custom-set-variables ;; custom-set-variables was added by Custom. diff --git a/package-config.el b/package-config.el index dfe57f3..f629ce9 100644 --- a/package-config.el +++ b/package-config.el @@ -50,7 +50,7 @@ (use-package dash :ensure t) -(if (not (eq system-type 'windows-nt)) +(unless (eq system-type 'windows-nt) (progn (use-package slime :ensure t) (use-package ledger-mode :ensure t))) diff --git a/work-eqs.el b/work-eqs.el index 2c3eff4..8971903 100644 --- a/work-eqs.el +++ b/work-eqs.el @@ -15,12 +15,11 @@ (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))))) - (let ((ofst (- emin (/ pmin div)))) + (let* ((div (/ (- pmax pmin) (- (float emax) (float emin)))) + (ofst (- emin (/ pmin div)))) (if (eq nil ai) (list div ofst) - (let ((final (+ ofst (/ ai div)))) - (list div ofst final)))))) + (list div ofst (+ ofst (/ ai div)))))) (defun cfm-circ (fpm radius) "Calculate the CFM of a circular duct given fpm and radius (in)." @@ -46,18 +45,18 @@ Takes Kᵤ, Tᵤ and optional loop-type (P, PI, or PID [default]) as arguments, (defun gn-water-per-lb (temp humidity) "Calculate the grains of water per lb of air, given temp (F) and humidity (%). Returns a list of Sat. Water Press., Hum. Ratio, and Gns water per lb air." - (let ((sat-water-press (+ .0182795 - (* temp .001029904) - (* (square temp) 0.00002579408) - (* (cube temp) (* 2.400493 (expt 10 -7))) - (* (expt temp 4) (* 8.100939 (expt 10 -10))) - (* (expt temp 5) (* 3.256805 (expt 10 -11))) - (* (expt temp 6) (* -1.001922 (expt 10 -13))) - (* (expt temp 7) (* 2.44161 (expt 10 -16)))))) - (let ((hum-press (* (/ humidity 100.0) sat-water-press))) - (let ((hum-ratio (/ (* hum-press 0.62198) (- 14.7 hum-press)))) - (let ((gns-water-lb-air (* hum-ratio 7000))) - (list sat-water-press hum-ratio gns-water-lb-air)))))) + (let* ((sat-water-press (+ .0182795 + (* temp .001029904) + (* (square temp) 0.00002579408) + (* (cube temp) (* 2.400493 (expt 10 -7))) + (* (expt temp 4) (* 8.100939 (expt 10 -10))) + (* (expt temp 5) (* 3.256805 (expt 10 -11))) + (* (expt temp 6) (* -1.001922 (expt 10 -13))) + (* (expt temp 7) (* 2.44161 (expt 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))) (defun mm-to-in (mm) "Convert milimeters to inches." -- 2.39.5