aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lispref')
-rw-r--r--doc/lispref/ChangeLog20
-rw-r--r--doc/lispref/control.texi14
-rw-r--r--doc/lispref/numbers.texi32
-rw-r--r--doc/lispref/positions.texi3
-rw-r--r--doc/lispref/windows.texi91
5 files changed, 77 insertions, 83 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 6579cc48fd5..b0156e5ac7e 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,23 @@
12012-09-02 Chong Yidong <cyd@gnu.org>
2
3 * windows.texi (Window Configurations): Recommend against using
4 save-window-excursion (Bug#12075).
5
6 * control.texi (Catch and Throw):
7 * positions.texi (Excursions): Don't mention it.
8
92012-09-01 Paul Eggert <eggert@cs.ucla.edu>
10
11 Better seed support for (random).
12 * numbers.texi (Random Numbers): Document new behavior of
13 the calls (random) and (random STRING).
14
152012-08-21 Martin Rudalics <rudalics@gmx.at>
16
17 * windows.texi (Window Point): Document recent changes in
18 window-point and set-window-point.
19 (Selecting Windows): Document recent change in select-window.
20
12012-08-06 Eli Zaretskii <eliz@gnu.org> 212012-08-06 Eli Zaretskii <eliz@gnu.org>
2 22
3 * functions.texi (Closures): Put the main index entry for 23 * functions.texi (Closures): Put the main index entry for
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 07d2d0d993c..25a7655b7b8 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -556,16 +556,14 @@ the @code{catch} in @code{foo-outer} specifies the same symbol, so that
556@code{catch} in between). 556@code{catch} in between).
557 557
558 Executing @code{throw} exits all Lisp constructs up to the matching 558 Executing @code{throw} exits all Lisp constructs up to the matching
559@code{catch}, including function calls. When binding constructs such as 559@code{catch}, including function calls. When binding constructs such
560@code{let} or function calls are exited in this way, the bindings are 560as @code{let} or function calls are exited in this way, the bindings
561unbound, just as they are when these constructs exit normally 561are unbound, just as they are when these constructs exit normally
562(@pxref{Local Variables}). Likewise, @code{throw} restores the buffer 562(@pxref{Local Variables}). Likewise, @code{throw} restores the buffer
563and position saved by @code{save-excursion} (@pxref{Excursions}), and 563and position saved by @code{save-excursion} (@pxref{Excursions}), and
564the narrowing status saved by @code{save-restriction} and the window 564the narrowing status saved by @code{save-restriction}. It also runs
565selection saved by @code{save-window-excursion} (@pxref{Window 565any cleanups established with the @code{unwind-protect} special form
566Configurations}). It also runs any cleanups established with the 566when it exits that form (@pxref{Cleanups}).
567@code{unwind-protect} special form when it exits that form
568(@pxref{Cleanups}).
569 567
570 The @code{throw} need not appear lexically within the @code{catch} 568 The @code{throw} need not appear lexically within the @code{catch}
571that it jumps to. It can equally well be called from another function 569that it jumps to. It can equally well be called from another function
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
index ce0716f39ef..17f3ee099bd 100644
--- a/doc/lispref/numbers.texi
+++ b/doc/lispref/numbers.texi
@@ -1199,30 +1199,32 @@ numbers are not truly random, but they have certain properties that
1199mimic a random series. For example, all possible values occur equally 1199mimic a random series. For example, all possible values occur equally
1200often in a pseudo-random series. 1200often in a pseudo-random series.
1201 1201
1202In Emacs, pseudo-random numbers are generated from a ``seed'' number. 1202In Emacs, pseudo-random numbers are generated from a ``seed''.
1203Starting from any given seed, the @code{random} function always 1203Starting from any given seed, the @code{random} function always
1204generates the same sequence of numbers. Emacs always starts with the 1204generates the same sequence of numbers. Emacs typically starts with a
1205same seed value, so the sequence of values of @code{random} is actually 1205different seed each time, so the sequence of values of @code{random}
1206the same in each Emacs run! For example, in one operating system, the 1206typically differs in each Emacs run.
1207first call to @code{(random)} after you start Emacs always returns 1207
1208@minus{}1457731, and the second one always returns @minus{}7692030. This 1208Sometimes you want the random number sequence to be repeatable. For
1209repeatability is helpful for debugging. 1209example, when debugging a program whose behavior depends on the random
1210 1210number sequence, it is helpful to get the same behavior in each
1211If you want random numbers that don't always come out the same, execute 1211program run. To make the sequence repeat, execute @code{(random "")}.
1212@code{(random t)}. This chooses a new seed based on the current time of 1212This sets the seed to a constant value for your particular Emacs
1213day and on Emacs's process @acronym{ID} number. 1213executable (though it may differ for other Emacs builds). You can use
1214other strings to choose various seed values.
1214 1215
1215@defun random &optional limit 1216@defun random &optional limit
1216This function returns a pseudo-random integer. Repeated calls return a 1217This function returns a pseudo-random integer. Repeated calls return a
1217series of pseudo-random integers. 1218series of pseudo-random integers.
1218 1219
1219If @var{limit} is a positive integer, the value is chosen to be 1220If @var{limit} is a positive integer, the value is chosen to be
1220nonnegative and less than @var{limit}. 1221nonnegative and less than @var{limit}. Otherwise, the value
1222might be any integer representable in Lisp.
1221 1223
1222If @var{limit} is @code{t}, it means to choose a new seed based on the 1224If @var{limit} is @code{t}, it means to choose a new seed based on the
1223current time of day and on Emacs's process @acronym{ID} number. 1225current time of day and on Emacs's process @acronym{ID} number.
1224 1226
1225On some machines, any integer representable in Lisp may be the result 1227If @var{limit} is a string, it means to choose a new seed based on the
1226of @code{random}. On other machines, the result can never be larger 1228string's contents.
1227than a certain maximum or less than a certain (negative) minimum. 1229
1228@end defun 1230@end defun
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi
index a59a99d124c..a0c65319850 100644
--- a/doc/lispref/positions.texi
+++ b/doc/lispref/positions.texi
@@ -850,9 +850,6 @@ after setting the desired current buffer, as in the following example:
850@cindex window excursions 850@cindex window excursions
851 Likewise, @code{save-excursion} does not restore window-buffer 851 Likewise, @code{save-excursion} does not restore window-buffer
852correspondences altered by functions such as @code{switch-to-buffer}. 852correspondences altered by functions such as @code{switch-to-buffer}.
853One way to restore these correspondences, and the selected window, is to
854use @code{save-window-excursion} inside @code{save-excursion}
855(@pxref{Window Configurations}).
856 853
857 @strong{Warning:} Ordinary insertion of text adjacent to the saved 854 @strong{Warning:} Ordinary insertion of text adjacent to the saved
858point value relocates the saved value, just as it relocates all 855point value relocates the saved value, just as it relocates all
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index c7c466c7d36..5fe007ba02d 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -1129,16 +1129,15 @@ are the opposite of what they are in those other functions.
1129 1129
1130@defun select-window window &optional norecord 1130@defun select-window window &optional norecord
1131This function makes @var{window} the selected window, as well as the 1131This function makes @var{window} the selected window, as well as the
1132window selected within its frame (@pxref{Basic Windows}). 1132window selected within its frame (@pxref{Basic Windows}). @var{window}
1133@var{window} must be a live window. Unless @var{window} already is the 1133must be a live window. This function makes also @var{window}'s buffer
1134selected window, its buffer becomes the current buffer (@pxref{Buffers 1134current (@pxref{Buffers and Windows}). The return value is
1135and Windows}). The return value is @var{window}. 1135@var{window}.
1136 1136
1137By default, this function also moves @var{window}'s selected buffer to 1137By default, this function also moves @var{window}'s buffer to the front
1138the front of the buffer list (@pxref{The Buffer List}), and makes 1138of the buffer list (@pxref{The Buffer List}), and makes @var{window} the
1139@var{window} the most recently selected window. However, if the 1139most recently selected window. However, if the optional argument
1140optional argument @var{norecord} is non-@code{nil}, these additional 1140@var{norecord} is non-@code{nil}, these additional actions are omitted.
1141actions are omitted.
1142@end defun 1141@end defun
1143 1142
1144@cindex most recently selected windows 1143@cindex most recently selected windows
@@ -2276,19 +2275,18 @@ For a nonselected window, this is the value point would have (in that
2276window's buffer) if that window were selected. The default for 2275window's buffer) if that window were selected. The default for
2277@var{window} is the selected window. 2276@var{window} is the selected window.
2278 2277
2279When @var{window} is the selected window and its buffer is also the 2278When @var{window} is the selected window, the value returned is the
2280current buffer, the value returned is the same as point in that buffer. 2279value of point in that window's buffer. Strictly speaking, it would be
2281Strictly speaking, it would be more correct to return the ``top-level'' 2280more correct to return the ``top-level'' value of point, outside of any
2282value of point, outside of any @code{save-excursion} forms. But that 2281@code{save-excursion} forms. But that value is hard to find.
2283value is hard to find.
2284@end defun 2282@end defun
2285 2283
2286@defun set-window-point window position 2284@defun set-window-point window position
2287This function positions point in @var{window} at position 2285This function positions point in @var{window} at position
2288@var{position} in @var{window}'s buffer. It returns @var{position}. 2286@var{position} in @var{window}'s buffer. It returns @var{position}.
2289 2287
2290If @var{window} is selected, and its buffer is current, 2288If @var{window} is selected, this simply does @code{goto-char} in
2291this simply does @code{goto-char}. 2289@var{window}'s buffer.
2292@end defun 2290@end defun
2293 2291
2294@defvar window-point-insertion-type 2292@defvar window-point-insertion-type
@@ -3155,42 +3153,21 @@ as @code{save-window-excursion}:
3155@end defun 3153@end defun
3156 3154
3157@defmac save-window-excursion forms@dots{} 3155@defmac save-window-excursion forms@dots{}
3158This special form records the window configuration, executes @var{forms} 3156This macro records the window configuration of the selected frame,
3159in sequence, then restores the earlier window configuration. The window 3157executes @var{forms} in sequence, then restores the earlier window
3160configuration includes, for each window, the value of point and the 3158configuration. The return value is the value of the final form in
3161portion of the buffer that is visible. It also includes the choice of 3159@var{forms}.
3162selected window. However, it does not include the value of point in 3160
3163the current buffer; use @code{save-excursion} also, if you wish to 3161Most Lisp code should not use this macro; @code{save-selected-window}
3164preserve that. 3162is typically sufficient. In particular, this macro cannot reliably
3165 3163prevent the code in @var{forms} from opening new windows, because new
3166Don't use this construct when @code{save-selected-window} is sufficient. 3164windows might be opened in other frames (@pxref{Choosing Window}), and
3167 3165@code{save-window-excursion} only saves and restores the window
3168Exit from @code{save-window-excursion} always triggers execution of 3166configuration on the current frame.
3169@code{window-size-change-functions}. (It doesn't know how to tell 3167
3170whether the restored configuration actually differs from the one in 3168Do not use this macro in @code{window-size-change-functions}; exiting
3171effect at the end of the @var{forms}.) 3169the macro triggers execution of @code{window-size-change-functions},
3172 3170leading to an endless loop.
3173The return value is the value of the final form in @var{forms}.
3174For example:
3175
3176@example
3177@group
3178(split-window)
3179 @result{} #<window 25 on control.texi>
3180@end group
3181@group
3182(setq w (selected-window))
3183 @result{} #<window 19 on control.texi>
3184@end group
3185@group
3186(save-window-excursion
3187 (delete-other-windows w)
3188 (switch-to-buffer "foo")
3189 'do-something)
3190 @result{} do-something
3191 ;; @r{The screen is now split again.}
3192@end group
3193@end example
3194@end defmac 3171@end defmac
3195 3172
3196@defun window-configuration-p object 3173@defun window-configuration-p object
@@ -3426,11 +3403,11 @@ Creating or deleting windows counts as a size change, and therefore
3426causes these functions to be called. Changing the frame size also 3403causes these functions to be called. Changing the frame size also
3427counts, because it changes the sizes of the existing windows. 3404counts, because it changes the sizes of the existing windows.
3428 3405
3429It is not a good idea to use @code{save-window-excursion} (@pxref{Window 3406You may use @code{save-selected-window} in these functions
3430Configurations}) in these functions, because that always counts as a 3407(@pxref{Selecting Windows}). However, do not use
3431size change, and it would cause these functions to be called over and 3408@code{save-window-excursion} (@pxref{Window Configurations}); exiting
3432over. In most cases, @code{save-selected-window} (@pxref{Selecting 3409that macro counts as a size change, which would cause these functions
3433Windows}) is what you need here. 3410to be called over and over.
3434@end defvar 3411@end defvar
3435 3412
3436@defvar window-configuration-change-hook 3413@defvar window-configuration-change-hook