[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#56400: Make setopt warn on type mismatch
From: |
Lars Ingebrigtsen |
Subject: |
bug#56400: Make setopt warn on type mismatch |
Date: |
Tue, 05 Jul 2022 18:57:17 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Stefan Kangas <stefan@marxist.se> writes:
> Why not make `setopt' warn in case there is a type mismatch?
> For example, in:
>
> (setopt tetris-buffer-width "hello")
>
> But the type of `tetris-buffer-width' is natnum.
It should throw an error already:
;;;###autoload
(defun setopt--set (variable value)
(custom-load-symbol variable)
;; Check that the type is correct.
(when-let ((type (get variable 'custom-type)))
(unless (widget-apply (widget-convert type) :match value)
(user-error "Value `%S' does not match type %s" value type)))
Did you mean a byte compilation warning? I don't really think that
people will be using setopt much in code, just in .emacs, so I'm not
sure that'd give us much.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug#56400: Make setopt warn on type mismatch, Juri Linkov, 2022/07/06