aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2018-06-07 18:53:27 -0700
committerPaul Eggert2018-06-07 19:11:49 -0700
commita0aa1d4ecc123d652285ef10ea62ed55c6c118d6 (patch)
treec56177683a5a552e17eb8ce7ed27256507361b60 /src
parenta0641286f6e58f4dca4221caa6dd559bfacea699 (diff)
downloademacs-a0aa1d4ecc123d652285ef10ea62ed55c6c118d6.tar.gz
emacs-a0aa1d4ecc123d652285ef10ea62ed55c6c118d6.zip
New function record_unwind_protect_excursion
This simplifies callers a bit, and will simplify future changes. * src/eval.c (record_unwind_protect_excursion): New function. * src/buffer.c (Fkill_buffer): * src/bytecode.c (exec_byte_code): * src/editfns.c (Fsave_excursion, Freplace_buffer_contents): * src/lread.c (readevalloop, Feval_buffer): * src/window.c (scroll_command): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c2
-rw-r--r--src/bytecode.c3
-rw-r--r--src/editfns.c4
-rw-r--r--src/eval.c6
-rw-r--r--src/lisp.h1
-rw-r--r--src/lread.c6
-rw-r--r--src/window.c2
7 files changed, 15 insertions, 9 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 14837372d34..244c1851fab 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1696,7 +1696,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1696 { 1696 {
1697 ptrdiff_t count = SPECPDL_INDEX (); 1697 ptrdiff_t count = SPECPDL_INDEX ();
1698 1698
1699 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 1699 record_unwind_protect_excursion ();
1700 set_buffer_internal (b); 1700 set_buffer_internal (b);
1701 1701
1702 /* First run the query functions; if any query is answered no, 1702 /* First run the query functions; if any query is answered no,
diff --git a/src/bytecode.c b/src/bytecode.c
index 55b193ffb2f..772cc982f9a 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -739,8 +739,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
739 NEXT; 739 NEXT;
740 740
741 CASE (Bsave_excursion): 741 CASE (Bsave_excursion):
742 record_unwind_protect (save_excursion_restore, 742 record_unwind_protect_excursion ();
743 save_excursion_save ());
744 NEXT; 743 NEXT;
745 744
746 CASE (Bsave_current_buffer): /* Obsolete since ??. */ 745 CASE (Bsave_current_buffer): /* Obsolete since ??. */
diff --git a/src/editfns.c b/src/editfns.c
index 608304c09ad..2377ceb18af 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1068,7 +1068,7 @@ usage: (save-excursion &rest BODY) */)
1068 register Lisp_Object val; 1068 register Lisp_Object val;
1069 ptrdiff_t count = SPECPDL_INDEX (); 1069 ptrdiff_t count = SPECPDL_INDEX ();
1070 1070
1071 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 1071 record_unwind_protect_excursion ();
1072 1072
1073 val = Fprogn (args); 1073 val = Fprogn (args);
1074 return unbind_to (count, val); 1074 return unbind_to (count, val);
@@ -3242,7 +3242,7 @@ buffer stay intact. */)
3242 3242
3243 Fundo_boundary (); 3243 Fundo_boundary ();
3244 ptrdiff_t count = SPECPDL_INDEX (); 3244 ptrdiff_t count = SPECPDL_INDEX ();
3245 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 3245 record_unwind_protect_excursion ();
3246 3246
3247 ptrdiff_t i = size_a; 3247 ptrdiff_t i = size_a;
3248 ptrdiff_t j = size_b; 3248 ptrdiff_t j = size_b;
diff --git a/src/eval.c b/src/eval.c
index 90d8c335185..86011a234c0 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3415,6 +3415,12 @@ record_unwind_protect_int (void (*function) (int), int arg)
3415} 3415}
3416 3416
3417void 3417void
3418record_unwind_protect_excursion (void)
3419{
3420 record_unwind_protect (save_excursion_restore, save_excursion_save ());
3421}
3422
3423void
3418record_unwind_protect_void (void (*function) (void)) 3424record_unwind_protect_void (void (*function) (void))
3419{ 3425{
3420 specpdl_ptr->unwind_void.kind = SPECPDL_UNWIND_VOID; 3426 specpdl_ptr->unwind_void.kind = SPECPDL_UNWIND_VOID;
diff --git a/src/lisp.h b/src/lisp.h
index 5b296cd04cd..10012b29db1 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3983,6 +3983,7 @@ extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object);
3983extern void record_unwind_protect_ptr (void (*) (void *), void *); 3983extern void record_unwind_protect_ptr (void (*) (void *), void *);
3984extern void record_unwind_protect_int (void (*) (int), int); 3984extern void record_unwind_protect_int (void (*) (int), int);
3985extern void record_unwind_protect_void (void (*) (void)); 3985extern void record_unwind_protect_void (void (*) (void));
3986extern void record_unwind_protect_excursion (void);
3986extern void record_unwind_protect_nothing (void); 3987extern void record_unwind_protect_nothing (void);
3987extern void clear_unwind_protect (ptrdiff_t); 3988extern void clear_unwind_protect (ptrdiff_t);
3988extern void set_unwind_protect (ptrdiff_t, void (*) (Lisp_Object), Lisp_Object); 3989extern void set_unwind_protect (ptrdiff_t, void (*) (Lisp_Object), Lisp_Object);
diff --git a/src/lread.c b/src/lread.c
index 239c66ccb85..d2c7eae20f9 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1976,11 +1976,11 @@ readevalloop (Lisp_Object readcharfun,
1976 if (!NILP (start)) 1976 if (!NILP (start))
1977 { 1977 {
1978 /* Switch to the buffer we are reading from. */ 1978 /* Switch to the buffer we are reading from. */
1979 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 1979 record_unwind_protect_excursion ();
1980 set_buffer_internal (b); 1980 set_buffer_internal (b);
1981 1981
1982 /* Save point in it. */ 1982 /* Save point in it. */
1983 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 1983 record_unwind_protect_excursion ();
1984 /* Save ZV in it. */ 1984 /* Save ZV in it. */
1985 record_unwind_protect (save_restriction_restore, save_restriction_save ()); 1985 record_unwind_protect (save_restriction_restore, save_restriction_save ());
1986 /* Those get unbound after we read one expression. */ 1986 /* Those get unbound after we read one expression. */
@@ -2137,7 +2137,7 @@ This function preserves the position of point. */)
2137 2137
2138 specbind (Qeval_buffer_list, Fcons (buf, Veval_buffer_list)); 2138 specbind (Qeval_buffer_list, Fcons (buf, Veval_buffer_list));
2139 specbind (Qstandard_output, tem); 2139 specbind (Qstandard_output, tem);
2140 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 2140 record_unwind_protect_excursion ();
2141 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); 2141 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
2142 specbind (Qlexical_binding, lisp_file_lexically_bound_p (buf) ? Qt : Qnil); 2142 specbind (Qlexical_binding, lisp_file_lexically_bound_p (buf) ? Qt : Qnil);
2143 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); 2143 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
diff --git a/src/window.c b/src/window.c
index f654d87e14a..2c6ff01ea43 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5656,7 +5656,7 @@ scroll_command (Lisp_Object window, Lisp_Object n, int direction)
5656 the moment. But don't screw up if window_scroll gets an error. */ 5656 the moment. But don't screw up if window_scroll gets an error. */
5657 if (XBUFFER (w->contents) != current_buffer) 5657 if (XBUFFER (w->contents) != current_buffer)
5658 { 5658 {
5659 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 5659 record_unwind_protect_excursion ();
5660 Fset_buffer (w->contents); 5660 Fset_buffer (w->contents);
5661 } 5661 }
5662 5662