help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Is there a way of setting a variable only when it exists?


From: Emanuel Berg
Subject: Re: Is there a way of setting a variable only when it exists?
Date: Tue, 15 Mar 2022 07:50:43 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Marcin Borkowski wrote:

>>>   want to do something else. In that case, the something
>>>   else tends to depend on the specifics so (if (boundp
>>>   'foo) (setq foo ..) ...) is about s good as it gets.
>>
>> If it exists set it with `setq'. If it doesn't exist,
>> create and set it ... with `setq'?
>
> What if it's an internal Emacs variable which might become
> a user option one day (I submitted a bug report about it)
> and then my customization silently disappears? It's the
> "silently" part I want to guard against...

Yeah, that whole system ... *mumble*

But here you go,

(let ((var (variable-at-point t))) ; ANY-SYMBOL
  (when (and (custom-variable-p var)
             (get var 'custom-set) )
    (message "user variable") ))

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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