1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

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.
This commit is contained in:
Eli Zaretskii 2024-09-08 09:19:34 +03:00
parent 79805652af
commit 2ce0d397b1
2 changed files with 3 additions and 2 deletions

View File

@ -1072,7 +1072,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))

View 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