On Emacs 31.1 (Windows 11) with AUCTeX, editing a plain LaTeX file
intermittently produces this new Emacs 31 diagnostic in the echo area:
Cannot syntax-propertize 3578..48519 because of narrowing!
The message comes from syntax-propertize in Emacs 31, which now complains
when it's asked for syntax properties while the buffer is narrowed and the
region before (point-min) hasn't been propertized yet.
The narrowing in question is AUCTeX's. TeX-find-macro-boundaries narrows to
(lower-bound . point-max) when it gets a lower bound. During fontification,
font-latex-extend-region-backwards-command-with-args calls it with such a
bound. If the syntax cache doesn't yet cover the text up to that bound, the
subsequent up-list triggers syntax-propertize inside the narrowing, and the
warning fires.
Backtrace, captured with debug-on-message:
Debugger entered--Lisp error: "Cannot syntax-propertize 3578..48519 because
of narrowing!"
syntax-propertize(54205)
internal--syntax-propertize(53830)
scan-lists(53829 1 1)
up-list-default-function(nil nil nil)
up-list()
TeX-find-macro-boundaries(48519)
TeX-find-macro-start(48519)
font-latex-extend-region-backwards-command-with-args()
font-lock-default-fontify-region(53599 54205 nil)
font-latex-fontify-region(53599 54205 nil)
font-lock-fontify-region(53599 54205)
#f(compiled-function (fun) #<bytecode
0x1b7b847fc10a578f>)(font-lock-fontify-region)
jit-lock--run-functions(53599 54205)
jit-lock-fontify-now(53599 54205)
jit-lock-function(53599)
redisplay_internal (C function)
Reproduction from emacs -Q:
emacs -Q, then M-x package-initialize, so only installed packages
(including AUCTeX) activate.
(setq debug-on-message "Cannot syntax-propertize [0-9]")
Open a .tex file of roughly 50k characters or more. Split the frame into
two windows on that buffer, top window showing the beginning of the file,
bottom window showing the end.
Insert a character near the top of the file and wait a moment.
The edit resets the syntax cache to near the top. The delayed
refontification of the bottom window's text then runs font-latex's region
extension, which narrows via TeX-find-macro-boundaries, and the debugger
pops with the backtrace above. It doesn't fire on every attempt, since it
depends on how far jit-lock has gotten. Scrolling the bottom window right
after the edit helps.
As far as I can tell the warning is harmless in itself, but it flashes
repeatedly during normal editing. A fix that works for me is to make sure
syntax properties cover the bound before narrowing, for instance a
(syntax-propertize lower-bound) at the top of TeX-find-macro-boundaries.
Advising the function that way makes the message disappear here, and it
should also give scan-lists correct syntax data near the boundary instead
of a guess.
The file involved is an ordinary LaTeX document, 57k characters, 614 lines,
longest line 368 characters, so long-line optimizations aren't involved
((long-line-optimizations-p) is nil).
Emacs : GNU Emacs 31.1 (build 2, x86_64-w64-mingw32)
of 2026-08-24
Package: 14.1.2
current state:
==============
(setq
window-system 'w32
LaTeX-version "2e"
TeX-style-path '("~/.emacs.d/auctex/"
"~/.emacs.d/elpa-31/auctex-14.1.2/style"
"~/.emacs.d/auctex/auto"
"~/.emacs.d/auctex/style" "auto" "style")
TeX-auto-save nil
TeX-parse-self t
TeX-master t
TeX-command-list '(("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil
(LaTeX-mode docTeX-mode) :help "Run LaTeX")
("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil
(plain-TeX-mode LaTeX-mode docTeX-mode
conTeXt-mode Texinfo-mode AmSTeX-mode)
:help "Run BibTeX")
("Biber" "biber %(output-dir) %s" TeX-run-Biber
nil
(plain-TeX-mode LaTeX-mode docTeX-mode
Texinfo-mode AmSTeX-mode)
:help "Run Biber")
("View" "%V" TeX-run-discard-or-function nil nil
:help "Run Viewer")
)
)
_______________________________________________
bug-auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-auctex