emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/improved-locked-narrowing ea8e0f67bb: Minor improvements to lock


From: Gregory Heytings
Subject: feature/improved-locked-narrowing ea8e0f67bb: Minor improvements to locked narrowing.
Date: Sun, 21 Aug 2022 17:26:22 -0400 (EDT)

branch: feature/improved-locked-narrowing
commit ea8e0f67bbb6eccf4c860348589d5d3abf8ade84
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>

    Minor improvements to locked narrowing.
    
    * 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  | 19 +++++++++++--------
 src/editfns.c | 10 +++++-----
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 35c8e086e3..fed3185fcc 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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.
diff --git a/src/editfns.c b/src/editfns.c
index 3389be6757..d7a62d914b 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -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'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]