all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mauro Aranda <maurooaranda@gmail.com>
To: "59937@debbugs.gnu.org" <59937@debbugs.gnu.org>
Cc: Drew Adams <drew.adams@oracle.com>
Subject: bug#59937: 28.2; Bad defcustom behavior
Date: Sun, 16 Jul 2023 20:00:40 -0300	[thread overview]
Message-ID: <48440e7d-1c21-fd75-6ebb-c3dbff2f6038@gmail.com> (raw)
In-Reply-To: <SJ0PR10MB54886B66634BF60228ABDDDDF3F59@SJ0PR10MB5488.namprd10.prod.outlook.com>

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

Hi Drew,

I'm sorry it took me so long to actually take a look at this.  I had to
reread the conversation to put myself back into topic.

As I said in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59937#26
I was looking for a way to:
1. Being able to create the restricted-sexp widget, even if the default
value for it isn't valid.
2. Being able to do it without prompting the user.

That's what the attached patch does.  AFAIU, we both agreed that that
approach was a good enough fix for this bug, so that the behavior of
certain defcustoms is less confusing.  We didn't really agree back then
about the warning, and I'm guessing that we still disagree on that, so I
didn't change anything about the warning.

[-- Attachment #2: 0001-Avoid-prompting-when-creating-a-restricted-sexp-widg.patch --]
[-- Type: text/x-patch, Size: 1494 bytes --]

From 12969e3b8b40c5af39209993c0a31e6b3bcb4a10 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@gmail.com>
Date: Sun, 16 Jul 2023 19:46:54 -0300
Subject: [PATCH] Avoid prompting when creating a restricted-sexp widget

* lisp/wid-edit.el (restricted-sexp): Turn value into a string before
reading.
(widget-field-value-create): Guard against value being nil, so the
field can be created even if the widget has a bad default value.
(Bug#59937)
---
 lisp/wid-edit.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 234f3d9b74d..aaec2360db8 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -2127,7 +2127,8 @@ widget-field-value-create
 	;; `widget-setup' is called.
 	(overlay (cons (make-marker) (make-marker))))
     (widget-put widget :field-overlay overlay)
-    (insert value)
+    (when value
+      (insert value))
     (and size
 	 (< (length value) size)
 	 (insert-char ?\s (- size (length value))))
@@ -3655,7 +3656,9 @@ 'restricted-sexp
                            value
                            (widget-get widget :match)
                            (widget-get widget :match-alternatives))
-                          :warning))
+                          :warning)
+                         ;; Make sure we will `read' a string.
+                         (setq value (prin1-to-string value)))
                        (read value)))
 
 (defun widget-restricted-sexp-match (widget value)
-- 
2.34.1


  reply	other threads:[~2023-07-16 23:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-10  5:06 bug#59937: 28.2; Bad defcustom behavior Drew Adams
2022-12-10 10:05 ` Mauro Aranda
2022-12-10 22:05   ` Drew Adams
2022-12-11 11:08     ` Mauro Aranda
2022-12-13 22:10       ` Drew Adams
2022-12-13 22:50         ` Mauro Aranda
2022-12-14  1:51           ` Drew Adams
2022-12-14 12:40             ` Mauro Aranda
2022-12-14 18:53               ` Drew Adams
2022-12-14 22:20                 ` Mauro Aranda
2022-12-14 22:42                   ` Drew Adams
2023-01-04 16:07                   ` Drew Adams
2023-01-04 22:31                     ` Mauro Aranda
2023-01-04 22:47                       ` Drew Adams
2023-07-16 23:00                         ` Mauro Aranda [this message]
2023-07-17 15:30                           ` Drew Adams
2023-07-17 16:21                             ` Mauro Aranda
2023-07-22 12:56                           ` Eli Zaretskii

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

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

  git send-email \
    --in-reply-to=48440e7d-1c21-fd75-6ebb-c3dbff2f6038@gmail.com \
    --to=maurooaranda@gmail.com \
    --cc=59937@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.