emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/long-lines-cleanup 7e26a5c774e 2/4: Remove labeled restrictions


From: Gregory Heytings
Subject: scratch/long-lines-cleanup 7e26a5c774e 2/4: Remove labeled restrictions before calling Fwiden
Date: Tue, 28 Mar 2023 19:14:27 -0400 (EDT)

branch: scratch/long-lines-cleanup
commit 7e26a5c774e7c71782d89abe1d4be125d8422a4b
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>

    Remove labeled restrictions before calling Fwiden
    
    * src/editfns.c (labeled_restrictions_remove_in_current_buffer):
    New function.
    
    * src/lisp.h: Make it externally visible.
    
    * src/xdisp.c (display_count_lines_logically):
    * src/lread.c (readevalloop):
    * src/indent.c (line_number_display_width):
    * src/fileio.c (write_region):
    * src/callproc.c (Fcall_process_region):
    * src/buffer.c (Ferase_buffer): Use it.
---
 src/buffer.c   | 1 +
 src/callproc.c | 1 +
 src/editfns.c  | 7 +++++++
 src/fileio.c   | 1 +
 src/indent.c   | 1 +
 src/lisp.h     | 1 +
 src/lread.c    | 1 +
 src/xdisp.c    | 1 +
 8 files changed, 14 insertions(+)

diff --git a/src/buffer.c b/src/buffer.c
index 0c740775e5b..252231357bc 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2386,6 +2386,7 @@ Any narrowing restriction in effect (see 
`narrow-to-region') is removed,
 so the buffer is truly empty after this.  */)
   (void)
 {
+  labeled_restrictions_remove_in_current_buffer ();
   Fwiden ();
 
   del_range (BEG, Z);
diff --git a/src/callproc.c b/src/callproc.c
index 5e1e1a8cc0a..6f3d4fad9be 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1113,6 +1113,7 @@ usage: (call-process-region START END PROGRAM &optional 
DELETE BUFFER DISPLAY &r
         {
           /* No need to save restrictions since we delete everything
              anyway.  */
+          labeled_restrictions_remove_in_current_buffer ();
           Fwiden ();
           del_range (BEG, Z);
         }
diff --git a/src/editfns.c b/src/editfns.c
index ff711ee2a09..4c5b691eb50 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2756,6 +2756,13 @@ labeled_restrictions_pop (Lisp_Object buf)
     XSETCDR (restrictions, list1 (XCDR (XCAR (XCDR (restrictions)))));
 }
 
+/* Unconditionally remove all labeled restrictions in current_buffer.  */
+void
+labeled_restrictions_remove_in_current_buffer (void)
+{
+  labeled_restrictions_remove (Fcurrent_buffer ());
+}
+
 static void
 unwind_reset_outermost_restriction (Lisp_Object buf)
 {
diff --git a/src/fileio.c b/src/fileio.c
index f00c389a520..b50b3c6b935 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5269,6 +5269,7 @@ write_region (Lisp_Object start, Lisp_Object end, 
Lisp_Object filename,
     }
 
   record_unwind_protect (save_restriction_restore, save_restriction_save ());
+  labeled_restrictions_remove_in_current_buffer ();
 
   /* Special kludge to simplify auto-saving.  */
   if (NILP (start))
diff --git a/src/indent.c b/src/indent.c
index 08d2bf5ea28..aef394dab88 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2065,6 +2065,7 @@ line_number_display_width (struct window *w, int *width, 
int *pixel_width)
        {
          record_unwind_protect (save_restriction_restore,
                                 save_restriction_save ());
+         labeled_restrictions_remove_in_current_buffer ();
          Fwiden ();
          saved_restriction = true;
        }
diff --git a/src/lisp.h b/src/lisp.h
index a3d06c3b45d..9c02d975a74 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4689,6 +4689,7 @@ extern Lisp_Object make_buffer_string_both (ptrdiff_t, 
ptrdiff_t, ptrdiff_t,
                                            ptrdiff_t, bool);
 extern void labeled_narrow_to_region (Lisp_Object, Lisp_Object, Lisp_Object);
 extern void reset_outermost_restrictions (void);
+extern void labeled_restrictions_remove_in_current_buffer (void);
 extern void init_editfns (void);
 extern void syms_of_editfns (void);
 
diff --git a/src/lread.c b/src/lread.c
index d0dc85f51c8..342d367d985 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2255,6 +2255,7 @@ readevalloop (Lisp_Object readcharfun,
          record_unwind_protect_excursion ();
          /* Save ZV in it.  */
          record_unwind_protect (save_restriction_restore, 
save_restriction_save ());
+         labeled_restrictions_remove_in_current_buffer ();
          /* Those get unbound after we read one expression.  */
 
          /* Set point and ZV around stuff to be read.  */
diff --git a/src/xdisp.c b/src/xdisp.c
index fa411e6e8dc..c752f6712ab 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -24199,6 +24199,7 @@ display_count_lines_logically (ptrdiff_t start_byte, 
ptrdiff_t limit_byte,
   ptrdiff_t val;
   specpdl_ref pdl_count = SPECPDL_INDEX ();
   record_unwind_protect (save_restriction_restore, save_restriction_save ());
+  labeled_restrictions_remove_in_current_buffer ();
   Fwiden ();
   val = display_count_lines (start_byte, limit_byte, count, byte_pos_ptr);
   unbind_to (pdl_count, Qnil);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]