New :type natnum for defcustom

* lisp/wid-edit.el (natnum): New widget type.  (Bug#15809)
* doc/lispref/customize.texi (Simple Types): Document it.
This commit is contained in:
Stefan Kangas 2021-09-25 01:15:49 +02:00
parent 988428df7d
commit f1071bf08e
3 changed files with 15 additions and 0 deletions

View file

@ -594,6 +594,9 @@ want to take the time to work out a more specific type to use.
@item integer
The value must be an integer.
@item natnum
The value must be a nonnegative integer.
@item number
The value must be a number (floating point or integer).

View file

@ -3737,6 +3737,11 @@ instead of only becoming available after doing (for instance)
---
** ':safe' settings in 'defcustom' are now propagated to the loaddefs files.
+++
** New ':type' for 'defcustom' for nonnegative integers.
The new 'natnum' type can be used for options that should be
nonnegative integers.
+++
** ERT can now output more verbose test failure reports.
If the 'EMACS_TEST_VERBOSE' environment variable is set, failure

View file

@ -3644,6 +3644,13 @@ match-alternatives: %S"
:type-error "This field should contain an integer"
:match-alternatives '(integerp))
(define-widget 'natnum 'restricted-sexp
"A nonnegative integer."
:tag "Integer (positive)"
:value 0
:type-error "This field should contain a nonnegative integer"
:match-alternatives '(natnump))
(define-widget 'number 'restricted-sexp
"A number (floating point or integer)."
:tag "Number"