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

From: Dmitry Gutov <[email-masked]>
Date: Sun, 9 Jun 2024 21:45:40 +0300

On 09/06/2024 14:36, Stefan Kangas wrote:
>> diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
>> index 579098c81b1..a064103aa25 100644
>> --- a/doc/emacs/maintaining.texi
>> +++ b/doc/emacs/maintaining.texi
>> @@ -2529,6 +2529,15 @@ Identifier Search
>>   referenced.  The XREF mode commands are available in this buffer, see
>>   @ref{Xref Commands}.
>>
>> +When invoked in a buffer whose major mode uses the @code{etags} backend,
>> +@kbd{M-?} searches files and buffers whose major mode matches that of
>> +the original buffer.  It guesses that mode from file extensions, so if
>> +@kbd{M-?} seems to be skipping relevant buffers or files, try
>> +customizing either the variable @code{semantic-symref-filepattern-alist}
> Why does this speak of Semantic?  Does `xref-find-references` depend on
> it somehow?

xref-backend-references's default implementation calls 
semantic-symref-perform-search under the cover. It's just the "symref" 
package, not the parser or the rest.

David's addition also uses it, and that's fine.

>> +;; Populate `semantic-symref-filepattern-alist' for the in-tree modes;
>> +;; AUCTeX is doing the same for its modes.
>> +(with-eval-after-load 'semantic/symref/grep
>> +  (defvar semantic-symref-filepattern-alist)
>> +  (push '(latex-mode "*.[tT]e[xX]" "*.ltx" "*.sty" "*.cl[so]"
>> +                     "*.bbl" "*.drv" "*.hva")
>> +        semantic-symref-filepattern-alist)
>> +  (push '(plain-tex-mode "*.[tT]e[xX]" "*.ins")
>> +        semantic-symref-filepattern-alist)
>> +  (push '(doctex-mode "*.dtx") semantic-symref-filepattern-alist))
> Doesn't this stuff rather belong in semantic itself?

Good point.