]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix the bytecode incompatibility due to the change to 'narrow-to-region'.
authorGregory Heytings <gregory@heytings.org>
Mon, 1 Aug 2022 19:11:01 +0000 (19:11 +0000)
committerGregory Heytings <gregory@heytings.org>
Mon, 1 Aug 2022 19:11:49 +0000 (21:11 +0200)
* 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.

doc/lispref/positions.texi
etc/NEWS
lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/comp.el
src/bytecode.c
src/editfns.c
src/lisp.h
src/lread.c
src/process.c
src/xdisp.c

index 3a9a152f8dd21efee4fd184d7068c0728d8457df..e08ee76ed9ad12885a8c5b577be67a8e5f4728d5 100644 (file)
@@ -995,7 +995,7 @@ the entire buffer regardless of any narrowing.
 types of text, consider using an alternative facility described in
 @ref{Swapping Text}.
 
-@deffn Command narrow-to-region start end &optional lock
+@deffn Command narrow-to-region start end
 This function sets the accessible portion of the current buffer to start
 at @var{start} and end at @var{end}.  Both arguments should be character
 positions.
@@ -1003,10 +1003,9 @@ positions.
 In an interactive call, @var{start} and @var{end} are set to the bounds
 of the current region (point and the mark, with the smallest first).
 
-When @var{lock} is non-@code{nil}, calls to @code{widen}, or to
-@code{narrow-to-region} with an optional argument @var{lock}
-@code{nil}, do not produce any effect until the end of the current
-body form.
+Note that, in rare circumstances, Emacs may decide to leave, for
+performance reasons, the accessible portion of the buffer unchanged
+after a call to @code{narrow-to-region}.
 @end deffn
 
 @deffn Command narrow-to-page &optional move-count
@@ -1032,9 +1031,9 @@ It is equivalent to the following expression:
 @end example
 @end deffn
 
-However, when @code{widen} is called inside a body form in which
-@code{narrow-to-region} was called with an optional argument
-@code{lock} non-@code{nil}, it does not produce any effect.
+Note that, in rare circumstances, Emacs may decide to leave, for
+performance reasons, the accessible portion of the buffer unchanged
+after a call to @code{widen}.
 
 @defun buffer-narrowed-p
 This function returns non-@code{nil} if the buffer is narrowed, and
index 963aa22c6804f74dc476b9242b31cdaaf3bf425c..b011413cbc3f8c0f5c89eea08a34f4d4141027a3 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2560,13 +2560,6 @@ things to be saved.
 ** New function 'string-equal-ignore-case'.
 This compares strings ignoring case differences.
 
-+++
-** New argument LOCK of 'narrow-to-region'.
-If 'narrow-to-region' is called from Lisp with the new optional
-argument LOCK non-nil, then calls to 'widen' and calls to
-'narrow-to-region' with the optional argument LOCK nil or omitted do
-not produce any effect until the end of the current body form.
-
 ** Themes
 
 ---
index 1ecd77f7517ec1f93e0b3383c07ac3ba4ddffe8e..b4954eee9ff1164adb4910901d36da98faee4174 100644 (file)
@@ -767,7 +767,7 @@ Each element is (INDEX . VALUE)")
 (byte-defop 122  0 byte-char-syntax)
 (byte-defop 123 -1 byte-buffer-substring)
 (byte-defop 124 -1 byte-delete-region)
-(byte-defop 125 -2 byte-narrow-to-region)
+(byte-defop 125 -1 byte-narrow-to-region)
 (byte-defop 126  1 byte-widen)
 (byte-defop 127  0 byte-end-of-line)
 
@@ -3833,7 +3833,7 @@ If it is nil, then the handler is \"byte-compile-SYMBOL.\""
 (byte-defop-compiler setcdr            2)
 (byte-defop-compiler buffer-substring  2)
 (byte-defop-compiler delete-region     2)
