]> code.delx.au - gnu-emacs/blobdiff - doc/lispref/variables.texi
Merge from emacs-24; up to 2014-05-29T17:16:00Z!dmantipov@yandex.ru
[gnu-emacs] / doc / lispref / variables.texi
index 5d1a47661aa2c11df35d22f008c5d25cc3e933ee..e890dbce359625044057ccb0a292701995c13a14 100644 (file)
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990-1995, 1998-2013 Free Software Foundation, Inc.
+@c Copyright (C) 1990-1995, 1998-2014 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Variables
 @chapter Variables
@@ -416,18 +416,23 @@ explicitly in the @code{defvar} form.  The variable is marked as
 @dfn{special}, meaning that it should always be dynamically bound
 (@pxref{Variable Scoping}).
 
-If @var{symbol} is void and @var{value} is specified, @code{defvar}
-evaluates @var{value} and sets @var{symbol} to the result.  But if
-@var{symbol} already has a value (i.e., it is not void), @var{value}
-is not even evaluated, and @var{symbol}'s value remains unchanged.  If
-@var{value} is omitted, the value of @var{symbol} is not changed in
-any case.
+If @var{value} is specified, and @var{symbol} is void (i.e., it has no
+dynamically bound value; @pxref{Void Variables}), then @var{value} is
+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.
 
 If @var{symbol} has a buffer-local binding in the current buffer,
-@code{defvar} operates on the default value, which is buffer-independent,
-not the current (buffer-local) binding.  It sets the default value if
+@code{defvar} acts on the default value, which is buffer-independent,
+rather than the buffer-local binding.  It sets the default value if
 the default value is void.  @xref{Buffer-Local Variables}.
 
+If @var{symbol} is already lexically bound (e.g., if the @code{defvar}
+form occurs in a @code{let} form with lexical binding enabled), then
+@code{defvar} sets the dynamic value.  The lexical binding remains in
+effect until its binding construct exits.  @xref{Variable Scoping}.
+
 When you evaluate a top-level @code{defvar} form with @kbd{C-M-x} in
 Emacs Lisp mode (@code{eval-defun}), a special feature of
 @code{eval-defun} arranges to set the variable unconditionally, without
@@ -823,7 +828,7 @@ following example:
 
 @example
 @group
-(defvar x -99)  ; @r{@code{x} receives an initial value of -99.}
+(defvar x -99)  ; @r{@code{x} receives an initial value of @minus{}99.}
 
 (defun getx ()
   x)            ; @r{@code{x} is used ``free'' in this function.}
@@ -833,7 +838,7 @@ following example:
      @result{} 1
 
 ;; @r{After the @code{let} form finishes, @code{x} reverts to its}
-;; @r{previous value, which is -99.}
+;; @r{previous value, which is @minus{}99.}
 
 (getx)
      @result{} -99
@@ -847,14 +852,14 @@ that @code{defun} construct itself.  When we call @code{getx} from
 within a @code{let} form in which @code{x} is (dynamically) bound, it
 retrieves the local value (i.e., 1).  But when we call @code{getx}
 outside the @code{let} form, it retrieves the global value (i.e.,
--99).
+@minus{}99).
 
   Here is another example, which illustrates setting a dynamically
 bound variable using @code{setq}:
 
 @example
 @group
-(defvar x -99)      ; @r{@code{x} receives an initial value of -99.}
+(defvar x -99)      ; @r{@code{x} receives an initial value of @minus{}99.}
 
 (defun addx ()
   (setq x (1+ x)))  ; @r{Add 1 to @code{x} and return its new value.}
@@ -865,7 +870,7 @@ bound variable using @code{setq}:
      @result{} 3           ; @r{The two @code{addx} calls add to @code{x} twice.}
 
 ;; @r{After the @code{let} form finishes, @code{x} reverts to its}
-;; @r{previous value, which is -99.}
+;; @r{previous value, which is @minus{}99.}
 
 (addx)
      @result{} -98
@@ -1971,7 +1976,7 @@ will set them to @code{t}:
 This variable holds a list of all variables of type @code{DEFVAR_BOOL}.
 @end defvar
 
-  Variables of type @code{DEFVAR_INT} can only take on integer values.
+  Variables of type @code{DEFVAR_INT} can take on only integer values.
 Attempting to assign them any other value will result in an error:
 
 @example