]> git.eshelyaron.com Git - emacs.git/commitdiff
Minor improvements to locked narrowing.
authorGregory Heytings <gregory@heytings.org>
Sun, 21 Aug 2022 21:25:32 +0000 (21:25 +0000)
committerGregory Heytings <gregory@heytings.org>
Sun, 21 Aug 2022 21:26:14 +0000 (23:26 +0200)
* lisp/subr.el (with-locked-narrowing): Add 'save-restriction' around
the macro body.  Update docstring.

* src/editfns.c (Fwiden, Fnarrowing_lock): Docstring improvements.

lisp/subr.el
src/editfns.c

index 35c8e086e3a4bc99a8a0ebdef87be3421fea6834..fed3185fcc061501834d835b36b688b831efcc73 100644 (file)
@@ -3919,14 +3919,17 @@ See also `locate-user-emacs-file'.")
 
 Inside BODY, `narrow-to-region' and `widen' can be used only
 within the START and END limits, unless the restrictions are
-unlocked by calling `narrowing-unlock' with TAG."
-  `(unwind-protect
-       (progn
-         (narrow-to-region ,start ,end)
-         (narrowing-lock ,tag)
-         ,@body)
-     (narrowing-unlock ,tag)
-     (widen)))
+unlocked by calling `narrowing-unlock' with TAG.  See
+`narrowing-lock' for a more detailed description.  The current
+restrictions, if any, are restored upon return."
+  `(save-restriction
+     (unwind-protect
+         (progn
+           (narrow-to-region ,start ,end)
+           (narrowing-lock ,tag)
+           ,@body)
+       (narrowing-unlock ,tag)
+       (widen))))
 
 (defun find-tag-default-bounds ()
   "Determine the boundaries of the default tag, based on text at point.
index 3389be67573f4759222054dfdfa3cbd47318619b..d7a62d914b859a6636fa41738c97b7ec803bb79b 100644 (file)
@@ -2687,9 +2687,9 @@ DEFUN ("widen", Fwiden, Swiden, 0, 0, "",
        doc: /* Remove restrictions (narrowing) from current buffer.
 
 This allows the buffer's full text to be seen and edited, unless
-the restrictions have been locked with `narrowing-lock', which see,
-in which case the the restrictions that were current when
-`narrowing-lock' was called are restored.  */)
+restrictions have been locked with `narrowing-lock', which see, in
+which case the restrictions that were current when `narrowing-lock'
+was called are restored.  */)
   (void)
 {
   Fset (Qoutermost_narrowing, Qnil);
@@ -2786,8 +2786,8 @@ used only within the limits of the restrictions that were current when
 
 Locking restrictions should be used sparingly, after carefully
 considering the potential adverse effects on the code that will be
-executed with locked restrictions.  It is meant to be used around
-portions of code that would become too slow, and make Emacs
+executed within locked restrictions.  It is typically meant to be used
+around portions of code that would become too slow, and make Emacs
 unresponsive, if they were executed in a large buffer.  For example,
 restrictions are locked by Emacs around low-level hooks such as
 `fontification-functions' or `post-command-hook'.