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

From: Mattias Engdegård <[email-masked]>
Date: Sat, 14 Sep 2024 19:26:07 +0200

Thanks for the contribution, David! My electronic servant complained about some regexps:

3881    (re-search-backward (concat "[]["
3882                                (mapconcat #'regexp-quote
3883                                           (mapcar #'char-to-string
3884                                                   tex-thingatpt-exclude-chars))
3885                                "\"*`'#=&()%,|$[:cntrl:][:blank:]]"))

This is not a correct way to build a regexp; `regexp-quote` can only be used to quote strings that should match literally, not characters inside [...], where backslashes have no escaping power.

There are various ways of doing this properly. I would suggest something like

  (rx-to-string `(or (in "\"#$%&'()*,=[]`|" cntrl blank)
                     ,@tex-thingatpt-exclude-chars)
                t))

but it also depends on what you want that `tex-thingatpt-exclude-chars` variable to be. Should it be a user option (defcustom)? The variable's doc string is a wall of text that basically says that it can be set to whatever you want but things will stop working so you'd better not.