auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: main 5ceda4ec: Make style/graphicx.el parse \graphicspath for search


From: Arash Esbati
Subject: Re: main 5ceda4ec: Make style/graphicx.el parse \graphicspath for searching
Date: Tue, 15 Oct 2024 18:14:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi all,

Ikumi Keita <ikumi@ikumi.que.jp> writes:

> branch: main
> commit 5ceda4ec37913fd2b989b8011d23c6de4252a285
> Author: Leo C. Stein <leo.stein@gmail.com>
> Commit: Ikumi Keita <ikumi@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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]