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: Michael Heerdegen
Subject: Re: Is there a way of setting a variable only when it exists?
Date: Mon, 14 Mar 2022 23:09:23 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

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.

> I assume it would be fairly easy to code such a macro (using `boundp'),

Maybe rather using `special-variable-p'?

Michael.




reply via email to

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