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. cad042f02e3e919876b47


From: Ikumi Keita
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. cad042f02e3e919876b474572e6cb375ed551dcb
Date: Fri, 1 Jun 2018 01:48:41 -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  cad042f02e3e919876b474572e6cb375ed551dcb (commit)
       via  3b1ffcd8c3387f67fd9be5e1da73d780dffbdd51 (commit)
       via  a8ea1273fd95da5702fe95ad3f41d151b621bc72 (commit)
       via  ff08d38666f10050f93b6cc4c5777420f30a0409 (commit)
      from  c64a0e1f7f7daf06a3ce56986cdd5afa7319fdfa (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 cad042f02e3e919876b474572e6cb375ed551dcb
Author: Ikumi Keita <address@hidden>
Date:   Thu May 31 16:01:59 2018 +0900

    Add note and test about the change involving non-ascii file name
    
    * doc/changes.texi (News in 12.2): Add note that support for standard
    LaTeX without e-TeX extension is now very limited.
    * tests/tex/command-expansion.el (TeX-command-detokenize): New test to
    check whether \input and \detokenize are supplied when necessary.

diff --git a/doc/changes.texi b/doc/changes.texi
index 3c85f58..3e3f417 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -25,10 +25,21 @@ was used in just the opposite way as the document says.  
Erase the
 customization if you have customized this option since it now acts in
 reverse to your expectation.
 
address@hidden A former customize option @code{japanese-TeX-command-list} is
-removed.  Use @code{japanese-TeX-engine-default}, or if it's really
-necessary, customize @code{TeX-command-list} directly if the task which
-the option used to carry is required.
address@hidden
+A former customize option @code{japanese-TeX-command-list} is removed.
+Use @code{japanese-TeX-engine-default}, or if it's really necessary,
+customize @code{TeX-command-list} directly if the task which the option
+used to carry is required.
+
address@hidden
+Support for standard @LaTeX{} without address@hidden extension is now very
+limited.  It doesn't work if raw @TeX{} code is put on the command line
+to invoke latex command.  It also fails for region compilation (@kbd{C-c
+C-r} and so on) with documents of non-ascii file name.  In addition, it
+no longer works with @previewlatex{}.  We consider this incompatibility
+is permissible because address@hidden extension is enabled for standard
address@hidden by default long ago.  @LaTeX{} variants such as address@hidden 
and
address@hidden are not affected.
 @end itemize
 
 @heading News in 12.1
diff --git a/tests/tex/command-expansion.el b/tests/tex/command-expansion.el
index b35b8f3..9215a32 100644
--- a/tests/tex/command-expansion.el
+++ b/tests/tex/command-expansion.el
@@ -84,4 +84,17 @@
        (TeX-view-command-raw)))
    :type 'error))
 
+(ert-deftest TeX-command-detokenize ()
+  "Check whether \"\\input\" and \"\\detokenize\" are supplied when necessary."
+  ;; Skip on w32 because the quoting style of `shell-quote-argument'
+  ;; is different.
+  (skip-unless (not (eq system-type 'w32)))
+  (should (string=
+           (let ((major-mode 'latex-mode)
+                (TeX-engine 'default)
+                (TeX-master "/tmp/abc")
+                (TeX-command-extra-options " \"\\foo\""))
+            (TeX-command-expand "%`%(extraopts)%' %T" #'TeX-master-file))
+          " \"\\foo\" \"\\input\" \\\\detokenize\\{\\ abc.tex\\ \\}")))
+
 ;;; command-expansion.el ends here

commit 3b1ffcd8c3387f67fd9be5e1da73d780dffbdd51
Author: Ikumi Keita <address@hidden>
Date:   Mon May 28 14:46:52 2018 +0900

    TL 2018 non-ascii file name fix for preview-latex
    
    * preview.el.in (preview-LaTeX-command): Wrap file name after implicit
    \input in \detokenize{}.
    (preview-cache-preamble): Arrange the ini file code so that non-ascii
    file name can be used with generated format file.  Be careful not to
    lose capability of handling file name with space.
    (preview-undump-replacements): Use new TeX macro defined in the above
    ini file code to accept even unusual file name with non-ascii
    character or space.
    Delegate quoting of format name to `TeX-inline-preview-internal' so
    that non-ascii character will not be quoted twice.
    (TeX-inline-preview-internal): Adjust to the above change.

diff --git a/preview.el.in b/preview.el.in
index 9f061c0..c6c8eaf 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -2217,7 +2217,14 @@ list of LaTeX commands is inserted just before 
\\begin{document}."
 (defcustom preview-LaTeX-command '("%`%l \"\\nonstopmode\\nofiles\
 \\PassOptionsToPackage{" ("," . preview-required-option-list) "}{preview}\
 \\AtBeginDocument{\\ifx\\ifPreview\\undefined"
