diff options
| author | Chong Yidong | 2012-11-07 13:22:10 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-11-07 13:22:10 +0800 |
| commit | 7c08f8ba7246ddd20f70e8306f646ac981a64f5a (patch) | |
| tree | a993781f3c7748d3862c69b94aed6b6ae9f254d1 | |
| parent | 2ee1d59f5bea4a206595d621dcb63477461b7155 (diff) | |
| download | emacs-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/ChangeLog | 11 | ||||
| -rw-r--r-- | doc/lispref/edebug.texi | 4 | ||||
| -rw-r--r-- | doc/lispref/lists.texi | 44 | ||||
| -rw-r--r-- | doc/lispref/variables.texi | 33 | ||||
| -rw-r--r-- | etc/NEWS | 4 |
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 @@ | |||
| 1 | 2012-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 | |||
| 1 | 2012-11-07 Glenn Morris <rgm@gnu.org> | 12 | 2012-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. | |||
| 1211 | A single evaluated expression, which is instrumented. | 1211 | A 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. | 1214 | A generalized variable. @xref{Generalized Variables}. |
| 1215 | @c @findex edebug-unwrap | ||
| 1216 | A place to store a value, as in the Common Lisp @code{setf} construct. | ||
| 1217 | 1215 | ||
| 1218 | @item body | 1216 | @item body |
| 1219 | Short for @code{&rest form}. See @code{&rest} below. | 1217 | Short 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 |
| 237 | This macro is a way of examining the @sc{car} of a list, | 237 | This macro provides a convenient way to examine the @sc{car} of a |
| 238 | and taking it off the list, all at once. | 238 | list, 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, | 239 | stored in @var{listname}. It removes the first element from the list, |
| 240 | @c but generalized variables have not been introduced yet. | 240 | saves the @sc{cdr} into @var{listname}, then returns the removed |
| 241 | (In fact, this macro can act on generalized variables, not just lists. | 241 | element. |
| 242 | @xref{Generalized Variables}.) | 242 | |
| 243 | 243 | In the simplest case, @var{listname} is an unquoted symbol naming a | |
| 244 | It operates on the list which is stored in the symbol @var{listname}. | 244 | list; in that case, this macro is equivalent to @w{@code{(prog1 |
| 245 | It removes this element from the list by setting @var{listname} | 245 | (car listname) (setq listname (cdr listname)))}}. |
| 246 | to the @sc{cdr} of its old value---but it also returns the @sc{car} | ||
| 247 | of that list, which is the element being removed. | ||
| 248 | 246 | ||
| 249 | @example | 247 | @example |
| 250 | x | 248 | x |
| @@ -255,7 +253,10 @@ x | |||
| 255 | @result{} (b c) | 253 | @result{} (b c) |
| 256 | @end example | 254 | @end example |
| 257 | 255 | ||
| 258 | @noindent | 256 | More generally, @var{listname} can be a generalized variable. In that |
| 257 | case, this macro saves into @var{listname} using @code{setf}. | ||
| 258 | @xref{Generalized Variables}. | ||
| 259 | |||
| 259 | For the @code{push} macro, which adds an element to a list, | 260 | For 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 |
| 684 | to modify a list which is stored in a variable. | 685 | to modify a list which is stored in a variable. |
| 685 | 686 | ||
| 686 | @defmac push newelt listname | 687 | @defmac push element listname |
| 687 | This macro provides an alternative way to write | 688 | This macro creates a new list whose @sc{car} is @var{element} and |
| 688 | @code{(setq @var{listname} (cons @var{newelt} @var{listname}))}. | 689 | whose @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, | 690 | list in @var{listname}. In the simplest case, @var{listname} is an |
| 690 | @c but generalized variables have not been introduced yet. | 691 | unquoted symbol naming a list, and this macro is equivalent |
| 691 | (In fact, this macro can act on generalized variables, not just lists. | 692 | to @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 | 703 | More generally, @code{listname} can be a generalized variable. In |
| 704 | that case, this macro does the equivalent of @w{@code{(setf | ||
| 705 | @var{listname} (cons @var{element} @var{listname}))}}. | ||
| 706 | @xref{Generalized Variables}. | ||
| 707 | |||
| 704 | For the @code{pop} macro, which removes the first element from a list, | 708 | For 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 | ||
| 1266 | This macro creates a buffer-local binding in the current buffer for | ||
| 1267 | @var{variable}, and gives it the buffer-local value @var{value}. It | ||
| 1268 | is 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 |
| 1266 | This function marks @var{variable} (a symbol) automatically | 1273 | This function marks @var{variable} (a symbol) automatically |
| 1267 | buffer-local, so that any subsequent attempt to set it will make it | 1274 | buffer-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 | ||
| 1308 | This macro defines @var{variable} as a variable with initial value | ||
| 1309 | @var{value} and @var{docstring}, and marks it as automatically | ||
| 1310 | buffer-local. It is equivalent to calling @code{defvar} followed by | ||
| 1311 | @code{make-variable-buffer-local}. @var{variable} should be an | ||
| 1312 | unquoted symbol. | ||
| 1313 | @end defmac | ||
| 1314 | |||
| 1300 | @defun local-variable-p variable &optional buffer | 1315 | @defun local-variable-p variable &optional buffer |
| 1301 | This returns @code{t} if @var{variable} is buffer-local in buffer | 1316 | This 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 | |||
| 1958 | of arrays, properties of symbols, and many other locations are also | 1972 | of arrays, properties of symbols, and many other locations are also |
| 1959 | places where Lisp values are stored. | 1973 | places where Lisp values are stored. |
| 1960 | 1974 | ||
| 1961 | @c FIXME? Not sure this is a useful analogy... | ||
| 1962 | Generalized variables are analogous to ``lvalues'' in the C | 1975 | Generalized variables are analogous to ``lvalues'' in the C |
| 1963 | language, where @samp{x = a[i]} gets an element from an array | 1976 | language, where @samp{x = a[i]} gets an element from an array |
| 1964 | and @samp{a[i] = x} stores an element using the same notation. | 1977 | and @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. | |||
| 2006 | A call to any of the following standard Lisp functions: | 2019 | A call to any of the following standard Lisp functions: |
| 2007 | 2020 | ||
| 2008 | @smallexample | 2021 | @smallexample |
| 2009 | car cdr nth nthcdr | 2022 | aref cddr symbol-function |
| 2010 | caar cadr cdar cddr | 2023 | car elt symbol-plist |
| 2011 | aref elt get gethash | 2024 | caar get symbol-value |
| 2012 | symbol-function symbol-value symbol-plist | 2025 | cadr gethash |
| 2026 | cdr nth | ||
| 2027 | cdar nthcdr | ||
| 2013 | @end smallexample | 2028 | @end smallexample |
| 2014 | 2029 | ||
| 2015 | @item | 2030 | @item |
| 2016 | The following Emacs-specific functions are also @code{setf}-able: | 2031 | A call to any of the following Emacs-specific functions: |
| 2017 | 2032 | ||
| 2018 | @smallexample | 2033 | @smallexample |
| 2019 | default-value process-get | 2034 | default-value process-get |
| @@ -2030,8 +2045,8 @@ process-filter | |||
| 2030 | @end itemize | 2045 | @end itemize |
| 2031 | 2046 | ||
| 2032 | @noindent | 2047 | @noindent |
| 2033 | Using 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. | 2049 | does 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. |
| 2037 | Note that for @code{nthcdr}, the list argument of the function must | 2052 | Note that for @code{nthcdr}, the list argument of the function must |
| @@ -788,6 +788,7 @@ Try M-x profiler-start ... M-x profiler-stop; and then M-x profiler-report. | |||
| 788 | The sampling rate can be based on CPU time (only supported on some | 788 | The sampling rate can be based on CPU time (only supported on some |
| 789 | systems), or based on memory allocations. | 789 | systems), 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. |
| 793 | You can define your own generalized variables using `gv-define-simple-setter', | 794 | You 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 |
| 824 | message is displayed in the echo area. This can be useful when trying | 825 | message is displayed in the echo area. This can be useful when trying |
| 825 | to work out which code is doing something. | 826 | to 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 |
| 828 | recursive invocations. | 829 | recursive 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 | +++ |