-(byte-defop-compiler narrow-to-region  2-3)
+(byte-defop-compiler narrow-to-region  2)
 (byte-defop-compiler (% byte-rem)      2)
 (byte-defop-compiler aset              3)
 
index 4354ea03a4eb653cae175959c4fb0108ea201fe7..5ee10fcbca2f0ba939cc787966df0419eee9de57 100644 (file)
@@ -1915,7 +1915,10 @@ and the annotation emission."
       (byte-char-syntax auto)
       (byte-buffer-substring auto)
       (byte-delete-region auto)
-      (byte-narrow-to-region auto)
+      (byte-narrow-to-region
+       (comp-emit-set-call (comp-call 'narrow-to-region
+                                      (comp-slot)
+                                      (comp-slot+1))))
       (byte-widen
        (comp-emit-set-call (comp-call 'widen)))
       (byte-end-of-line auto)
index 2b1eccdc518836a868ddcedd552568299af65d72..d75767bb0c59b31300a76f295802a7cab533d167 100644 (file)
@@ -1480,8 +1480,8 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
 
        CASE (Bnarrow_to_region):
          {
-           Lisp_Object v2 = POP, v1 = POP;
-           TOP = Fnarrow_to_region (TOP, v1, v2);
+           Lisp_Object v1 = POP;
+           TOP = Fnarrow_to_region (TOP, v1);
            NEXT;
          }
 
index 79af27d24da2e5d3978c9194fbbd3eac0d16ce54..35b2415e8b10d2dafc82348256d7f32ec501799c 100644 (file)
@@ -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)
 {
index 807fcb0e5ba28db3141a76c1dc03cd8701c9e6a7..c8ad0bc56f5873357dc7bec6333bffeee56a8eae 100644 (file)
@@ -4679,6 +4679,7 @@ extern void save_restriction_restore (Lisp_Object);
 extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool);
 extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t,
                                            ptrdiff_t, bool);
+extern Lisp_Object narrow_to_region_internal (Lisp_Object, Lisp_Object, bool);
 extern void init_editfns (void);
 extern void syms_of_editfns (void);
 
index 0720774db2bffef343f1972032c5b89a356206f4..0b46a2e4ee548fa465853b65ac5ce3e709d3f0bd 100644 (file)
@@ -2261,7 +2261,7 @@ readevalloop (Lisp_Object readcharfun,
          /* Set point and ZV around stuff to be read.  */
          Fgoto_char (start);
          if (!NILP (end))
-           Fnarrow_to_region (make_fixnum (BEGV), end, Qnil);
+           Fnarrow_to_region (make_fixnum (BEGV), end);
 
          /* Just for cleanliness, convert END to a marker
             if it is an integer.  */
index a15efa39bd17b397ec34383cae728e2ad2a2ec91..1ac5a509e5678262141cb5b8d13800f394cc82b9 100644 (file)
@@ -6339,7 +6339,7 @@ Otherwise it discards the output.  */)
 
       /* If the restriction isn't what it should be, set it.  */
       if (old_begv != BEGV || old_zv != ZV)
-       Fnarrow_to_region (make_fixnum (old_begv), make_fixnum (old_zv), Qnil);
+       Fnarrow_to_region (make_fixnum (old_begv), make_fixnum (old_zv));
 
       bset_read_only (current_buffer, old_read_only);
       SET_PT_BOTH (opoint, opoint_byte);
index 88a489e290f6ed8d9e6a74e2a0a814598ae4b06b..65d9221a159bdaaeda82f025491dbf0d8829564c 100644 (file)
@@ -4406,7 +4406,8 @@ handle_fontified_prop (struct it *it)
              if (!begv) begv = BEGV;
              zv = get_narrowed_zv (it->w, charpos);
            }
-         Fnarrow_to_region (make_fixnum (begv), make_fixnum (zv), Qt);
+         narrow_to_region_internal (make_fixnum (begv), make_fixnum (zv), true);
+         specbind (Qrestrictions_locked, Qt);
        }
 
       /* Don't allow Lisp that runs from 'fontification-functions'