summaryrefslogtreecommitdiff
path: root/src/editfns.c
diff options
context:
space:
mode:
authorGregory Heytings <gregory@heytings.org>2022-08-01 19:11:01 +0000
committerGregory Heytings <gregory@heytings.org>2022-08-01 21:11:49 +0200
commit9d8a6c82838f2f24e76a67379b02956aa668d7cf (patch)
tree4c2a1c40d39de489d90575d13efffcee13955a94 /src/editfns.c
parentc2ed2e68586098b600ff10a85e882ceb9eeb0c32 (diff)
downloademacs-9d8a6c82838f2f24e76a67379b02956aa668d7cf.tar.gz
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/editfns.c')
-rw-r--r--src/editfns.c52
1 files changed, 30 insertions, 22 deletions
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, "",
doc: /* Remove restrictions (narrowing) from current buffer.
This allows the buffer's full text to be seen and edited.
-When called from Lisp inside a body form in which `narrow-to-region'
-was called with an optional argument LOCK non-nil, this function does
-not produce any effect. */)
+Note that, when the current buffer contains one or more lines whose
+length is above `long-line-threshold', Emacs may decide to leave, for
+performance reasons, the accessible portion of the buffer unchanged
+after this function is called. */)
(void)
{
if (! NILP (Vrestrictions_locked))
@@ -2689,22 +2690,11 @@ unwind_locked_zv (Lisp_Object point_max)
SET_BUF_ZV (current_buffer, XFIXNUM (point_max));
}
-DEFUN ("narrow-to-region", Fnarrow_to_region, Snarrow_to_region, 2, 3, "r",
- doc: /* Restrict editing in this buffer to the current region.
-The rest of the text becomes temporarily invisible and untouchable
-but is not deleted; if you save the buffer in a file, the invisible
-text is included in the file. \\[widen] makes all visible again.
-See also `save-restriction'.
-
-When calling from Lisp, pass two arguments START and END:
-positions (integers or markers) bounding the text that should
-remain visible.
-
-When called from Lisp with the optional argument LOCK non-nil,
-calls to `widen', or to `narrow-to-region' with an optional
-argument LOCK nil, do not produce any effect until the end of
-the current body form. */)
- (Lisp_Object start, Lisp_Object end, Lisp_Object lock)
+/* Internal function for Fnarrow_to_region, meant to be used with a
+ third argument 'true', in which case it should be followed by "specbind
+ (Qrestrictions_locked, Qt)". */
+Lisp_Object
+narrow_to_region_internal (Lisp_Object start, Lisp_Object end, bool lock)
{
EMACS_INT s = fix_position (start), e = fix_position (end);
@@ -2713,7 +2703,7 @@ the current body form. */)
EMACS_INT tem = s; s = e; e = tem;
}
- if (! NILP (lock))
+ if (lock)
{
if (!(BEGV <= s && s <= e && e <= ZV))
args_out_of_range (start, end);
@@ -2727,8 +2717,6 @@ the current body form. */)
SET_BUF_BEGV (current_buffer, s);
SET_BUF_ZV (current_buffer, e);
-
- specbind (Qrestrictions_locked, Qt);
}
else
{
@@ -2754,6 +2742,26 @@ the current body form. */)
return Qnil;
}
+DEFUN ("narrow-to-region", Fnarrow_to_region, Snarrow_to_region, 2, 2, "r",
+ doc: /* Restrict editing in this buffer to the current region.
+The rest of the text becomes temporarily invisible and untouchable
+but is not deleted; if you save the buffer in a file, the invisible
+text is included in the file. \\[widen] makes all visible again.
+See also `save-restriction'.
+
+When calling from Lisp, pass two arguments START and END:
+positions (integers or markers) bounding the text that should
+remain visible.
+
+Note that, when the current buffer contains one or more lines whose
+length is above `long-line-threshold', Emacs may decide to leave, for
+performance reasons, the accessible portion of the buffer unchanged
+after this function is called. */)
+ (Lisp_Object start, Lisp_Object end)
+{
+ return narrow_to_region_internal (start, end, false);
+}
+
Lisp_Object
save_restriction_save (void)
{