auctex-devel
[Top][All Lists]
Advanced

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

[AUCTeX-devel] Use `TeX-search-files-by-type' in `LaTeX-includegraphics-


From: Ikumi Keita
Subject: [AUCTeX-devel] Use `TeX-search-files-by-type' in `LaTeX-includegraphics-read-file-TeX'
Date: Tue, 03 Oct 2017 19:45:15 +0900

Hi all,

[Breif summary of this message]
Is it acceptable to change a little the implicit specification of
EXTENSION argument of `TeX-search-files-kpathsea'?

[Detail]
I'm currently considering to adjust
`LaTeX-includegraphics-read-file-TeX' in style/graphicx.el to use
`TeX-search-files-by-type'.  It now uses only `TeX-search-files', so it
doesn't benefit from kpathsea library.

At first I thought it is a simple job of replacing `TeX-search-files'
with `TeX-search-files-by-type' at a glance of
`LaTeX-search-files-type-alist' having "graphics" entry:
----------------------------------------------------------------------
(defcustom LaTeX-search-files-type-alist
  '((texinputs "${TEXINPUTS.latex}" ("tex/generic/" "tex/latex/")
               TeX-file-extensions)
    (docs "${TEXDOCS}" ("doc/") TeX-doc-extensions)
    (graphics "${TEXINPUTS}" ("tex/") LaTeX-includegraphics-extensions)
...
----------------------------------------------------------------------
However, it turned out not so easy because of small conflicts in
treatment of EXTENSIONS argument between `TeX-search-files' and
`TeX-search-files-kpathsea'.

(1) `TeX-search-files-kpathsea' treats EXTENSIONS as list of _literal_
extensions according to this line:
----------------------------------------------------------------------
           (setq extensions (concat "\\." (regexp-opt extensions t) "\\'")
----------------------------------------------------------------------
Thus we cannot supply regexps in EXTENSIONS.

(2) `TeX-search-files' hands over EXTENSIONS to `TeX-match-extension'
and `TeX-strip-extension'.  The latter hands over EXTENSIONS to the
former, thus it is `TeX-match-extension' that determines the treatment
of EXTENSIONS.  Since it does
----------------------------------------------------------------------
  (let ((regexp (concat "\\.\\("
                        (mapconcat 'identity extensions "\\|")
                        "\\)$"))
----------------------------------------------------------------------
, EXTENSIONS is regarded as a list of _regexps_.

`TeX-search-files-by-type' first tries `TeX-search-files-kpathsea' and
fallbacks on `TeX-search-files'.  It just gives the EXTENSION argument
to both functions as-is.  This doesn't cause much problem when EXTENSION
doesn't contain regexp meta chars.  For example, the default value of
`TeX-file-extensions' is ("tex" "sty" "cls" "ltx" "texi" "txi" "texinfo"
"dtx"), which is totally valid as both the literal extensions and the
regular expressions.

However, this is not the case for `LaTeX-includegraphics-extensions',
whose typical value contains "jpe?g".  Therefore, if
`LaTeX-includegraphics-extensions' is given as EXTENSION argument of
`TeX-search-files-kapthsea', the function never searches for files with
"jpeg" or "jpg" as their extension but instead files with _literal_
"jpe?g" extensions.

My current idea is to modify `TeX-search-files-kapthsea' so that it
treats EXTENSIONS argument as a list of regexps, not of literal
extensions.  The attached patch #1 implements this idea.  It also
adjusts related functions and :type arguments of relavant defcustom's.

Are these changes acceptable?  Or should I make out a more sophisticated
approach which preserves the default behavior of
`TeX-search-files-kapthsea'?  If OK, the attached patch #2 implements
actual change of using `TeX-search-files-by-type' in
`LaTeX-includegraphics-read-file-TeX' and #3 adds support for dvipdfmx
in graphicx.el.

N.B.  The patch #2 assumes the policy to drop support for older emacsen
so that it gives a list, not alist, as a completion table for
`completing-read'.

Best,
Ikumi Keita

Attachment: includegraphics-patch1
Description: Arrange spec of argument

Attachment: includegraphics-patch2
Description: Use `TeX-search-files-kapthsea'

Attachment: includegraphics-patch3
Description: Add support for dvipdfmx


reply via email to

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