summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2025-02-17 21:58:53 +0100
committerStefan Kangas <stefankangas@gmail.com>2025-02-17 22:46:56 +0100
commitafbf932106fdd1043b0debe9fc9134e031e4c9a6 (patch)
tree2bbd79a4e77be4e02dbf2c37d223896f16236762 /lisp
parent1d27028df803e4dc1c063db5593222311838e051 (diff)
downloademacs-afbf932106fdd1043b0debe9fc9134e031e4c9a6.tar.gz
emacs-afbf932106fdd1043b0debe9fc9134e031e4c9a6.tar.bz2
emacs-afbf932106fdd1043b0debe9fc9134e031e4c9a6.zip
New functions plusp and minusp
* lisp/emacs-lisp/cl-lib.el (cl-plusp, cl-minusp): Move from here... * lisp/subr.el (plusp, minusp): ...to here. Make old names into aliases, documented as deprecated. Add type declarations. Change from defsubst to regular functions with compiler macros. * lisp/obsolete/cl.el: Don't alias plusp and minusp. * test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-test-plusp) (cl-lib-test-minusp): Move tests from here... * test/lisp/subr-tests.el (subr-test-plusp, subr-test-minusp): ...to here. * doc/lispref/numbers.texi (Predicates on Numbers): Document plusp and minusp. * doc/misc/cl.texi (Predicates on Numbers): Delete cl-plusp and cl-minusp. * lisp/emacs-lisp/shortdoc.el (number): Document plusp and minusp instead of cl-plusp and cl-minusp.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/cl-lib.el18
-rw-r--r--lisp/emacs-lisp/shortdoc.el12
-rw-r--r--lisp/obsolete/cl.el2
-rw-r--r--lisp/subr.el14
4 files changed, 30 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index 1fc36517796..4a83e9d6a7c 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -270,15 +270,17 @@ 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.")
+
+(defalias 'cl-minusp #'minusp
+ "Return t if NUMBER is negative.
+
+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.
diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el
index af995123dc5..23b9b582a9a 100644
--- a/lisp/emacs-lisp/shortdoc.el
+++ b/lisp/emacs-lisp/shortdoc.el
@@ -1412,12 +1412,12 @@ 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))
+ (plusp
+ :eval (plusp 0)
+ :eval (plusp 1))
+ (minusp
+ :eval (minusp 0)
+ :eval (minusp -1))
(oddp
:eval (oddp 3))
(evenp
diff --git a/lisp/obsolete/cl.el b/lisp/obsolete/cl.el
index 4fb49b596e2..5baa155c592 100644
--- a/lisp/obsolete/cl.el
+++ b/lisp/obsolete/cl.el
@@ -272,8 +272,6 @@
first
svref
copy-seq
- minusp
- plusp
floatp-safe
declaim
proclaim
diff --git a/lisp/subr.el b/lisp/subr.el
index 173c69675aa..225483a609c 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -550,6 +550,20 @@ was called."
(compiler-macro (lambda (_) `(= 0 ,number))))
(= 0 number))
+(defun plusp (number)
+ "Return t if NUMBER is positive."
+ (declare (ftype (function (number) boolean))
+ (side-effect-free t)
+ (compiler-macro (lambda (_) `(> ,number 0))))
+ (> number 0))
+
+(defun minusp (number)
+ "Return t if NUMBER is negative."
+ (declare (ftype (function (number) boolean))
+ (side-effect-free t)
+ (compiler-macro (lambda (_) `(< ,number 0))))
+ (< number 0))
+
(defun oddp (integer)
"Return t if INTEGER is odd."
(declare (ftype (function (integer) boolean))