From: Gregory Heytings Date: Sun, 21 Aug 2022 21:25:32 +0000 (+0000) Subject: Minor improvements to locked narrowing. X-Git-Tag: emacs-29.0.90~1447^2~15 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ea8e0f67bbb6eccf4c860348589d5d3abf8ade84;p=emacs.git 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. --- 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'.") 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 3389be67573..d7a62d914b8 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'.