aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/custom.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-07-05 19:32:37 +0200
committerLars Ingebrigtsen2022-07-05 19:33:24 +0200
commit6d8638e5e494fb0ceafffe19bbf349fff643e12d (patch)
tree5516261421fca0015b97667f9caaa4573fb68b33 /lisp/custom.el
parent99872bedf07315f642d143feaed9075a7ea20cba (diff)
downloademacs-6d8638e5e494fb0ceafffe19bbf349fff643e12d.tar.gz
emacs-6d8638e5e494fb0ceafffe19bbf349fff643e12d.zip
Give a warning if setopt has been used with an invalid value
* lisp/cus-edit.el (setopt--set): Mark the variable for checking. * lisp/custom.el (custom-initialize-reset): Give a warning if the type is wrong (bug#56400). * lisp/wid-edit.el (widget-convert): Autoload.
Diffstat (limited to 'lisp/custom.el')
-rw-r--r--lisp/custom.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index 2b7621229d9..a6e2ab351d4 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -90,6 +90,16 @@ The value is either the symbol's current value
90 (as obtained using the `:get' function), if any, 90 (as obtained using the `:get' function), if any,
91or the value in the symbol's `saved-value' property if any, 91or the value in the symbol's `saved-value' property if any,
92or (last of all) the value of EXP." 92or (last of all) the value of EXP."
93 ;; If this value has been set with `setopt' (for instance in
94 ;; ~/.emacs), we didn't necessarily know the type of the user option
95 ;; then. So check now, and issue a warning if it's wrong.
96 (when-let ((value (get symbol 'custom-check-value))
97 (type (get symbol 'custom-type)))
98 (when (and (boundp symbol)
99 (eq (car value) (symbol-value symbol))
100 ;; Check that the type is correct.
101 (not (widget-apply (widget-convert type) :match (car value))))
102 (warn "Value `%S' for `%s' does not match type %s" value symbol type)))
93 (funcall (or (get symbol 'custom-set) #'set-default-toplevel-value) 103 (funcall (or (get symbol 'custom-set) #'set-default-toplevel-value)
94 symbol 104 symbol
95 (condition-case nil 105 (condition-case nil