]> git.eshelyaron.com Git - emacs.git/commitdiff
Prefer '(oddp A)' to '(= 1 (% A 2))'
authorStefan Kangas <stefankangas@gmail.com>
Mon, 17 Feb 2025 04:06:20 +0000 (05:06 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 18 Feb 2025 08:50:50 +0000 (09:50 +0100)
* lisp/align.el (align-match-tex-pattern):
* lisp/calc/calc-funcs.el (math-bernoulli-number):
* lisp/cedet/semantic/bovine/el.el (semantic-ctxt-current-assignment):
* lisp/comint.el (comint-within-quotes):
* lisp/emacs-lisp/chart.el (chart-axis-draw):
* lisp/emacs-lisp/cl-extra.el (cl-round):
* lisp/emacs-lisp/eieio.el (defclass):
* lisp/emacs-lisp/elint.el (elint-check-setq-form):
* lisp/emulation/cua-rect.el (cua--rectangle-right-side):
* lisp/progmodes/gud.el (gud-gdb-completions-1):
* lisp/ps-print.el (ps-end-job):
* lisp/ses.el (ses-center):
* lisp/vc/ediff-ptch.el (ediff-get-patch-buffer): Prefer '(oddp A)' to
'(= 1 (% A 2))' and variations thereof.

(cherry picked from commit e373a6e0d30c28045a0f33e662933c2c2660a220)

12 files changed:
lisp/align.el
lisp/calc/calc-funcs.el
lisp/comint.el
lisp/emacs-lisp/chart.el
lisp/emacs-lisp/cl-extra.el
lisp/emacs-lisp/eieio.el
lisp/emacs-lisp/elint.el
lisp/emulation/cua-rect.el
lisp/progmodes/gud.el
lisp/ps-print.el
lisp/ses.el
lisp/vc/ediff-ptch.el

index 2b1e8cb846615eb3b16734888284b72c8e00dac6..2f1c932f9bad3f00d6ee23ff17fa8c3781b62fbe 100644 (file)
@@ -1035,7 +1035,7 @@ current position."
               (while (and (> pos (point-min))
                           (eq (char-before pos) ?\\))
                 (setq count (1+ count) pos (1- pos)))
-              (eq (mod count 2) 1))
+              (oddp count))
             (goto-char (match-beginning (if reverse 1 2)))))
     result))
 
