From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thibaut Verron Newsgroups: gmane.emacs.help Subject: Re: Generality of defvar Date: Wed, 27 Jul 2022 09:29:22 +0200 Message-ID: References: <87r127h40s.fsf@posteo.net-N7wjq17--3-2> Reply-To: thibaut.verron@gmail.com Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2915"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Philip Kaludercic , carlmarcos--- via Users list for the GNU Emacs text editor To: carlmarcos@tutanota.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 27 09:31:07 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oGbVa-0000ZY-BU for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 27 Jul 2022 09:31:06 +0200 Original-Received: from localhost ([::1]:49226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGbVZ-0002eo-0w for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 27 Jul 2022 03:31:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGbU8-0002bg-NI for help-gnu-emacs@gnu.org; Wed, 27 Jul 2022 03:29:37 -0400 Original-Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]:41908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGbU6-0001Hj-WF for help-gnu-emacs@gnu.org; Wed, 27 Jul 2022 03:29:36 -0400 Original-Received: by mail-il1-x12b.google.com with SMTP id d4so8459042ilc.8 for ; Wed, 27 Jul 2022 00:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=u7M+LAQBbbBxH+8QHoHeGtdc2mzOjoIaVK4YRj7VHWs=; b=gVtQe0CpbEDgLM+Q9Zo4PeyqJbiqabBrtaqkLyKNQd8L6Q8O+3+VYU0DQxohwA+J4N ALU4xHO3LPJVf8pQ6A+4JO7VkoD1IQfO800sumcNTZ3M38UToW9VAWEQLL5lUNvHZ3tN J750UNoQAVBop1+AcGSFmNP4QQWfmYtM0X+bEXjaRnCnBlmRW926JCV64m4hkg9Fm7Ym 5OBoH4QTeDiH6hNxL2sTtI640KAvObzQP2TQB91FUYJbM/T8ZnaAveWFvsAV05/r1xMx BAp6PxaT0XQCd9u98+Azk/QwoT3Ft0mQDWP5WinZInCRfPcFEFKNKgvmOOmX+jh3jVoe hwYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=u7M+LAQBbbBxH+8QHoHeGtdc2mzOjoIaVK4YRj7VHWs=; b=D79Crmze2XH3Z/206/6WqJW4GG2737ZoDtYdFkuO0VDdqIgqRVrZXnfQbZJDJFkxoj G9g96FauLmOumrfIMRAjzfF0hc1Qj4rev2duaH7HDlTkRozMkwX8vGqx5hNYfkndShK7 ztEQRBSv8tjEsgHSZmHq0RjDaYKKsybR2YDHbRROpdmLyYlbXzNXAzVHTQTiV0Y81frU C0q/GemGj3UbSeumTgjl54iVZ1G3jaZBtqXl93g/STBEtAZ9xcE3ydd1BjS11NcB6CTG XiNNtlscHhB+MyJyIaHqaaTScxqTezCQK6G5eCJwkRhHI0M7X6gGP+LVbgtYqJVlZMhk edFA== X-Gm-Message-State: AJIora9/cPxTS8VxsAvsxDiD3485V4UxLkqyj+u7/iM/t6Es6rrqyPF0 7f7Ps1aDJzK9b8c9AuLpxFEU9xdSel3O5YFtx/Y= X-Google-Smtp-Source: AGRyM1vmESK/9fMJmiSaIpnRHeMGYrW4Oij7EC5bWkUewPNEWzOwrkxtgQZnSZ051xSORVA+BKeZcqZlTQcBJ9oojUo= X-Received: by 2002:a05:6e02:1988:b0:2dc:408:680a with SMTP id g8-20020a056e02198800b002dc0408680amr8134766ilf.223.1658906973269; Wed, 27 Jul 2022 00:29:33 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::12b; envelope-from=thibaut.verron@gmail.com; helo=mail-il1-x12b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138640 Archived-At: Le mer. 27 juil. 2022 =C3=A0 01:11, carlmarcos--- via Users list for the GN= U Emacs text editor a =C3=A9crit : > Jul 26, 2022, 23:01 by philipk@posteo.net: > > > carlmarcos--- via Users list for the GNU Emacs text editor > > 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?