diff options
author | Gregory Heytings <gregory@heytings.org> | 2023-07-06 17:04:53 +0000 |
---|---|---|
committer | Gregory Heytings <gregory@heytings.org> | 2023-07-06 17:14:17 +0000 |
commit | b741dc7fcde0c601a01470655ceaeeef854ac32e (patch) | |
tree | e51a18878cf3197c5afa29ad5a5b6ee186a9a97a /lisp | |
parent | 9b38773a20b43e2354ddf036ffa28e397537da3f (diff) | |
download | emacs-b741dc7fcde0c601a01470655ceaeeef854ac32e.tar.gz |
Add internal function to enter a labeled restriction
* src/editfns.c (Finternal__labeled_narrow_to_region): New
function. A specific function is necessary to avoid unnecessary
slowdowns when 'narrow-to-region'/'widen' are called in a loop.
(Fnarrow_to_region): Remove the call to Fset, which has been moved
into Finternal__labeled_narrow_to_region.
(labeled_narrow_to_region): Use the new function.
(syms_of_editfns): Add the symbol of the new function.
* lisp/subr.el (internal--with-restriction): Use the new function.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/subr.el | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 85adef5b689..0b397b7bebf 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3980,8 +3980,9 @@ same LABEL argument. (defun internal--with-restriction (start end body &optional label) "Helper function for `with-restriction', which see." (save-restriction - (narrow-to-region start end) - (if label (internal--label-restriction label)) + (if label + (internal--labeled-narrow-to-region start end label) + (narrow-to-region start end)) (funcall body))) (defmacro without-restriction (&rest rest) |