[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: |
Marcin Borkowski |
Subject: |
Re: Is there a way of setting a variable only when it exists? |
Date: |
Tue, 15 Mar 2022 07:16:17 +0100 |
User-agent: |
mu4e 1.1.0; emacs 29.0.50 |
On 2022-03-14, at 23:09, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> I'd like to be able to say something like
>>
>> (setq-safe hello "world")
>>
>> so that `hello' is set to `"world"' if it is an existing variable (e.g.,
>> defined by `defvar') and an error is raised if `hello' does not exist.
>
> Byte compiling can help with things like name changes.
Not necessarily. My use-case is an internal Emacs variable I'm setting
in my `init.el'; at the same time I submitted a bug report/feature
request to make it a user option, so I assume that it might change its
name in a future Emacs version.
>> I assume it would be fairly easy to code such a macro (using `boundp'),
>
> Maybe rather using `special-variable-p'?
Might be a good idea in this case, yes.
Thanks,
--
Marcin Borkowski
http://mbork.pl
- Re: Is there a way of setting a variable only when it exists?, (continued)
- Re: Is there a way of setting a variable only when it exists?, Michael Heerdegen, 2022/03/15
- Re: Is there a way of setting a variable only when it exists?, Marcin Borkowski, 2022/03/16
- Re: Is there a way of setting a variable only when it exists?, Tomas Nordin, 2022/03/16
- Re: Is there a way of setting a variable only when it exists?, Marcin Borkowski, 2022/03/16
- Re: Is there a way of setting a variable only when it exists?, Emanuel Berg, 2022/03/17
- Re: Is there a way of setting a variable only when it exists?, Jean Louis, 2022/03/15
Re: Is there a way of setting a variable only when it exists?, Michael Heerdegen, 2022/03/14
- Re: Is there a way of setting a variable only when it exists?,
Marcin Borkowski <=
- Re: Is there a way of setting a variable only when it exists?, Emanuel Berg, 2022/03/15
- Re: Is there a way of setting a variable only when it exists?, Michael Heerdegen, 2022/03/15
- Re: Is there a way of setting a variable only when it exists?, Marcin Borkowski, 2022/03/16
- Re: Is there a way of setting a variable only when it exists?, Michael Heerdegen, 2022/03/16
- Re: Is there a way of setting a variable only when it exists?, Marcin Borkowski, 2022/03/18
- Re: Is there a way of setting a variable only when it exists?, Emanuel Berg, 2022/03/17
- Re: Is there a way of setting a variable only when it exists?, Stefan Monnier, 2022/03/17
- Re: Is there a way of setting a variable only when it exists?, Marcin Borkowski, 2022/03/18
Re: Is there a way of setting a variable only when it exists?, Jean Louis, 2022/03/19
Re: Is there a way of setting a variable only when it exists?, Emanuel Berg, 2022/03/19