-preview-default-preamble "\\fi}\"%' %t")
+preview-default-preamble "\\fi}\"%' \"{\\detokenize{\" %t \"}}\"")
+  ;; Since TeXLive 2018, the default encoding for LaTeX files has been
+  ;; changed to UTF-8 if used with classic TeX or pdfTeX.  I.e.,
+  ;; \usepackage[utf8]{inputenc} is enabled by default in (pdf)latex.
+  ;; c.f. LaTeX News issue 28
+  ;; Due to this change, \detokenize is required to recognize
+  ;; non-ascii characters in the file name when \input is supplemented
+  ;; implicitly by %`-%' pair.
   "*Command used for starting a preview.
 See description of `TeX-command-list' for details."
   :group 'preview-latex
@@ -3272,8 +3279,12 @@ This is passed through `preview-do-replacements'."
 
 (defcustom preview-undump-replacements
   '(("\\`\\([^ ]+\\)\
- .*? \"\\\\input\" \\(.*\\)\\'"
-     . ("\\1 -interaction=nonstopmode \"&" preview-format-name "\" \\2")))
+ .*? \"\\\\input\" \"{\\\\detokenize{\" \\(.*\\) \"}}\"\\'"
+     . ("\\1 -interaction=nonstopmode " preview-format-name
+       " \"/AUCTEXINPUT{\" \\2 \"}\"")))
+  ;; See the ini file code below in `preview-cache-preamble' for the
+  ;; wierd /AUCTEXINPUT construct.  In short, it is crafted so that
+  ;; dumped format file can read file of non-ascii name.
   "Use a dumped format for reading preamble."
   :group 'preview-latex
   :type '(repeat
@@ -3317,8 +3328,11 @@ If FORMAT-CONS is non-nil, a previous format may get 
reused."
       ;; in the tools bundle is an empty file.
       (write-region "\\ifx\\pdfoutput\\undefined\\else\
 \\let\\PREVIEWdump\\dump\\def\\dump{%
-\\edef\\next{{\\catcode`\\ 9 \\pdfoutput=\\the\\pdfoutput\\relax\
-\\the\\everyjob}}\\everyjob\\next\\catcode`\\ 10 
\\let\\dump\\PREVIEWdump\\dump}\\fi\\input mylatex.ltx \\relax\n" nil dump-file)
+\\edef\\next{{\\pdfoutput=\\the\\pdfoutput\\relax\
+\\the\\everyjob}}\\everyjob\\next\\catcode`\\ 10 %
+\\catcode`/ 0 %
+\\def\\AUCTEXINPUT##1{\\catcode`/ 12\\relax\\catcode`\\ 
9\\relax\\input{\\detokenize{##1}}}%
+\\let\\dump\\PREVIEWdump\\dump}\\fi\\input mylatex.ltx \\relax%\n" nil 
dump-file)
       (TeX-save-document master)
       (prog1
          (preview-generate-preview
@@ -3505,8 +3519,9 @@ internal parameters, STR may be a log to insert into the 
current log."
   (set-buffer commandbuff)
   (let*
       ((preview-format-name (shell-quote-argument
-                            (preview-dump-file-name
-                             (file-name-nondirectory master))))
+                            (concat "&"
+                                    (preview-dump-file-name
+                                     (file-name-nondirectory master)))))
        (process-environment (copy-sequence process-environment))
        (process
        (progn

commit a8ea1273fd95da5702fe95ad3f41d151b621bc72
Author: Ikumi Keita <address@hidden>
Date:   Mon May 28 14:39:26 2018 +0900

    Accept non-ascii file name in accord with change in TL 2018
    
    * tex.el (TeX-expand-list-builtin): Add new entry %T.  Same as %t,
    except to enclose with \detokenize{} for non UTF-8 LaTeX when \input
    is supplmented.
    Adjust the entries %` and %' so that \input is supplemented only when
    any TeX code is present between them and leave the bind to
    `TeX-command-text' for later examination.
    The bind to `TeX-command-pos' is no longer retained.
    (TeX-command-list): Use %T for "LaTeX".
    Adjust "TeX" and "AmSTeX" as the same with "LaTeX" in the aspect that
    user can supply one's own TeX code, as well as any command line
    options, through `TeX-command-extra-options'.
    * tex-buf.el (TeX--master-or-region-file-with-extra-quotes): New
    function to act as a wrapper of `TeX-master-file' and
    `TeX-region-file' inside `TeX-command-expand'.
    (TeX-command-expand): Use the above function as the value of `file'
    and get rid of tricky temporal overriding of `file' with lambda form.
    (TeX-region-create): Make the first line parsing of %&FORMAT
    construct, if any, to be valid even for region compilation.
    Discard text properties when constructing the content of _region_.tex.
    Drop bind check for `buffer-file-coding-system'.
    * tests/tex/command-expansion.el (TeX-command-expansion): Reflect the
    change that \input is not necessarily supplemented now by %`-%' pair
    in `TeX-command-expand'.

diff --git a/tests/tex/command-expansion.el b/tests/tex/command-expansion.el
index 91b3235..b35b8f3 100644
--- a/tests/tex/command-expansion.el
+++ b/tests/tex/command-expansion.el
@@ -1,6 +1,6 @@
 ;;; command-expansion.el --- tests for TeX command expansion
 
-;; Copyright (C) 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2018 Free Software Foundation, Inc.
 
 ;; This file is part of AUCTeX.
 
@@ -31,7 +31,7 @@
                  (list (cons "Test" '("%%%% %`%'" TeX-run-command t t)))))
             (TeX-command-expand (nth 1 (assoc "Test" TeX-command-list))
                                 'TeX-master-file))
-           "%%  \"\\input\"")))
+           "%% ")))
 
 (ert-deftest TeX-command-expansion-errors ()
   "Test error handling in `TeX-command-expand'."
diff --git a/tex-buf.el b/tex-buf.el
index eed31f2..aec2579 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -542,12 +542,8 @@ without further expansion."
   (let (pat
        pos ;;FIXME: Should this be dynamically scoped?
        entry TeX-command-text TeX-command-pos
-        ;; FIXME: This variable appears to be unused!
-       (file `(lambda (&rest args)
-                (shell-quote-argument
-                 (concat (and (stringp TeX-command-pos) TeX-command-pos)
-                         (apply #',file args)
-                         (and (stringp TeX-command-pos) TeX-command-pos)))))
+       (orig-file file)
+       (file #'TeX--master-or-region-file-with-extra-quotes)
         expansion-res case-fold-search string expansion arguments)
     (setq list (cons
                (list "%%" (lambda nil
@@ -585,6 +581,47 @@ without further expansion."
                (replace-match string t t command)))))
   command)
 
+(defun TeX--master-or-region-file-with-extra-quotes
+    (&optional extension nondirectory ask extra)
+  "Return file name with quote for shell.
+Wrapper for `TeX-master-file' or `TeX-region-file' to be used in
+`TeX-command-expand'.
+It is assumed that `orig-file' has dynamic binding of the value of
+`TeX-master-file' or `TeX-region-file'.  Pass EXTENSION, NONDIRECTORY
+and ASK to that function as-is, and arrange the returned file name for
+use with command shell.
+Enclose the file name with space within quotes `\"' first when
+\" \\input\" is supplemented (indicated by dynamically binded
+variable `TeX-command-text' having string value.)
+Enclose the file name within \\detokenize{} when the following three
+conditions are met:
+1. compiling with standard (pdf)LaTeX or upLaTeX
+2. \" \\input\" is supplemented
+3. EXTRA is non-nil. (default when expanding \"%T\")"
+  (shell-quote-argument
+   (let* ((raw (funcall orig-file extension nondirectory ask))
+         ;; String `TeX-command-text' means that the file name is
+         ;; given through \input command.
+         (quote-for-space (if (and (stringp TeX-command-text)
+                                   (string-match " " raw))
+                              "\"" "")))
+     (format
+      (if (and extra
+              (stringp TeX-command-text)
+              (memq major-mode '(latex-mode doctex-mode))
+              (memq TeX-engine '(default uptex)))
+         ;; Since TeXLive 2018, the default encoding for LaTeX
+         ;; files has been changed to UTF-8 if used with
+         ;; classic TeX or pdfTeX.  I.e.,
+         ;; \usepackage[utf8]{inputenc} is enabled by default
+         ;; in (pdf)latex.
+         ;; c.f. LaTeX News issue 28
+         ;; Due to this change, \detokenize is required to
+         ;; recognize non-ascii characters in the file name
+         ;; when \input precedes.
+         "\\detokenize{ %s }" "%s")
+      (concat quote-for-space raw quote-for-space)))))
+
 (defun TeX-check-files (derived originals extensions)
   "Check if DERIVED is newer than any of the ORIGINALS.
 Try each original with each member of EXTENSIONS, in all directories
@@ -2123,8 +2160,10 @@ original file."
                           (if (not (re-search-forward TeX-header-end nil t))
                               ""
                             (re-search-forward "[\r\n]" nil t)
-                            (buffer-substring (point-min) (point)))))))))
+                            (buffer-substring-no-properties
+                             (point-min) (point)))))))))
         (header-offset 0)
+        first-line
         ;; We search for the trailer from the master file, if it is
         ;; not present in the region.
         (trailer-offset 0)
@@ -2144,21 +2183,36 @@ original file."
                              ;;(beginning-of-line 1)
                              (re-search-backward "[\r\n]" nil t)
                              (setq trailer-offset (TeX-current-offset))
-                             (buffer-substring (point) (point-max))))))))))
+                             (buffer-substring-no-properties
+                              (point) (point-max))))))))))
     ;; file name should be relative to master
     (setq original (TeX-quote-filename (file-relative-name
                                        original (TeX-master-directory)))
          master-name (TeX-quote-filename master-name))
+
+    ;; If the first line begins with "%&", put that line separately on
+    ;; the very first line of the region file so that the first line
+    ;; parsing will work.
+    (setq first-line (if (and (> (length header) 1)
+                             (string= (substring header 0 2) "%&"))
+                        ;; This would work even if header has no newline.
+                        (substring header 0 (string-match "\n" header))
+                      ""))
+    (unless (string= first-line "")
+      ;; Remove first-line from header.
+      (setq header (substring header (length first-line)))
+      (setq first-line (concat first-line "\n")))
+
     (with-current-buffer file-buffer
       (setq buffer-read-only t
            buffer-undo-list t)
       (setq original-content (buffer-string))
       (let ((inhibit-read-only t))
        (erase-buffer)
-       (when (boundp 'buffer-file-coding-system)
-         (setq buffer-file-coding-system
-               (with-current-buffer master-buffer buffer-file-coding-system)))
-       (insert "\\message{ !name(" master-name ")}"
+       (setq buffer-file-coding-system
+             (with-current-buffer master-buffer buffer-file-coding-system))
+       (insert first-line
+               "\\message{ !name(" master-name ")}"
                header
                TeX-region-extra
                "\n\\message{ !name(" original ") !offset(")
diff --git a/tex.el b/tex.el
index f7955f3..63ae293 100644
--- a/tex.el
+++ b/tex.el
@@ -116,10 +116,10 @@ If nil, none is specified."
 ;; `TeX-expand-list-builtin' for a description of the % escapes
 
 (defcustom TeX-command-list
-  '(("TeX" "%(PDF)%(tex) %(file-line-error) %(extraopts) 
%`%S%(PDFout)%(mode)%' %t"
+  '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) 
%S%(PDFout)%(mode)%' %t"
      TeX-run-TeX nil
      (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX")
-    ("LaTeX" "%`%l%(mode)%' %t"
+    ("LaTeX" "%`%l%(mode)%' %T"
      TeX-run-TeX nil
      (latex-mode doctex-mode) :help "Run LaTeX")
     ;; Not part of standard TeX.
@@ -127,7 +127,7 @@ If nil, none is specified."
      (texinfo-mode) :help "Run Makeinfo with Info output")
     ("Makeinfo HTML" "makeinfo %(extraopts) --html %t" TeX-run-compile nil
      (texinfo-mode) :help "Run Makeinfo with HTML output")
-    ("AmSTeX" "amstex %(PDFout) %(extraopts) %`%S%(mode)%' %t"
+    ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %t"
      TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
     ;; support for ConTeXt  --pg
     ;; first version of ConTeXt to support nonstopmode: 2003.2.10
@@ -498,8 +498,19 @@ string."
     ;; `file' means to call `TeX-master-file' or `TeX-region-file'
     ("%s" file nil t)
     ("%t" file t t)
+    ;; If any TeX codes appear in the interval between %` and %', move
+    ;; all of them after the interval and supplement " \input".  The
+    ;; appearance is marked by leaving the bind to `TeX-command-text'
+    ;; with the TeX codes.
+    ;; Rule:
+    ;; 1. %` and %' must appear in pair.
+    ;; 2. %` and %' must not appear more than once in one command
+    ;;    line string (including the results of %-expansion).
+    ;; 3. Each TeX codes between %` and %' must be enclosed in
+    ;;    double quotes and preceded by a space.
     ("%`" (lambda nil
-           (setq TeX-command-pos t TeX-command-text "")))
+           (setq TeX-command-pos t TeX-command-text nil)
+           ""))
     (" \"\\" (lambda nil
               (if (eq TeX-command-pos t)
                   (setq TeX-command-pos pos
@@ -523,18 +534,13 @@ string."
                                TeX-command-pos t)
                        (setq pos (1+ pos)))))
     ("%'" (lambda nil
-           (prog1
-               (if (stringp TeX-command-text)
-                   (progn
-                     (setq pos (+ pos (length TeX-command-text) 9)
-                           TeX-command-pos
-                           (and (string-match " "
-                                              (funcall file t t))
-                                "\""))
-                     (concat TeX-command-text " \"\\input\""))
-                 (setq TeX-command-pos nil)
-                 "")
-             (setq TeX-command-text nil))))
+           (setq TeX-command-pos nil)
+           (if (stringp TeX-command-text)
+               (progn
+                 (setq pos (+ pos (length TeX-command-text) 9))
+                 (concat TeX-command-text " \"\\input\""))
+             "")))
+    ("%T" TeX--master-or-region-file-with-extra-quotes t t nil t)
     ("%n" TeX-current-line)
     ("%d" file "dvi" t)
     ("%f" file "ps" t)

commit ff08d38666f10050f93b6cc4c5777420f30a0409
Author: Ikumi Keita <address@hidden>
Date:   Mon May 28 14:15:51 2018 +0900

    Fix region compilation with \usepackage[utf8]{inputenc}
    
    * tex-buf.el (TeX-quote-filename): Wrap non-ascii characters in
    \unexpanded{} for non UTF-8 LaTeX so that raw file name is recovered.

diff --git a/tex-buf.el b/tex-buf.el
index ad6dad6..eed31f2 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -2032,7 +2032,33 @@ The hooks are run in the region buffer, you may use the 
variable
     (while (setq pos (string-match "[~#]" file pos))
       (setq file (replace-match "\\\\string\\&" t nil file 0)
            pos (+ pos 8))))
-  file)
+  ;; Use \unexpanded so that \message outputs the raw file name.
+  ;; When \usepackage[utf8]{inputenc} is used in standard (pdf)latex,
+  ;; \message does not output non-ascii file name in raw form without
+  ;; \enuexpanded, which makes AUCTeX to fail to recognize the file
+  ;; names right when analysing the process output buffer.
+  ;; Note that \usepackage[utf8]{inputenc} is enabled by default in
+  ;; standard (pdf)latex since TeXLive 2018.
+  (if (and (memq major-mode '(latex-mode doctex-mode))
+          ;; Japanese upLaTeX requires the same treatment with
+          ;; respect to non-ascii characters other than Japanese, in
+          ;; file names within \message{}.
+          ;; However, pLaTeX (non u- version) does not support
+          ;; non-ascii file name encoded in UTF-8.  So considering
+          ;; `ptex' doesn't make sense here.  We cater for only
+          ;; `default' and `uptex' engines.
+          (memq TeX-engine '(default uptex)))
+      ;; It would fail to put entire `file' inside \unexpanded{} when
+      ;; the above loop injects \string before "#" and "~".  So put
+      ;; only multibyte characters inside \unexpanded{}.
+      ;; It is safe in upLaTeX to use \unexpanded{} on Japanese
+      ;; characters though they are handled by upLaTeX in a totally
+      ;; different way from inputenc.
+      ;; Thus put all multibyte characters, without considering
+      ;; whether they are Japanese or not, inside \unexpanded{}.
+      (replace-regexp-in-string "[[:multibyte:]]+"
+                               "\\\\unexpanded{\\&}" file t)
+    file))
 
 (defvar font-lock-mode-enable-list)
 (defvar font-lock-auto-fontify)

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

Summary of changes:
 doc/changes.texi               |  19 ++++++--
 preview.el.in                  |  29 ++++++++---
 tests/tex/command-expansion.el |  17 ++++++-
 tex-buf.el                     | 106 ++++++++++++++++++++++++++++++++++++-----
 tex.el                         |  38 ++++++++-------
 5 files changed, 167 insertions(+), 42 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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