Subject: bug#64391: buffer narrowing slowdown regression in emacs 29

From: Gregory Heytings <[email-masked]>
Date: Sun, 09 Jul 2023 16:04:09 +0000

>>> I also question the wisdom of telling only in the doc string that the 
>>> tag is evaluated.  I could understand if you did that the other way 
>>> around, but if the doc string says that, the manual should also say 
>>> it.
>>
>> But the patch I sent changes both the manual and the docstring?
>
> It does, but only the latter says that LABEL is evaluated.
>

Oh, indeed, now I see what you mean.  Here's the updated patch.

On a second thought, I believe its better to not replace LABEL with TAG, 
because that would mean changing that word in many places, including 
places in which such a change would make the text less understandable, 
e.g. the docstring of narrow-to-region:

However, when restrictions have been set by `with-restriction' with a 
label, `narrow-to-region' can be used only within the limits of these 
restrictions.  If the START or END arguments are outside these limits, the 
corresponding limit set by `with-restriction' is used instead of the 
argument.  To gain access to other portions of the buffer, use 
`without-restriction' with the same label.

diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi
index e74a165b9ed..183d0e39aee 100644
--- a/doc/lispref/positions.texi
+++ b/doc/lispref/positions.texi
@@ -1169,9 +1169,10 @@ Narrowing

  @cindex labeled narrowing
  @cindex labeled restriction
-When the optional argument @var{label}, a symbol, is present, the
-narrowing is @dfn{labeled}.  A labeled narrowing differs from a
-non-labeled one in several ways:
+When the optional argument @var{label}, which is evaluated to get the
+label to use and must not be @code{nil}, is present, the narrowing is
+@dfn{labeled}.  A labeled narrowing differs from a non-labeled one in
+several ways:

  @itemize @bullet
  @item
diff --git a/lisp/subr.el b/lisp/subr.el
index 0b397b7bebf..2f0144e0f11 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3964,11 +3964,11 @@ with-restriction

  The current restrictions, if any, are restored upon return.

-When the optional :label LABEL argument is present, in which
-LABEL is a symbol, inside BODY, `narrow-to-region' and `widen'
-can be used only within the START and END limits.  To gain access
-to other portions of the buffer, use `without-restriction' with the
-same LABEL argument.
+When the optional LABEL argument, which is evaluated to get the
+label to use and must not be nil, is present, inside BODY,
+`narrow-to-region' and `widen' can be used only within the START
+and END limits.  To gain access to other portions of the buffer,
+use `without-restriction' with the same LABEL argument.

  \(fn START END [:label LABEL] BODY)"
    (declare (indent 2) (debug t))
@@ -3990,9 +3990,8 @@ without-restriction

  The current restrictions, if any, are restored upon return.

-When the optional :label LABEL argument is present, the
-restrictions set by `with-restriction' with the same LABEL argument
-are lifted.
+When the optional LABEL argument is present, the restrictions set
+by `with-restriction' with the same LABEL argument are lifted.

  \(fn [:label LABEL] BODY)"
    (declare (indent 0) (debug t))