emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f1071bf 1/2: New :type natnum for defcustom


From: Stefan Kangas
Subject: master f1071bf 1/2: New :type natnum for defcustom
Date: Fri, 24 Sep 2021 22:26:27 -0400 (EDT)

branch: master
commit f1071bf08e246d0820edfb66163acb65e90d9482
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    New :type natnum for defcustom
    
    * lisp/wid-edit.el (natnum): New widget type.  (Bug#15809)
    * doc/lispref/customize.texi (Simple Types): Document it.
---
 doc/lispref/customize.texi | 3 +++
 etc/NEWS                   | 5 +++++
 lisp/wid-edit.el           | 7 +++++++
 3 files changed, 15 insertions(+)

diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi
index bc35982..b93b8bc 100644
--- a/doc/lispref/customize.texi
+++ b/doc/lispref/customize.texi
@@ -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).
 
diff --git a/etc/NEWS b/etc/NEWS
index 31b09da..84a6b3f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3738,6 +3738,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
 summaries will include the failing condition.
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index ab358da..72353b9 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -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"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]