You need to add an entry to ffap-string-at-point-mode-alist
. That list contains an entry for latex-mode
, but under AucTeX since version 14.01, the mode is LaTeX-mode
, so it fails to match the latex-mode
entry and instead gets the default file
entry.
Try adding this to your init file:
(with-eval-after-load 'ffap
(setq ffap-string-at-point-mode-alist
(cons '(LaTeX-mode "--:\\\\$+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:")
ffap-string-at-point-mode-alist)))
and see if that solves the problem. The entry added is identical to the latex-mode
entry, except for the mode name.
There may be other variables that need similar treatment (e.g. ffap-alist
) but for this particular problem, modifying ffap-string-at-point-mode-alist
seems to be enough.
You might want to report a bug with Emacs (although, since AucTeX is a third-party package, the devs might not want to make changes to ffap
based on AucTeX's needs and might want you to open a report with AucTeX). EDIT: See @ArashEsbati's comment below.
EDIT: Here are a couple of improvements to the code above. One is to add the modification to ffap-alist
(as is done in the Emacs 30 code that @ArashEsbati points to in the comment below): that does not have any bearing to the question above, but it would have a bearing if you used \input{~/Downloads/foo}
, leaving the .tex
extension implicit. The second one is to use add-to-list
which checks whether something exists in a list already before adding it; if it does exist, then it does not add it a second time. That's not a problem for these two variables (at worst, there would be two identical entries, but you would see no problems from that), but it could be one in general, so it's best to avoid it; besides, it is neater to have a single entry:
(with-eval-after-load 'ffap
(add-to-list 'ffap-string-at-point-mode-alist
'(LaTeX-mode "--:\\\\$+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:"))
(add-to-list 'ffap-alist '(LaTeX-mode . ffap-latex-mode)))
The additional benefit is that when Emacs 30 rolls out, the above code will be a no-op, even if you forget to delete it from your init file.