Simplify after adding internal function to enter a labeled restriction
* src/editfns.c: (Finternal__labeled_narrow_to_region): Merge the code of Finternal__label_restriction into this function. (Finternal__label_restriction): Remove this function. (syms_of_editfns): Remove the 'outermost-restriction' buffer local variable, which is not used anymore, and the symbol of 'internal--label-restriction'. (Fwiden): Remove the call to reset the 'outermost-restriction' buffer local variable.
This commit is contained in:
parent
b741dc7fcd
commit
01fb898420
1 changed files with 14 additions and 39 deletions
|
@ -2682,11 +2682,12 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region,
|
||||||
records the restriction bounds that were current when the first
|
records the restriction bounds that were current when the first
|
||||||
labeled restriction was entered (which may be a narrowing that was
|
labeled restriction was entered (which may be a narrowing that was
|
||||||
set by the user and is visible on display). This alist is used
|
set by the user and is visible on display). This alist is used
|
||||||
internally by narrow-to-region, widen, internal--label-restriction,
|
internally by narrow-to-region, internal--labeled-narrow-to-region,
|
||||||
internal--unlabel-restriction and save-restriction. For efficiency
|
widen, internal--unlabel-restriction and save-restriction. For
|
||||||
reasons, an alist is used instead of a buffer-local variable:
|
efficiency reasons, an alist is used instead of a buffer-local
|
||||||
otherwise reset_outermost_restrictions, which is called during each
|
variable: otherwise reset_outermost_restrictions, which is called
|
||||||
redisplay cycle, would have to loop through all live buffers. */
|
during each redisplay cycle, would have to loop through all live
|
||||||
|
buffers. */
|
||||||
static Lisp_Object labeled_restrictions;
|
static Lisp_Object labeled_restrictions;
|
||||||
|
|
||||||
/* Add BUF with its list of labeled RESTRICTIONS in the
|
/* Add BUF with its list of labeled RESTRICTIONS in the
|
||||||
|
@ -2884,7 +2885,6 @@ To gain access to other portions of the buffer, use
|
||||||
`without-restriction' with the same label. */)
|
`without-restriction' with the same label. */)
|
||||||
(void)
|
(void)
|
||||||
{
|
{
|
||||||
Fset (Qoutermost_restriction, Qnil);
|
|
||||||
Lisp_Object buf = Fcurrent_buffer ();
|
Lisp_Object buf = Fcurrent_buffer ();
|
||||||
Lisp_Object label = labeled_restrictions_peek_label (buf);
|
Lisp_Object label = labeled_restrictions_peek_label (buf);
|
||||||
|
|
||||||
|
@ -2981,20 +2981,18 @@ argument. To gain access to other portions of the buffer, use
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN ("internal--label-restriction", Finternal__label_restriction,
|
DEFUN ("internal--labeled-narrow-to-region", Finternal__labeled_narrow_to_region,
|
||||||
Sinternal__label_restriction, 1, 1, 0,
|
Sinternal__labeled_narrow_to_region, 3, 3, 0,
|
||||||
doc: /* Label the current restriction with LABEL.
|
doc: /* Restrict editing in this buffer to START-END, and label the restriction with LABEL.
|
||||||
|
|
||||||
This is an internal function used by `with-restriction'. */)
|
This is an internal function used by `with-restriction'. */)
|
||||||
(Lisp_Object label)
|
(Lisp_Object start, Lisp_Object end, Lisp_Object label)
|
||||||
{
|
{
|
||||||
Lisp_Object buf = Fcurrent_buffer ();
|
Lisp_Object buf = Fcurrent_buffer ();
|
||||||
Lisp_Object outermost_restriction
|
Lisp_Object outermost_restriction = list3 (Qoutermost_restriction,
|
||||||
= buffer_local_value (Qoutermost_restriction, buf);
|
Fpoint_min_marker (),
|
||||||
/* If internal--label-restriction is ever called without being
|
Fpoint_max_marker ());
|
||||||
preceded by narrow-to-region, do nothing. */
|
Fnarrow_to_region (start, end);
|
||||||
if (NILP (outermost_restriction))
|
|
||||||
return Qnil;
|
|
||||||
if (NILP (labeled_restrictions_peek_label (buf)))
|
if (NILP (labeled_restrictions_peek_label (buf)))
|
||||||
labeled_restrictions_push (buf, outermost_restriction);
|
labeled_restrictions_push (buf, outermost_restriction);
|
||||||
labeled_restrictions_push (buf, list3 (label,
|
labeled_restrictions_push (buf, list3 (label,
|
||||||
|
@ -3003,24 +3001,6 @@ This is an internal function used by `with-restriction'. */)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN ("internal--labeled-narrow-to-region", Finternal__labeled_narrow_to_region,
|
|
||||||
Sinternal__labeled_narrow_to_region, 3, 3, 0,
|
|
||||||
doc: /* Restrict editing to START-END, and label the restriction with LABEL.
|
|
||||||
|
|
||||||
This is an internal function used by `with-restriction'. */)
|
|
||||||
(Lisp_Object start, Lisp_Object end, Lisp_Object label)
|
|
||||||
{
|
|
||||||
/* Record the accessible range of the buffer when narrow-to-region
|
|
||||||
is called, that is, before applying the narrowing. That
|
|
||||||
information is used only by internal--label-restriction. */
|
|
||||||
Fset (Qoutermost_restriction, list3 (Qoutermost_restriction,
|
|
||||||
Fpoint_min_marker (),
|
|
||||||
Fpoint_max_marker ()));
|
|
||||||
Fnarrow_to_region (start, end);
|
|
||||||
Finternal__label_restriction (label);
|
|
||||||
return Qnil;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN ("internal--unlabel-restriction", Finternal__unlabel_restriction,
|
DEFUN ("internal--unlabel-restriction", Finternal__unlabel_restriction,
|
||||||
Sinternal__unlabel_restriction, 1, 1, 0,
|
Sinternal__unlabel_restriction, 1, 1, 0,
|
||||||
doc: /* If the current restriction is labeled with LABEL, remove its label.
|
doc: /* If the current restriction is labeled with LABEL, remove its label.
|
||||||
|
@ -4875,10 +4855,6 @@ This variable is experimental; email 32252@debbugs.gnu.org if you need
|
||||||
it to be non-nil. */);
|
it to be non-nil. */);
|
||||||
binary_as_unsigned = false;
|
binary_as_unsigned = false;
|
||||||
|
|
||||||
DEFVAR_LISP ("outermost-restriction", Voutermost_restriction,
|
|
||||||
doc: /* Outermost narrowing bounds, if any. Internal use only. */);
|
|
||||||
Voutermost_restriction = Qnil;
|
|
||||||
Fmake_variable_buffer_local (Qoutermost_restriction);
|
|
||||||
DEFSYM (Qoutermost_restriction, "outermost-restriction");
|
DEFSYM (Qoutermost_restriction, "outermost-restriction");
|
||||||
Funintern (Qoutermost_restriction, Qnil);
|
Funintern (Qoutermost_restriction, Qnil);
|
||||||
|
|
||||||
|
@ -4973,7 +4949,6 @@ it to be non-nil. */);
|
||||||
defsubr (&Sdelete_and_extract_region);
|
defsubr (&Sdelete_and_extract_region);
|
||||||
defsubr (&Swiden);
|
defsubr (&Swiden);
|
||||||
defsubr (&Snarrow_to_region);
|
defsubr (&Snarrow_to_region);
|
||||||
defsubr (&Sinternal__label_restriction);
|
|
||||||
defsubr (&Sinternal__labeled_narrow_to_region);
|
defsubr (&Sinternal__labeled_narrow_to_region);
|
||||||
defsubr (&Sinternal__unlabel_restriction);
|
defsubr (&Sinternal__unlabel_restriction);
|
||||||
defsubr (&Ssave_restriction);
|
defsubr (&Ssave_restriction);
|
||||||
|
|
Loading…
Add table
Reference in a new issue