[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18059: 24.3.92; defvar and special variables

From: Noam Postavsky
Subject: bug#18059: 24.3.92; defvar and special variables
Date: Sat, 10 Feb 2018 14:29:52 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

tags 18059 + patch

Michael Heerdegen <address@hidden> 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:

>From c284028ba554fb4292d3a3ef275351d5f2dda80e Mon Sep 17 00:00:00 2001
From: Noam Postavsky <address@hidden>
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
 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
+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
+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,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]