aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGregory Heytings2022-08-01 19:11:01 +0000
committerGregory Heytings2022-08-01 21:11:49 +0200
commit9d8a6c82838f2f24e76a67379b02956aa668d7cf (patch)
tree4c2a1c40d39de489d90575d13efffcee13955a94 /src
parentc2ed2e68586098b600ff10a85e882ceb9eeb0c32 (diff)
downloademacs-9d8a6c82838f2f24e76a67379b02956aa668d7cf.tar.gz
emacs-9d8a6c82838f2f24e76a67379b02956aa668d7cf.zip
Fix the bytecode incompatibility due to the change to 'narrow-to-region'.
* src/editfns.c (narrow_to_region_internal): New function, which contains the body previously in 'Fnarrow_to_region' but accepts a third argument. (Fnarrow_to_region): Use the new function. Update the docstring. (Fwiden): Update the docstring. * src/lisp.h: Prototype of the new function. * src/xdisp.c (handle_fontified_prop): Use the new function instead of 'Fnarrow_to_region'. * src/process.c (Finternal_default_process_filter): * src/lread.c (readevalloop): Remove the third argument to 'Fnarrow_to_region'. * src/bytecode.c (exec_byte_code): * lisp/emacs-lisp/comp.el (comp-limplify-lap-inst): * lisp/emacs-lisp/bytecomp.el: Restore the statu quo ante. * etc/NEWS: Remove the entry about the new optional argument. * doc/lispref/positions.texi (Narrowing): Update the documentation.
Diffstat (limited to 'src')
-rw-r--r--src/bytecode.c4
-rw-r--r--src/editfns.c52
-rw-r--r--src/lisp.h1
-rw-r--r--src/lread.c2
-rw-r--r--src/process.c2
-rw-r--r--src/xdisp.c3
6 files changed, 37 insertions, 27 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 2b1eccdc518..d75767bb0c5 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -1480,8 +1480,8 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
1480 1480
1481 CASE (Bnarrow_to_region): 1481 CASE (Bnarrow_to_region):
1482 { 1482 {
1483 Lisp_Object v2 = POP, v1 = POP; 1483 Lisp_Object v1 = POP;
1484 TOP = Fnarrow_to_region (TOP, v1, v2); 1484 TOP = Fnarrow_to_region (TOP, v1);
1485 NEXT; 1485 NEXT;
1486 } 1486 }
1487 1487
diff --git a/src/editfns.c b/src/editfns.c
index 79af27d24da..35b2415e8b1 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2660,9 +2660,10 @@ DEFUN ("widen", Fwiden, Swiden, 0, 0, "",
2660 doc: /* Remove restrictions (narrowing) from current buffer. 2660 doc: /* Remove restrictions (narrowing) from current buffer.
2661This allows the buffer's full text to be seen and edited. 2661This allows the buffer's full text to be seen and edited.
2662 2662
2663When called from Lisp inside a body form in which `narrow-to-region' 2663Note that, when the current buffer contains one or more lines whose
2664was called with an optional argument LOCK non-nil, this function does 2664length is above `long-line-threshold', Emacs may decide to leave, for
2665not produce any effect. */) 2665performance reasons, the accessible portion of the buffer unchanged
2666after this function is called. */)
2666 (void) 2667 (void)
2667{ 2668{
2668 if (! NILP (Vrestrictions_locked)) 2669 if (! NILP (Vrestrictions_locked))
@@ -2689,22 +2690,11 @@ unwind_locked_zv (Lisp_Object point_max)
2689 SET_BUF_ZV (current_buffer, XFIXNUM (point_max)); 2690 SET_BUF_ZV (current_buffer, XFIXNUM (point_max));
2690} 2691}
2691 2692
2692DEFUN ("narrow-to-region", Fnarrow_to_region, Snarrow_to_region, 2, 3, "r", 2693/* Internal function for Fnarrow_to_region, meant to be used with a
2693 doc: /* Restrict editing in this buffer to the current region. 2694 third argument 'true', in which case it should be followed by "specbind
2694The rest of the text becomes temporarily invisible and untouchable 2695 (Qrestrictions_locked, Qt)". */
2695but is not deleted; if you save the buffer in a file, the invisible 2696Lisp_Object
2696text is included in the file. \\[widen] makes all visible again. 2697narrow_to_region_internal (Lisp_Object start, Lisp_Object end, bool lock)
2697See also `save-restriction'.
2698
2699When calling from Lisp, pass two arguments START and END:
2700positions (integers or markers) bounding the text that should
2701remain visible.
2702
2703When called from Lisp with the optional argument LOCK non-nil,
2704calls to `widen', or to `narrow-to-region' with an optional
2705argument LOCK nil, do not produce any effect until the end of
2706the current body form. */)
2707 (Lisp_Object start, Lisp_Object end, Lisp_Object lock)
2708{ 2698{
2709 EMACS_INT s = fix_position (start), e = fix_position (end); 2699 EMACS_INT s = fix_position (start), e = fix_position (end);
2710 2700
@@ -2713,7 +2703,7 @@ the current body form. */)
2713 EMACS_INT tem = s; s = e; e = tem; 2703 EMACS_INT tem = s; s = e; e = tem;
2714 } 2704 }
2715 2705
2716 if (! NILP (lock)) 2706 if (lock)
2717 { 2707 {
2718 if (!(BEGV <= s && s <= e && e <= ZV)) 2708 if (!(BEGV <= s && s <= e && e <= ZV))
2719 args_out_of_range (start, end); 2709 args_out_of_range (start, end);
@@ -2727,8 +2717,6 @@ the current body form. */)
2727 2717
2728 SET_BUF_BEGV (current_buffer, s); 2718 SET_BUF_BEGV (current_buffer, s);
2729 SET_BUF_ZV (current_buffer, e); 2719 SET_BUF_ZV (current_buffer, e);
2730
2731 specbind (Qrestrictions_locked, Qt);
2732 } 2720 }
2733 else 2721 else
2734 { 2722 {
@@ -2754,6 +2742,26 @@ the current body form. */)
2754 return Qnil; 2742 return Qnil;
2755} 2743}
2756 2744
2745DEFUN ("narrow-to-region", Fnarrow_to_region, Snarrow_to_region, 2, 2, "r",
2746 doc: /* Restrict editing in this buffer to the current region.
2747The rest of the text becomes temporarily invisible and untouchable
2748but is not deleted; if you save the buffer in a file, the invisible
2749text is included in the file. \\[widen] makes all visible again.
2750See also `save-restriction'.
2751
2752When calling from Lisp, pass two arguments START and END:
2753positions (integers or markers) bounding the text that should
2754remain visible.
2755
2756Note that, when the current buffer contains one or more lines whose
2757length is above `long-line-threshold', Emacs may decide to leave, for
2758performance reasons, the accessible portion of the buffer unchanged
2759after this function is called. */)
2760 (Lisp_Object start, Lisp_Object end)
2761{
2762 return narrow_to_region_internal (start, end, false);
2763}
2764
2757Lisp_Object 2765Lisp_Object
2758save_restriction_save (void) 2766save_restriction_save (void)
2759{ 2767{
diff --git a/src/lisp.h b/src/lisp.h
index 807fcb0e5ba..c8ad0bc56f5 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4679,6 +4679,7 @@ extern void save_restriction_restore (Lisp_Object);
4679extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); 4679extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool);
4680extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, 4680extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t,
4681 ptrdiff_t, bool); 4681 ptrdiff_t, bool);
4682extern Lisp_Object narrow_to_region_internal (Lisp_Object, Lisp_Object, bool);
4682extern void init_editfns (void); 4683extern void init_editfns (void);
4683extern void syms_of_editfns (void); 4684extern void syms_of_editfns (void);
4684 4685
diff --git a/src/lread.c b/src/lread.c
index 0720774db2b..0b46a2e4ee5 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2261,7 +2261,7 @@ readevalloop (Lisp_Object readcharfun,
2261 /* Set point and ZV around stuff to be read. */ 2261 /* Set point and ZV around stuff to be read. */
2262 Fgoto_char (start); 2262 Fgoto_char (start);
2263 if (!NILP (end)) 2263 if (!NILP (end))
2264 Fnarrow_to_region (make_fixnum (BEGV), end, Qnil); 2264 Fnarrow_to_region (make_fixnum (BEGV), end);
2265 2265
2266 /* Just for cleanliness, convert END to a marker 2266 /* Just for cleanliness, convert END to a marker
2267 if it is an integer. */ 2267 if it is an integer. */
diff --git a/src/process.c b/src/process.c
index a15efa39bd1..1ac5a509e56 100644
--- a/src/process.c
+++ b/src/process.c
@@ -6339,7 +6339,7 @@ Otherwise it discards the output. */)
6339 6339
6340 /* If the restriction isn't what it should be, set it. */ 6340 /* If the restriction isn't what it should be, set it. */
6341 if (old_begv != BEGV || old_zv != ZV) 6341 if (old_begv != BEGV || old_zv != ZV)
6342 Fnarrow_to_region (make_fixnum (old_begv), make_fixnum (old_zv), Qnil); 6342 Fnarrow_to_region (make_fixnum (old_begv), make_fixnum (old_zv));
6343 6343
6344 bset_read_only (current_buffer, old_read_only); 6344 bset_read_only (current_buffer, old_read_only);
6345 SET_PT_BOTH (opoint, opoint_byte); 6345 SET_PT_BOTH (opoint, opoint_byte);
diff --git a/src/xdisp.c b/src/xdisp.c
index 88a489e290f..65d9221a159 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -4406,7 +4406,8 @@ handle_fontified_prop (struct it *it)
4406 if (!begv) begv = BEGV; 4406 if (!begv) begv = BEGV;
4407 zv = get_narrowed_zv (it->w, charpos); 4407 zv = get_narrowed_zv (it->w, charpos);
4408 } 4408 }
4409 Fnarrow_to_region (make_fixnum (begv), make_fixnum (zv), Qt); 4409 narrow_to_region_internal (make_fixnum (begv), make_fixnum (zv), true);
4410 specbind (Qrestrictions_locked, Qt);
4410 } 4411 }
4411 4412
4412 /* Don't allow Lisp that runs from 'fontification-functions' 4413 /* Don't allow Lisp that runs from 'fontification-functions'