Skip to content

Commit 01fb898

Browse files
author
Gregory Heytings
committed
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.
1 parent b741dc7 commit 01fb898

File tree

1 file changed

+14
-39
lines changed

1 file changed

+14
-39
lines changed

src/editfns.c

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,11 +2682,12 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region,
26822682
records the restriction bounds that were current when the first
26832683
labeled restriction was entered (which may be a narrowing that was
26842684
set by the user and is visible on display). This alist is used
2685-
internally by narrow-to-region, widen, internal--label-restriction,
2686-
internal--unlabel-restriction and save-restriction. For efficiency
2687-
reasons, an alist is used instead of a buffer-local variable:
2688-
otherwise reset_outermost_restrictions, which is called during each
2689-
redisplay cycle, would have to loop through all live buffers. */
2685+
internally by narrow-to-region, internal--labeled-narrow-to-region,
2686+
widen, internal--unlabel-restriction and save-restriction. For
2687+
efficiency reasons, an alist is used instead of a buffer-local
2688+
variable: otherwise reset_outermost_restrictions, which is called
2689+
during each redisplay cycle, would have to loop through all live
2690+
buffers. */
26902691
static Lisp_Object labeled_restrictions;
26912692

26922693
/* Add BUF with its list of labeled RESTRICTIONS in the
@@ -2884,7 +2885,6 @@ To gain access to other portions of the buffer, use
28842885
`without-restriction' with the same label. */)
28852886
(void)
28862887
{
2887-
Fset (Qoutermost_restriction, Qnil);
28882888
Lisp_Object buf = Fcurrent_buffer ();
28892889
Lisp_Object label = labeled_restrictions_peek_label (buf);
28902890

@@ -2981,20 +2981,18 @@ argument. To gain access to other portions of the buffer, use
29812981
return Qnil;
29822982
}
29832983

2984-
DEFUN ("internal--label-restriction", Finternal__label_restriction,
2985-
Sinternal__label_restriction, 1, 1, 0,
2986-
doc: /* Label the current restriction with LABEL.
2984+
DEFUN ("internal--labeled-narrow-to-region", Finternal__labeled_narrow_to_region,
2985+
Sinternal__labeled_narrow_to_region, 3, 3, 0,
2986+
doc: /* Restrict editing in this buffer to START-END, and label the restriction with LABEL.
29872987
29882988
This is an internal function used by `with-restriction'. */)
2989-
(Lisp_Object label)
2989+
(Lisp_Object start, Lisp_Object end, Lisp_Object label)
29902990
{
29912991
Lisp_Object buf = Fcurrent_buffer ();
2992-
Lisp_Object outermost_restriction
2993-
= buffer_local_value (Qoutermost_restriction, buf);
2994-
/* If internal--label-restriction is ever called without being
2995-
preceded by narrow-to-region, do nothing. */
2996-
if (NILP (outermost_restriction))
2997-
return Qnil;
2992+
Lisp_Object outermost_restriction = list3 (Qoutermost_restriction,
2993+
Fpoint_min_marker (),
2994+
Fpoint_max_marker ());
2995+
Fnarrow_to_region (start, end);
29982996
if (NILP (labeled_restrictions_peek_label (buf)))
29992997
labeled_restrictions_push (buf, outermost_restriction);
30002998
labeled_restrictions_push (buf, list3 (label,
@@ -3003,24 +3001,6 @@ This is an internal function used by `with-restriction'. */)
30033001
return Qnil;
30043002
}
30053003

3006-
DEFUN ("internal--labeled-narrow-to-region", Finternal__labeled_narrow_to_region,
3007-
Sinternal__labeled_narrow_to_region, 3, 3, 0,
3008-
doc: /* Restrict editing to START-END, and label the restriction with LABEL.
3009-
3010-
This is an internal function used by `with-restriction'. */)
3011-
(Lisp_Object start, Lisp_Object end, Lisp_Object label)
3012-
{
3013-
/* Record the accessible range of the buffer when narrow-to-region
3014-
is called, that is, before applying the narrowing. That
3015-
information is used only by internal--label-restriction. */
3016-
Fset (Qoutermost_restriction, list3 (Qoutermost_restriction,
3017-
Fpoint_min_marker (),
3018-
Fpoint_max_marker ()));
3019-
Fnarrow_to_region (start, end);
3020-
Finternal__label_restriction (label);
3021-
return Qnil;
3022-
}
3023-
30243004
DEFUN ("internal--unlabel-restriction", Finternal__unlabel_restriction,
30253005
Sinternal__unlabel_restriction, 1, 1, 0,
30263006
doc: /* If the current restriction is labeled with LABEL, remove its label.
@@ -4875,10 +4855,6 @@ This variable is experimental; email [email protected] if you need
48754855
it to be non-nil. */);
48764856
binary_as_unsigned = false;
48774857

4878-
DEFVAR_LISP ("outermost-restriction", Voutermost_restriction,
4879-
doc: /* Outermost narrowing bounds, if any. Internal use only. */);
4880-
Voutermost_restriction = Qnil;
4881-
Fmake_variable_buffer_local (Qoutermost_restriction);
48824858
DEFSYM (Qoutermost_restriction, "outermost-restriction");
48834859
Funintern (Qoutermost_restriction, Qnil);
48844860

@@ -4973,7 +4949,6 @@ it to be non-nil. */);
49734949
defsubr (&Sdelete_and_extract_region);
49744950
defsubr (&Swiden);
49754951
defsubr (&Snarrow_to_region);
4976-
defsubr (&Sinternal__label_restriction);
49774952
defsubr (&Sinternal__labeled_narrow_to_region);
49784953
defsubr (&Sinternal__unlabel_restriction);
49794954
defsubr (&Ssave_restriction);

0 commit comments

Comments
 (0)