Function: with-restriction

with-restriction is a macro defined in compat-29.el.

Signature

(with-restriction START END [:label LABEL] BODY)

Documentation

[Compatibility macro for with-restriction, defined in Emacs 29.1. See (compat)
Emacs 29.1' for more details.]

Execute BODY with restrictions set to START and END.

The current restrictions, if any, are restored upon return.

When the optional :label LABEL argument is present, in which LABEL is a symbol, 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.

Source Code

;; Defined in ~/.emacs.d/elpa/compat-30.1.0.1/compat-29.el
(compat-defmacro with-restriction (start end &rest rest) ;; <compat-tests:with-restriction>
  "Execute BODY with restrictions set to START and END.

The current restrictions, if any, are restored upon return.

When the optional :label LABEL argument is present, in which
LABEL is a symbol, 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 0) (debug t))
  `(save-restriction
     (narrow-to-region ,start ,end)
     ;; Locking is ignored
     ,@(if (eq (car rest) :label) (cddr rest) rest)))