Skip to content

Commit 9e9e116

Browse files
author
Gregory Heytings
committed
Simplify 'without-restriction'
This simplification is symmetrical to 01fb898. * src/editfns.c: (Finternal__labeled_widen): Add a call to 'Fwiden', and rename from 'internal--unlabel-restriction'. (unwind_labeled_narrow_to_region): Use the renamed function, and remove the call to 'Fwiden'. (syms_of_editfns): Rename the symbol. * lisp/subr.el (internal--without-restriction): Use the renamed function.
1 parent d622602 commit 9e9e116

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lisp/subr.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,8 +4146,9 @@ by `with-restriction' with the same LABEL argument are lifted.
41464146
(defun internal--without-restriction (body &optional label)
41474147
"Helper function for `without-restriction', which see."
41484148
(save-restriction
4149-
(if label (internal--unlabel-restriction label))
4150-
(widen)
4149+
(if label
4150+
(internal--labeled-widen label)
4151+
(widen))
41514152
(funcall body)))
41524153

41534154
(defun find-tag-default-bounds ()

src/editfns.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,7 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region,
26912691
labeled restriction was entered (which may be a narrowing that was
26922692
set by the user and is visible on display). This alist is used
26932693
internally by narrow-to-region, internal--labeled-narrow-to-region,
2694-
widen, internal--unlabel-restriction and save-restriction. For
2694+
widen, internal--labeled-widen and save-restriction. For
26952695
efficiency reasons, an alist is used instead of a buffer-local
26962696
variable: otherwise reset_outermost_restrictions, which is called
26972697
during each redisplay cycle, would have to loop through all live
@@ -2867,8 +2867,7 @@ labeled_restrictions_restore (Lisp_Object buf_and_restrictions)
28672867
static void
28682868
unwind_labeled_narrow_to_region (Lisp_Object label)
28692869
{
2870-
Finternal__unlabel_restriction (label);
2871-
Fwiden ();
2870+
Finternal__labeled_widen (label);
28722871
}
28732872

28742873
/* Narrow current_buffer to BEGV-ZV with a restriction labeled with
@@ -2991,7 +2990,7 @@ argument. To gain access to other portions of the buffer, use
29912990

29922991
DEFUN ("internal--labeled-narrow-to-region", Finternal__labeled_narrow_to_region,
29932992
Sinternal__labeled_narrow_to_region, 3, 3, 0,
2994-
doc: /* Restrict editing in this buffer to START-END, and label the restriction with LABEL.
2993+
doc: /* Restrict this buffer to START-END, and label the restriction with LABEL.
29952994
29962995
This is an internal function used by `with-restriction'. */)
29972996
(Lisp_Object start, Lisp_Object end, Lisp_Object label)
@@ -3009,16 +3008,17 @@ This is an internal function used by `with-restriction'. */)
30093008
return Qnil;
30103009
}
30113010

3012-
DEFUN ("internal--unlabel-restriction", Finternal__unlabel_restriction,
3013-
Sinternal__unlabel_restriction, 1, 1, 0,
3014-
doc: /* If the current restriction is labeled with LABEL, remove its label.
3011+
DEFUN ("internal--labeled-widen", Finternal__labeled_widen,
3012+
Sinternal__labeled_widen, 1, 1, 0,
3013+
doc: /* Remove the current restriction if it is labeled with LABEL, and widen.
30153014
30163015
This is an internal function used by `without-restriction'. */)
30173016
(Lisp_Object label)
30183017
{
30193018
Lisp_Object buf = Fcurrent_buffer ();
30203019
if (EQ (labeled_restrictions_peek_label (buf), label))
30213020
labeled_restrictions_pop (buf);
3021+
Fwiden ();
30223022
return Qnil;
30233023
}
30243024

@@ -4958,7 +4958,7 @@ it to be non-nil. */);
49584958
defsubr (&Swiden);
49594959
defsubr (&Snarrow_to_region);
49604960
defsubr (&Sinternal__labeled_narrow_to_region);
4961-
defsubr (&Sinternal__unlabel_restriction);
4961+
defsubr (&Sinternal__labeled_widen);
49624962
defsubr (&Ssave_restriction);
49634963
defsubr (&Stranspose_regions);
49644964
}

0 commit comments

Comments
 (0)