aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2007-10-24 08:20:03 +0000
committerRichard M. Stallman2007-10-24 08:20:03 +0000
commite388c68f041fd7133bce398e5cb499b3687f8aa5 (patch)
tree46b28a4c2aa8a77d5f289f59aac6be20fc224efa
parent17bec671b52712738c33805b5e1c2cb9f95da7d8 (diff)
downloademacs-e388c68f041fd7133bce398e5cb499b3687f8aa5.tar.gz
emacs-e388c68f041fd7133bce398e5cb499b3687f8aa5.zip
(Frame-Local Variables): Node deleted.
(Variables): Delete Frame-Local Variables from menu. (Local Variables, Buffer-Local Variables, Intro to Buffer-Local) (Default Value): Don't mention frame-local vars.
-rw-r--r--lispref/variables.texi141
1 files changed, 14 insertions, 127 deletions
diff --git a/lispref/variables.texi b/lispref/variables.texi
index 9d9dc8260bb..b90492bf6be 100644
--- a/lispref/variables.texi
+++ b/lispref/variables.texi
@@ -39,7 +39,6 @@ variable.
39* Setting Variables:: Storing new values in variables. 39* Setting Variables:: Storing new values in variables.
40* Variable Scoping:: How Lisp chooses among local and global values. 40* Variable Scoping:: How Lisp chooses among local and global values.
41* Buffer-Local Variables:: Variable values in effect only in one buffer. 41* Buffer-Local Variables:: Variable values in effect only in one buffer.
42* Frame-Local Variables:: Variable values in effect only in one frame.
43* Future Local Variables:: New kinds of local values we might add some day. 42* Future Local Variables:: New kinds of local values we might add some day.
44* File Local Variables:: Handling local variable lists in files. 43* File Local Variables:: Handling local variable lists in files.
45* Variable Aliases:: Variables that are aliases for other variables. 44* Variable Aliases:: Variables that are aliases for other variables.
@@ -255,11 +254,10 @@ Macro calls (@pxref{Macros}).
255@end itemize 254@end itemize
256 255
257 Variables can also have buffer-local bindings (@pxref{Buffer-Local 256 Variables can also have buffer-local bindings (@pxref{Buffer-Local
258Variables}) and frame-local bindings (@pxref{Frame-Local Variables}); a 257Variables}); a few variables have terminal-local bindings
259few variables have terminal-local bindings (@pxref{Multiple Displays}). 258(@pxref{Multiple Displays}). These kinds of bindings work somewhat
260These kinds of bindings work somewhat like ordinary local bindings, but 259like ordinary local bindings, but they are localized depending on
261they are localized depending on ``where'' you are in Emacs, rather than 260``where'' you are in Emacs, rather than localized in time.
262localized in time.
263 261
264@defvar max-specpdl-size 262@defvar max-specpdl-size
265@anchor{Definition of max-specpdl-size} 263@anchor{Definition of max-specpdl-size}
@@ -1085,16 +1083,12 @@ use short names like @code{x}.
1085@cindex buffer-local variables 1083@cindex buffer-local variables
1086 1084
1087 Global and local variable bindings are found in most programming 1085 Global and local variable bindings are found in most programming
1088languages in one form or another. Emacs, however, also supports additional, 1086languages in one form or another. Emacs, however, also supports
1089unusual kinds of variable binding: @dfn{buffer-local} bindings, which 1087additional, unusual kinds of variable binding, such as
1090apply only in one buffer, and @dfn{frame-local} bindings, which apply only in 1088@dfn{buffer-local} bindings, which apply only in one buffer. Having
1091one frame. Having different values for a variable in different buffers 1089different values for a variable in different buffers is an important
1092and/or frames is an important customization method. 1090customization method. (A few variables have bindings that are local
1093 1091to each terminal; see @ref{Multiple Displays}.)
1094 This section describes buffer-local bindings; for frame-local
1095bindings, see the following section, @ref{Frame-Local Variables}. (A few
1096variables have bindings that are local to each terminal; see
1097@ref{Multiple Displays}.)
1098 1092
1099@menu 1093@menu
1100* Intro to Buffer-Local:: Introduction and concepts. 1094* Intro to Buffer-Local:: Introduction and concepts.
@@ -1121,8 +1115,7 @@ this is the global binding.
1121other buffers. The default binding is shared by all the buffers that 1115other buffers. The default binding is shared by all the buffers that
1122don't have their own bindings for the variable. (This includes all 1116don't have their own bindings for the variable. (This includes all
1123newly-created buffers.) If you set the variable in a buffer that does 1117newly-created buffers.) If you set the variable in a buffer that does
1124not have a buffer-local binding for it, this sets the default binding 1118not have a buffer-local binding for it, this sets the default binding,
1125(assuming there are no frame-local bindings to complicate the matter),
1126so the new value is visible in all the buffers that see the default 1119so the new value is visible in all the buffers that see the default
1127binding. 1120binding.
1128 1121
@@ -1153,11 +1146,11 @@ the default binding untouched. This means that the default value cannot
1153be changed with @code{setq} in any buffer; the only way to change it is 1146be changed with @code{setq} in any buffer; the only way to change it is
1154with @code{setq-default}. 1147with @code{setq-default}.
1155 1148
1156 @strong{Warning:} When a variable has buffer-local or frame-local 1149 @strong{Warning:} When a variable has buffer-local
1157bindings in one or more buffers, @code{let} rebinds the binding that's 1150bindings in one or more buffers, @code{let} rebinds the binding that's
1158currently in effect. For instance, if the current buffer has a 1151currently in effect. For instance, if the current buffer has a
1159buffer-local value, @code{let} temporarily rebinds that. If no 1152buffer-local value, @code{let} temporarily rebinds that. If no
1160buffer-local or frame-local bindings are in effect, @code{let} rebinds 1153buffer-local bindings are in effect, @code{let} rebinds
1161the default value. If inside the @code{let} you then change to a 1154the default value. If inside the @code{let} you then change to a
1162different current buffer in which a different binding is in effect, 1155different current buffer in which a different binding is in effect,
1163you won't see the @code{let} binding any more. And if you exit the 1156you won't see the @code{let} binding any more. And if you exit the
@@ -1421,7 +1414,7 @@ this variable.
1421@c Emacs 19 feature 1414@c Emacs 19 feature
1422 The special forms @code{defvar} and @code{defconst} also set the 1415 The special forms @code{defvar} and @code{defconst} also set the
1423default value (if they set the variable at all), rather than any 1416default value (if they set the variable at all), rather than any
1424buffer-local or frame-local value. 1417buffer-local value.
1425 1418
1426@defun default-value symbol 1419@defun default-value symbol
1427This function returns @var{symbol}'s default value. This is the value 1420This function returns @var{symbol}'s default value. This is the value
@@ -1520,112 +1513,6 @@ an ordinary evaluated argument.
1520@end example 1513@end example
1521@end defun 1514@end defun
1522 1515
1523@node Frame-Local Variables
1524@section Frame-Local Variables
1525@cindex frame-local variables
1526
1527 Just as variables can have buffer-local bindings, they can also have
1528frame-local bindings. These bindings belong to one frame, and are in
1529effect when that frame is selected. Frame-local bindings are actually
1530frame parameters: you create a frame-local binding in a specific frame
1531by calling @code{modify-frame-parameters} and specifying the variable
1532name as the parameter name.
1533
1534 To enable frame-local bindings for a certain variable, call the function
1535@code{make-variable-frame-local}.
1536
1537@deffn Command make-variable-frame-local variable
1538Enable the use of frame-local bindings for @var{variable}. This does
1539not in itself create any frame-local bindings for the variable; however,
1540if some frame already has a value for @var{variable} as a frame
1541parameter, that value automatically becomes a frame-local binding.
1542
1543If @var{variable} does not have a default value, then calling this
1544command will give it a default value of @code{nil}. If @var{variable}
1545already has a default value, that value remains unchanged.
1546
1547If the variable is terminal-local, this function signals an error,
1548because such variables cannot have frame-local bindings as well.
1549@xref{Multiple Displays}. A few variables that are implemented
1550specially in Emacs can be buffer-local, but can never be frame-local.
1551
1552This command returns @var{variable}.
1553@end deffn
1554
1555 Buffer-local bindings take precedence over frame-local bindings. Thus,
1556consider a variable @code{foo}: if the current buffer has a buffer-local
1557binding for @code{foo}, that binding is active; otherwise, if the
1558selected frame has a frame-local binding for @code{foo}, that binding is
1559active; otherwise, the default binding of @code{foo} is active.
1560
1561 Here is an example. First we prepare a few bindings for @code{foo}:
1562
1563@example
1564(setq f1 (selected-frame))
1565(make-variable-frame-local 'foo)
1566
1567;; @r{Make a buffer-local binding for @code{foo} in @samp{b1}.}
1568(set-buffer (get-buffer-create "b1"))
1569(make-local-variable 'foo)
1570(setq foo '(b 1))
1571
1572;; @r{Make a frame-local binding for @code{foo} in a new frame.}
1573;; @r{Store that frame in @code{f2}.}
1574(setq f2 (make-frame))
1575(modify-frame-parameters f2 '((foo . (f 2))))
1576@end example
1577
1578 Now we examine @code{foo} in various contexts. Whenever the
1579buffer @samp{b1} is current, its buffer-local binding is in effect,
1580regardless of the selected frame:
1581
1582@example
1583(select-frame f1)
1584(set-buffer (get-buffer-create "b1"))
1585foo
1586 @result{} (b 1)
1587
1588(select-frame f2)
1589(set-buffer (get-buffer-create "b1"))
1590foo
1591 @result{} (b 1)
1592@end example
1593
1594@noindent
1595Otherwise, the frame gets a chance to provide the binding; when frame
1596@code{f2} is selected, its frame-local binding is in effect:
1597
1598@example
1599(select-frame f2)
1600(set-buffer (get-buffer "*scratch*"))
1601foo
1602 @result{} (f 2)
1603@end example
1604
1605@noindent
1606When neither the current buffer nor the selected frame provides
1607a binding, the default binding is used:
1608
1609@example
1610(select-frame f1)
1611(set-buffer (get-buffer "*scratch*"))
1612foo
1613 @result{} nil
1614@end example
1615
1616@noindent
1617When the active binding of a variable is a frame-local binding, setting
1618the variable changes that binding. You can observe the result with
1619@code{frame-parameters}:
1620
1621@example
1622(select-frame f2)
1623(set-buffer (get-buffer "*scratch*"))
1624(setq foo 'nobody)
1625(assq 'foo (frame-parameters f2))
1626 @result{} (foo . nobody)
1627@end example
1628
1629@node Future Local Variables 1516@node Future Local Variables
1630@section Possible Future Local Variables 1517@section Possible Future Local Variables
1631 1518