Subject: Re: bug#21401: 11.88.6; Incorrect detection of TeX variant

From: Tassilo Horn <[email-masked]>
Date: Thu, 03 Sep 2015 08:31:45 +0200

Tassilo Horn <[email-masked]> writes:

Hi Jonathan & Matthew,

>> The following simple file results in AucTeX assuming the compiler to
>> run is AmS-TeX which no longer exists on most machines.
>>
>> \documentclass[11pt]{article}
>>  \usepackage{basicart1}
>> \begin{document}
>>
>> \Document{DocNum}{\today}
>
> I think this line is the culprit.  AmS-TeX is detected by something
> matching the regex "\\\\document\\b" near the beginning of the document
> (see `TeX-format-list').
>
> I don't know AmS-TeX at all but I think the regexes in `TeX-format-list'
> should be matched case-sensitively (they are currently not), no?  And
> then your \Document wouldn't be matched.
>
> Matthew Saltzman <[email-masked]> writes:
>
>> It's not so much that AmS-TeX is detected, as the amstex processor is
>> still part of TeXLive (and I presume other distributions as well), but
>> when AmS-TeX is detected and the option to produce PDF output is
>> selected, the command that is invoked is pdfamstex, which does not
>> exist at all, anywhere.
>
> I guess we should use amstex -output-format=pdf then, right?

I've committed the following patch to the git master.  Could you please
try it out and report back if that fixes the issues (i.e., the wrong
detection of AMS-TeX, and the nonexisting command when trying to process
a real AMS-TeX document with TeX-PDF-mode enabled)?

--8<---------------cut here---------------start------------->8---
References: master origin/master origin/HEAD
Author:     Tassilo Horn <[email-masked]>
AuthorDate: Thu Sep 3 08:26:50 2015 +0200
Commit:     Tassilo Horn <[email-masked]>
CommitDate: Thu Sep 3 08:26:50 2015 +0200

    Case-sensitive mode detection + AMS-TeX fixes
    
    * tex.el (TeX-tex-mode): Don't ignore case when matching the
    TeX-format-list regexes.
    (TeX-expand-list): Add expansion of %(PDFout) to -output-format
    option for AmS-TeX.
    (TeX-command-list): Use it instead of calling the non-existing
    pdfamstex command.

1 parent commit, 1 merged branch, 2 containing branches
 Parent     | 66b97ff Don't add font-latex-setup to latex-mode-hook
 Merged     | master
 Containing | master simplify-TeX-parse-error
 Follows    | release_11_88 (170)

2 files changed, 16 insertions(+), 3 deletions(-)
 ChangeLog |  9 +++++++++
 tex.el    | 10 +++++++---

modified   ChangeLog
@@ -1,3 +1,12 @@
+2015-09-03  Tassilo Horn  <[email-masked]>
+
+	* tex.el (TeX-tex-mode): Don't ignore case when matching the
+	TeX-format-list regexes.
+	(TeX-expand-list): Add expansion of %(PDFout) to -output-format
+	option for AmS-TeX.
+	(TeX-command-list): Use it instead of calling the non-existing
+	pdfamstex command.
+
 2015-09-02  Tassilo Horn  <[email-masked]>
 
 	* font-latex.el: Remove code which set up font-latex for use with
modified   tex.el
@@ -132,7 +132,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" "%(PDF)amstex %(extraopts) %`%S%(PDFout)%(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
@@ -455,7 +455,11 @@ string."
 		    "pdf"
 		  "")))
     ("%(PDFout)" (lambda ()
-		   (cond ((and (eq TeX-engine 'xetex)
+		   (cond ((eq major-mode 'ams-tex-mode)
+			  (if TeX-PDF-mode
+			      " -output-format=pdf"
+			    " -output-format=dvi"))
+			 ((and (eq TeX-engine 'xetex)
 			       (not TeX-PDF-mode))
 			  " -no-pdf")
 			 ((and (eq TeX-engine 'luatex)
@@ -3398,7 +3402,7 @@ The algorithm is as follows:
 		       (regexp-quote TeX-esc)
 		       "\\)*\\)\\(%+ *\\)"))
 		     (entry TeX-format-list)
-		     answer)
+		     answer case-fold-search)
 		 (while (and entry (not answer))
 		   (if (re-search-forward (nth 2 (car entry))
 					  10000 t)
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo