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.
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
@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
** 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
---
(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)
(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)
(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)
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;
}
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))
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);
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);
SET_BUF_BEGV (current_buffer, s);
SET_BUF_ZV (current_buffer, e);
-
- specbind (Qrestrictions_locked, Qt);
}
else
{
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)
{
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);
/* 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. */
/* 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);
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'