Hello,
I often want or need to browse the code of the LaTeX packages I use, and
ideally using find-file-at-point on the name of a package should make
this easy. However, the default value of ffap-tex-path does not contain
the complete tree that TeX uses to find its files. Hence ffap usually
does not fine the file I'm looking for automagically.
I first tried setting that variable to the output of
$ kpsewhich -expand-path $(kpsewhich -show-path tex)
but that makes ffap very slow because there are many paths to search.
Instead of that, I now use the following replacement for
ffap-latex-mode, which is called by ffap when in latex-mode:
(defun ffap-latex-mode (name)
"ffap function in latex buffers, using kpsewhich."
(with-temp-buffer
;; order is important : the first path found will be opened.
(let ((ext '(".sty" ".cls" ".ltx" ".tex" ""))
args)
(setq args (mapcar (lambda (x) (concat name x)) ext))
(funcall `(lambda () (call-process "kpsewhich" nil t nil ,@args)))
(when (< (point-min) (point-max))
(buffer-substring (goto-char (point-min)) (point-at-eol))))))
Despite the use of an external process this is rather fast, and proved
useful to me. I thought it might be useful to others too. It obviously
requires kpsewhich to be installed. I have
$ kpsewhich --version
kpathsea version 6.1.0
--
Nico.
_______________________________________________
auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex