auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 7371b4617346d6f77fed2


From: Ikumi Keita
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 7371b4617346d6f77fed2e916acd5b794743a733
Date: Sun, 1 Apr 2018 10:52:30 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  7371b4617346d6f77fed2e916acd5b794743a733 (commit)
       via  3b758bf2076402b973925f32c0db4f0584705b91 (commit)
       via  59fa964e9da26c71ec5a82ba510f01e71437e3a3 (commit)
      from  e783b973e9c367d1ab31ca07bc31a0b19c110f28 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7371b4617346d6f77fed2e916acd5b794743a733
Author: Ikumi Keita <address@hidden>
Date:   Sun Apr 1 23:51:25 2018 +0900

    Add support for dvipdfmx to \includegraphics
    
    * style/graphicx.el (LaTeX-includegraphics-extensions-list): Add
    support for dvipdfmx.
    * tests/latex/latex-test.el (LaTeX-includegraphics-extensions): New
    test to check whether correct extensions are generated.

diff --git a/style/graphicx.el b/style/graphicx.el
index 94ec51c..bb89b13 100644
--- a/style/graphicx.el
+++ b/style/graphicx.el
@@ -124,8 +124,11 @@ Return value is a list of regexps."
                        temp))
             ;; We're generating a .dvi to process with dvips or dvipdfmx
             (progn
-              (dolist (x '("jpe?g" "pdf" "png"))
-                (setq temp (delete x temp)))
+              ;; dvipdfmx can handle jpeg, pdf and png for image formats.
+              (unless (and TeX-PDF-mode
+                           (string= (TeX-PDF-from-DVI) "Dvipdfmx"))
+                (dolist (x '("jpe?g" "pdf" "png"))
+                  (setq temp (delete x temp))))
               (TeX-delete-duplicate-strings
                (append LaTeX-includegraphics-dvips-extensions
                        temp)))))
@@ -148,7 +151,13 @@ Return value is a list of regexps."
                    temp)))
          ;; For anything else
          (t
-          temp))))
+          (if (and TeX-PDF-mode
+                   (string= (TeX-PDF-from-DVI) "Dvipdfmx"))
+              ;; dvipdfmx can handle the same image formats as dvips.
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-dvips-extensions
+                       temp))
+            temp)))))
 
 (defun LaTeX-includegraphics-extensions (&optional list)
   "Return appropriate extensions for input files to \\includegraphics.
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index a2dc565..78d2341 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -162,4 +162,90 @@ backend=biber % here is a comment
     (should (LaTeX-provided-package-options-member
             "biblatex" "backend=biber"))))
 
