Function: with-restriction
with-restriction is a macro defined in subr.el.gz.
Signature
(with-restriction START END [:label LABEL] BODY)
Documentation
Execute BODY with restrictions set to START and END.
The current restrictions, if any, are restored upon return.
When the optional LABEL argument, which is evaluated to get the
label to use and must yield a non-nil value, is present, inside
BODY, narrow-to-region and widen can be used only within the
START and END limits. To gain access to other portions of the
buffer, use without-restriction with the same LABEL argument.
Probably introduced at or before Emacs version 29.1.
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro with-restriction (start end &rest rest)
"Execute BODY with restrictions set to START and END.
The current restrictions, if any, are restored upon return.
When the optional LABEL argument, which is evaluated to get the
label to use and must yield a non-nil value, is present, inside
BODY, `narrow-to-region' and `widen' can be used only within the
START and END limits. To gain access to other portions of the
buffer, use `without-restriction' with the same LABEL argument.
\(fn START END [:label LABEL] BODY)"
(declare (indent 2) (debug t))
(if (eq (car rest) :label)
`(save-restriction
(internal--labeled-narrow-to-region ,start ,end ,(cadr rest))
,@(cddr rest))
`(save-restriction (narrow-to-region ,start ,end) ,@rest)))