]> git.earman.xyz Git - emacsinit.git/commitdiff
Cleanup various if/when/unless/cond statements
authorrearman <rearman@r717.net>
Tue, 24 Jan 2023 20:25:24 +0000 (15:25 -0500)
committerrearman <rearman@r717.net>
Tue, 24 Jan 2023 20:25:24 +0000 (15:25 -0500)
defuns.el
init.el
package-config.el
work-eqs.el

index c1bdcdb738ad526c395a01d33affe0fc59cb906d..ec5f2a8e7c92d80c3409fcd6a1f8407a2c6e3816 100644 (file)
--- 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 d8bab1d0f6da63ac2f47c0a9d161926d7fe2d88b..a972fc66108958375e0bfb07e2c80db09459aa51 100644 (file)
--- a/init.el
+++ b/init.el
                                         ("\\.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.
index dfe57f3fa60d05f9c67bcbff5b6233656a6b984d..f629ce96320a9b1f8f0746936f4e31f2bf6cf647 100644 (file)
@@ -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)))
index 2c3eff4f8906d0b90283cc1e487565569ce90df6..89719034f0f4d70d636d80f765ffec96b6e35ff0 100644 (file)
 (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."