Subject: bug#53749: 29.0.50; [PATCH] Xref backend for TeX buffers

From: Dmitry Gutov <[email-masked]>
Date: Tue, 7 May 2024 05:06:36 +0300

On 02/05/2024 16:32, David Fussner via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> Hi Dmitry,
> 
> Thanks for looking over the patch. Here's the recipe for the purported
> bug in xref.el:
> 
> 1. Please apply my patch to tex-mode.el (and xref.el).
> 
> 2. I've attached xref-bug.zip, which contains a directory with 4
> identical LaTeX files and one LaTeX file with a single additional
> character. Please extract it.
> 
> 3. emacs -Q
> 
> 4. C-x C-f xref-bug/mwea.ltx, and please don't visit the other 4
> files.
> 
> 5. Put point on \__hook_debug:n in line 6.
> 
> 6. M-?, RTN, ... RTN, RTN.
> 
> The xref buffer should offer 5 hits, one from each file in the
> directory.
> 
> 7. Comment out the the line I added to xref--collect-matches,
> byte-compile and load the file.
> 
> 8. With point in the same place, M-?, RTN, ... RTN, RTN.
> 
> The xref buffer should offer 3 hits. The first is from the
> file-visiting buffer (where I also set syntax-propertize--done to 0,
> because in my testing there could be some issues here, too). The
> second hit is from the first file opened in *xref-temp. Here,
> syntax-propertize runs to line-end, and all is well. The next two
> files are missed, because syntax-propertize--done is set to line-end
> and they have exactly the same line length as file two, and therefore
> syntax-propertize thinks that's good enough and doesn't actually
> change anything. The fifth file has an additional character in line 6,
> so syntax-propertize decides it needs to work on this line because
> line-end > syntax-propertize--done.
> 
> You can put point on, say, \documentclass, and you'll get all 5 hits,
> because this string doesn't begin or end with a non-word, non-symbol
> character, and syntax-propertize doesn't need to run. You can make the
> search string "\documentclass" and you'll get 2 hits, as line 1 has
> the same length in all 5 files. (It's worth trying "\usepackage" as
> the search string, too.)
> 
> That's my diagnosis anyway. Does it make sense?

Thank you, David, for the thorough scenario. I see the problem now.