summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>2025-02-17 16:56:22 -0500
committerRichard Stallman <rms@gnu.org>2025-02-17 16:56:22 -0500
commitabd861ca2694898b347b94251710da38c687dd68 (patch)
tree1e8d0a2680b7ce953d10fb3c91bca40658694e95 /lisp/emacs-lisp
parentf3ef16f86ffbb0ab5b76fa11e85eda5b1eff4b4b (diff)
parent8a7c1a31ac0a61384661878e9f7f7e77ada34ade (diff)
downloademacs-abd861ca2694898b347b94251710da38c687dd68.tar.gz
emacs-abd861ca2694898b347b94251710da38c687dd68.tar.bz2
emacs-abd861ca2694898b347b94251710da38c687dd68.zip
merging with my changes in cond-star.el.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/bytecomp.el2
-rw-r--r--lisp/emacs-lisp/chart.el2
-rw-r--r--lisp/emacs-lisp/checkdoc.el2
-rw-r--r--lisp/emacs-lisp/cl-extra.el2
-rw-r--r--lisp/emacs-lisp/cl-lib.el38
-rw-r--r--lisp/emacs-lisp/cl-macs.el4
-rw-r--r--lisp/emacs-lisp/crm.el30
-rw-r--r--lisp/emacs-lisp/eieio.el4
-rw-r--r--lisp/emacs-lisp/elint.el4
-rw-r--r--lisp/emacs-lisp/ert-x.el2
-rw-r--r--lisp/emacs-lisp/ert.el12
-rw-r--r--lisp/emacs-lisp/gv.el2
-rw-r--r--lisp/emacs-lisp/helper.el2
-rw-r--r--lisp/emacs-lisp/macroexp.el2
-rw-r--r--lisp/emacs-lisp/pcase.el2
-rw-r--r--lisp/emacs-lisp/pp.el2
-rw-r--r--lisp/emacs-lisp/rx.el2
-rw-r--r--lisp/emacs-lisp/shortdoc.el36
18 files changed, 87 insertions, 63 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e48cac6c9b1..88e45ddb868 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3772,7 +3772,7 @@ This assumes the function has the `important-return-value' property."
;; Add missing &optional (or &rest) arguments.
(dotimes (_ (- (/ (1+ fmax2) 2) alen))
(byte-compile-push-constant nil)))
- ((zerop (logand fmax2 1))
+ ((evenp fmax2)
(byte-compile-report-error
(format "Too many arguments for inlined function %S" form))
(byte-compile-discard (- alen (/ fmax2 2))))
diff --git a/lisp/emacs-lisp/chart.el b/lisp/emacs-lisp/chart.el
index 6f2f85fc765..2a01501f99e 100644
--- a/lisp/emacs-lisp/chart.el
+++ b/lisp/emacs-lisp/chart.el
@@ -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))
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index dd3da9ae8c0..3541e3d0a57 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -2109,7 +2109,7 @@ The text checked is between START and LIMIT."
(goto-char start)
(while (and (< (point) p) (re-search-forward "\\\\\"" limit t))
(setq c (1+ c)))
- (and (< 0 c) (= (% c 2) 0))))))
+ (and (< 0 c) (evenp c))))))
(defun checkdoc-in-abbreviation-p (begin)
"Return non-nil if point is at an abbreviation.
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index 09470457d93..ab06682cf93 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -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))))
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index dba01b28325..4a83e9d6a7c 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -270,27 +270,29 @@ so that they are registered at compile-time as well as run-time."
(define-obsolete-function-alias 'cl-floatp-safe 'floatp "24.4")
-(defsubst cl-plusp (number)
- "Return t if NUMBER is positive."
- (declare (side-effect-free t))
- (> number 0))
+(defalias 'cl-plusp #'plusp
+ "Return t if NUMBER is positive.
-(defsubst cl-minusp (number)
- "Return t if NUMBER is negative."
- (declare (side-effect-free t))
- (< number 0))
+This function is considered deprecated in favor of the built-in function
+`plusp' that was added in Emacs 31.1.")
-(defun cl-oddp (integer)
- "Return t if INTEGER is odd."
- (declare (side-effect-free t)
- (compiler-macro (lambda (_) `(eq (logand ,integer 1) 1))))
- (eq (logand integer 1) 1))
+(defalias 'cl-minusp #'minusp
+ "Return t if NUMBER is negative.
-(defun cl-evenp (integer)
- "Return t if INTEGER is even."
- (declare (side-effect-free t)
- (compiler-macro (lambda (_) `(eq (logand ,integer 1) 0))))
- (eq (logand integer 1) 0))
+This function is considered deprecated in favor of the built-in function
+`minusp' that was added in Emacs 31.1.")
+
+(defalias 'cl-oddp #'oddp
+ "Return t if INTEGER is odd.
+
+This function is considered deprecated in favor of the built-in function
+`evenp' that was added in Emacs 31.1.")
+
+(defalias 'cl-evenp #'evenp
+ "Return t if INTEGER is even.
+
+This function is considered deprecated in favor of the built-in function
+`evenp' that was added in Emacs 31.1.")
(defconst cl-digit-char-table
(let* ((digits (make-vector 256 nil))
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index caaffcf19be..e73edbadaf2 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2701,7 +2701,7 @@ Example:
(let ((speed (assq (nth 1 (assq 'speed (cdr spec)))
'((0 nil) (1 t) (2 t) (3 t))))
(safety (assq (nth 1 (assq 'safety (cdr spec)))
- '((0 t) (1 t) (2 t) (3 nil)))))
+ '((0 t) (1 nil) (2 nil) (3 nil)))))
(if speed (setq cl--optimize-speed (car speed)
byte-optimize (nth 1 speed)))
(if safety (setq cl--optimize-safety (car safety)
@@ -3259,7 +3259,7 @@ To see the documentation for a defined struct type, use
(declare (side-effect-free t))
,access-body)
forms)
- (when (cl-oddp (length desc))
+ (when (oddp (length desc))
(push
(macroexp-warn-and-return
(format-message
diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index a371a8e14de..676252ae126 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -79,9 +79,25 @@
(define-obsolete-variable-alias 'crm-default-separator 'crm-separator "29.1")
-(defvar crm-separator "[ \t]*,[ \t]*"
+(defvar crm-separator
+ (propertize "[ \t]*,[ \t]*" 'separator "," 'description "comma-separated list")
"Separator regexp used for separating strings in `completing-read-multiple'.
-It should be a regexp that does not match the list of completion candidates.")
+It should be a regexp that does not match the list of completion
+candidates. The regexp string can carry the text properties `separator'
+and `description', which if present `completing-read-multiple' will show
+as part of the prompt. See the user option `crm-prompt'.")
+
+(defcustom crm-prompt "[%d] %p"
+ "Prompt format for `completing-read-multiple'.
+The prompt is formatted by `format-spec' with the keys %d, %s and %p
+standing for the separator description, the separator itself and the
+original prompt respectively."
+ :type '(choice (const :tag "Original prompt" "%p")
+ (const :tag "Description and prompt" "[%d] %p")
+ (const :tag "Short CRM indication" "[CRM%s] %p")
+ (string :tag "Custom string"))
+ :group 'minibuffer
+ :version "31.1")
(defvar-keymap crm-local-completion-map
:doc "Local keymap for minibuffer multiple input with completion.
@@ -266,8 +282,14 @@ with empty strings removed."
(unless (eq require-match t) require-match))
(setq-local crm-completion-table table))
(setq input (read-from-minibuffer
- prompt initial-input map
- nil hist def inherit-input-method)))
+ (format-spec
+ crm-prompt
+ (let* ((sep (or (get-text-property 0 'separator crm-separator)
+ (string-replace "[ \t]*" "" crm-separator)))
+ (desc (or (get-text-property 0 'description crm-separator)
+ (concat "list separated by " sep))))
+ `((?s . ,sep) (?d . ,desc) (?p . ,prompt))))
+ initial-input map nil hist def inherit-input-method)))
;; If the user enters empty input, `read-from-minibuffer'
;; returns the empty string, not DEF.
(when (and def (string-equal input ""))
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index 1fa177b08da..0f029813f80 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -115,10 +115,10 @@ and reference them using the function `class-option'."
(cl-check-type superclasses list)
(cond ((and (stringp (car options-and-doc))
- (/= 1 (% (length options-and-doc) 2)))
+ (evenp (length options-and-doc)))
(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))
diff --git a/lisp/emacs-lisp/elint.el b/lisp/emacs-lisp/elint.el
index 0f5d15be838..5ae8880167d 100644
--- a/lisp/emacs-lisp/elint.el
+++ b/lisp/emacs-lisp/elint.el
@@ -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)
@@ -833,7 +833,7 @@ CODE can be a lambda expression, a macro, or byte-compiled code."
"Lint the defcustom FORM in ENV."
(if (and (> (length form) 3)
;; even no. of keyword/value args ?
- (zerop (logand (length form) 1)))
+ (evenp (length form)))
(elint-env-add-global-var (elint-form (nth 2 form) env)
(car (cdr form)))
(elint-error "Malformed variable declaration: %s" form)
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index 147787d3d38..0dacec130a0 100644
--- a/lisp/emacs-lisp/ert-x.el
+++ b/lisp/emacs-lisp/ert-x.el
@@ -260,7 +260,7 @@ structure with the plists in ARGS."
(string (let ((begin (point)))
(insert x)
(set-text-properties begin (point) current-plist)))
- (list (unless (zerop (mod (length x) 2))
+ (list (unless (evenp (length x))
(error "Odd number of args in plist: %S" x))
(setq current-plist x))))
(buffer-string)))
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 5d1b9f2acbb..28be8666f28 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -576,7 +576,7 @@ Return nil if they are."
(defun ert--significant-plist-keys (plist)
"Return the keys of PLIST that have non-null values, in order."
- (cl-assert (zerop (mod (length plist) 2)) t)
+ (cl-assert (evenp (length plist)) t)
(cl-loop for (key value . rest) on plist by #'cddr
unless (or (null value) (memq key accu)) collect key into accu
finally (cl-return accu)))
@@ -587,8 +587,8 @@ Return nil if they are."
Returns nil if they are equivalent, i.e., have the same value for
each key, where absent values are treated as nil. The order of
key/value pairs in each list does not matter."
- (cl-assert (zerop (mod (length a) 2)) t)
- (cl-assert (zerop (mod (length b) 2)) t)
+ (cl-assert (evenp (length a)) t)
+ (cl-assert (evenp (length b)) t)
;; Normalizing the plists would be another way to do this but it
;; requires a total ordering on all lisp objects (since any object
;; is valid as a text property key). Perhaps defining such an
@@ -1419,7 +1419,7 @@ Returns the stats object."
(message "%9s %S%s"
(ert-string-for-test-result result nil)
(ert-test-name test)
- (if (cl-plusp
+ (if (plusp
(length (getenv "EMACS_TEST_VERBOSE")))
(ert-reason-for-test-result result)
""))))
@@ -1432,7 +1432,7 @@ Returns the stats object."
(message "%9s %S%s"
(ert-string-for-test-result result nil)
(ert-test-name test)
- (if (cl-plusp
+ (if (plusp
(length (getenv "EMACS_TEST_VERBOSE")))
(ert-reason-for-test-result result)
""))))
@@ -2123,7 +2123,7 @@ non-nil, returns the face for expected results.."
(defun ert-face-for-stats (stats)
"Return a face that represents STATS."
(cond ((ert--stats-aborted-p stats) 'nil)
- ((cl-plusp (ert-stats-completed-unexpected stats))
+ ((plusp (ert-stats-completed-unexpected stats))
(ert-face-for-test-result nil))
((eql (ert-stats-completed-expected stats) (ert-stats-total stats))
(ert-face-for-test-result t))
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index c863857d6ba..dcbdf6942f7 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -294,7 +294,7 @@ The return value is the last VAL in the list.
\(fn PLACE VAL PLACE VAL ...)"
(declare (debug (&rest [gv-place form])))
- (if (/= (logand (length args) 1) 0)
+ (if (oddp (length args))
(signal 'wrong-number-of-arguments (list 'setf (length args))))
(if (and args (null (cddr args)))
(let ((place (pop args))
diff --git a/lisp/emacs-lisp/helper.el b/lisp/emacs-lisp/helper.el
index d8f758d2fe5..8a173219545 100644
--- a/lisp/emacs-lisp/helper.el
+++ b/lisp/emacs-lisp/helper.el
@@ -80,7 +80,7 @@
(recenter))
((and (or (eq continue 'backspace)
(eq continue ?\177))
- (zerop (% state 2)))
+ (evenp state))
(scroll-down))
(t (setq continue nil))))))))
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index 4b6f77cc940..897a72d7485 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -435,7 +435,7 @@ Assumes the caller has bound `macroexpand-all-environment'."
;; Malformed code is translated to code that signals an error
;; at run time.
(let ((nargs (length args)))
- (if (/= (logand nargs 1) 0)
+ (if (oddp nargs)
(macroexp-warn-and-return
(format-message "odd number of arguments in `setq' form")
`(signal 'wrong-number-of-arguments '(setq ,nargs))
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index a6a4751f49a..c68b8961ee3 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -370,7 +370,7 @@ undetected, binding variables to arbitrary values, such as nil.
(cond
(args
(let ((arg-length (length args)))
- (unless (= 0 (mod arg-length 2))
+ (unless (evenp arg-length)
(signal 'wrong-number-of-arguments
(list 'pcase-setq (+ 2 arg-length)))))
(let ((result))
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el
index e4fa4426c03..6df15b197c8 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -577,7 +577,7 @@ the bounds of a region containing Lisp code to pretty-print."
(insert ")")))
(defun pp--format-definition (sexp indent edebug)
- (while (and (cl-plusp indent)
+ (while (and (plusp indent)
sexp)
(insert " ")
;; We don't understand all the edebug specs.
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index 8fbe35220f1..c512d42cd15 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -1072,7 +1072,7 @@ Return (REGEXP . PRECEDENCE)."
"Expand `eval' arguments. Return a new rx form."
(unless (and body (null (cdr body)))
(error "rx `eval' form takes exactly one argument"))
- (eval (car body)))
+ (eval (car body) lexical-binding))
(defun rx--translate-eval (body)
"Translate the `eval' form. Return (REGEXP . PRECEDENCE)."
diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el
index cc9971b232f..23b9b582a9a 100644
--- a/lisp/emacs-lisp/shortdoc.el
+++ b/lisp/emacs-lisp/shortdoc.el
@@ -278,17 +278,17 @@ A FUNC form can have any number of `:no-eval' (or `:no-value'),
:args (function map)
:eval (map-values-apply #'1+ (list '(1 . 2) '(3 . 4))))
(map-filter
- :eval (map-filter (lambda (k _) (cl-oddp k)) (list '(1 . 2) '(4 . 6)))
- :eval (map-filter (lambda (k v) (cl-evenp (+ k v))) (list '(1 . 2) '(4 . 6))))
+ :eval (map-filter (lambda (k _) (oddp k)) (list '(1 . 2) '(4 . 6)))
+ :eval (map-filter (lambda (k v) (evenp (+ k v))) (list '(1 . 2) '(4 . 6))))
(map-remove
- :eval (map-remove (lambda (k _) (cl-oddp k)) (list '(1 . 2) '(4 . 6)))
- :eval (map-remove (lambda (k v) (cl-evenp (+ k v))) (list '(1 . 2) '(4 . 6))))
+ :eval (map-remove (lambda (k _) (oddp k)) (list '(1 . 2) '(4 . 6)))
+ :eval (map-remove (lambda (k v) (evenp (+ k v))) (list '(1 . 2) '(4 . 6))))
(map-some
- :eval (map-some (lambda (k _) (cl-oddp k)) (list '(1 . 2) '(4 . 6)))
- :eval (map-some (lambda (k v) (cl-evenp (+ k v))) (list '(1 . 2) '(4 . 6))))
+ :eval (map-some (lambda (k _) (oddp k)) (list '(1 . 2) '(4 . 6)))
+ :eval (map-some (lambda (k v) (evenp (+ k v))) (list '(1 . 2) '(4 . 6))))
(map-every-p
- :eval (map-every-p (lambda (k _) (cl-oddp k)) (list '(1 . 2) '(4 . 6)))
- :eval (map-every-p (lambda (k v) (cl-evenp (+ k v))) (list '(1 . 3) '(4 . 6))))
+ :eval (map-every-p (lambda (k _) (oddp k)) (list '(1 . 2) '(4 . 6)))
+ :eval (map-every-p (lambda (k v) (evenp (+ k v))) (list '(1 . 3) '(4 . 6))))
"Combining and changing maps"
(map-merge
:eval (map-merge 'alist '(1 2 3 4) #s(hash-table data (5 6 7 8)))
@@ -1412,16 +1412,16 @@ A FUNC form can have any number of `:no-eval' (or `:no-value'),
:eval (natnump -1)
:eval (natnump 0)
:eval (natnump 23))
- (cl-plusp
- :eval (cl-plusp 0)
- :eval (cl-plusp 1))
- (cl-minusp
- :eval (cl-minusp 0)
- :eval (cl-minusp -1))
- (cl-oddp
- :eval (cl-oddp 3))
- (cl-evenp
- :eval (cl-evenp 6))
+ (plusp
+ :eval (plusp 0)
+ :eval (plusp 1))
+ (minusp
+ :eval (minusp 0)
+ :eval (minusp -1))
+ (oddp
+ :eval (oddp 3))
+ (evenp
+ :eval (evenp 6))
(bignump
:eval (bignump 4)
:eval (bignump (expt 2 90)))