Prefer cl-evenp/cl-oddp in some places

* lisp/erc/erc.el (erc-format-message):
* lisp/obsolete/thumbs.el (thumbs-emboss-image):
* lisp/org/org-capture.el (org-capture-escaped-%):
* lisp/org/org-element-ast.el (org-element-create):
* lisp/org/org-macro.el (org-macro-extract-arguments):
* lisp/org/org-persist.el (org-persist--get-collection):
* lisp/org/ox-odt.el (org-odt-get-table-cell-styles):
* lisp/org/ox.el (org-export--dispatch-ui):
* lisp/progmodes/cperl-mode.el (cperl-forward-re)
(cperl-find-pods-heres): Prefer 'cl-evenp/'cl-oddp' to free-coding them
in some files that already depend on cl-lib in run-time.
This commit is contained in:
Stefan Kangas 2025-02-17 01:57:22 +01:00
parent 35d4316101
commit 9efd11e5fd
9 changed files with 14 additions and 14 deletions

View file

@ -9735,7 +9735,7 @@ if yet untried."
"Format MSG according to ARGS.
See also `format-spec'."
(when (eq (logand (length args) 1) 1) ; oddp
(unless (cl-evenp (length args))
(error "Obscure usage of this function appeared"))
(let ((entry (erc-retrieve-catalog-entry msg)))
(when (not entry)

View file

@ -628,7 +628,7 @@ ACTION and ARG should be a valid convert command."
(defun thumbs-emboss-image (emboss)
"Emboss the image with value EMBOSS."
(interactive "nEmboss value: ")
(if (or (< emboss 3) (> emboss 31) (zerop (% emboss 2)))
(if (or (< emboss 3) (> emboss 31) (cl-evenp emboss))
(error "Arg must be an odd number between 3 and 31"))
(thumbs-modify-image "emboss" (number-to-string emboss)))

View file

@ -1920,7 +1920,7 @@ placeholder to check."
(goto-char (match-beginning 0))
(let ((n (abs (skip-chars-backward "\\\\"))))
(delete-char (/ (1+ n) 2))
(= (% n 2) 1))))
(cl-oddp n))))
(defun org-capture-expand-embedded-elisp (&optional mark)
"Evaluate embedded elisp %(sexp) and replace with the result.

View file

@ -734,7 +734,7 @@ string. Alternatively, TYPE can be a string. When TYPE is nil or
(cl-assert
;; FIXME: Just use `plistp' from Emacs 29 when available.
(let ((len (proper-list-p props)))
(and len (zerop (% len 2)))))
(and len (cl-evenp len))))
;; Assign parray.
(when (and props (not (stringp type)) (not (eq type 'plain-text)))
(let ((node (list 'dummy props)))

View file

@ -329,7 +329,7 @@ Return a list of arguments, as strings. This is the opposite of
(lambda (str)
(let ((len (length (match-string 1 str))))
(concat (make-string (/ len 2) ?\\)
(if (zerop (mod len 2)) "\000" ","))))
(if (cl-evenp len) "\000" ","))))
s nil t)
"\000"))

View file

@ -594,7 +594,7 @@ MISC, if non-nil will be appended to the collection. It must be a plist."
(unless (and (listp container) (listp (car container)))
(setq container (list container)))
(setq associated (org-persist--normalize-associated associated))
(when (and misc (or (not (listp misc)) (= 1 (% (length misc) 2))))
(when (and misc (or (not (listp misc)) (cl-oddp (length misc))))
(error "org-persist: Not a plist: %S" misc))
(or (org-persist--find-index
`( :container ,(org-persist--normalize-container container)

View file

@ -3293,13 +3293,13 @@ styles congruent with the ODF-1.2 specification."
(= (1+ r) (car table-dimensions)))
"LastRow")
((and (cdr (assq 'use-banding-rows-styles cell-style-selectors))
(= (% r 2) 1)) "EvenRow")
(cl-oddp r)) "EvenRow")
((and (cdr (assq 'use-banding-rows-styles cell-style-selectors))
(= (% r 2) 0)) "OddRow")
(cl-evenp r)) "OddRow")
((and (cdr (assq 'use-banding-columns-styles cell-style-selectors))
(= (% c 2) 1)) "EvenColumn")
(cl-oddp c)) "EvenColumn")
((and (cdr (assq 'use-banding-columns-styles cell-style-selectors))
(= (% c 2) 0)) "OddColumn")
(cl-evenp c)) "OddColumn")
(t ""))))
(concat template-name cell-type)))))

View file

@ -7287,14 +7287,14 @@ back to standard interface."
(lambda (sub-entry)
(cl-incf index)
(format
(if (zerop (mod index 2)) " [%s] %-26s"
(if (cl-evenp index) " [%s] %-26s"
"[%s] %s\n")
(funcall fontify-key
(char-to-string (car sub-entry))
top-key)
(nth 1 sub-entry)))
sub-menu "")
(when (zerop (mod index 2)) "\n"))))))))
(when (cl-evenp index) "\n"))))))))
entries ""))
;; Publishing menu is hard-coded.
(format "\n[%s] Publish

View file

@ -3825,7 +3825,7 @@ modify syntax-type text property if the situation is too hard."
(char-after (- (point) 2)))
(save-excursion
(forward-char -2)
(= 0 (% (skip-chars-backward "\\\\") 2)))
(cl-evenp (skip-chars-backward "\\\\")))
(forward-char -1)))
;; Now we are after the first part.
(and is-2arg ; Have trailing part
@ -5164,7 +5164,7 @@ recursive calls in starting lines of here-documents."
(or ; Should work with delim = \
(not (eq (preceding-char) ?\\ ))
;; XXXX Double \\ is needed with 19.33
(= (% (skip-chars-backward "\\\\") 2) 0))
(cl-evenp (skip-chars-backward "\\\\")))
(looking-at
(cond
((eq (char-after b) ?\] )