aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Heytings2022-08-21 21:25:32 +0000
committerGregory Heytings2022-08-21 23:26:14 +0200
commitea8e0f67bbb6eccf4c860348589d5d3abf8ade84 (patch)
tree0b3f3698379ef06f8779872fe7b48d0a7a787865
parent2342fb052b276f8f5b0e00647a1150b3a9c51c66 (diff)
downloademacs-ea8e0f67bbb6eccf4c860348589d5d3abf8ade84.tar.gz
emacs-ea8e0f67bbb6eccf4c860348589d5d3abf8ade84.zip
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.
-rw-r--r--lisp/subr.el19
-rw-r--r--src/editfns.c10
2 files changed, 16 insertions, 13 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 35c8e086e3a..fed3185fcc0 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3919,14 +3919,17 @@ See also `locate-user-emacs-file'.")
3919 3919
3920Inside BODY, `narrow-to-region' and `widen' can be used only 3920Inside BODY, `narrow-to-region' and `widen' can be used only
3921within the START and END limits, unless the restrictions are 3921within the START and END limits, unless the restrictions are
3922unlocked by calling `narrowing-unlock' with TAG." 3922unlocked by calling `narrowing-unlock' with TAG. See
3923 `(unwind-protect 3923`narrowing-lock' for a more detailed description. The current
3924 (progn 3924restrictions, if any, are restored upon return."
3925 (narrow-to-region ,start ,end) 3925 `(save-restriction
3926 (narrowing-lock ,tag) 3926 (unwind-protect
3927 ,@body) 3927 (progn
3928 (narrowing-unlock ,tag) 3928 (narrow-to-region ,start ,end)
3929 (widen))) 3929 (narrowing-lock ,tag)
3930 ,@body)
3931 (narrowing-unlock ,tag)
3932 (widen))))
3930 3933
3931(defun find-tag-default-bounds () 3934(defun find-tag-default-bounds ()
3932 "Determine the boundaries of the default tag, based on text at point. 3935 "Determine the boundaries of the default tag, based on text at point.
diff --git a/src/editfns.c b/src/editfns.c
index 3389be67573..d7a62d914b8 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2687,9 +2687,9 @@ DEFUN ("widen", Fwiden, Swiden, 0, 0, "",
2687 doc: /* Remove restrictions (narrowing) from current buffer. 2687 doc: /* Remove restrictions (narrowing) from current buffer.
2688 2688
2689This allows the buffer's full text to be seen and edited, unless 2689This allows the buffer's full text to be seen and edited, unless
2690the restrictions have been locked with `narrowing-lock', which see, 2690restrictions have been locked with `narrowing-lock', which see, in
2691in which case the the restrictions that were current when 2691which case the restrictions that were current when `narrowing-lock'
2692`narrowing-lock' was called are restored. */) 2692was called are restored. */)
2693 (void) 2693 (void)
2694{ 2694{
2695 Fset (Qoutermost_narrowing, Qnil); 2695 Fset (Qoutermost_narrowing, Qnil);
@@ -2786,8 +2786,8 @@ used only within the limits of the restrictions that were current when
2786 2786
2787Locking restrictions should be used sparingly, after carefully 2787Locking restrictions should be used sparingly, after carefully
2788considering the potential adverse effects on the code that will be 2788considering the potential adverse effects on the code that will be
2789executed with locked restrictions. It is meant to be used around 2789executed within locked restrictions. It is typically meant to be used
2790portions of code that would become too slow, and make Emacs 2790around portions of code that would become too slow, and make Emacs
2791unresponsive, if they were executed in a large buffer. For example, 2791unresponsive, if they were executed in a large buffer. For example,
2792restrictions are locked by Emacs around low-level hooks such as 2792restrictions are locked by Emacs around low-level hooks such as
2793`fontification-functions' or `post-command-hook'. 2793`fontification-functions' or `post-command-hook'.