]> git.eshelyaron.com Git - emacs.git/commitdiff
New function record_unwind_protect_excursion
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 Jun 2018 01:53:27 +0000 (18:53 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 Jun 2018 02:11:49 +0000 (19:11 -0700)
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.

src/buffer.c
src/bytecode.c
src/editfns.c
src/eval.c
src/lisp.h
src/lread.c
src/window.c

index 14837372d345f7b9e171c0c5efaed8d0be958ad7..244c1851fab649dc62c7274227b5c621703a1ef7 100644 (file)
@@ -1696,7 +1696,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
   {
     ptrdiff_t count = SPECPDL_INDEX ();
 
-    record_unwind_protect (save_excursion_restore, save_excursion_save ());
+    record_unwind_protect_excursion ();
     set_buffer_internal (b);
 
     /* First run the query functions; if any query is answered no,
index 55b193ffb2fff8b12ca6a5188ac435149c473eaf..772cc982f9acfcca981ddc1c143596322439771f 100644 (file)
@@ -739,8 +739,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
          NEXT;
 
        CASE (Bsave_excursion):
-         record_unwind_protect (save_excursion_restore,
-                                save_excursion_save ());
+         record_unwind_protect_excursion ();
          NEXT;
 
        CASE (Bsave_current_buffer): /* Obsolete since ??.  */
index 608304c09ad8b3b1899a7562e18beb022d035003..2377ceb18af82bbc96609b02c97ace5e2ccb4659 100644 (file)
@@ -1068,7 +1068,7 @@ usage: (save-excursion &rest BODY)  */)
   register Lisp_Object val;
   ptrdiff_t count = SPECPDL_INDEX ();
 
-  record_unwind_protect (save_excursion_restore, save_excursion_save ());
+  record_unwind_protect_excursion ();
 
   val = Fprogn (args);
   return unbind_to (count, val);
@@ -3242,7 +3242,7 @@ buffer stay intact.  */)
 
   Fundo_boundary ();
   ptrdiff_t count = SPECPDL_INDEX ();
-  record_unwind_protect (save_excursion_restore, save_excursion_save ());
+  record_unwind_protect_excursion ();
 
   ptrdiff_t i = size_a;
   ptrdiff_t j = size_b;
index 90d8c3351855de7d9f83caddc407850de4126dba..86011a234c0b4f5eb81455b12c826c999f0c7ca9 100644 (file)
@@ -3414,6 +3414,12 @@ record_unwind_protect_int (void (*function) (int), int arg)
   grow_specpdl ();
 }
 
+void
+record_unwind_protect_excursion (void)
+{
+  record_unwind_protect (save_excursion_restore, save_excursion_save ());
+}
+
 void
 record_unwind_protect_void (void (*function) (void))
 {
index 5b296cd04cd2994dcfdd1b6154e7e27f9868ef84..10012b29db14401086d18c83a9a7f302862a5948 100644 (file)
@@ -3983,6 +3983,7 @@ extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object);
 extern void record_unwind_protect_ptr (void (*) (void *), void *);
 extern void record_unwind_protect_int (void (*) (int), int);
 extern void record_unwind_protect_void (void (*) (void));
+extern void record_unwind_protect_excursion (void);
 extern void record_unwind_protect_nothing (void);
 extern void clear_unwind_protect (ptrdiff_t);
 extern void set_unwind_protect (ptrdiff_t, void (*) (Lisp_Object), Lisp_Object);
index 239c66ccb85d3f885a8b90755b7a5db4aafddb39..d2c7eae20f9c69e9c9d52212b85e2bdcfef1a914 100644 (file)
@@ -1976,11 +1976,11 @@ readevalloop (Lisp_Object readcharfun,
       if (!NILP (start))
        {
          /* Switch to the buffer we are reading from.  */
-         record_unwind_protect (save_excursion_restore, save_excursion_save ());
+         record_unwind_protect_excursion ();
          set_buffer_internal (b);
 
          /* Save point in it.  */
-         record_unwind_protect (save_excursion_restore, save_excursion_save ());
+         record_unwind_protect_excursion ();
          /* Save ZV in it.  */
          record_unwind_protect (save_restriction_restore, save_restriction_save ());
          /* Those get unbound after we read one expression.  */
@@ -2137,7 +2137,7 @@ This function preserves the position of point.  */)
 
   specbind (Qeval_buffer_list, Fcons (buf, Veval_buffer_list));
   specbind (Qstandard_output, tem);
-  record_unwind_protect (save_excursion_restore, save_excursion_save ());
+  record_unwind_protect_excursion ();
   BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
   specbind (Qlexical_binding, lisp_file_lexically_bound_p (buf) ? Qt : Qnil);
   BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
index f654d87e14a218e6cdfb0b12432cfb5550f86e9c..2c6ff01ea43f8e378c3338312e05953865277cc2 100644 (file)
@@ -5656,7 +5656,7 @@ scroll_command (Lisp_Object window, Lisp_Object n, int direction)
      the moment.  But don't screw up if window_scroll gets an error.  */
   if (XBUFFER (w->contents) != current_buffer)
     {
-      record_unwind_protect (save_excursion_restore, save_excursion_save ());
+      record_unwind_protect_excursion ();
       Fset_buffer (w->contents);
     }