index 28e9c1f30bb3d9eff80d4ef9a6113b39e63c12a9..8535e580da7133e3fd921216d96444cf3dbde002 100644 (file)
     (nreverse coefs)))
 
 (defun math-bernoulli-number (n)
-  (if (= (% n 2) 1)
+  (if (oddp n)
       (if (= n 1)
          '(frac -1 2)
        0)
index 0f99eaf14641ac0a815384dafab4760a49ab1ff4..94a405502295ebe7810f8f3ae2548be7626bc065 100644 (file)
@@ -1754,7 +1754,7 @@ Go to the history element by the absolute history position HIST-POS."
 Quotes are single and double."
   (let ((countsq (comint-how-many-region "\\(^\\|[^\\]\\)'" beg end))
        (countdq (comint-how-many-region "\\(^\\|[^\\]\\)\"" beg end)))
-    (or (= (mod countsq 2) 1) (= (mod countdq 2) 1))))
+    (or (oddp countsq) (oddp countdq))))
 
 (defun comint-how-many-region (regexp beg end)
   "Return number of matches for REGEXP from BEG to END."
index 6f2f85fc7652b02d578ef2d658508a36027cf2e4..2a01501f99eda97d1a6cbb9789a24c15a545dd61 100644 (file)
@@ -347,7 +347,7 @@ of the drawing."
         (odd nil)
         p1)
     (while s
-      (setq odd (= (% (length s) 2) 1))
+      (setq odd (oddp (length s)))
       (setq r (chart-translate-namezone (oref a chart) i))
       (if (eq dir 'vertical)
          (setq p (/ (+ (car r) (cdr r)) 2))
index ec7dc5aa9e3b869f802b4c7e7c292817e922b3f5..2d9b8d0b0f1b952a1dfeff6d4f686268126957fd 100644 (file)
@@ -392,7 +392,7 @@ With two arguments, return rounding and remainder of their quotient."
                 (res (cl-floor (+ x hy) y)))
            (if (and (= (car (cdr res)) 0)
                     (= (+ hy hy) y)
-                    (/= (% (car res) 2) 0))
+                    (oddp (car res)))
                (list (1- (car res)) hy)
              (list (car res) (- (car (cdr res)) hy))))
        (let ((q (round (/ x y))))
index ea54aa016965580f04ec7dfc13569315b3b98ef5..666c90181a41fdd31b6f19f88f039a12a4efcf70 100644 (file)
@@ -118,7 +118,7 @@ and reference them using the function `class-option'."
               (/= 1 (% (length options-and-doc) 2)))
          (error "Too many arguments to `defclass'"))
         ((and (symbolp (car options-and-doc))
-              (/= 0 (% (length options-and-doc) 2)))
+              (oddp (length options-and-doc)))
          (error "Too many arguments to `defclass'")))
 
   (if (stringp (car options-and-doc))
index fcc17106131f3478a9b21f6c11e77855000c7b48..5ae8880167d9539b85e1ed905371bc13ed4df9b6 100644 (file)
@@ -798,7 +798,7 @@ CODE can be a lambda expression, a macro, or byte-compiled code."
 
 (defun elint-check-setq-form (form env)
   "Lint the setq FORM in ENV."
-  (or (= (mod (length form) 2) 1)
+  (or (oddp (length form))
       ;; (setq foo) is valid and equivalent to (setq foo nil).
       (elint-warning "Missing value in setq: %s" form))
   (let ((newenv env)
index 18a5ce930ec51929479880bfd1c8d9378dfe8d0f..7783d18f6e4ca3482733a496a5bfdbbdb480d75c 100644 (file)
@@ -187,7 +187,7 @@ Activates the region if needed.  Only lasts until the region is deactivated."
   ;; t if point is on right side of rectangle.
   (if (and topbot (= (cua--rectangle-left) (cua--rectangle-right)))
       (< (cua--rectangle-corner) 2)
-    (= (mod (cua--rectangle-corner) 2) 1)))
+    (oddp (cua--rectangle-corner))))
 
 (defun cua--rectangle-column ()
   (if (cua--rectangle-right-side)
index df9b87f903ed887921da8e27c914869f227d2a53..6c36d08c9ee29a1f3eee8c4d3064d57b643822c2 100644 (file)
@@ -920,7 +920,7 @@ CONTEXT is the text before COMMAND on the line."
         (while (string-match "\\([^'\\]\\|\\\\'\\)*'" str pos)
           (setq count (1+ count)
                 pos (match-end 0)))
-        (and (= (mod count 2) 1)
+        (and (oddp count)
              (setq complete-list (list (concat str "'"))))))
   complete-list)
 
index c1258db2c54b144deed99c9a743df8f3c6304175..d133e0bad67a141e75650be64a2a5f2971139c19 100644 (file)
@@ -6462,7 +6462,7 @@ If FACE is not a valid face name, use default face."
            (replace-match (format "/Lines %d def\n/PageCount %d def"
                                   total-lines total-pages) t)))))
     ;; Set dummy page
-    (and ps-spool-duplex (= (mod ps-page-order 2) 1)
+    (and ps-spool-duplex (oddp ps-page-order)
         (let ((ps-n-up-printing 0))
           (ps-header-sheet)
           (ps-output "/PrintHeader false def\n/ColumnIndex 0 def\n"
index 88e83ae160b1081b44987217710c30b6c9a32639..d23cefc53f426e2de8cb46c45ddce130775b6af9 100644 (file)
@@ -4105,7 +4105,7 @@ printer otherwise."
        value ; Too large for field, anyway.
       (setq half (make-string (/ width 2) fill))
       (concat half value half
-             (if (> (% width 2) 0) (char-to-string fill))))))
+             (if (oddp width) (char-to-string fill))))))
 
 (defun ses-center-span (value &optional fill printer)
   "Print VALUE, centered within the span that starts in the current column
index e83e7e95c0fe36b19bb338345544a307d8b60d1e..42b0d6850ef7a8fbcd27e7b13dc55bf3551962d1 100644 (file)
@@ -552,7 +552,7 @@ an optional argument, then use it."
          ((and (integerp arg) (eq 0 (mod arg 2)))
           (setq patch-buf (ediff-prompt-for-patch-buffer)))
          ;; odd prefix arg: get patch from a file
-         ((and (integerp arg) (eq 1 (mod arg 2)))
+         ((and (integerp arg) (oddp arg))
           (setq patch-buf (ediff-prompt-for-patch-file)))
          (t (setq patch-buf
                   (if (y-or-n-p "Is the patch already in a buffer? ")