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.
This commit is contained in:
parent
c2ed2e6858
commit
9d8a6c8283
10 changed files with 50 additions and 45 deletions
|
@ -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
|
||||
|
|
7
etc/NEWS
7
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
|
||||
|
||||
---
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Add table
Reference in a new issue