Subject: bug#57684: locked narrowing breaks existing code without an apparent way to repair

From: Paul Pogonyshev <[email-masked]>
Date: Thu, 8 Sep 2022 21:37:02 +0200

"Locked narrowing" added in Emacs 29 cannot be (temporarily) canceled by
code called inside. This in particular breaks Logview (
https://github.com/doublep/logview), because this narrowing is in effect
during fontification and causes Logview to fall down into an infinite loop.
Moreover, variable `restrictions-locked' appears to be not exposed to
Elisp, meaning that this cannot be cleared even with an explicit let-bind.

The mode simply cannot work without an ability to temporarily widen the
text. Macro `logview--std-temporarily-widening' is used 35 times in its
code:

(defmacro logview--std-temporarily-widening (&rest body)
  (declare (indent 0) (debug t))
  `(save-restriction
     (let ((logview--point-min (logview--point-min))
           (logview--point-max (logview--point-max)))
       (widen)
       ,@body)))

To make it even harder to debug, Emacs sometimes hangs completely with even
C-g not aborting faulty code (in this case "faulty" because of incompatible
changes in Emacs itself).

Paul