From unknown Thu Sep 11 23:47:57 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#79208 <79208@debbugs.gnu.org> To: bug#79208 <79208@debbugs.gnu.org> Subject: Status: [PATCH] (setq-default,setopt): Warn about unknown vars. Reply-To: bug#79208 <79208@debbugs.gnu.org> Date: Fri, 12 Sep 2025 06:47:57 +0000 retitle 79208 [PATCH] (setq-default,setopt): Warn about unknown vars. reassign 79208 emacs submitter 79208 Eshel Yaron severity 79208 normal tag 79208 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 10 07:05:25 2025 Received: (at submit) by debbugs.gnu.org; 10 Aug 2025 11:05:25 +0000 Received: from localhost ([127.0.0.1]:44150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ul3rh-0004e4-2p for submit@debbugs.gnu.org; Sun, 10 Aug 2025 07:05:25 -0400 Received: from lists.gnu.org ([2001:470:142::17]:40490) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ul3re-0004dm-L8 for submit@debbugs.gnu.org; Sun, 10 Aug 2025 07:05:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ul3rY-00032i-SX for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2025 07:05:16 -0400 Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ul3rX-0007mt-Ff for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2025 07:05:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1754823913; bh=IingjzFYfoo5YC5M3qCsO4HpwSYe0j3tVr1e7ErwJtE=; h=From:To:Subject:Date:From; b=QPP4vdOGG4unZbESCj+pHR0nldH7+UzC3ENIiGfNkE+fuRrWChDu1jYjlAseG3iFr nsopF4hzkQLQi1IOKLhovnkAkYgdBLfmXeLQqUD7bjpisSY5sQGFjb5G+nvuTWs5br xfImrJbVR5jYxmm9VWRMos4Vl62J4CJteraCk506++SGOfGHNJnQRSH81QtSv2L5pX 8XnjC/ZPMY9+JQgVzjz2ty4xbGzBOHmwUu+LFOOwrTCPz6PdKlBZCyEcyp6dTdjA7n vVyTPbLNyktEQThs5LdJbOS5hR4Ig+gZ/NFurOzXo/ks8zl2FCwyqcUieBzKcT6kCP m28cMEYLEI5VA== From: Eshel Yaron To: bug-gnu-emacs@gnu.org Subject: [PATCH] (setq-default,setopt): Warn about unknown vars. Date: Sun, 10 Aug 2025 13:05:08 +0200 Message-ID: <871ppj8mjf.fsf@mail.eshelyaron.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@eshelyaron.com; helo=eshelyaron.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch Hi, This patch makes the byte-compiler (and by extension, Flymake), emit warnings when setq-default and setopt are used to set the value of unknown variables, similarly to the warnings we get with setq. Ideally we should do something similar for setq-local, but AFAICT that requires a different solution due to different implementation details. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-setq-default-setopt-Warn-about-unknown-vars.patch >From 36bd5ddae0c4f02081b6171ceb59f2c23605b440 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 10 Aug 2025 12:47:00 +0200 Subject: [PATCH] (setq-default,setopt): Warn about unknown vars. --- lisp/emacs-lisp/bytecomp.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index cbfca753b30..1a7f10b739b 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -4390,6 +4390,8 @@ byte-compile-set-default (if (eq (car-safe varexp) 'quote) ;; If the varexp is constant, check the var's name. (let ((var (car-safe (cdr varexp)))) + (when (symbolp var) + (byte-compile-free-vars-warn var var t)) (and (or (not (symbolp var)) (macroexp--const-symbol-p var t)) (byte-compile-warning-enabled-p 'constants @@ -4401,6 +4403,8 @@ byte-compile-set-default var)))) (byte-compile-normal-call form))) +(byte-defop-compiler-1 setopt--set byte-compile-set-default) + (defun byte-compile-quote (form) (byte-compile-constant (car (cdr form)))) -- 2.47.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 10 07:59:48 2025 Received: (at 79208) by debbugs.gnu.org; 10 Aug 2025 11:59:48 +0000 Received: from localhost ([127.0.0.1]:44241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ul4iK-0001T6-GQ for submit@debbugs.gnu.org; Sun, 10 Aug 2025 07:59:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54618) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ul4iH-0001Sm-UZ for 79208@debbugs.gnu.org; Sun, 10 Aug 2025 07:59:46 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ul4iC-0007Db-2j; Sun, 10 Aug 2025 07:59:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=C13z3Gy77kM3W23duqKnePvXNhknsRDDVBmy4z6OLBI=; b=ppnc3dgE5R8j cG51xn7+U7SObGrcADeLrX2u10x/YNUvJX2NFO2fVBe+sSSBmm8pehFFXh5ju6msy3BrHK/C2fTrO of1kUpGvcy5Np4eJAeYKd6gWCNwuFzxj4kbnc+5JTO3TS0u8zx70im0wLYXozhphcREAkS9EBN3ME Sd1ZrKtFyxCjGbORGP2QUf0Hpec3Hrd4Y2E8mjQgXxqHosFX1KpKbjfBTBKKBUDWWyQtSfPhWuTtK KQoT+DKDsFrTtsqnPQCmDHvwJFREaiY3zDecw+Pjms6feSSap4h+7dPO+nHbD4Bz23hnRTSptaSGy wLIghX10zXW2yP+XCTkLkA==; Date: Sun, 10 Aug 2025 14:59:37 +0300 Message-Id: <86frdzjsk6.fsf@gnu.org> From: Eli Zaretskii To: Eshel Yaron , Stefan Monnier In-Reply-To: <871ppj8mjf.fsf@mail.eshelyaron.com> (bug-gnu-emacs@gnu.org) Subject: Re: bug#79208: [PATCH] (setq-default, setopt): Warn about unknown vars. References: <871ppj8mjf.fsf@mail.eshelyaron.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79208 Cc: 79208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sun, 10 Aug 2025 13:05:08 +0200 > From: Eshel Yaron via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > This patch makes the byte-compiler (and by extension, Flymake), emit > warnings when setq-default and setopt are used to set the value of > unknown variables, similarly to the warnings we get with setq. > > Ideally we should do something similar for setq-local, but AFAICT that > requires a different solution due to different implementation details. Stefan, any comments? From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 11 04:53:42 2025 Received: (at 79208) by debbugs.gnu.org; 11 Aug 2025 08:53:42 +0000 Received: from localhost ([127.0.0.1]:47048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ulOHm-0007ZV-32 for submit@debbugs.gnu.org; Mon, 11 Aug 2025 04:53:42 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64349) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ulOHh-0007ZC-GL for 79208@debbugs.gnu.org; Mon, 11 Aug 2025 04:53:39 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 89A4080A42; Mon, 11 Aug 2025 04:53:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1754902404; bh=SW2TRovcQrNU5qT9IJ0sssuVlX6MymaJ54OL33HKYvk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=F1bPISQ1kgmnHoqc18IWpxEbvtNXYyQYdDsgaEUktVGooARYQTzJ7ym1VzB8nvfje uVYIotEghiM9zEqW/yuuk5pCd9JG7cZy1keE8Hy4xMZbn0p0w19rYb7k0WH29XthZX 7c2PZP30kg5VyWjldp7LpA22oKxrAoeR8tJtWVk8jNAI3ImImPMR4bFJCNg8SFJBYq lIy74V8bD00P4ATQ7nUfT0Q0CSMco8M6Jm/n6+cYB4FxMv1//XE1/FMjQV4HH9BBtI DJSCPU5QpRk46B6ipDUPFyeiPZGvtIKJa99whb7yiIhrOJejrc3xd13Tm2B3voTP2I RM31v+qiiDQ8Q== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 80A7F80185; Mon, 11 Aug 2025 04:53:24 -0400 (EDT) Received: from asado (dyn.144-85-254-173.dsl.vtx.ch [144.85.254.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6BB31120977; Mon, 11 Aug 2025 04:53:23 -0400 (EDT) From: Stefan Monnier To: Eshel Yaron Subject: Re: bug#79208: [PATCH] (setq-default, setopt): Warn about unknown vars. In-Reply-To: <871ppj8mjf.fsf@mail.eshelyaron.com> Message-ID: References: <871ppj8mjf.fsf@mail.eshelyaron.com> Date: Mon, 11 Aug 2025 04:53:21 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.006 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79208 Cc: 79208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > This patch makes the byte-compiler (and by extension, Flymake), emit > warnings when setq-default and setopt are used to set the value of > unknown variables, similarly to the warnings we get with setq. I think this is probably OK for `setq-default` but for `setopt` I'm not sure it's a good idea: `setopt` is expected to be rarely used in ELisp packages and more often in user init files. User init files normally lack the "needed" `require`s to silence those warnings, so it risks just increasing the amount of false positives. We should try and come up with some way for the byte-compiler to emit useful warnings when compiling init files, but AFAIK we don't have that yet. > Ideally we should do something similar for setq-local, but AFAICT that > requires a different solution due to different implementation details. Adding the warning for `setq-local` risks a similar problem: it's fairly common for major modes to `setq-local` some vars for optional third-party packages, which may not even be installed. AFAIK we don't really have a good answer for those problems either, the only "solution" we have would be `with-suppressed-warnings`. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 11 07:11:30 2025 Received: (at 79208) by debbugs.gnu.org; 11 Aug 2025 11:11:30 +0000 Received: from localhost ([127.0.0.1]:47292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ulQR8-0005jK-6s for submit@debbugs.gnu.org; Mon, 11 Aug 2025 07:11:30 -0400 Received: from mail.eshelyaron.com ([107.175.124.16]:56678 helo=eshelyaron.com) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ulQR0-0005iu-7F for 79208@debbugs.gnu.org; Mon, 11 Aug 2025 07:11:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1754910680; bh=Id6aFzL36TjvSKdAvl6pY8M5YElYlso7g4y41YpvbAM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=tCvBsbqLFMFuFt0HaAw3a9shdEp+TiDVBz933dA5V9DMivJx6bvNdRQcMOFd/y/S1 wpYgI36l1TekfsajkDtd1J+pseqOtj2nYpDSI7j39R7beoEhBm9ux9Ww5dw4dJuAXD 5wWjj4ndoPldkwZYVu2iDHMgJxjFHxt3zUjje32V4Qu8wbTKandeWrioFo/ZqV9dcQ XNUHGFvomN0Sw7amuOmvasRot+w0JVi4Y7Sn54202I5yWdlfOhsCN+BoEqgIa0SJXG WlMV2lDhQCc4HnHqupNP2dMed1kzeJDDZpHJ9Za5Q+HuqXiuXIYOMZhvJFzMAkoUca eaRAk/r5GDrBA== From: Eshel Yaron To: Stefan Monnier Subject: Re: bug#79208: [PATCH] (setq-default, setopt): Warn about unknown vars. In-Reply-To: References: <871ppj8mjf.fsf@mail.eshelyaron.com> Date: Mon, 11 Aug 2025 13:11:14 +0200 Message-ID: <871ppi15bh.fsf@mail.eshelyaron.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 2.4 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Stefan Monnier writes: >> This patch makes the byte-compiler (and by extension, Flymake), emit >> warnings when setq-default and setopt are used to set the value of >> unknown variables, similarly to the warnings we get wit [...] Content analysis details: (2.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [107.175.124.16 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [107.175.124.16 listed in bl.score.senderscore.com] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 T_SPF_TEMPERROR SPF: test of record failed (temperror) 2.0 FORGED_SPF_HELO No description available. 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 79208 Cc: 79208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> This patch makes the byte-compiler (and by extension, Flymake), emit >> warnings when setq-default and setopt are used to set the value of >> unknown variables, similarly to the warnings we get with setq. > > I think this is probably OK for `setq-default` but for `setopt` I'm not > sure it's a good idea: `setopt` is expected to be rarely used in ELisp > packages and more often in user init files. User init files normally > lack the "needed" `require`s to silence those warnings, so it risks just > increasing the amount of false positives. Indeed, it's likely to surface false positives, and we should try to minimize those. But especially in init files, it's important to warn about typos in variable names, because users are more likely to be left puzzled by such a mistake than people doing more serious development. > We should try and come up with some way for the byte-compiler to emit > useful warnings when compiling init files, but AFAIK we don't have > that yet. > >> Ideally we should do something similar for setq-local, but AFAICT that >> requires a different solution due to different implementation details. > > Adding the warning for `setq-local` risks a similar problem: it's fairly > common for major modes to `setq-local` some vars for optional > third-party packages, which may not even be installed. Hmm, is it really a different situation from setq? > AFAIK we don't really have a good answer for those problems either, > the only "solution" we have would be `with-suppressed-warnings`. What about declaring these variables with unary defvar forms? (Not perfect either, of course, but it is also a solution, no?) Thanks, Eshel From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 12 04:10:22 2025 Received: (at 79208) by debbugs.gnu.org; 12 Aug 2025 08:10:22 +0000 Received: from localhost ([127.0.0.1]:51610 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ulk5N-0004th-SQ for submit@debbugs.gnu.org; Tue, 12 Aug 2025 04:10:22 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:44304) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ulk5J-0004sM-79 for 79208@debbugs.gnu.org; Tue, 12 Aug 2025 04:10:18 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 229A0440900; Tue, 12 Aug 2025 04:10:09 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1754986207; bh=pJ7mFRBi5vPw79n9YPAyj9IeSfcmoZX/LXtyZyaK640=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=EyW9jq8K5GYudP7fgXXzhn23FoLfAGiKhu+vjS4KA2WAoBuuKxcjY3XSiMVGx20IG u5vpWsx3/zIBwRcPmwlWdovSmKiZp7nqyNWIkB4VZ/XLlFRD7SHWxKJYLRCt87Nrah VbbrUHKaCSI6m9MNTDFiG2kS+Ns0MLHY7oC5ICRYau3VUxN+k1Zk3tpUY/3TTS+IOr 1SfIFkP1Gb2eg1jG/EX2kH+MbxdQ2ikNSr+hNoJzk1rgP9MScfI4MP5S7cACySCKZB 6dwkMpggKkbJwo2uGw1qFNeWwHR6p5xS1SMpSY8VWtPeUqgh9K16wM9L/2nryEvPKu RLT3Rp29ljeRg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D6042440879; Tue, 12 Aug 2025 04:10:07 -0400 (EDT) Received: from asado (dyn.144-85-254-173.dsl.vtx.ch [144.85.254.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D9E0D1201A9; Tue, 12 Aug 2025 04:10:06 -0400 (EDT) From: Stefan Monnier To: Eshel Yaron Subject: Re: bug#79208: [PATCH] (setq-default, setopt): Warn about unknown vars. In-Reply-To: <871ppi15bh.fsf@mail.eshelyaron.com> Message-ID: References: <871ppj8mjf.fsf@mail.eshelyaron.com> <871ppi15bh.fsf@mail.eshelyaron.com> Date: Tue, 12 Aug 2025 04:09:57 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.074 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79208 Cc: 79208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> I think this is probably OK for `setq-default` but for `setopt` I'm not >> sure it's a good idea: `setopt` is expected to be rarely used in ELisp >> packages and more often in user init files. User init files normally >> lack the "needed" `require`s to silence those warnings, so it risks just >> increasing the amount of false positives. > Indeed, it's likely to surface false positives, and we should try to > minimize those. But especially in init files, it's important to warn > about typos in variable names, because users are more likely to be left > puzzled by such a mistake than people doing more serious development. I know. It would be good to make it work, but currently in a "well" written init file, nothing is `require`d so the only `setopt` for which we'll get correct warnings are those applied to those variables that are preloaded. =F0=9F=99=81 >> We should try and come up with some way for the byte-compiler to emit >> useful warnings when compiling init files, but AFAIK we don't have >> that yet. When the init file uses `use-package` we could arrange for the macro to eagerly load the configured packages (but only when the init file is compiled), which should fix that at least for `use-package` users. >>> Ideally we should do something similar for setq-local, but AFAICT that >>> requires a different solution due to different implementation details. >> Adding the warning for `setq-local` risks a similar problem: it's fairly >> common for major modes to `setq-local` some vars for optional >> third-party packages, which may not even be installed.=20=20 > Hmm, is it really a different situation from setq? My impression is that the proportion of `setq-local` applied to variables of non-`require`d package is higher than for `setq`, yes. >> AFAIK we don't really have a good answer for those problems either, >> the only "solution" we have would be `with-suppressed-warnings`. > What about declaring these variables with unary defvar forms? > (Not perfect either, of course, but it is also a solution, no?) Indeed, that's another solution, but suffers from the same kind of inconveniences (e.g. when writing such `defvar`s or `with-suppressed-warnings`, I usually copy the name of the var from its use rather than from its definition, so any typo just gets duplicated and I won't be notified when the var becomes obsolete/renamed/deleted). Stefan