From: Stefan Kangas Date: Mon, 17 Feb 2025 00:57:22 +0000 (+0100) Subject: Prefer cl-evenp/cl-oddp in some places X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7cde649efc43bd4934a1038964018a052eca0b5f;p=emacs.git 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. (cherry picked from commit 9efd11e5fd4324fb1686b802c15ae36046b0939a) --- diff --git a/lisp/obsolete/thumbs.el b/lisp/obsolete/thumbs.el index 582bb7f0caf..a4f28ce97c5 100644 --- a/lisp/obsolete/thumbs.el +++ b/lisp/obsolete/thumbs.el @@ -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))) diff --git a/lisp/org/org-capture.el b/lisp/org/org-capture.el index 0720ad53cc7..d4ae0207c36 100644 --- a/lisp/org/org-capture.el +++ b/lisp/org/org-capture.el @@ -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. diff --git a/lisp/org/org-element-ast.el b/lisp/org/org-element-ast.el index d4473cf4024..5e1a93a2417 100644 --- a/lisp/org/org-element-ast.el +++ b/lisp/org/org-element-ast.el @@ -738,7 +738,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))) diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el index 66ae4d7af68..500dfbc545d 100644 --- a/lisp/org/org-macro.el +++ b/lisp/org/org-macro.el @@ -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")) diff --git a/lisp/org/org-persist.el b/lisp/org/org-persist.el index deab2544cbd..aed8ebfcc05 100644 --- a/lisp/org/org-persist.el +++ b/lisp/org/org-persist.el @@ -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) diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el index ba8b4d9d3bb..04c70c5b563 100644 --- a/lisp/org/ox-odt.el +++ b/lisp/org/ox-odt.el @@ -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))))) diff --git a/lisp/org/ox.el b/lisp/org/ox.el index 39ab81b90ed..a9f450968f6 100644 --- a/lisp/org/ox.el +++ b/lisp/org/ox.el @@ -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 diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index ac4088fa829..496c951d087 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -3822,7 +3822,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 @@ -5161,7 +5161,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) ?\] )