diff options
Diffstat (limited to 'doc/lispref')
| -rw-r--r-- | doc/lispref/ChangeLog | 20 | ||||
| -rw-r--r-- | doc/lispref/control.texi | 14 | ||||
| -rw-r--r-- | doc/lispref/numbers.texi | 32 | ||||
| -rw-r--r-- | doc/lispref/positions.texi | 3 | ||||
| -rw-r--r-- | doc/lispref/windows.texi | 91 |
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 @@ | |||
| 1 | 2012-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 | |||
| 9 | 2012-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 | |||
| 15 | 2012-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 | |||
| 1 | 2012-08-06 Eli Zaretskii <eliz@gnu.org> | 21 | 2012-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 | 560 | as @code{let} or function calls are exited in this way, the bindings |
| 561 | unbound, just as they are when these constructs exit normally | 561 | are 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 |
| 563 | and position saved by @code{save-excursion} (@pxref{Excursions}), and | 563 | and position saved by @code{save-excursion} (@pxref{Excursions}), and |
| 564 | the narrowing status saved by @code{save-restriction} and the window | 564 | the narrowing status saved by @code{save-restriction}. It also runs |
| 565 | selection saved by @code{save-window-excursion} (@pxref{Window | 565 | any cleanups established with the @code{unwind-protect} special form |
| 566 | Configurations}). It also runs any cleanups established with the | 566 | when 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} |
| 571 | that it jumps to. It can equally well be called from another function | 569 | that 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 | |||
| 1199 | mimic a random series. For example, all possible values occur equally | 1199 | mimic a random series. For example, all possible values occur equally |
| 1200 | often in a pseudo-random series. | 1200 | often in a pseudo-random series. |
| 1201 | 1201 | ||
| 1202 | In Emacs, pseudo-random numbers are generated from a ``seed'' number. | 1202 | In Emacs, pseudo-random numbers are generated from a ``seed''. |
| 1203 | Starting from any given seed, the @code{random} function always | 1203 | Starting from any given seed, the @code{random} function always |
| 1204 | generates the same sequence of numbers. Emacs always starts with the | 1204 | generates the same sequence of numbers. Emacs typically starts with a |
| 1205 | same seed value, so the sequence of values of @code{random} is actually | 1205 | different seed each time, so the sequence of values of @code{random} |
| 1206 | the same in each Emacs run! For example, in one operating system, the | 1206 | typically differs in each Emacs run. |
| 1207 | first call to @code{(random)} after you start Emacs always returns | 1207 | |
| 1208 | @minus{}1457731, and the second one always returns @minus{}7692030. This | 1208 | Sometimes you want the random number sequence to be repeatable. For |
| 1209 | repeatability is helpful for debugging. | 1209 | example, when debugging a program whose behavior depends on the random |
| 1210 | 1210 | number sequence, it is helpful to get the same behavior in each | |
| 1211 | If you want random numbers that don't always come out the same, execute | 1211 | program run. To make the sequence repeat, execute @code{(random "")}. |
| 1212 | @code{(random t)}. This chooses a new seed based on the current time of | 1212 | This sets the seed to a constant value for your particular Emacs |
| 1213 | day and on Emacs's process @acronym{ID} number. | 1213 | executable (though it may differ for other Emacs builds). You can use |
| 1214 | other strings to choose various seed values. | ||
| 1214 | 1215 | ||
| 1215 | @defun random &optional limit | 1216 | @defun random &optional limit |
| 1216 | This function returns a pseudo-random integer. Repeated calls return a | 1217 | This function returns a pseudo-random integer. Repeated calls return a |
| 1217 | series of pseudo-random integers. | 1218 | series of pseudo-random integers. |
| 1218 | 1219 | ||
| 1219 | If @var{limit} is a positive integer, the value is chosen to be | 1220 | If @var{limit} is a positive integer, the value is chosen to be |
| 1220 | nonnegative and less than @var{limit}. | 1221 | nonnegative and less than @var{limit}. Otherwise, the value |
| 1222 | might be any integer representable in Lisp. | ||
| 1221 | 1223 | ||
| 1222 | If @var{limit} is @code{t}, it means to choose a new seed based on the | 1224 | If @var{limit} is @code{t}, it means to choose a new seed based on the |
| 1223 | current time of day and on Emacs's process @acronym{ID} number. | 1225 | current time of day and on Emacs's process @acronym{ID} number. |
| 1224 | 1226 | ||
| 1225 | On some machines, any integer representable in Lisp may be the result | 1227 | If @var{limit} is a string, it means to choose a new seed based on the |
| 1226 | of @code{random}. On other machines, the result can never be larger | 1228 | string's contents. |
| 1227 | than 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 |
| 852 | correspondences altered by functions such as @code{switch-to-buffer}. | 852 | correspondences altered by functions such as @code{switch-to-buffer}. |
| 853 | One way to restore these correspondences, and the selected window, is to | ||
| 854 | use @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 |
| 858 | point value relocates the saved value, just as it relocates all | 855 | point 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 |
| 1131 | This function makes @var{window} the selected window, as well as the | 1131 | This function makes @var{window} the selected window, as well as the |
| 1132 | window selected within its frame (@pxref{Basic Windows}). | 1132 | window selected within its frame (@pxref{Basic Windows}). @var{window} |
| 1133 | @var{window} must be a live window. Unless @var{window} already is the | 1133 | must be a live window. This function makes also @var{window}'s buffer |
| 1134 | selected window, its buffer becomes the current buffer (@pxref{Buffers | 1134 | current (@pxref{Buffers and Windows}). The return value is |
| 1135 | and Windows}). The return value is @var{window}. | 1135 | @var{window}. |
| 1136 | 1136 | ||
| 1137 | By default, this function also moves @var{window}'s selected buffer to | 1137 | By default, this function also moves @var{window}'s buffer to the front |
| 1138 | the front of the buffer list (@pxref{The Buffer List}), and makes | 1138 | of the buffer list (@pxref{The Buffer List}), and makes @var{window} the |
| 1139 | @var{window} the most recently selected window. However, if the | 1139 | most recently selected window. However, if the optional argument |
| 1140 | optional argument @var{norecord} is non-@code{nil}, these additional | 1140 | @var{norecord} is non-@code{nil}, these additional actions are omitted. |
| 1141 | actions 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 | |||
| 2276 | window's buffer) if that window were selected. The default for | 2275 | window'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 | ||
| 2279 | When @var{window} is the selected window and its buffer is also the | 2278 | When @var{window} is the selected window, the value returned is the |
| 2280 | current buffer, the value returned is the same as point in that buffer. | 2279 | value of point in that window's buffer. Strictly speaking, it would be |
| 2281 | Strictly speaking, it would be more correct to return the ``top-level'' | 2280 | more correct to return the ``top-level'' value of point, outside of any |
| 2282 | value of point, outside of any @code{save-excursion} forms. But that | 2281 | @code{save-excursion} forms. But that value is hard to find. |
| 2283 | value 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 |
| 2287 | This function positions point in @var{window} at position | 2285 | This 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 | ||
| 2290 | If @var{window} is selected, and its buffer is current, | 2288 | If @var{window} is selected, this simply does @code{goto-char} in |
| 2291 | this 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{} |
| 3158 | This special form records the window configuration, executes @var{forms} | 3156 | This macro records the window configuration of the selected frame, |
| 3159 | in sequence, then restores the earlier window configuration. The window | 3157 | executes @var{forms} in sequence, then restores the earlier window |
| 3160 | configuration includes, for each window, the value of point and the | 3158 | configuration. The return value is the value of the final form in |
| 3161 | portion of the buffer that is visible. It also includes the choice of | 3159 | @var{forms}. |
| 3162 | selected window. However, it does not include the value of point in | 3160 | |
| 3163 | the current buffer; use @code{save-excursion} also, if you wish to | 3161 | Most Lisp code should not use this macro; @code{save-selected-window} |
| 3164 | preserve that. | 3162 | is typically sufficient. In particular, this macro cannot reliably |
| 3165 | 3163 | prevent the code in @var{forms} from opening new windows, because new | |
| 3166 | Don't use this construct when @code{save-selected-window} is sufficient. | 3164 | windows might be opened in other frames (@pxref{Choosing Window}), and |
| 3167 | 3165 | @code{save-window-excursion} only saves and restores the window | |
| 3168 | Exit from @code{save-window-excursion} always triggers execution of | 3166 | configuration on the current frame. |
| 3169 | @code{window-size-change-functions}. (It doesn't know how to tell | 3167 | |
| 3170 | whether the restored configuration actually differs from the one in | 3168 | Do not use this macro in @code{window-size-change-functions}; exiting |
| 3171 | effect at the end of the @var{forms}.) | 3169 | the macro triggers execution of @code{window-size-change-functions}, |
| 3172 | 3170 | leading to an endless loop. | |
| 3173 | The return value is the value of the final form in @var{forms}. | ||
| 3174 | For 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 | |||
| 3426 | causes these functions to be called. Changing the frame size also | 3403 | causes these functions to be called. Changing the frame size also |
| 3427 | counts, because it changes the sizes of the existing windows. | 3404 | counts, because it changes the sizes of the existing windows. |
| 3428 | 3405 | ||
| 3429 | It is not a good idea to use @code{save-window-excursion} (@pxref{Window | 3406 | You may use @code{save-selected-window} in these functions |
| 3430 | Configurations}) in these functions, because that always counts as a | 3407 | (@pxref{Selecting Windows}). However, do not use |
| 3431 | size change, and it would cause these functions to be called over and | 3408 | @code{save-window-excursion} (@pxref{Window Configurations}); exiting |
| 3432 | over. In most cases, @code{save-selected-window} (@pxref{Selecting | 3409 | that macro counts as a size change, which would cause these functions |
| 3433 | Windows}) is what you need here. | 3410 | to 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 |