summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Heytings <gregory@heytings.org>2023-08-16 15:58:29 +0000
committerGregory Heytings <gregory@heytings.org>2024-01-15 13:26:28 +0000
commit53b5b77010117e2f58565dacf96fddeb734b6021 (patch)
tree71fc8170c91ac6c7fc6ea9868cc2e35a5c1c9cea
parent5bb5590dec95e813ed120b3f09734451b4ebb18f (diff)
downloademacs-53b5b77010117e2f58565dacf96fddeb734b6021.tar.gz
Simplify 'without-restriction'
This simplification is symmetrical to 01fb898420. * 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. (cherry picked from commit 9e9e11648d3d5514de85edfb69f0949a062f4716)
-rw-r--r--lisp/subr.el5
-rw-r--r--src/editfns.c16
2 files changed, 11 insertions, 10 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index e8a6bb01c1e..d9df8d1a458 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4013,8 +4013,9 @@ by `with-restriction' with the same LABEL argument are lifted.
(defun internal--without-restriction (body &optional label)
"Helper function for `without-restriction', which see."
(save-restriction
- (if label (internal--unlabel-restriction label))
- (widen)
+ (if label
+ (internal--labeled-widen label)
+ (widen))
(funcall body)))
(defun find-tag-default-bounds ()
diff --git a/src/editfns.c b/src/editfns.c
index 6ddee0840c2..85f7739df07 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2684,7 +2684,7 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region,
labeled restriction was entered (which may be a narrowing that was
set by the user and is visible on display). This alist is used
internally by narrow-to-region, internal--labeled-narrow-to-region,
- widen, internal--unlabel-restriction and save-restriction. For
+ widen, internal--labeled-widen and save-restriction. For
efficiency reasons, an alist is used instead of a buffer-local
variable: otherwise reset_outermost_restrictions, which is called
during each redisplay cycle, would have to loop through all live
@@ -2860,8 +2860,7 @@ labeled_restrictions_restore (Lisp_Object buf_and_restrictions)
static void
unwind_labeled_narrow_to_region (Lisp_Object label)
{
- Finternal__unlabel_restriction (label);
- Fwiden ();
+ Finternal__labeled_widen (label);
}
/* Narrow current_buffer to BEGV-ZV with a restriction labeled with
@@ -2984,7 +2983,7 @@ argument. To gain access to other portions of the buffer, use
DEFUN ("internal--labeled-narrow-to-region", Finternal__labeled_narrow_to_region,
Sinternal__labeled_narrow_to_region, 3, 3, 0,
- doc: /* Restrict editing in this buffer to START-END, and label the restriction with LABEL.
+ doc: /* Restrict this buffer 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)
@@ -3002,9 +3001,9 @@ This is an internal function used by `with-restriction'. */)
return Qnil;
}
-DEFUN ("internal--unlabel-restriction", Finternal__unlabel_restriction,
- Sinternal__unlabel_restriction, 1, 1, 0,
- doc: /* If the current restriction is labeled with LABEL, remove its label.
+DEFUN ("internal--labeled-widen", Finternal__labeled_widen,
+ Sinternal__labeled_widen, 1, 1, 0,
+ doc: /* Remove the current restriction if it is labeled with LABEL, and widen.
This is an internal function used by `without-restriction'. */)
(Lisp_Object label)
@@ -3012,6 +3011,7 @@ This is an internal function used by `without-restriction'. */)
Lisp_Object buf = Fcurrent_buffer ();
if (EQ (labeled_restrictions_peek_label (buf), label))
labeled_restrictions_pop (buf);
+ Fwiden ();
return Qnil;
}
@@ -4951,7 +4951,7 @@ it to be non-nil. */);
defsubr (&Swiden);
defsubr (&Snarrow_to_region);
defsubr (&Sinternal__labeled_narrow_to_region);
- defsubr (&Sinternal__unlabel_restriction);
+ defsubr (&Sinternal__labeled_widen);
defsubr (&Ssave_restriction);
defsubr (&Stranspose_regions);
}