emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 6d8638e5e4: Give a warning if setopt has been used with an in


From: Stefan Monnier
Subject: Re: master 6d8638e5e4: Give a warning if setopt has been used with an invalid value
Date: Tue, 05 Jul 2022 16:30:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Lars Ingebrigtsen [2022-07-05 13:33:29] wrote:
> diff --git a/lisp/custom.el b/lisp/custom.el
> index 2b7621229d..a6e2ab351d 100644
> --- a/lisp/custom.el
> +++ b/lisp/custom.el
> @@ -90,6 +90,16 @@ The value is either the symbol's current value
>   (as obtained using the `:get' function), if any,
>  or the value in the symbol's `saved-value' property if any,
>  or (last of all) the value of EXP."
> +  ;; If this value has been set with `setopt' (for instance in
> +  ;; ~/.emacs), we didn't necessarily know the type of the user option
> +  ;; then.  So check now, and issue a warning if it's wrong.
> +  (when-let ((value (get symbol 'custom-check-value))
> +             (type (get symbol 'custom-type)))
> +    (when (and (boundp symbol)
> +               (eq (car value) (symbol-value symbol))
> +               ;; Check that the type is correct.
> +               (not (widget-apply (widget-convert type) :match (car value))))
> +      (warn "Value `%S' for `%s' does not match type %s" value symbol type)))
>    (funcall (or (get symbol 'custom-set) #'set-default-toplevel-value)
>             symbol
>             (condition-case nil

This breaks bootstrap for me because `when-let` in `subr.el` uses
`macroexp-progn` which is not yet defined when `custom.el` is loaded.

Maybe `macroexp.el` should be loaded earlier in `loadup.el` (it is after
all a file that provides some of the core infrastructure for ELisp's own
execution, whereas `custom.el` is dedicated to higher-level
functionality).  But according to a comment I put in `loadup.el` there
might be some issues to deal with if we want to do that.
Personally I just don't find `when-let` to be worth the trouble.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]