aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-11-07 13:22:10 +0800
committerChong Yidong2012-11-07 13:22:10 +0800
commit7c08f8ba7246ddd20f70e8306f646ac981a64f5a (patch)
treea993781f3c7748d3862c69b94aed6b6ae9f254d1
parent2ee1d59f5bea4a206595d621dcb63477461b7155 (diff)
downloademacs-7c08f8ba7246ddd20f70e8306f646ac981a64f5a.tar.gz
emacs-7c08f8ba7246ddd20f70e8306f646ac981a64f5a.zip
Document setf-local, defvar-local, and some doc updates for setf.
* doc/lispref/edebug.texi (Specification List): setf is no longer CL-only. * doc/lispref/lists.texi (List Elements, List Variables): Clarify descriptions of push and pop for generalized variables. * doc/lispref/variables.texi (Creating Buffer-Local): Document setq-local and defvar-local. (Setting Generalized Variables): Arrange table alphabetically.
-rw-r--r--doc/lispref/ChangeLog11
-rw-r--r--doc/lispref/edebug.texi4
-rw-r--r--doc/lispref/lists.texi44
-rw-r--r--doc/lispref/variables.texi33
-rw-r--r--etc/NEWS4
5 files changed, 63 insertions, 33 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 6e7a0b7a648..9af670dc6cc 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,14 @@
12012-11-07 Chong Yidong <cyd@gnu.org>
2
3 * variables.texi (Creating Buffer-Local): Document setq-local and
4 defvar-local.
5 (Setting Generalized Variables): Arrange table alphabetically.
6
7 * lists.texi (List Elements, List Variables): Clarify descriptions
8 of push and pop for generalized variables.
9
10 * edebug.texi (Specification List): setf is no longer CL-only.
11
12012-11-07 Glenn Morris <rgm@gnu.org> 122012-11-07 Glenn Morris <rgm@gnu.org>
2 13
3 * variables.texi (Adding Generalized Variables): 14 * variables.texi (Adding Generalized Variables):
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi
index 0211f9e1b9c..b5edda06bad 100644
--- a/doc/lispref/edebug.texi
+++ b/doc/lispref/edebug.texi
@@ -1211,9 +1211,7 @@ A single unevaluated Lisp object, which is not instrumented.
1211A single evaluated expression, which is instrumented. 1211A single evaluated expression, which is instrumented.
1212 1212
1213@item place 1213@item place
1214@c I can't see that this index entry is useful without any explanation. 1214A generalized variable. @xref{Generalized Variables}.
1215@c @findex edebug-unwrap
1216A place to store a value, as in the Common Lisp @code{setf} construct.
1217 1215
1218@item body 1216@item body
1219Short for @code{&rest form}. See @code{&rest} below. 1217Short for @code{&rest form}. See @code{&rest} below.
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi
index 458db838177..40e8d08f72c 100644
--- a/doc/lispref/lists.texi
+++ b/doc/lispref/lists.texi
@@ -234,17 +234,15 @@ This is in contrast to @code{cdr}, which signals an error if
234@end defun 234@end defun
235 235
236@defmac pop listname 236@defmac pop listname
237This macro is a way of examining the @sc{car} of a list, 237This macro provides a convenient way to examine the @sc{car} of a
238and taking it off the list, all at once. 238list, and take it off the list, all at once. It operates on the list
239@c FIXME I don't think is a particularly good way to do it, 239stored in @var{listname}. It removes the first element from the list,
240@c but generalized variables have not been introduced yet. 240saves the @sc{cdr} into @var{listname}, then returns the removed
241(In fact, this macro can act on generalized variables, not just lists. 241element.
242@xref{Generalized Variables}.) 242
243 243In the simplest case, @var{listname} is an unquoted symbol naming a
244It operates on the list which is stored in the symbol @var{listname}. 244list; in that case, this macro is equivalent to @w{@code{(prog1
245It removes this element from the list by setting @var{listname} 245(car listname) (setq listname (cdr listname)))}}.
246to the @sc{cdr} of its old value---but it also returns the @sc{car}
247of that list, which is the element being removed.
248 246
249@example 247@example
250x 248x
@@ -255,7 +253,10 @@ x
255 @result{} (b c) 253 @result{} (b c)
256@end example 254@end example
257 255
258@noindent 256More generally, @var{listname} can be a generalized variable. In that
257case, this macro saves into @var{listname} using @code{setf}.
258@xref{Generalized Variables}.
259
259For the @code{push} macro, which adds an element to a list, 260For the @code{push} macro, which adds an element to a list,
260@xref{List Variables}. 261@xref{List Variables}.
261@end defmac 262@end defmac
@@ -683,13 +684,12 @@ Some examples:
683 These functions, and one macro, provide convenient ways 684 These functions, and one macro, provide convenient ways
684to modify a list which is stored in a variable. 685to modify a list which is stored in a variable.
685 686
686@defmac push newelt listname 687@defmac push element listname
687This macro provides an alternative way to write 688This macro creates a new list whose @sc{car} is @var{element} and
688@code{(setq @var{listname} (cons @var{newelt} @var{listname}))}. 689whose @sc{cdr} is the list specified by @var{listname}, and saves that
689@c FIXME I don't think is a particularly good way to do it, 690list in @var{listname}. In the simplest case, @var{listname} is an
690@c but generalized variables have not been introduced yet. 691unquoted symbol naming a list, and this macro is equivalent
691(In fact, this macro can act on generalized variables, not just lists. 692to @w{@code{(setq @var{listname} (cons @var{element} @var{listname}))}}.
692@xref{Generalized Variables}.)
693 693
694@example 694@example
695(setq l '(a b)) 695(setq l '(a b))
@@ -700,7 +700,11 @@ l
700 @result{} (c a b) 700 @result{} (c a b)
701@end example 701@end example
702 702
703@noindent 703More generally, @code{listname} can be a generalized variable. In
704that case, this macro does the equivalent of @w{@code{(setf
705@var{listname} (cons @var{element} @var{listname}))}}.
706@xref{Generalized Variables}.
707
704For the @code{pop} macro, which removes the first element from a list, 708For the @code{pop} macro, which removes the first element from a list,
705@xref{List Elements}. 709@xref{List Elements}.
706@end defmac 710@end defmac
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index fb98b3cd035..c8451527d4f 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1262,6 +1262,13 @@ needed if you use the @var{local} argument to @code{add-hook} or
1262@code{remove-hook}. 1262@code{remove-hook}.
1263@end deffn 1263@end deffn
1264 1264
1265@defmac setq-local variable value
1266This macro creates a buffer-local binding in the current buffer for
1267@var{variable}, and gives it the buffer-local value @var{value}. It
1268is equivalent to calling @code{make-local-variable} followed by
1269@code{setq}. @var{variable} should be an unquoted symbol.
1270@end defmac
1271
1265@deffn Command make-variable-buffer-local variable 1272@deffn Command make-variable-buffer-local variable
1266This function marks @var{variable} (a symbol) automatically 1273This function marks @var{variable} (a symbol) automatically
1267buffer-local, so that any subsequent attempt to set it will make it 1274buffer-local, so that any subsequent attempt to set it will make it
@@ -1297,6 +1304,14 @@ on having separate values in separate buffers, then using
1297@code{make-variable-buffer-local} can be the best solution. 1304@code{make-variable-buffer-local} can be the best solution.
1298@end deffn 1305@end deffn
1299 1306
1307@defmac defvar-local variable value &optional docstring
1308This macro defines @var{variable} as a variable with initial value
1309@var{value} and @var{docstring}, and marks it as automatically
1310buffer-local. It is equivalent to calling @code{defvar} followed by
1311@code{make-variable-buffer-local}. @var{variable} should be an
1312unquoted symbol.
1313@end defmac
1314
1300@defun local-variable-p variable &optional buffer 1315@defun local-variable-p variable &optional buffer
1301This returns @code{t} if @var{variable} is buffer-local in buffer 1316This returns @code{t} if @var{variable} is buffer-local in buffer
1302@var{buffer} (which defaults to the current buffer); otherwise, 1317@var{buffer} (which defaults to the current buffer); otherwise,
@@ -1948,7 +1963,6 @@ Attempting to assign them any other value will result in an error:
1948@error{} Wrong type argument: integerp, 1000.0 1963@error{} Wrong type argument: integerp, 1000.0
1949@end example 1964@end example
1950 1965
1951@c FIXME? Not sure this is the right place for this section.
1952@node Generalized Variables 1966@node Generalized Variables
1953@section Generalized Variables 1967@section Generalized Variables
1954 1968
@@ -1958,7 +1972,6 @@ a regular Lisp variable. But the @sc{car}s and @sc{cdr}s of lists, elements
1958of arrays, properties of symbols, and many other locations are also 1972of arrays, properties of symbols, and many other locations are also
1959places where Lisp values are stored. 1973places where Lisp values are stored.
1960 1974
1961@c FIXME? Not sure this is a useful analogy...
1962Generalized variables are analogous to ``lvalues'' in the C 1975Generalized variables are analogous to ``lvalues'' in the C
1963language, where @samp{x = a[i]} gets an element from an array 1976language, where @samp{x = a[i]} gets an element from an array
1964and @samp{a[i] = x} stores an element using the same notation. 1977and @samp{a[i] = x} stores an element using the same notation.
@@ -2006,14 +2019,16 @@ so there is no performance penalty for using it in compiled code.
2006A call to any of the following standard Lisp functions: 2019A call to any of the following standard Lisp functions:
2007 2020
2008@smallexample 2021@smallexample
2009car cdr nth nthcdr 2022aref cddr symbol-function
2010caar cadr cdar cddr 2023car elt symbol-plist
2011aref elt get gethash 2024caar get symbol-value
2012symbol-function symbol-value symbol-plist 2025cadr gethash
2026cdr nth
2027cdar nthcdr
2013@end smallexample 2028@end smallexample
2014 2029
2015@item 2030@item
2016The following Emacs-specific functions are also @code{setf}-able: 2031A call to any of the following Emacs-specific functions:
2017 2032
2018@smallexample 2033@smallexample
2019default-value process-get 2034default-value process-get
@@ -2030,8 +2045,8 @@ process-filter
2030@end itemize 2045@end itemize
2031 2046
2032@noindent 2047@noindent
2033Using any forms other than these in the @var{place} argument to 2048@code{setf} signals an error if you pass a @var{place} form that it
2034@code{setf} will signal an error. 2049does not know how to handle.
2035 2050
2036@c And for cl-lib's cl-getf. 2051@c And for cl-lib's cl-getf.
2037Note that for @code{nthcdr}, the list argument of the function must 2052Note that for @code{nthcdr}, the list argument of the function must
diff --git a/etc/NEWS b/etc/NEWS
index be5de734636..7023ce5cb98 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -788,6 +788,7 @@ Try M-x profiler-start ... M-x profiler-stop; and then M-x profiler-report.
788The sampling rate can be based on CPU time (only supported on some 788The sampling rate can be based on CPU time (only supported on some
789systems), or based on memory allocations. 789systems), or based on memory allocations.
790 790
791+++
791** CL-style generalized variables are now in core Elisp. 792** CL-style generalized variables are now in core Elisp.
792`setf' is autoloaded; `push' and `pop' accept generalized variables. 793`setf' is autoloaded; `push' and `pop' accept generalized variables.
793You can define your own generalized variables using `gv-define-simple-setter', 794You can define your own generalized variables using `gv-define-simple-setter',
@@ -823,7 +824,7 @@ These do not trigger the debugger.
823*** Set `debug-on-message' to enter the debugger when a certain 824*** Set `debug-on-message' to enter the debugger when a certain
824message is displayed in the echo area. This can be useful when trying 825message is displayed in the echo area. This can be useful when trying
825to work out which code is doing something. 826to work out which code is doing something.
826 827---
827*** New var `inhibit-debugger', automatically set to prevent accidental 828*** New var `inhibit-debugger', automatically set to prevent accidental
828recursive invocations. 829recursive invocations.
829 830
@@ -936,6 +937,7 @@ describing the cycle.
936+++ 937+++
937*** `tty-top-frame' returns the topmost frame of a text terminal. 938*** `tty-top-frame' returns the topmost frame of a text terminal.
938 939
940+++
939** New macros `setq-local' and `defvar-local'. 941** New macros `setq-local' and `defvar-local'.
940 942
941+++ 943+++