1

I am on Emacs 29.1. Suppose that in a *.tex file I have

~/Downloads/foo.tex
[~/Downloads/foo.tex]
{~/Downloads/foo.tex}

If I am on one those strings above and I do M-x find-file-at-point the file is correctly found and opened in a new buffer. However if the path is within the input latex command

\input{~/Downloads/foo.tex}

when I do M-x find-file-at-point it goes into file browsing which in my case is managed by *helm-mode-find-file-at-point

1 Answer 1

2

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.

7
  • 1
    This issue was reported with #71376 and was fixed with commit 57c0549c in Emacs source tree. It will be part of Emacs 30. But until then, your solution is the way to go. Commented Jul 26 at 5:57
  • 1
    Thanks! I should have looked before suggesting to send a bug report.
    – NickD
    Commented Jul 26 at 12:19
  • Thanks! This solved the problem. Do you think this other issue emacs.stackexchange.com/questions/81802/… is connected to the presente one ? Commented Jul 26 at 18:13
  • It looks like a different issue to me.
    – NickD
    Commented Jul 26 at 19:18
  • at which point of the init.el config file should be this setting optimally placed? I guess before I load latex mode settings? Am I correct? Commented Jul 27 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.