From ce809c0f2c18e0a29bd28c80c5d2304fbd11b9b7 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 8 Sep 2024 09:19:34 +0300 Subject: [PATCH] Improve diagnostic of type mismatch in 'setopt' * 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 | 3 ++- test/lisp/cus-edit-tests.el | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index c10c1d435cb..f44a4e07652 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -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)) diff --git a/test/lisp/cus-edit-tests.el b/test/lisp/cus-edit-tests.el index 535711e02cf..ecef4c35b47 100644 --- a/test/lisp/cus-edit-tests.el +++ b/test/lisp/cus-edit-tests.el @@ -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 -- 2.39.2