[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX] ffap-latex-mode to use kpsewhich
From: |
Nicolas Richard |
Subject: |
[AUCTeX] ffap-latex-mode to use kpsewhich |
Date: |
Fri, 30 Nov 2012 14:57:37 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [AUCTeX] ffap-latex-mode to use kpsewhich,
Nicolas Richard <=