unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 18059@debbugs.gnu.org
Subject: bug#18059: 24.3.92; defvar and special variables
Date: Sat, 10 Feb 2018 14:29:52 -0500	[thread overview]
Message-ID: <87mv0gbq33.fsf@users.sourceforge.net> (raw)
In-Reply-To: <87ha2c7lxy.fsf@web.de> (Michael Heerdegen's message of "Sun, 20 Jul 2014 05:23:21 +0200")

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

tags 18059 + patch
quit

Michael Heerdegen <michael_heerdegen@web.de> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2218 bytes --]

From c284028ba554fb4292d3a3ef275351d5f2dda80e Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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


  reply	other threads:[~2018-02-10 19:29 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-20  3:23 bug#18059: 24.3.92; defvar and special variables Michael Heerdegen
2018-02-10 19:29 ` Noam Postavsky [this message]
2018-02-10 23:59   ` Michael Heerdegen
2018-02-11  0:17     ` Drew Adams
2018-02-11  0:43       ` Noam Postavsky
2018-02-11  0:38     ` Noam Postavsky
2018-02-11  1:32       ` Michael Heerdegen
2018-02-11  2:26         ` Noam Postavsky
2018-02-11 15:14       ` Stefan Monnier
2018-02-11 15:35         ` Noam Postavsky
2018-02-11 16:38           ` Michael Heerdegen
2018-02-11 17:00             ` Noam Postavsky
2018-02-14  0:27           ` Noam Postavsky
2018-02-18 22:28             ` Noam Postavsky
2018-02-19  1:44               ` Michael Heerdegen
2018-02-21 15:09                 ` Noam Postavsky
2018-02-21 16:08                   ` Drew Adams
2018-02-21 16:23                     ` Noam Postavsky
2018-02-21 16:33                       ` Noam Postavsky
2018-02-21 17:15                         ` Drew Adams
2018-02-21 18:00                           ` Noam Postavsky
2018-02-21 19:14                             ` Drew Adams
2018-02-21 19:19                             ` Stefan Monnier
2018-02-21 22:20                               ` Michael Heerdegen
2018-02-23 14:05                                 ` Stefan Monnier
2018-02-23 14:55                                   ` Michael Heerdegen
2018-03-04 23:27                                     ` Noam Postavsky
2018-03-05  9:51                                       ` Michael Heerdegen
2018-03-07 13:00                                         ` Noam Postavsky
2018-03-09  9:58                                           ` Michael Heerdegen
2018-03-09 13:43                                             ` Stefan Monnier
2018-03-11 16:45                                               ` Noam Postavsky
2018-03-11 22:16                                                 ` Drew Adams
2018-03-14 11:15                                                   ` Noam Postavsky
2018-03-23 12:23                                                     ` Noam Postavsky
2018-03-05 15:57                                       ` Eli Zaretskii
2018-03-08 23:36                             ` Noam Postavsky
2018-03-09  0:15                               ` Drew Adams
2018-02-21 17:11                       ` Drew Adams
2018-02-11 15:57     ` Eli Zaretskii

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=87mv0gbq33.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=18059@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).