Prefer oddp/evenp to open-coding in a few more cases
* 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>.
This commit is contained in:
parent
abd861ca26
commit
515542b653
7 changed files with 12 additions and 13 deletions
|
@ -2090,8 +2090,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
|
||||
|
|
|
@ -1060,7 +1060,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
|
||||
|
|
|
@ -2893,7 +2893,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.
|
||||
|
|
|
@ -9622,11 +9622,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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -2181,7 +2181,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."
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue