From dcb2379a463678bdadd05ee39d61e7da84c71c5e Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Mon, 13 Feb 2023 10:23:39 +0000 Subject: [PATCH] Minor improvements to labeled narrowing * lisp/subr.el (internal--with-narrowing): (internal--without-narrowing): Remove unnecessary 'progn'. * etc/NEWS: Mention 'with-narrowing' in the entry about long lines. * doc/lispref/positions.texi (Narrowing): Fix typo. * doc/lispref/display.texi (Auto Faces): Use @pxref. * doc/lispref/commands.texi (Command Overview): Use @pxref. --- doc/lispref/commands.texi | 4 ++-- doc/lispref/display.texi | 2 +- doc/lispref/positions.texi | 2 +- etc/NEWS | 5 +++-- lisp/subr.el | 14 ++++++-------- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index be34027d21d..9723c279a45 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi @@ -100,8 +100,8 @@ emacs, The GNU Emacs Manual}) runs these two hooks just as a keyboard command does. Note that, when the buffer text includes very long lines, these two -hooks are called as if they were in a @code{with-narrowing} form (see -@ref{Narrowing}), with a +hooks are called as if they were in a @code{with-narrowing} form +(@pxref{Narrowing}), with a @code{long-line-optimizations-in-command-hooks} label and with the buffer narrowed to a portion around point. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 1b7ef006634..f0ca7440c60 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -3503,7 +3503,7 @@ usually assign faces to around 400 to 600 characters at each call. Note that, when the buffer text includes very long lines, these functions are called as if they were in a @code{with-narrowing} form -(see @ref{Narrowing}), with a +(@pxref{Narrowing}), with a @code{long-line-optimizations-in-fontification-functions} label and with the buffer narrowed to a portion around @var{pos}. @end defvar diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index e7d5c610d67..bad83e1be2d 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi @@ -1193,5 +1193,5 @@ restores the saved bounds. In that case it is equivalent to When the optional @var{label} argument is present however, the narrowing set by @code{with-narrowing} with the same @var{label} -argument are lifted. +argument is lifted. @end defspec diff --git a/etc/NEWS b/etc/NEWS index 01e7f2cfb09..de4f65ebe62 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -619,8 +619,9 @@ In buffers in which these display optimizations are in effect, the 'fontification-functions', 'pre-command-hook' and 'post-command-hook' hooks are executed on a narrowed portion of the buffer, whose size is controlled by the options 'long-line-optimizations-region-size' and -'long-line-optimizations-bol-search-limit'. This may, in particular, -cause occasional mis-fontifications in these buffers. +'long-line-optimizations-bol-search-limit', as if they were in a +'with-narrowing' form. This may, in particular, cause occasional +mis-fontifications in these buffers. The new function 'long-line-optimizations-p' returns non-nil when these optimizations are in effect in the current buffer. diff --git a/lisp/subr.el b/lisp/subr.el index 7ed0cb02a70..d280c7fef13 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3961,10 +3961,9 @@ same LABEL argument. (defun internal--with-narrowing (start end body &optional label) "Helper function for `with-narrowing', which see." (save-restriction - (progn - (narrow-to-region start end) - (if label (internal--lock-narrowing label)) - (funcall body)))) + (narrow-to-region start end) + (if label (internal--lock-narrowing label)) + (funcall body))) (defmacro without-narrowing (&rest rest) "Execute BODY without restrictions. @@ -3984,10 +3983,9 @@ are lifted. (defun internal--without-narrowing (body &optional label) "Helper function for `without-narrowing', which see." (save-restriction - (progn - (if label (internal--unlock-narrowing label)) - (widen) - (funcall body)))) + (if label (internal--unlock-narrowing label)) + (widen) + (funcall body))) (defun find-tag-default-bounds () "Determine the boundaries of the default tag, based on text at point. -- 2.39.2