[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 08:05:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Marcin Borkowski wrote:
>>> 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.
If that variable change its name the byte-compiler will warn
you since you will be shooting blanks.
Here, try type:
(setq no-such-var 'oh-la-la)
then byte-compile, the byte-compiler will say:
In toplevel form:
geh.el:19:7: Warning: assignment to free variable ‘no-such-var’
BTW I wrote a program ages ago [1] and it tells me in 152
Elisp files just a small bunch of very few variables that I've
ever used `setf' or `setq' on
;; .emacs.el, 204: show-paren-delay
;; erc-incal.el, 34: erc-user-full-name
;; erc-incal.el, 77: erc-header-line-format
;; spell.el, 17: ispell-program-name
;; w3m-incal.el, 26: w3m-tab-width
are actually options.
I don't remember anymore why that was important to know?
I didn't like custom or options back then (and still don't) so
maybe an attitude/political thing but ... yeah, what?
[1] https://dataswamp.org/~incal/emacs-init/custom-vars.el
--
underground experts united
https://dataswamp.org/~incal
- RE: [External] : 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?, Jean Louis, 2022/03/19
Re: Is there a way of setting a variable only when it exists?, Emanuel Berg, 2022/03/19