From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Is there a way of setting a variable only when it exists?
Date: Tue, 15 Mar 2022 08:05:52 +0100 [thread overview]
Message-ID: <8735jj4rvz.fsf@zoho.eu> (raw)
In-Reply-To: 87bky7viz2.fsf@mbork.pl
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
next prev parent reply other threads:[~2022-03-15 7:05 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 6:00 Is there a way of setting a variable only when it exists? Marcin Borkowski
2022-03-14 12:52 ` Eli Zaretskii
2022-03-14 13:16 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-03-14 13:48 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-15 6:17 ` Marcin Borkowski
2022-03-15 6:50 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-15 6:58 ` Jean Louis
2022-03-15 7:45 ` Marcin Borkowski
2022-03-15 8:12 ` Jean Louis
2022-03-15 7:49 ` tomas
2022-03-15 8:13 ` Jean Louis
2022-03-15 8:36 ` tomas
2022-03-15 9:28 ` Jean Louis
2022-03-15 10:01 ` tomas
2022-03-15 11:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-15 8:14 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-15 15:33 ` [External] : " Drew Adams
2022-03-15 15:38 ` Drew Adams
2022-03-16 18:32 ` Marcin Borkowski
2022-03-16 0:47 ` Michael Heerdegen
2022-03-16 18:33 ` Marcin Borkowski
2022-03-16 6:02 ` Tomas Nordin
2022-03-16 6:37 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-16 18:34 ` Marcin Borkowski
2022-03-15 6:48 ` Jean Louis
2022-03-14 22:09 ` Michael Heerdegen
2022-03-15 6:16 ` Marcin Borkowski
2022-03-15 7:05 ` Emanuel Berg via Users list for the GNU Emacs text editor [this message]
2022-03-16 0:25 ` Michael Heerdegen
2022-03-16 18:33 ` Marcin Borkowski
2022-03-16 19:25 ` Michael Heerdegen
2022-03-18 5:58 ` Marcin Borkowski
2022-03-16 20:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-17 20:47 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-03-18 5:59 ` Marcin Borkowski
2022-03-18 17:59 ` Jean Louis
2022-03-19 9:25 ` Emanuel Berg via Users list for the GNU Emacs text editor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735jj4rvz.fsf@zoho.eu \
--to=help-gnu-emacs@gnu.org \
--cc=moasenwood@zoho.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).