aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Heytings2022-08-01 19:11:01 +0000
committerGregory Heytings2022-08-01 21:11:49 +0200
commit9d8a6c82838f2f24e76a67379b02956aa668d7cf (patch)
tree4c2a1c40d39de489d90575d13efffcee13955a94
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.
-rw-r--r--doc/lispref/positions.texi15
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/emacs-lisp/bytecomp.el4
-rw-r--r--lisp/emacs-lisp/comp.el5
-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
10 files changed, 50 insertions, 45 deletions
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi
index 3a9a152f8dd..e08ee76ed9a 100644
--- a/doc/lispref/positions.texi
+++ b/doc/lispref/positions.texi
@@ -995,7 +995,7 @@ the entire buffer regardless of any narrowing.
995types of text, consider using an alternative facility described in 995types of text, consider using an alternative facility described in
996@ref{Swapping Text}. 996@ref{Swapping Text}.
997 997
998@deffn Command narrow-to-region start end &optional lock 998@deffn Command narrow-to-region start end
999This function sets the accessible portion of the current buffer to start 999This function sets the accessible portion of the current buffer to start
1000at @var{start} and end at @var{end}. Both arguments should be character 1000at @var{start} and end at @var{end}. Both arguments should be character
1001positions. 1001positions.
@@ -1003,10 +1003,9 @@ positions.
1003In an interactive call, @var{start} and @var{end} are set to the bounds 1003In an interactive call, @var{start} and @var{end} are set to the bounds
1004of the current region (point and the mark, with the smallest first). 1004of the current region (point and the mark, with the smallest first).
1005 1005
1006When @var{lock} is non-@code{nil}, calls to @code{widen}, or to 1006Note that, in rare circumstances, Emacs may decide to leave, for
1007@code{narrow-to-region} with an optional argument @var{lock} 1007performance reasons, the accessible portion of the buffer unchanged
1008@code{nil}, do not produce any effect until the end of the current 1008after a call to @code{narrow-to-region}.
1009body form.
1010@end deffn 1009@end deffn
1011 1010
1012@deffn Command narrow-to-page &optional move-count 1011@deffn Command narrow-to-page &optional move-count
@@ -1032,9 +1031,9 @@ It is equivalent to the following expression:
1032@end example 1031@end example
1033@end deffn 1032@end deffn
1034 1033
1035However, when @code{widen} is called inside a body form in which 1034Note that, in rare circumstances, Emacs may decide to leave, for
1036@code{narrow-to-region} was called with an optional argument 1035performance reasons, the accessible portion of the buffer unchanged
1037@code{lock} non-@code{nil}, it does not produce any effect. 1036after a call to @code{widen}.
1038 1037
1039@defun buffer-narrowed-p 1038@defun buffer-narrowed-p
1040This function returns non-@code{nil} if the buffer is narrowed, and 1039This function returns non-@code{nil} if the buffer is narrowed, and
diff --git a/etc/NEWS b/etc/NEWS
index 963aa22c680..b011413cbc3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2560,13 +2560,6 @@ things to be saved.
2560** New function 'string-equal-ignore-case'. 2560** New function 'string-equal-ignore-case'.
2561This compares strings ignoring case differences. 2561This compares strings ignoring case differences.
2562 2562
2563+++
2564** New argument LOCK of 'narrow-to-region'.
2565If 'narrow-to-region' is called from Lisp with the new optional
2566argument LOCK non-nil, then calls to 'widen' and calls to
2567'narrow-to-region' with the optional argument LOCK nil or omitted do
2568not produce any effect until the end of the current body form.
2569
2570** Themes 2563** Themes
2571 2564
2572--- 2565---
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 1ecd77f7517..b4954eee9ff 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -767,7 +767,7 @@ Each element is (INDEX . VALUE)")
767(byte-defop 122 0 byte-char-syntax) 767(byte-defop 122 0 byte-char-syntax)
768(byte-defop 123 -1 byte-buffer-substring) 768(byte-defop 123 -1 byte-buffer-substring)
769(byte-defop 124 -1 byte-delete-region) 769(byte-defop 124 -1 byte-delete-region)
770(byte-defop 125 -2 byte-narrow-to-region) 770(byte-defop 125 -1 byte-narrow-to-region)
771(byte-defop 126 1 byte-widen) 771(byte-defop 126 1 byte-widen)
772(byte-defop 127 0 byte-end-of-line) 772(byte-defop 127 0 byte-end-of-line)
773 773
@@ -3833,7 +3833,7 @@ If it is nil, then the handler is \"byte-compile-SYMBOL.\""
3833(byte-defop-compiler setcdr 2) 3833(byte-defop-compiler setcdr 2)
3834(byte-defop-compiler buffer-substring 2) 3834(byte-defop-compiler buffer-substring 2)
3835(byte-defop-compiler delete-region 2) 3835(byte-defop-compiler delete-region 2)
3836(byte-defop-compiler narrow-to-region 2-3) 3836(byte-defop-compiler narrow-to-region 2)
3837(byte-defop-compiler (% byte-rem) 2) 3837(byte-defop-compiler (% byte-rem) 2)
3838(byte-defop-compiler aset 3) 3838(byte-defop-compiler aset 3)
3839 3839
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 4354ea03a4e..5ee10fcbca2 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -1915,7 +1915,10 @@ and the annotation emission."
1915 (byte-char-syntax auto) 1915 (byte-char-syntax auto)
1916 (byte-buffer-substring auto) 1916 (byte-buffer-substring auto)
1917 (byte-delete-region auto) 1917 (byte-delete-region auto)
1918 (byte-narrow-to-region auto) 1918 (byte-narrow-to-region
1919 (comp-emit-set-call (comp-call 'narrow-to-region
1920 (comp-slot)
1921 (comp-slot+1))))
1919 (byte-widen 1922 (byte-widen
1920 (comp-emit-set-call (comp-call 'widen))) 1923 (comp-emit-set-call (comp-call 'widen)))
1921 (byte-end-of-line auto) 1924 (byte-end-of-line auto)
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'