diff options
| author | Stefan Monnier | 2015-03-25 09:47:12 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2015-03-25 09:47:12 -0400 |
| commit | 599ca626d760215b090012c69c749d391cfd6fbe (patch) | |
| tree | 6cc2d4c57d53e317d33bfc7fb2012908c14316c2 | |
| parent | 76040ddd8a4142e2933f1c24940d9e20c206ee6f (diff) | |
| download | emacs-599ca626d760215b090012c69c749d391cfd6fbe.tar.gz emacs-599ca626d760215b090012c69c749d391cfd6fbe.zip | |
`save-excursion' does not save&restore the mark any more
* src/editfns.c (save_excursion_save): Don't save the mark.
(save_excursion_restore): Don't restore the mark.
(Fsave_excursion): Fix docstring accordingly.
* doc/lispintro/emacs-lisp-intro.texi:
* doc/lispref/positions.texi (Excursions, Narrowing): `save-excursion' does
not save&restore the mark any more.
| -rw-r--r-- | doc/lispintro/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/lispintro/emacs-lisp-intro.texi | 44 | ||||
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/positions.texi | 21 | ||||
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/editfns.c | 54 |
7 files changed, 55 insertions, 81 deletions
diff --git a/doc/lispintro/ChangeLog b/doc/lispintro/ChangeLog index 57ab03b1155..c54c165d22c 100644 --- a/doc/lispintro/ChangeLog +++ b/doc/lispintro/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2015-03-25 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp-intro.texi: `save-excursion' doesn't save&restore the mark. | ||
| 4 | |||
| 1 | 2014-12-31 Paul Eggert <eggert@cs.ucla.edu> | 5 | 2014-12-31 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 6 | ||
| 3 | Less 'make' chatter for Emacs doc | 7 | Less 'make' chatter for Emacs doc |
diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index c67623d89cb..ed125bb3747 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi | |||
| @@ -352,7 +352,7 @@ How To Write Function Definitions | |||
| 352 | * if:: What if? | 352 | * if:: What if? |
| 353 | * else:: If--then--else expressions. | 353 | * else:: If--then--else expressions. |
| 354 | * Truth & Falsehood:: What Lisp considers false and true. | 354 | * Truth & Falsehood:: What Lisp considers false and true. |
| 355 | * save-excursion:: Keeping track of point, mark, and buffer. | 355 | * save-excursion:: Keeping track of point and buffer. |
| 356 | * Review:: | 356 | * Review:: |
| 357 | * defun Exercises:: | 357 | * defun Exercises:: |
| 358 | 358 | ||
| @@ -2966,7 +2966,7 @@ symbol refers to it.) | |||
| 2966 | * if:: What if? | 2966 | * if:: What if? |
| 2967 | * else:: If--then--else expressions. | 2967 | * else:: If--then--else expressions. |
| 2968 | * Truth & Falsehood:: What Lisp considers false and true. | 2968 | * Truth & Falsehood:: What Lisp considers false and true. |
| 2969 | * save-excursion:: Keeping track of point, mark, and buffer. | 2969 | * save-excursion:: Keeping track of point and buffer. |
| 2970 | * Review:: | 2970 | * Review:: |
| 2971 | * defun Exercises:: | 2971 | * defun Exercises:: |
| 2972 | @end menu | 2972 | @end menu |
| @@ -4159,11 +4159,11 @@ The @code{save-excursion} function is the third and final special form | |||
| 4159 | that we will discuss in this chapter. | 4159 | that we will discuss in this chapter. |
| 4160 | 4160 | ||
| 4161 | In Emacs Lisp programs used for editing, the @code{save-excursion} | 4161 | In Emacs Lisp programs used for editing, the @code{save-excursion} |
| 4162 | function is very common. It saves the location of point and mark, | 4162 | function is very common. It saves the location of point, |
| 4163 | executes the body of the function, and then restores point and mark to | 4163 | executes the body of the function, and then restores point to |
| 4164 | their previous positions if their locations were changed. Its primary | 4164 | its previous position if its location was changed. Its primary |
| 4165 | purpose is to keep the user from being surprised and disturbed by | 4165 | purpose is to keep the user from being surprised and disturbed by |
| 4166 | unexpected movement of point or mark. | 4166 | unexpected movement of point. |
| 4167 | 4167 | ||
| 4168 | @menu | 4168 | @menu |
| 4169 | * Point and mark:: A review of various locations. | 4169 | * Point and mark:: A review of various locations. |
| @@ -4201,7 +4201,7 @@ region}. Numerous commands work on the region, including | |||
| 4201 | @code{print-region}. | 4201 | @code{print-region}. |
| 4202 | 4202 | ||
| 4203 | The @code{save-excursion} special form saves the locations of point and | 4203 | The @code{save-excursion} special form saves the locations of point and |
| 4204 | mark and restores those positions after the code within the body of the | 4204 | restores this position after the code within the body of the |
| 4205 | special form is evaluated by the Lisp interpreter. Thus, if point were | 4205 | special form is evaluated by the Lisp interpreter. Thus, if point were |
| 4206 | in the beginning of a piece of text and some code moved point to the end | 4206 | in the beginning of a piece of text and some code moved point to the end |
| 4207 | of the buffer, the @code{save-excursion} would put point back to where | 4207 | of the buffer, the @code{save-excursion} would put point back to where |
| @@ -4212,16 +4212,16 @@ In Emacs, a function frequently moves point as part of its internal | |||
| 4212 | workings even though a user would not expect this. For example, | 4212 | workings even though a user would not expect this. For example, |
| 4213 | @code{count-lines-region} moves point. To prevent the user from being | 4213 | @code{count-lines-region} moves point. To prevent the user from being |
| 4214 | bothered by jumps that are both unexpected and (from the user's point of | 4214 | bothered by jumps that are both unexpected and (from the user's point of |
| 4215 | view) unnecessary, @code{save-excursion} is often used to keep point and | 4215 | view) unnecessary, @code{save-excursion} is often used to keep point in |
| 4216 | mark in the location expected by the user. The use of | 4216 | the location expected by the user. The use of |
| 4217 | @code{save-excursion} is good housekeeping. | 4217 | @code{save-excursion} is good housekeeping. |
| 4218 | 4218 | ||
| 4219 | To make sure the house stays clean, @code{save-excursion} restores the | 4219 | To make sure the house stays clean, @code{save-excursion} restores the |
| 4220 | values of point and mark even if something goes wrong in the code inside | 4220 | value of point even if something goes wrong in the code inside |
| 4221 | of it (or, to be more precise and to use the proper jargon, ``in case of | 4221 | of it (or, to be more precise and to use the proper jargon, ``in case of |
| 4222 | abnormal exit''). This feature is very helpful. | 4222 | abnormal exit''). This feature is very helpful. |
| 4223 | 4223 | ||
| 4224 | In addition to recording the values of point and mark, | 4224 | In addition to recording the value of point, |
| 4225 | @code{save-excursion} keeps track of the current buffer, and restores | 4225 | @code{save-excursion} keeps track of the current buffer, and restores |
| 4226 | it, too. This means you can write code that will change the buffer and | 4226 | it, too. This means you can write code that will change the buffer and |
| 4227 | have @code{save-excursion} switch you back to the original buffer. | 4227 | have @code{save-excursion} switch you back to the original buffer. |
| @@ -4386,9 +4386,9 @@ For example, | |||
| 4386 | @end smallexample | 4386 | @end smallexample |
| 4387 | 4387 | ||
| 4388 | @item save-excursion | 4388 | @item save-excursion |
| 4389 | Record the values of point and mark and the current buffer before | 4389 | Record the values of point and the current buffer before |
| 4390 | evaluating the body of this special form. Restore the values of point | 4390 | evaluating the body of this special form. Restore the value of point and |
| 4391 | and mark and buffer afterward. | 4391 | buffer afterward. |
| 4392 | 4392 | ||
| 4393 | @need 1250 | 4393 | @need 1250 |
| 4394 | For example, | 4394 | For example, |
| @@ -5201,8 +5201,8 @@ of the two-element list, @code{(oldbuf (current-buffer))}. | |||
| 5201 | The body of the @code{let} expression in @code{append-to-buffer} | 5201 | The body of the @code{let} expression in @code{append-to-buffer} |
| 5202 | consists of a @code{save-excursion} expression. | 5202 | consists of a @code{save-excursion} expression. |
| 5203 | 5203 | ||
| 5204 | The @code{save-excursion} function saves the locations of point and | 5204 | The @code{save-excursion} function saves the location of point, and restores it |
| 5205 | mark, and restores them to those positions after the expressions in the | 5205 | to that position after the expressions in the |
| 5206 | body of the @code{save-excursion} complete execution. In addition, | 5206 | body of the @code{save-excursion} complete execution. In addition, |
| 5207 | @code{save-excursion} keeps track of the original buffer, and | 5207 | @code{save-excursion} keeps track of the original buffer, and |
| 5208 | restores it. This is how @code{save-excursion} is used in | 5208 | restores it. This is how @code{save-excursion} is used in |
| @@ -5390,7 +5390,7 @@ Conventionally bound to @kbd{M-.} (that's a period following the | |||
| 5390 | @key{META} key). | 5390 | @key{META} key). |
| 5391 | 5391 | ||
| 5392 | @item save-excursion | 5392 | @item save-excursion |
| 5393 | Save the location of point and mark and restore their values after the | 5393 | Save the location of point and restore its value after the |
| 5394 | arguments to @code{save-excursion} have been evaluated. Also, remember | 5394 | arguments to @code{save-excursion} have been evaluated. Also, remember |
| 5395 | the current buffer and return to it. | 5395 | the current buffer and return to it. |
| 5396 | 5396 | ||
| @@ -5896,7 +5896,7 @@ the value of point, which will be at the end of the inserted text, is | |||
| 5896 | recorded in the variable @code{newmark}. | 5896 | recorded in the variable @code{newmark}. |
| 5897 | 5897 | ||
| 5898 | After the body of the outer @code{save-excursion} is evaluated, point | 5898 | After the body of the outer @code{save-excursion} is evaluated, point |
| 5899 | and mark are relocated to their original places. | 5899 | is relocated to its original place. |
| 5900 | 5900 | ||
| 5901 | However, it is convenient to locate a mark at the end of the newly | 5901 | However, it is convenient to locate a mark at the end of the newly |
| 5902 | inserted text and locate point at its beginning. The @code{newmark} | 5902 | inserted text and locate point at its beginning. The @code{newmark} |
| @@ -6685,8 +6685,8 @@ restored just before the completion of the function by the | |||
| 6685 | @code{save-restriction} special form. | 6685 | @code{save-restriction} special form. |
| 6686 | 6686 | ||
| 6687 | The call to @code{widen} is followed by @code{save-excursion}, which | 6687 | The call to @code{widen} is followed by @code{save-excursion}, which |
| 6688 | saves the location of the cursor (i.e., of point) and of the mark, and | 6688 | saves the location of the cursor (i.e., of point), and |
| 6689 | restores them after the code in the body of the @code{save-excursion} | 6689 | restores it after the code in the body of the @code{save-excursion} |
| 6690 | uses the @code{beginning-of-line} function to move point. | 6690 | uses the @code{beginning-of-line} function to move point. |
| 6691 | 6691 | ||
| 6692 | (Note that the @code{(widen)} expression comes between the | 6692 | (Note that the @code{(widen)} expression comes between the |
| @@ -6757,8 +6757,8 @@ it, and @code{count-lines} counts only the lines @emph{before} the | |||
| 6757 | current line. | 6757 | current line. |
| 6758 | 6758 | ||
| 6759 | After @code{count-lines} has done its job, and the message has been | 6759 | After @code{count-lines} has done its job, and the message has been |
| 6760 | printed in the echo area, the @code{save-excursion} restores point and | 6760 | printed in the echo area, the @code{save-excursion} restores point to |
| 6761 | mark to their original positions; and @code{save-restriction} restores | 6761 | its original position; and @code{save-restriction} restores |
| 6762 | the original narrowing, if any. | 6762 | the original narrowing, if any. |
| 6763 | 6763 | ||
| 6764 | @node narrow Exercise | 6764 | @node narrow Exercise |
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 9b1bbb357a5..9e1b7b074e2 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2015-03-25 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * positions.texi (Excursions, Narrowing): `save-excursion' does not | ||
| 4 | save&restore the mark any more. | ||
| 5 | |||
| 1 | 2015-03-24 Paul Eggert <eggert@cs.ucla.edu> | 6 | 2015-03-24 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 7 | ||
| 3 | * numbers.texi (Float Basics): Improve ldexp documentation. | 8 | * numbers.texi (Float Basics): Improve ldexp documentation. |
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index b74116ebf1d..103161c7ae2 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi | |||
| @@ -825,8 +825,8 @@ is zero or less. | |||
| 825 | It is often useful to move point ``temporarily'' within a localized | 825 | It is often useful to move point ``temporarily'' within a localized |
| 826 | portion of the program. This is called an @dfn{excursion}, and it is | 826 | portion of the program. This is called an @dfn{excursion}, and it is |
| 827 | done with the @code{save-excursion} special form. This construct | 827 | done with the @code{save-excursion} special form. This construct |
| 828 | remembers the initial identity of the current buffer, and its values | 828 | remembers the initial identity of the current buffer, and its value |
| 829 | of point and the mark, and restores them after the excursion | 829 | of point, and restores them after the excursion |
| 830 | completes. It is the standard way to move point within one part of a | 830 | completes. It is the standard way to move point within one part of a |
| 831 | program and avoid affecting the rest of the program, and is used | 831 | program and avoid affecting the rest of the program, and is used |
| 832 | thousands of times in the Lisp sources of Emacs. | 832 | thousands of times in the Lisp sources of Emacs. |
| @@ -841,18 +841,18 @@ Configurations} and in @ref{Frame Configurations}. @c frameset? | |||
| 841 | @cindex mark excursion | 841 | @cindex mark excursion |
| 842 | @cindex point excursion | 842 | @cindex point excursion |
| 843 | This special form saves the identity of the current buffer and the | 843 | This special form saves the identity of the current buffer and the |
| 844 | values of point and the mark in it, evaluates @var{body}, and finally | 844 | value of point in it, evaluates @var{body}, and finally |
| 845 | restores the buffer and its saved values of point and the mark. All | 845 | restores the buffer and its saved value of point. both saved values are |
| 846 | three saved values are restored even in case of an abnormal exit via | 846 | restored even in case of an abnormal exit via |
| 847 | @code{throw} or error (@pxref{Nonlocal Exits}). | 847 | @code{throw} or error (@pxref{Nonlocal Exits}). |
| 848 | 848 | ||
| 849 | The value returned by @code{save-excursion} is the result of the last | 849 | The value returned by @code{save-excursion} is the result of the last |
| 850 | form in @var{body}, or @code{nil} if no body forms were given. | 850 | form in @var{body}, or @code{nil} if no body forms were given. |
| 851 | @end defspec | 851 | @end defspec |
| 852 | 852 | ||
| 853 | Because @code{save-excursion} only saves point and mark for the | 853 | Because @code{save-excursion} only saves point for the |
| 854 | buffer that was current at the start of the excursion, any changes | 854 | buffer that was current at the start of the excursion, any changes |
| 855 | made to point and/or mark in other buffers, during the excursion, will | 855 | made to point in other buffers, during the excursion, will |
| 856 | remain in effect afterward. This frequently leads to unintended | 856 | remain in effect afterward. This frequently leads to unintended |
| 857 | consequences, so the byte compiler warns if you call @code{set-buffer} | 857 | consequences, so the byte compiler warns if you call @code{set-buffer} |
| 858 | during an excursion: | 858 | during an excursion: |
| @@ -888,11 +888,6 @@ type @code{nil}. @xref{Marker Insertion Types}. Therefore, when the | |||
| 888 | saved point value is restored, it normally comes before the inserted | 888 | saved point value is restored, it normally comes before the inserted |
| 889 | text. | 889 | text. |
| 890 | 890 | ||
| 891 | Although @code{save-excursion} saves the location of the mark, it does | ||
| 892 | not prevent functions which modify the buffer from setting | ||
| 893 | @code{deactivate-mark}, and thus causing the deactivation of the mark | ||
| 894 | after the command finishes. @xref{The Mark}. | ||
| 895 | |||
| 896 | @node Narrowing | 891 | @node Narrowing |
| 897 | @section Narrowing | 892 | @section Narrowing |
| 898 | @cindex narrowing | 893 | @cindex narrowing |
| @@ -980,7 +975,7 @@ restores the restrictions on the original buffer (the buffer whose | |||
| 980 | restrictions it saved from), but it does not restore the identity of the | 975 | restrictions it saved from), but it does not restore the identity of the |
| 981 | current buffer. | 976 | current buffer. |
| 982 | 977 | ||
| 983 | @code{save-restriction} does @emph{not} restore point and the mark; use | 978 | @code{save-restriction} does @emph{not} restore point; use |
| 984 | @code{save-excursion} for that. If you use both @code{save-restriction} | 979 | @code{save-excursion} for that. If you use both @code{save-restriction} |
| 985 | and @code{save-excursion} together, @code{save-excursion} should come | 980 | and @code{save-excursion} together, @code{save-excursion} should come |
| 986 | first (on the outside). Otherwise, the old point value would be | 981 | first (on the outside). Otherwise, the old point value would be |
| @@ -617,6 +617,8 @@ a typographically-correct documents. | |||
| 617 | 617 | ||
| 618 | * Incompatible Lisp Changes in Emacs 25.1 | 618 | * Incompatible Lisp Changes in Emacs 25.1 |
| 619 | 619 | ||
| 620 | ** `save-excursion' does not save&restore the mark any more. | ||
| 621 | |||
| 620 | ** read-buffer-function can now be called with a 4th argument (`predicate'). | 622 | ** read-buffer-function can now be called with a 4th argument (`predicate'). |
| 621 | 623 | ||
| 622 | ** completion-table-dynamic stays in the minibuffer. | 624 | ** completion-table-dynamic stays in the minibuffer. |
diff --git a/src/ChangeLog b/src/ChangeLog index 23f125c567d..632b798ce08 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2015-03-25 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * editfns.c (save_excursion_save): Don't save the mark. | ||
| 4 | (save_excursion_restore): Don't restore the mark. | ||
| 5 | (Fsave_excursion): Fix docstring accordingly. | ||
| 6 | |||
| 1 | 2015-03-24 Paul Eggert <eggert@cs.ucla.edu> | 7 | 2015-03-24 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 8 | ||
| 3 | Fix minor ldexp issues | 9 | Fix minor ldexp issues |
diff --git a/src/editfns.c b/src/editfns.c index 7c146f13e14..f463890a98d 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -849,14 +849,11 @@ save_excursion_save (void) | |||
| 849 | { | 849 | { |
| 850 | return make_save_obj_obj_obj_obj | 850 | return make_save_obj_obj_obj_obj |
| 851 | (Fpoint_marker (), | 851 | (Fpoint_marker (), |
| 852 | /* Do not copy the mark if it points to nowhere. */ | 852 | Qnil, |
| 853 | (XMARKER (BVAR (current_buffer, mark))->buffer | ||
| 854 | ? Fcopy_marker (BVAR (current_buffer, mark), Qnil) | ||
| 855 | : Qnil), | ||
| 856 | /* Selected window if current buffer is shown in it, nil otherwise. */ | 853 | /* Selected window if current buffer is shown in it, nil otherwise. */ |
| 857 | (EQ (XWINDOW (selected_window)->contents, Fcurrent_buffer ()) | 854 | (EQ (XWINDOW (selected_window)->contents, Fcurrent_buffer ()) |
| 858 | ? selected_window : Qnil), | 855 | ? selected_window : Qnil), |
| 859 | BVAR (current_buffer, mark_active)); | 856 | Qnil); |
| 860 | } | 857 | } |
| 861 | 858 | ||
| 862 | /* Restore saved buffer before leaving `save-excursion' special form. */ | 859 | /* Restore saved buffer before leaving `save-excursion' special form. */ |
| @@ -864,8 +861,8 @@ save_excursion_save (void) | |||
| 864 | void | 861 | void |
| 865 | save_excursion_restore (Lisp_Object info) | 862 | save_excursion_restore (Lisp_Object info) |
| 866 | { | 863 | { |
| 867 | Lisp_Object tem, tem1, omark, nmark; | 864 | Lisp_Object tem, tem1; |
| 868 | struct gcpro gcpro1, gcpro2, gcpro3; | 865 | struct gcpro gcpro1; |
| 869 | 866 | ||
| 870 | tem = Fmarker_buffer (XSAVE_OBJECT (info, 0)); | 867 | tem = Fmarker_buffer (XSAVE_OBJECT (info, 0)); |
| 871 | /* If we're unwinding to top level, saved buffer may be deleted. This | 868 | /* If we're unwinding to top level, saved buffer may be deleted. This |
| @@ -873,8 +870,7 @@ save_excursion_restore (Lisp_Object info) | |||
| 873 | if (NILP (tem)) | 870 | if (NILP (tem)) |
| 874 | goto out; | 871 | goto out; |
| 875 | 872 | ||
| 876 | omark = nmark = Qnil; | 873 | GCPRO1 (info); |
| 877 | GCPRO3 (info, omark, nmark); | ||
| 878 | 874 | ||
| 879 | Fset_buffer (tem); | 875 | Fset_buffer (tem); |
| 880 | 876 | ||
| @@ -883,34 +879,6 @@ save_excursion_restore (Lisp_Object info) | |||
| 883 | Fgoto_char (tem); | 879 | Fgoto_char (tem); |
| 884 | unchain_marker (XMARKER (tem)); | 880 | unchain_marker (XMARKER (tem)); |
| 885 | 881 | ||
| 886 | /* Mark marker. */ | ||
| 887 | tem = XSAVE_OBJECT (info, 1); | ||
| 888 | omark = Fmarker_position (BVAR (current_buffer, mark)); | ||
| 889 | if (NILP (tem)) | ||
| 890 | unchain_marker (XMARKER (BVAR (current_buffer, mark))); | ||
| 891 | else | ||
| 892 | { | ||
| 893 | Fset_marker (BVAR (current_buffer, mark), tem, Fcurrent_buffer ()); | ||
| 894 | nmark = Fmarker_position (tem); | ||
| 895 | unchain_marker (XMARKER (tem)); | ||
| 896 | } | ||
| 897 | |||
| 898 | /* Mark active. */ | ||
| 899 | tem = XSAVE_OBJECT (info, 3); | ||
| 900 | tem1 = BVAR (current_buffer, mark_active); | ||
| 901 | bset_mark_active (current_buffer, tem); | ||
| 902 | |||
| 903 | /* If mark is active now, and either was not active | ||
| 904 | or was at a different place, run the activate hook. */ | ||
| 905 | if (! NILP (tem)) | ||
| 906 | { | ||
| 907 | if (! EQ (omark, nmark)) | ||
| 908 | run_hook (intern ("activate-mark-hook")); | ||
| 909 | } | ||
| 910 | /* If mark has ceased to be active, run deactivate hook. */ | ||
| 911 | else if (! NILP (tem1)) | ||
| 912 | run_hook (intern ("deactivate-mark-hook")); | ||
| 913 | |||
| 914 | /* If buffer was visible in a window, and a different window was | 882 | /* If buffer was visible in a window, and a different window was |
| 915 | selected, and the old selected window is still showing this | 883 | selected, and the old selected window is still showing this |
| 916 | buffer, restore point in that window. */ | 884 | buffer, restore point in that window. */ |
| @@ -932,18 +900,12 @@ save_excursion_restore (Lisp_Object info) | |||
| 932 | } | 900 | } |
| 933 | 901 | ||
| 934 | DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0, | 902 | DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0, |
| 935 | doc: /* Save point, mark, and current buffer; execute BODY; restore those things. | 903 | doc: /* Save point, and current buffer; execute BODY; restore those things. |
| 936 | Executes BODY just like `progn'. | 904 | Executes BODY just like `progn'. |
| 937 | The values of point, mark and the current buffer are restored | 905 | The values of point and the current buffer are restored |
| 938 | even in case of abnormal exit (throw or error). | 906 | even in case of abnormal exit (throw or error). |
| 939 | The state of activation of the mark is also restored. | ||
| 940 | |||
| 941 | This construct does not save `deactivate-mark', and therefore | ||
| 942 | functions that change the buffer will still cause deactivation | ||
| 943 | of the mark at the end of the command. To prevent that, bind | ||
| 944 | `deactivate-mark' with `let'. | ||
| 945 | 907 | ||
| 946 | If you only want to save the current buffer but not point nor mark, | 908 | If you only want to save the current buffer but not point, |
| 947 | then just use `save-current-buffer', or even `with-current-buffer'. | 909 | then just use `save-current-buffer', or even `with-current-buffer'. |
| 948 | 910 | ||
| 949 | usage: (save-excursion &rest BODY) */) | 911 | usage: (save-excursion &rest BODY) */) |