[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lispref/variables.texi
From: |
Richard M. Stallman |
Subject: |
[Emacs-diffs] Changes to emacs/lispref/variables.texi |
Date: |
Wed, 04 Jun 2003 05:25:00 -0400 |
Index: emacs/lispref/variables.texi
diff -c emacs/lispref/variables.texi:1.38 emacs/lispref/variables.texi:1.39
*** emacs/lispref/variables.texi:1.38 Tue Feb 4 09:47:54 2003
--- emacs/lispref/variables.texi Wed Jun 4 05:25:00 2003
***************
*** 1184,1199 ****
be changed with @code{setq} in any buffer; the only way to change it is
with @code{setq-default}.
! @strong{Warning:} When a variable has buffer-local values in one or
! more buffers, binding the variable with @code{let} and changing to a
! different current buffer in which a different binding is in
! effect, and then exiting the @code{let}, the variable may not be
! restored to the value it had before the @code{let}.
!
! To preserve your sanity, avoid using a variable in that way. If you
! use @code{save-excursion} around each piece of code that changes to a
! different current buffer, you will not have this problem
! (@pxref{Excursions}). Here is an example of what to avoid:
@example
@group
--- 1184,1200 ----
be changed with @code{setq} in any buffer; the only way to change it is
with @code{setq-default}.
! @strong{Warning:} When a variable has buffer-local or frame-local
! bindings in one or more buffers, @code{let} rebinds the binding that's
! currently in effect. For instance, if the current buffer has a
! buffer-local value, @code{let} temporarily rebinds that. If no
! buffer-local or frame-local bindings are in effect, @code{let} rebinds
! the default value. If inside the @code{let} you then change to a
! different current buffer in which a different binding is in effect,
! you won't see the @code{let} binding any more. And if you exit the
! @code{let} while still in the other buffer, you won't see the
! unbinding occur (though it will occur properly). Here is an example
! to illustrate:
@example
@group
***************
*** 1208,1231 ****
;; foo @result{} 'g ; @r{the global value since foo is not local in
@samp{b}}
@address@hidden)
@group
! foo @result{} 'a ; @r{we are still in buffer @samp{b}, but exiting the
let}
! ; @r{restored the local value in buffer @samp{a}}
@end group
@group
! (set-buffer "a") ; @r{This can be seen here:}
! foo @result{} 'a ; @r{we are back to the local value in buffer
@samp{a}}
! @end group
! @end example
!
! @noindent
! But @code{save-excursion} as shown here avoids the problem:
!
! @example
! @group
! (let ((foo 'temp))
! (save-excursion
! (set-buffer "b")
! @address@hidden))
@end group
@end example
--- 1209,1220 ----
;; foo @result{} 'g ; @r{the global value since foo is not local in
@samp{b}}
@address@hidden)
@group
! foo @result{} 'g ; @r{exiting restored the local value in buffer
@samp{a},}
! ; @r{but we don't see that in buffer @samp{b}}
@end group
@group
! (set-buffer "a") ; @r{verify the local value was restored}
! foo @result{} 'a
@end group
@end example
- [Emacs-diffs] Changes to emacs/lispref/variables.texi,
Richard M. Stallman <=