From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#18059: 24.3.92; defvar and special variables Date: Sat, 10 Feb 2018 14:29:52 -0500 Message-ID: <87mv0gbq33.fsf@users.sourceforge.net> References: <87ha2c7lxy.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1518290977 24470 195.159.176.226 (10 Feb 2018 19:29:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 10 Feb 2018 19:29:37 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: 18059@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 10 20:29:33 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekapl-0004sJ-36 for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Feb 2018 20:29:13 +0100 Original-Received: from localhost ([::1]:52453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekarm-0007Au-AR for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Feb 2018 14:31:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekarb-00076d-Ak for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 14:31:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekarX-0000P7-20 for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 14:31:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57586) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ekarW-0000OL-PV for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 14:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ekarW-0008Id-IK for bug-gnu-emacs@gnu.org; Sat, 10 Feb 2018 14:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Feb 2018 19:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18059 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18059-submit@debbugs.gnu.org id=B18059.151829100631765 (code B ref 18059); Sat, 10 Feb 2018 19:31:02 +0000 Original-Received: (at 18059) by debbugs.gnu.org; 10 Feb 2018 19:30:06 +0000 Original-Received: from localhost ([127.0.0.1]:37247 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekaqb-0008GH-So for submit@debbugs.gnu.org; Sat, 10 Feb 2018 14:30:06 -0500 Original-Received: from mail-io0-f193.google.com ([209.85.223.193]:32832) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekaqX-0008Ez-10; Sat, 10 Feb 2018 14:30:01 -0500 Original-Received: by mail-io0-f193.google.com with SMTP id n7so13369554iob.0; Sat, 10 Feb 2018 11:30:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=b66jI6zTMrcl16ZwQycQwgdx4QRbBXcsAqPa9KqTS0w=; b=mRJVKKXhxqj69Pup0lsS5t5ZTU8O5mvrj+56qYlNVBLc4Iq4hCW2FWiZ6MYPfbsWoP K8MCwkZSgP/kLWx3pDNZ7kokNwAhqB6piukbChPff3uD/5lee9AVNWiwDTpA3VxttXTs KoPJR4YLL7v3nQWRjcap0jyv7zEtkofWCsPnQ7sH6zAm703U6wWTYdmc10kQQVPhYti0 XXAm7vQrgrsDFdVVOgklcarJIXbSrjSvAQ0mrohaxTW5N06vV0xdleHfsuN1HHdmaQlm GJ+XK9vHi5//CoPV6srCHdmWJhBaDoEuItWJnlLvl4GRmY/L9Khh9PEHiKsb48fDLxwq 2tWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=b66jI6zTMrcl16ZwQycQwgdx4QRbBXcsAqPa9KqTS0w=; b=SIc8UBu19TAixbnEGy6OHMVaCLb8rjYkwunVOonZJP4agYyGpZNML3DAVJUgy0s/6t Epn2Yo7xNa1gO4BRj+OCP67e9zAm+cx/P78iZ1XazjzSHe5bJOJu7lXKApfY8VWTIjAe sdUMsusZmJKYRo9bVjneH51XKImh7K4/9hm5/fjSlSvF+GqSESIQX5smhuDth3DSkJg9 cgnpCkxNhpBMtnQDFUoK+1rkVWPxYd1jn7E3qZ2BQPsXmf3lcZKmwxNEfXP+zheX5NBz v4xcj5BIjn9kzpe4OkkvhBfAAGU4RYEFY/pQuE6A7uhuvYTh2ATrGb0ZvIrgkBPU/xLA JCgQ== X-Gm-Message-State: APf1xPAGeecBoZnHVASTN+swtiQnABQOuoPxnf08kpSvA0ropCiwh862 FMnsrA6N1F+sR3aXWRcmjj6kCg== X-Google-Smtp-Source: AH8x224Oq8b232PU9FjRLMOeUPg7x6b876GKJry3nhpnIqqmM0Owg/jJHnPPG54J01tQVABiovajbQ== X-Received: by 10.107.5.129 with SMTP id 123mr7939547iof.281.1518290995104; Sat, 10 Feb 2018 11:29:55 -0800 (PST) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id o1sm6181251iob.64.2018.02.10.11.29.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Feb 2018 11:29:53 -0800 (PST) In-Reply-To: <87ha2c7lxy.fsf@web.de> (Michael Heerdegen's message of "Sun, 20 Jul 2014 05:23:21 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:143107 Archived-At: --=-=-= Content-Type: text/plain tags 18059 + patch quit Michael Heerdegen writes: >>>From eval.c: > > /* A simple (defvar foo) with lexical scoping does "nothing" except > declare that var to be dynamically scoped *locally* (i.e. within > the current file or let-block). */ > > This behavior isn't obvious, so it should be mentioned in the docstring > of "defvar" and in > > (info "(elisp) Defining Variables") How about this: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Explain-more-about-defvar-foo-form-Bug-18059.patch Content-Description: patch >From c284028ba554fb4292d3a3ef275351d5f2dda80e Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 10 Feb 2018 14:06:05 -0500 Subject: [PATCH] Explain more about (defvar foo) form (Bug#18059) * doc/lispref/variables.texi (Defining Variables): * doc/lispref/compile.texi (Compiler Errors): Emphasize that omitting VALUE for `defvar' marks the variable special only locally. --- doc/lispref/compile.texi | 4 ++-- doc/lispref/variables.texi | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index 0e39866d34..77d35be1ba 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi @@ -500,8 +500,8 @@ Compiler Errors @item Likewise, you can tell the compiler that a variable is defined using @code{defvar} with no initial value. (Note that this marks the -variable as special, i.e.@: dynamically bound.) @xref{Defining -Variables}. +variable as special, i.e.@: dynamically bound, but only within the +file.) @xref{Defining Variables}. @end itemize You can also suppress any and all compiler warnings within a certain diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index e025d3fd10..cd9e1afc97 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -442,9 +442,13 @@ Defining Variables evaluated and @var{symbol} is set to the result. But if @var{symbol} is not void, @var{value} is not evaluated, and @var{symbol}'s value is left unchanged. If @var{value} is omitted, the value of @var{symbol} -is not changed in any case. Using @code{defvar} with no value is one -method of suppressing byte compilation warnings, see @ref{Compiler -Errors}. +is not changed in any case. + +Note that specifying a value, even @code{nil}, marks the variable as +special permanently. Whereas if @var{value} is omitted then the +variable is only marked special locally (i.e. within the current file +or let-block). This can be useful for suppressing byte compilation +warnings, see @ref{Compiler Errors}. If @var{symbol} has a buffer-local binding in the current buffer, @code{defvar} acts on the default value, which is buffer-independent, -- 2.11.0 --=-=-=--