aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Heytings2023-03-28 23:06:55 +0000
committerGregory Heytings2023-03-29 01:12:36 +0200
commit7e26a5c774e7c71782d89abe1d4be125d8422a4b (patch)
tree7e9ab1f0c27dc2945ff89cd595a30450925e0227
parent85ed1c9ca6b786763740766d77b1f806c2f301a1 (diff)
downloademacs-7e26a5c774e7c71782d89abe1d4be125d8422a4b.tar.gz
emacs-7e26a5c774e7c71782d89abe1d4be125d8422a4b.zip
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.
-rw-r--r--src/buffer.c1
-rw-r--r--src/callproc.c1
-rw-r--r--src/editfns.c7
-rw-r--r--src/fileio.c1
-rw-r--r--src/indent.c1
-rw-r--r--src/lisp.h1
-rw-r--r--src/lread.c1
-rw-r--r--src/xdisp.c1
8 files changed, 14 insertions, 0 deletions
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,
2386so the buffer is truly empty after this. */) 2386so the buffer is truly empty after this. */)
2387 (void) 2387 (void)
2388{ 2388{
2389 labeled_restrictions_remove_in_current_buffer ();
2389 Fwiden (); 2390 Fwiden ();
2390 2391
2391 del_range (BEG, Z); 2392 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
1113 { 1113 {
1114 /* No need to save restrictions since we delete everything 1114 /* No need to save restrictions since we delete everything
1115 anyway. */ 1115 anyway. */
1116 labeled_restrictions_remove_in_current_buffer ();
1116 Fwiden (); 1117 Fwiden ();
1117 del_range (BEG, Z); 1118 del_range (BEG, Z);
1118 } 1119 }
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)
2756 XSETCDR (restrictions, list1 (XCDR (XCAR (XCDR (restrictions))))); 2756 XSETCDR (restrictions, list1 (XCDR (XCAR (XCDR (restrictions)))));
2757} 2757}
2758 2758
2759/* Unconditionally remove all labeled restrictions in current_buffer. */
2760void
2761labeled_restrictions_remove_in_current_buffer (void)
2762{
2763 labeled_restrictions_remove (Fcurrent_buffer ());
2764}
2765
2759static void 2766static void
2760unwind_reset_outermost_restriction (Lisp_Object buf) 2767unwind_reset_outermost_restriction (Lisp_Object buf)
2761{ 2768{
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,
5269 } 5269 }
5270 5270
5271 record_unwind_protect (save_restriction_restore, save_restriction_save ()); 5271 record_unwind_protect (save_restriction_restore, save_restriction_save ());
5272 labeled_restrictions_remove_in_current_buffer ();
5272 5273
5273 /* Special kludge to simplify auto-saving. */ 5274 /* Special kludge to simplify auto-saving. */
5274 if (NILP (start)) 5275 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)
2065 { 2065 {
2066 record_unwind_protect (save_restriction_restore, 2066 record_unwind_protect (save_restriction_restore,
2067 save_restriction_save ()); 2067 save_restriction_save ());
2068 labeled_restrictions_remove_in_current_buffer ();
2068 Fwiden (); 2069 Fwiden ();
2069 saved_restriction = true; 2070 saved_restriction = true;
2070 } 2071 }
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,
4689 ptrdiff_t, bool); 4689 ptrdiff_t, bool);
4690extern void labeled_narrow_to_region (Lisp_Object, Lisp_Object, Lisp_Object); 4690extern void labeled_narrow_to_region (Lisp_Object, Lisp_Object, Lisp_Object);
4691extern void reset_outermost_restrictions (void); 4691extern void reset_outermost_restrictions (void);
4692extern void labeled_restrictions_remove_in_current_buffer (void);
4692extern void init_editfns (void); 4693extern void init_editfns (void);
4693extern void syms_of_editfns (void); 4694extern void syms_of_editfns (void);
4694 4695
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,
2255 record_unwind_protect_excursion (); 2255 record_unwind_protect_excursion ();
2256 /* Save ZV in it. */ 2256 /* Save ZV in it. */
2257 record_unwind_protect (save_restriction_restore, save_restriction_save ()); 2257 record_unwind_protect (save_restriction_restore, save_restriction_save ());
2258 labeled_restrictions_remove_in_current_buffer ();
2258 /* Those get unbound after we read one expression. */ 2259 /* Those get unbound after we read one expression. */
2259 2260
2260 /* Set point and ZV around stuff to be read. */ 2261 /* 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,
24199 ptrdiff_t val; 24199 ptrdiff_t val;
24200 specpdl_ref pdl_count = SPECPDL_INDEX (); 24200 specpdl_ref pdl_count = SPECPDL_INDEX ();
24201 record_unwind_protect (save_restriction_restore, save_restriction_save ()); 24201 record_unwind_protect (save_restriction_restore, save_restriction_save ());
24202 labeled_restrictions_remove_in_current_buffer ();
24202 Fwiden (); 24203 Fwiden ();
24203 val = display_count_lines (start_byte, limit_byte, count, byte_pos_ptr); 24204 val = display_count_lines (start_byte, limit_byte, count, byte_pos_ptr);
24204 unbind_to (pdl_count, Qnil); 24205 unbind_to (pdl_count, Qnil);