Hi all, Ikumi Keita <ik...@ikumi.que.jp> writes:
> branch: main > commit 5ceda4ec37913fd2b989b8011d23c6de4252a285 > Author: Leo C. Stein <leo.st...@gmail.com> > Commit: Ikumi Keita <ik...@ikumi.que.jp> > > Make style/graphicx.el parse \graphicspath for searching > > * style/graphicx.el (LaTeX-parse-graphicspath): New function. > (LaTeX-includegraphics-read-file-TeX): Use it. > * tex.el (TeX-search-files-kpathsea): Attach a new optional argument > `extra-dirs'. > (TeX-search-files-by-type): Accept optional argument `extra-dirs' to > pass it to `TeX-search-files-kpathsea'. > * NEWS.org (Added): Announce the new facility. > > +(defun LaTeX-parse-graphicspath () > + "Parse the current document for \\graphicspath commands. > +Return value is a list of paths." > + (let ((results '()) > + (graphicspath-regex "\\\\graphicspath{\\({\\([^}]*\\)}\\)*}") > + (single-path-regex "{\\([^{}]*\\)}")) > + (save-excursion I suggest to change this part into something like this in case narrawing is in effect: (save-excursion (save-restriction (widen) (goto-char (point-min)) ...)) > + (goto-char (point-min)) > + (while (re-search-forward graphicspath-regex nil t) > + (let ((start-pos (match-beginning 0)) > + (end-pos (match-end 0))) > + (save-excursion > + (goto-char start-pos) > + (while (re-search-forward single-path-regex end-pos t) > + (push (match-string-no-properties 1) results))))) > + (nreverse results)))) Best, Arash