Prefer '(oddp A)' to '(= 1 (% A 2))'

* 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.
This commit is contained in:
Stefan Kangas 2025-02-17 05:06:20 +01:00
parent 5ce746c3b0
commit e373a6e0d3
13 changed files with 13 additions and 13 deletions

View file

@ -1076,7 +1076,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))

View file

@ -867,7 +867,7 @@
(nreverse coefs)))
(defun math-bernoulli-number (n)
(if (= (% n 2) 1)
(if (oddp n)
(if (= n 1)
'(frac -1 2)
0)

View file

@ -765,7 +765,7 @@ In Emacs Lisp this is easily defined by parenthesis bounding."
(forward-comment 1)
(setq start (point))
(forward-sexp 1)
(if (= (% count 2) 1)
(if (oddp count)
(setq lastodd
(buffer-substring-no-properties start (point))))
)

View file

@ -1756,7 +1756,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."

View 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))

View 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))))

View 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))

View 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)

View 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)

View file

@ -919,7 +919,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)

View 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"

View 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

View 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? ")