]> git.eshelyaron.com Git - emacs.git/commitdiff
Prefer oddp/evenp to open-coding in a few more cases
authorStefan Kangas <stefankangas@gmail.com>
Mon, 17 Feb 2025 22:00:54 +0000 (23:00 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 18 Feb 2025 08:58:35 +0000 (09:58 +0100)
* lisp/arc-mode.el (archive-zip-summarize):
* lisp/cus-edit.el (setopt):
* lisp/isearch.el (isearch-backslash):
* lisp/simple.el (blink-paren-post-self-insert-function):
* lisp/subr.el (setq-local, buffer-local-set-state):
* lisp/term.el (term-within-quotes):
* test/src/data-tests.el (test-bool-vector-bv-from-hex-string): Use
oddp/evenp instead of open-coding them.
Reported by Pip Cet <pipcet@protonmail.com>.

(cherry picked from commit 515542b653c438014eda844eacc96cf23cfaaa2d)

lisp/arc-mode.el
lisp/cus-edit.el
lisp/isearch.el
lisp/simple.el
lisp/subr.el
lisp/term.el
test/src/data-tests.el

index 18dd0f42f8efce42b5288162560fb5972980c8f0..1ad9c084ed9e2ae1294651a70968462cf77f6d3f 100644 (file)
@@ -2092,8 +2092,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
                            ((memq creator '(0 5 6 7 10 11 15)) ; Dos etc.
                             (logior ?\444
                                     (if isdir (logior 16384 ?\111) 0)
-                                    (if (zerop
-                                         (logand 1 (get-byte (+ p 38))))
+                                    (if (evenp (get-byte (+ p 38)))
                                         ?\222 0)))
                            (t nil)))
             (fiddle  (and archive-zip-case-fiddle
index ee0e9a53f1b82a39dc4d59251c5278cb0dceefe9..2ce2c45b51b7303bd9aa1b5a47bbd62b4c090b9f 100644 (file)
@@ -1062,7 +1062,7 @@ even if it doesn't match the type.)
 
 \(fn [VARIABLE VALUE]...)"
   (declare (debug setq))
-  (unless (zerop (mod (length pairs) 2))
+  (unless (evenp (length pairs))
     (error "PAIRS must have an even number of variable/value members"))
   (let ((expr nil))
     (while pairs
index a0e546101a4c519a3e85dd3ee3162de3a071db75..39dac326da5ecead0bc59e106d3a3a36cca0b2e4 100644 (file)
@@ -2853,7 +2853,7 @@ The command accepts Unicode names like \"smiling face\" or
 
 (defun isearch-backslash (str)
   "Return t if STR ends in an odd number of backslashes."
-  (= (mod (- (length str) (string-match "\\\\*\\'" str)) 2) 1))
+  (oddp (- (length str) (string-match "\\\\*\\'" str))))
 
 (defun isearch-fallback (want-backslash &optional allow-invalid to-barrier)
   "Return point to previous successful match to allow regexp liberalization.
index 78fb3f5d368a79765f74b442dce2e78483b5b9b1..8f9216d2cc28d2b8552e8f8eb5f3ad065ef9a409 100644 (file)
@@ -9442,11 +9442,11 @@ More precisely, a char with closeparen syntax is self-inserted.")
             ;; Verify an even number of quoting characters precede the close.
              ;; FIXME: Also check if this parenthesis closes a comment as
              ;; can happen in Pascal and SML.
-            (= 1 (logand 1 (- (point)
-                              (save-excursion
-                                (forward-char -1)
-                                (skip-syntax-backward "/\\")
-                                (point))))))
+            (oddp (- (point)
+                     (save-excursion
+                       (forward-char -1)
+                       (skip-syntax-backward "/\\")
+                       (point)))))
     (funcall blink-paren-function)))
 
 (put 'blink-paren-post-self-insert-function 'priority 100)
index 7a013c750ae2739852c3188a1aee20757336ab62..5b224b1fc6785d528fc6c973fd4d240a02dfa066 100644 (file)
@@ -176,7 +176,7 @@ pair.
 
 \(fn [VARIABLE VALUE]...)"
   (declare (debug setq))
-  (unless (zerop (mod (length pairs) 2))
+  (unless (evenp (length pairs))
     (error "PAIRS must have an even number of variable/value members"))
   (let ((expr nil))
     (while pairs
@@ -217,7 +217,7 @@ in order to restore the state of the local variables set via this macro.
 
 \(fn [VARIABLE VALUE]...)"
   (declare (debug setq))
-  (unless (zerop (mod (length pairs) 2))
+  (unless (evenp (length pairs))
     (error "PAIRS must have an even number of variable/value members"))
   `(prog1
        (buffer-local-set-state--get ',pairs)
index ad85cc2cdbd976504b69aca31763d0176ea87acc..954a1d9b9722b61a551af7ac68e4e1f59b322604 100644 (file)
@@ -2177,7 +2177,7 @@ A useful command to bind to SPC.  See `term-replace-by-expanded-history'."
 Quotes are single and double."
   (let ((countsq (term-how-many-region "\\(^\\|[^\\]\\)'" beg end))
        (countdq (term-how-many-region "\\(^\\|[^\\]\\)\"" beg end)))
-    (or (= (mod countsq 2) 1) (= (mod countdq 2) 1))))
+    (or (oddp countsq) (oddp countdq))))
 
 (defun term-how-many-region (regexp beg end)
   "Return number of matches for REGEXP from BEG to END."
index abbc88dea4c50ffdc9cb6cc963a9a6c34f25570f..44c786ac5794b4a63b2273be87e37d808a031bef 100644 (file)
@@ -184,7 +184,7 @@ this is exactly representable and is greater than
     (let ((i 0))
       (dolist (n (nreverse nibbles))
         (dotimes (_ 4)
-          (aset bv i (> (logand 1 n) 0))
+          (aset bv i (oddp n))
           (cl-incf i)
           (setf n (ash n -1)))))
     bv))