unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 15809@debbugs.gnu.org
Subject: bug#15809: 24.3.50; wrong defcustom type for `suggest-key-bindings'
Date: Fri, 24 Sep 2021 16:34:38 -0700	[thread overview]
Message-ID: <CADwFkmkaZBj=L6_fpoJ4wLgOUqWP=oH0Bzu918UgOhZ30NGR6Q@mail.gmail.com> (raw)
In-Reply-To: <87zh46wzj7.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 28 Oct 2020 09:00:28 +0100")

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]

tags 15809 + patch
thanks

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Stefan Kangas <stefan@marxist.se> writes:
>
>>> Or to be more general, perhaps there should be a custom interval type?  Like
>>>
>>> (integer :minimum 1)
>>>
>>> ?
>>>
>>> Or just `natnum'?
>>
>> natnum sounds like it could be generally useful, yes.  We have plenty of
>> customizable things that should never be negative.
>
> Yeah, that's the most common numerical restriction (by far), and the few
> variables that are numbers with other ranges can be done with a
> defcustom predicate.

How about the attached?

[-- Attachment #2: 0001-New-type-natnum-for-defcustom.patch --]
[-- Type: text/x-diff, Size: 1984 bytes --]

From 7313d60a163b66af039efc69046e4df4dff21457 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Sat, 25 Sep 2021 01:15:49 +0200
Subject: [PATCH 1/2] 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 bc35982c17..b93b8bc015 100644
--- a/doc/lispref/customize.texi
+++ b/doc/lispref/customize.texi
@@ -594,6 +594,9 @@ Simple Types
 @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 c266dddafa..b2e7331517 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3724,6 +3724,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
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index ab358da7e3..72353b9190 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -3644,6 +3644,13 @@ 'integer
   :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"
-- 
2.30.2


[-- Attachment #3: 0002-Set-type-of-suggest-key-bindings-to-natnum.patch --]
[-- Type: text/x-diff, Size: 838 bytes --]

From 95127f0d7441999c78e4c4e9ab8217757148e5c9 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Sat, 25 Sep 2021 01:25:47 +0200
Subject: [PATCH 2/2] Set :type of suggest-key-bindings to natnum

* lisp/simple.el (suggest-key-bindings): Set :type to
natnum.  (Bug#15809)
---
 lisp/simple.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 298e3ea5ee..dd480396f6 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2144,7 +2144,7 @@ suggest-key-bindings
 \\[execute-extended-command] for all commands that have them."
   :group 'keyboard
   :type '(choice (const :tag "off" nil)
-                 (integer :tag "time" 2)
+                 (natnum :tag "time" 2)
                  (other :tag "on")))
 
 (defcustom extended-command-suggest-shorter t
-- 
2.30.2


  parent reply	other threads:[~2021-09-24 23:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05 15:30 bug#15809: 24.3.50; wrong defcustom type for `suggest-key-bindings' Drew Adams
2014-02-08  3:36 ` Lars Ingebrigtsen
2014-02-09  2:14   ` Drew Adams
2014-02-11 11:47     ` Lars Ingebrigtsen
2020-10-28  7:50   ` Stefan Kangas
2020-10-28  8:00     ` Lars Ingebrigtsen
2020-10-28 14:25       ` Drew Adams
2021-09-24 23:32         ` Stefan Kangas
2021-09-25  1:50           ` bug#15809: [External] : " Drew Adams
2021-09-24 23:34       ` Stefan Kangas [this message]
2021-09-25  1:09         ` Lars Ingebrigtsen
2021-09-25  1:29           ` bug#15809: [External] : " Drew Adams
2021-09-25  1:54           ` Stefan Kangas
2021-09-25  2:06             ` Lars Ingebrigtsen
2021-09-25  2:43               ` Stefan Kangas
2021-09-25  1:24         ` bug#15809: [External] : " Drew Adams
2021-09-25  2:25           ` Stefan Kangas
2021-09-25 15:22             ` Drew Adams
2021-09-25 15:56               ` Stefan Kangas
2021-09-25 16:01               ` Eli Zaretskii
     [not found] <D0F524A8-6F43-4A73-928B-EC91FAFA2866@acm.org>
2021-09-25 10:50 ` Mattias Engdegård
2021-09-25 10:57 ` Mattias Engdegård
2021-09-25 13:00 ` Stefan Kangas
2021-09-25 13:07   ` Mattias Engdegård
2021-09-25 14:53     ` Stefan Kangas
2021-09-25 18:32       ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmkaZBj=L6_fpoJ4wLgOUqWP=oH0Bzu918UgOhZ30NGR6Q@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=15809@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).