]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid prompting when creating a restricted-sexp widget
authorMauro Aranda <maurooaranda@gmail.com>
Sun, 16 Jul 2023 22:46:54 +0000 (19:46 -0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 22 Jul 2023 12:55:31 +0000 (15:55 +0300)
* 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

index 606093fd2935755d4d1c54a44075ac58b15b654a..b9291af2bd521a543bb07a4a44e40387f30d1814 100644 (file)
@@ -2127,7 +2127,8 @@ the earlier input."
        ;; `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 @@ match-alternatives: %S"
                            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)