From: Thibaut Verron <thibaut.verron@gmail.com>
To: carlmarcos@tutanota.com
Cc: Philip Kaludercic <philipk@posteo.net>,
carlmarcos--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Subject: Re: Generality of defvar
Date: Wed, 27 Jul 2022 09:29:22 +0200 [thread overview]
Message-ID: <CAFsi02SEVCEjGNoQ6vPZvMw7d5F39JZAAPCR5VOUnzQDUERkQA@mail.gmail.com> (raw)
In-Reply-To: <N7wlf5Z--7-2@tutanota.com>
Le mer. 27 juil. 2022 à 01:11, carlmarcos--- via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> a écrit :
> Jul 26, 2022, 23:01 by philipk@posteo.net:
>
> > carlmarcos--- via Users list for the GNU Emacs text editor
> > <help-gnu-emacs@gnu.org> writes:
> >
> >> Have been looking into defvar and noticed the generality of its use
> >>
> >> (defvar aname t)
> >> (defvar bname nil)
> >> (defvar cname 1)
> >> (defvar dname "text")
> >>
> >> Then I can do
> >>
> >> (when aname (setq debug-on-error t))
> >> (when bname (setq debug-on-error nil))
> >>
> >> Is this correct?
> >>
> >
> > You can /do/ it, but what do you /want/ to archive?
> >
> Want to use a defvar to enable or disable some functionality using `when',
> such as enabling error diagnostics with the command
>
> (when myopt (setq debug-on-error t))
>
In principle yes, but for this example there already is a variable for that
purpose, debug-on-error.
So you might as well just use it as your control variable, and use
conditionals like (when debug-on-error ...) or (unless debug-on-error ...)
if you want to do more things.
Also, those lines:
(when aname (setq debug-on-error t))
(when bname (setq debug-on-error nil))
are equivalent to
(setq debug-on-error (and aname (not bname)))
I don't really see the point of having two variables hold opposite values.
Wouldn't
(if aname
(setq debug-on-error t)
(setq debug-on-error nil))
or equivalently
(setq debug-on-error aname)
be more what you want?
next prev parent reply other threads:[~2022-07-27 7:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 20:35 Generality of defvar carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-26 23:01 ` Philip Kaludercic
[not found] ` <87r127h40s.fsf@posteo.net-N7wjq17--3-2>
2022-07-26 23:10 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27 7:29 ` Thibaut Verron [this message]
[not found] ` <CAFsi02SEVCEjGNoQ6vPZvMw7d5F39JZAAPCR5VOUnzQDUERkQA@mail.gmail.com-N7yZ2U2----2>
2022-07-27 12:18 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27 12:34 ` Emanuel Berg
2022-07-27 12:52 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27 13:21 ` Thibaut Verron
2022-07-27 13:24 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27 13:47 ` Thibaut Verron
2022-07-27 16:29 ` Christopher Dimech
2022-07-27 16:39 ` Thibaut Verron
2022-07-28 6:42 ` Christopher Dimech
2022-07-28 7:06 ` Thibaut Verron
2022-07-28 7:34 ` Christopher Dimech
2022-07-28 9:37 ` thibaut.verron
2022-07-28 13:57 ` Christopher Dimech
2022-07-26 23:16 ` Emanuel Berg
2022-07-26 23:23 ` Emanuel Berg
2022-07-26 23:36 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27 4:57 ` Yuri Khan
2022-07-27 6:59 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-29 15:56 ` Emanuel Berg
2022-07-29 16:25 ` [External] : " Drew Adams
2022-07-30 3:56 ` Emanuel Berg
2022-07-30 19:36 ` Drew Adams
2022-08-01 3:24 ` Emanuel Berg
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=CAFsi02SEVCEjGNoQ6vPZvMw7d5F39JZAAPCR5VOUnzQDUERkQA@mail.gmail.com \
--to=thibaut.verron@gmail.com \
--cc=carlmarcos@tutanota.com \
--cc=help-gnu-emacs@gnu.org \
--cc=philipk@posteo.net \
/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).