+(ert-deftest LaTeX-includegraphics-extensions ()
+  "Check correct extensions are generated accoding to `TeX-engine'."
+  (with-temp-buffer
+    (LaTeX-mode)
+    (TeX-load-style "graphicx")
+    (let (TeX-engine TeX-PDF-mode TeX-PDF-from-DVI
+                    TeX-PDF-via-dvips-ps2pdf TeX-DVI-via-PDFTeX)
+      ;; tests for default engine
+      (setq TeX-engine 'default)
+      ;; default 1
+      (setq TeX-PDF-mode t
+           TeX-PDF-from-DVI nil
+           TeX-DVI-via-PDFTeX nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("png" "pdf" "jpe?g" "jbig2" "jb2" "mps"
+                     "PNG" "PDF" "JPE?G" "JBIG2" "JB2" "eps") #'string<)))
+      ;; default 2
+      (setq TeX-PDF-mode t
+           TeX-PDF-from-DVI "Dvips"
+           TeX-DVI-via-PDFTeX nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS") #'string<)))
+      ;; default 3
+      (setq TeX-PDF-mode nil
+           TeX-PDF-from-DVI nil
+           TeX-DVI-via-PDFTeX nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS") #'string<)))
+      ;; default 4
+      (setq TeX-PDF-mode nil
+           TeX-PDF-from-DVI nil
+           TeX-DVI-via-PDFTeX t)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("png" "pdf" "jpe?g" "jbig2" "jb2" "mps"
+                     "PNG" "PDF" "JPE?G" "JBIG2" "JB2" "eps") #'string<)))
+      ;; default 5
+      (setq TeX-PDF-mode t
+           TeX-PDF-from-DVI "Dvipdfmx"
+           TeX-DVI-via-PDFTeX nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS" "jpe?g" "pdf" "png") #'string<)))
+
+      ;; tests for luatex engine
+      (setq TeX-engine 'luatex)
+      ;; luatex 1
+      (setq TeX-PDF-mode t)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("png" "pdf" "jpe?g" "jbig2" "jb2" "mps"
+                     "PNG" "PDF" "JPE?G" "JBIG2" "JB2" "eps") #'string<)))
+      ;; luatex 2
+      (setq TeX-PDF-mode nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS") #'string<)))
+
+      ;; test for xetex engine
+      (setq TeX-engine 'xetex)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("pdf" "eps" "mps" "ps" "png" "jpe?g" "jp2" "jpf"
+                     "PDF" "EPS" "MPS" "PS" "PNG" "JPE?G" "JP2" "JPF"
+                     "bmp" "pict" "psd" "mac" "tga" "gif" "tif" "tiff"
+                     "BMP" "PICT" "PSD" "MAC" "TGA" "GIF" "TIF" "TIFF")
+                   #'string<)))
+
+      ;; test for other engine
+      (setq TeX-engine 'omega)
+      ;; other 1
+      (setq TeX-PDF-mode t
+           TeX-PDF-from-DVI "Dvipdfmx")
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS" "jpe?g" "pdf" "png") #'string<)))
+      ;; other 2
+      (setq TeX-PDF-mode nil
+           TeX-PDF-from-DVI nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "jpe?g" "pdf" "png") #'string<))))))
+
 ;;; latex-test.el ends here

commit 3b758bf2076402b973925f32c0db4f0584705b91
Author: Ikumi Keita <address@hidden>
Date:   Sun Apr 1 23:51:25 2018 +0900

    Use `TeX-search-files-by-type' to assist input \includegraphics
    
    * style/graphicx.el (LaTeX-includegraphics-extensions-list): New
    function.
    (LaTeX-includegraphics-extensions): Delegate most of its task to the
    above new function and become its wrapper.
    (LaTeX-includegraphics-global-files): New variable.
    (LaTeX-includegraphics-read-file-TeX): Use `TeX-search-files-by-type'
    rather than `TeX-search-files' and cache global value in the above
    new variable.
    Reflect the option `LaTeX-includegraphics-strip-extension-flag'.
    * tex.el (TeX-search-files-type-alist): Remove `graphics' entry,
    which is supplied in latex-mode by `LaTeX-search-files-type-alist'.
    (TeX-normal-mode): Add `LaTeX-includegraphics-global-files' to list of
    variables to be cleared.

diff --git a/style/graphicx.el b/style/graphicx.el
index 08dbf75..94ec51c 100644
--- a/style/graphicx.el
+++ b/style/graphicx.el
@@ -105,65 +105,85 @@ key-val's."
                         LaTeX-graphicx-key-val-options))
      optional)))
 
+(defun LaTeX-includegraphics-extensions-list ()
+  "Return appropriate extensions for input files to \\includegraphics.
+Return value is a list of regexps."
+  (let ((temp (copy-sequence LaTeX-includegraphics-extensions)))
+    (cond (;; 'default TeX-engine:
+          (eq TeX-engine 'default)
+          (if ;; we want to produce a pdf
+              (if TeX-PDF-mode
+                  ;; Return t if default compiler produces PDF,
+                  ;; nil for "Dvips" or "Dvipdfmx"
+                  (not (TeX-PDF-from-DVI))
+                ;; t if pdftex is used in dvi-mode
+                TeX-DVI-via-PDFTeX)
+              ;; We're using pdflatex in pdf-mode
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-pdftex-extensions
+                       temp))
+            ;; We're generating a .dvi to process with dvips or dvipdfmx
+            (progn
+              (dolist (x '("jpe?g" "pdf" "png"))
+                (setq temp (delete x temp)))
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-dvips-extensions
+                       temp)))))
+         ;; Running luatex in pdf or dvi-mode:
+         ((eq TeX-engine 'luatex)
+          (if TeX-PDF-mode
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-pdftex-extensions
+                       temp))
+            (progn
+              (dolist (x '("jpe?g" "pdf" "png"))
+                (setq temp (delete x temp)))
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-dvips-extensions
+                       temp)))))
+         ;; Running xetex in any mode:
+         ((eq TeX-engine 'xetex)
+          (TeX-delete-duplicate-strings
+           (append LaTeX-includegraphics-xetex-extensions
+                   temp)))
+         ;; For anything else
+         (t
+          temp))))
+
 (defun LaTeX-includegraphics-extensions (&optional list)
-  "Return appropriate extensions for input files to \\includegraphics."
-  (let* ((temp (copy-sequence LaTeX-includegraphics-extensions))
-        (LaTeX-includegraphics-extensions
-         (cond (;; 'default TeX-engine:
-                (eq TeX-engine 'default)
-                (if ;; we want to produce a pdf
-                    (if TeX-PDF-mode
-                        ;; Return t if default compiler produces PDF,
-                        ;; nil for "Dvips" or "Dvipdfmx"
-                        (not (TeX-PDF-from-DVI))
-                      ;; t if pdftex is used in dvi-mode
-                      TeX-DVI-via-PDFTeX)
-                    ;; We're using pdflatex in pdf-mode
-                    (TeX-delete-duplicate-strings
-                     (append LaTeX-includegraphics-pdftex-extensions
-                             temp))
-                  ;; We're generating a .dvi to process with dvips or dvipdfmx
-                  (progn
-                    (dolist (x '("jpe?g" "pdf" "png"))
-                      (setq temp (delete x temp)))
-                    (TeX-delete-duplicate-strings
-                     (append LaTeX-includegraphics-dvips-extensions
-                             temp)))))
-               ;; Running luatex in pdf or dvi-mode:
-               ((eq TeX-engine 'luatex)
-                (if TeX-PDF-mode
-                    (TeX-delete-duplicate-strings
-                     (append LaTeX-includegraphics-pdftex-extensions
-                             temp))
-                  (progn
-                    (dolist (x '("jpe?g" "pdf" "png"))
-                      (setq temp (delete x temp)))
-                    (TeX-delete-duplicate-strings
-                     (append LaTeX-includegraphics-dvips-extensions
-                             temp)))))
-               ;; Running xetex in any mode:
-               ((eq TeX-engine 'xetex)
-                (TeX-delete-duplicate-strings (append 
LaTeX-includegraphics-xetex-extensions
-                                     temp)))
-               ;; For anything else
-               (t
-                temp))))
-    (concat "\\."
-           (mapconcat 'identity
-                      (or list LaTeX-includegraphics-extensions)
-                      "$\\|\\.")
-           "$")))
+  "Return appropriate extensions for input files to \\includegraphics.
+Return value is a single regexp.
+Optional argument LIST if non-nil is used as list of regexps of
+extensions to be matched."
+  (unless list
+    (setq list (LaTeX-includegraphics-extensions-list)))
+  (concat "\\." (mapconcat #'identity list "$\\|\\.") "$"))
+
+(defvar LaTeX-includegraphics-global-files nil
+  "List of the non-local graphic files to include in LaTeX documents.
+Initialized once at the first time you prompt for an input file.
+May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
 
 (defun LaTeX-includegraphics-read-file-TeX ()
   "Read image file for \\includegraphics.
 Offers all graphic files found in the TeX search path.  See
 `LaTeX-includegraphics-read-file' for more."
-  (completing-read
-   "Image file: "
-   (TeX-delete-dups-by-car
-    (mapcar 'list
-           (TeX-search-files nil LaTeX-includegraphics-extensions t t)))
-   nil nil nil))
+  (let ((LaTeX-includegraphics-extensions
+        (LaTeX-includegraphics-extensions-list)))
+    (unless LaTeX-includegraphics-global-files
+      (message "Searching for graphic files...")
+      (setq LaTeX-includegraphics-global-files
+           (TeX-search-files-by-type
+            'graphics 'global t
+            LaTeX-includegraphics-strip-extension-flag))
+      (message "Searching for graphic files...done"))
+    (completing-read
+     "Image file: "
+     (append
+      (TeX-search-files-by-type 'graphics 'local t
+                               LaTeX-includegraphics-strip-extension-flag)
+      LaTeX-includegraphics-global-files)
+     nil nil nil)))
 
 (defun LaTeX-includegraphics-read-file-relative ()
   "Read image file for \\includegraphics.
diff --git a/tex.el b/tex.el
index 8e1f7ee..42759c5 100644
--- a/tex.el
+++ b/tex.el
@@ -4608,7 +4608,6 @@ If optional argument EXTENSIONS is not set, use 
`TeX-file-extensions'"
 (defvar TeX-search-files-type-alist
   '((texinputs "${TEXINPUTS}" ("tex/") TeX-file-extensions)
     (docs "${TEXDOCS}" ("doc/") TeX-doc-extensions)
-    (graphics "${TEXINPUTS}" ("tex/") LaTeX-includegraphics-extensions)
     (bibinputs "${BIBINPUTS}" ("bibtex/bib/") BibTeX-file-extensions)
     (bstinputs "${BSTINPUTS}" ("bibtex/bst/") BibTeX-style-extensions))
   "Alist of filetypes with locations and file extensions.
@@ -6020,7 +6019,8 @@ With optional argument ARG, also reload the style hooks."
            BibLaTeX-global-style-files nil
            TeX-Biber-global-files nil
            TeX-global-input-files nil
-           LaTeX-global-class-files nil))
+           LaTeX-global-class-files nil
+           LaTeX-includegraphics-global-files nil))
   (let ((TeX-auto-save t))
     (if (buffer-modified-p)
        (save-buffer)

commit 59fa964e9da26c71ec5a82ba510f01e71437e3a3
Author: Ikumi Keita <address@hidden>
Date:   Sun Apr 1 23:51:25 2018 +0900

    Resolve conflict of argument spec between regexp and literal
    
    * tex.el (TeX-search-files-kpathsea): Treat EXTENSIONS argument as a
    list of regexps in accordance with other parts of AUCTeX.
    (TeX-ispell-document): Treat `TeX-file-extensions' as a list of
    regexps in accordance with other parts of AUCTeX.
    (TeX-file-extensions, TeX-Biber-file-extensions):
    (BibTeX-file-extensions, BibLaTeX-style-extensions):
    (BibTeX-style-extensions): Change custom type to regexp from string.
    (TeX-doc-extensions): Turn into list of regexps.
    * latex.el (LaTeX-split-bibs): Treat `TeX-Biber-file-extensions' as a
    list of regexps in accordance with other parts of AUCTeX.

diff --git a/latex.el b/latex.el
index bf96729..3315614 100644
--- a/latex.el
+++ b/latex.el
@@ -1626,7 +1626,7 @@ Split the string at commas and remove Biber file 
extensions."
     (dolist (bib bibs)
       (LaTeX-add-bibliographies (TeX-replace-regexp-in-string
                                 (concat "\\(?:\\."
-                                        (mapconcat #'regexp-quote
+                                        (mapconcat #'identity
                                                    TeX-Biber-file-extensions
                                                    "\\|\\.")
                                         "\\)")
diff --git a/tex.el b/tex.el
index 83d360a..8e1f7ee 100644
--- a/tex.el
+++ b/tex.el
@@ -4415,7 +4415,7 @@ Check for potential LaTeX environments."
 (defcustom TeX-file-extensions '("tex" "sty" "cls" "ltx" "texi" "txi" 
"texinfo" "dtx")
   "*File extensions used by manually generated TeX files."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defcustom TeX-all-extensions '("[^.\n]+")
   "All possible file extensions."
@@ -4430,8 +4430,8 @@ Check for potential LaTeX environments."
   (make-variable-buffer-local 'TeX-default-extension)
 
 (defvar TeX-doc-extensions
-  '("dvi" "pdf" "ps" "txt" "html" "dvi.gz" "pdf.gz" "ps.gz" "txt.gz" "html.gz"
-    "dvi.bz2" "pdf.bz2" "ps.bz2" "txt.bz2" "html.bz2")
+  '("dvi" "pdf" "ps" "txt" "html" "dvi\\.gz" "pdf\\.gz" "ps\\.gz" "txt\\.gz"
+    "html\\.gz" "dvi\\.bz2" "pdf\\.bz2" "ps\\.bz2" "txt\\.bz2" "html\\.bz2")
   "File extensions of documentation files.")
 
 (defcustom docTeX-default-extension "dtx"
@@ -4450,22 +4450,22 @@ Access to the value should be through the function 
`TeX-output-extension'.")
 (defcustom TeX-Biber-file-extensions '("bib" "ris" "xml")
   "Valid file extensions for Biber files."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defcustom BibTeX-file-extensions '("bib")
   "Valid file extensions for BibTeX files."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defcustom BibLaTeX-style-extensions '("bbx")
   "Valid file extensions for BibLaTeX styles."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defcustom BibTeX-style-extensions '("bst")
   "Valid file extensions for BibTeX styles."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defun TeX-match-extension (file &optional extensions)
   "Return non-nil if FILE has one of EXTENSIONS.
@@ -4543,7 +4543,9 @@ non-nil, remove file extension."
          result)
       (if (eq scope 'global)
          (setq dirs (delete "./" dirs)))
-      (setq extensions (concat "\\." (regexp-opt extensions t) "\\'")
+      (setq extensions (concat "\\.\\(?:"
+                              (mapconcat #'identity extensions "\\|")
+                              "\\)\\'")
            result (apply #'append (mapcar (lambda (x)
                                             (when (file-readable-p x)
                                               (directory-files
@@ -6491,7 +6493,7 @@ NAME may be a package, a command, or a document."
                                   (cons (file-name-nondirectory name)
                                         (TeX-style-list)) "\\|")
                        "\\)\\.\\("
-                       (mapconcat 'regexp-quote TeX-file-extensions "\\|")
+                       (mapconcat #'identity TeX-file-extensions "\\|")
                        "\\)\\'"))
        (buffers (buffer-list)))
     (while buffers

-----------------------------------------------------------------------

Summary of changes:
 latex.el                  |   2 +-
 style/graphicx.el         | 135 ++++++++++++++++++++++++++++------------------
 tests/latex/latex-test.el |  86 +++++++++++++++++++++++++++++
 tex.el                    |  24 +++++----
 4 files changed, 182 insertions(+), 65 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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