]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve diagnostic of type mismatch in 'setopt'
authorEli Zaretskii <eliz@gnu.org>
Sun, 8 Sep 2024 06:19:34 +0000 (09:19 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sun, 8 Sep 2024 11:24:41 +0000 (13:24 +0200)
* lisp/cus-edit.el (setopt--set): Name the variable in the warning
message.  (Bug#73084)

* test/lisp/cus-edit-tests.el (test-setopt): Adjust test.

(cherry picked from commit 2ce0d397b12cafcb3e1ac5630bc3fbca61bd6b87)

lisp/cus-edit.el
test/lisp/cus-edit-tests.el

index c10c1d435cb94f90cfae39518e86b16b0f19c638..f44a4e076529694198718c1d98e7738da943b20f 100644 (file)
@@ -1074,7 +1074,8 @@ plain variables.  This means that `setopt' will execute any
   ;; Check that the type is correct.
   (when-let ((type (get variable 'custom-type)))
     (unless (widget-apply (widget-convert type) :match value)
-      (warn "Value `%S' does not match type %s" value type)))
+      (warn "Value `%S' for variable `%s' does not match its type \"%s\""
+            value variable type)))
   (put variable 'custom-check-value (list value))
   (funcall (or (get variable 'custom-set) #'set-default) variable value))
 
index 535711e02cf668d81ff121f1cabe225ebd93dfcf..ecef4c35b47598723c6eaa648d81792a6aedc6fb 100644 (file)
@@ -90,7 +90,7 @@
               (erase-buffer))
             (setopt cus-edit-test-foo1 :foo)
             (buffer-substring-no-properties (point-min) (point-max)))))
-    (should (string-search "Value `:foo' does not match type number"
+    (should (string-search "Value `:foo' for variable `cus-edit-test-foo1' does not match its type \"number\""
                            warn-txt))))
 
 (defcustom cus-edit-test-bug63290-option nil