branch: externals/compat commit b8f21000f623bf6bfad9470c80e2954e1cfb61b8 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
compat-28: Add support for natnum defcustom type --- NEWS.org | 1 + compat-28.el | 11 +++++++++++ compat-tests.el | 5 +++++ compat.texi | 5 +++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/NEWS.org b/NEWS.org index a2f14b073d..8bd2dd51b3 100644 --- a/NEWS.org +++ b/NEWS.org @@ -5,6 +5,7 @@ * Development - compat-27: Drop obsolete ~compat-call dired-get-marked-files~. +- compat-28: Add support for ~defcustom~ type ~natnum~. - compat-29: Add ~with-restriction~ and ~without-restriction~. - compat-29: Add ~cl-constantly~. - compat-29: Drop ~with-narrowing~ which was renamed to ~with-restriction~. diff --git a/compat-28.el b/compat-28.el index 6ec47005dc..4cca3c2025 100644 --- a/compat-28.el +++ b/compat-28.el @@ -833,5 +833,16 @@ function will never return nil." ;; Obsolete Alias since 29 (compat-defalias button-buttonize buttonize :obsolete t) ;; <compat-tests:button-buttonize> +;;;; Defined in wid-edit.el + +(compat-guard t ;; <compat-tests:widget-natnum> + :feature wid-edit + (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))) + (provide 'compat-28) ;;; compat-28.el ends here diff --git a/compat-tests.el b/compat-tests.el index 2f6d6c8398..bdf9c04b6f 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -2956,5 +2956,10 @@ (should-equal 3 (seq-length '(a b c))) (should-equal 3 (seq-length [a b c]))) +(ert-deftest widget-natnum () + (with-temp-buffer + (should-error (widget-create 'compat--not-existing)) + (should-equal (take 3 (widget-create 'natnum)) '(natnum :value "0")))) + (provide 'compat-tests) ;;; compat-tests.el ends here diff --git a/compat.texi b/compat.texi index f39d07a88e..16988a7979 100644 --- a/compat.texi +++ b/compat.texi @@ -1689,6 +1689,9 @@ The following functions and macros are implemented in Emacs 28.1. These functions are made available by Compat on Emacs versions older than 28.1. +The @code{defcustom} type @code{natnum} introduced in Emacs 28.1 is +made available by Compat. + @c copied from lispref/processes.texi @defun process-lines-ignore-status program &rest args This function is just like @code{process-lines}, but does not signal @@ -2213,8 +2216,6 @@ Support for the @code{:success} handler of @code{condition-case}. @item The function @code{benchmark-call}. @item -Support for the @code{natnum} defcustom type. -@item Additional Edebug keywords. @item The libjansson JSON APIs, e.g., @code{json-parse-string}.