Hi AUCTeX developers,

In AUCTeX 11.89, a new option 'TeX-PDF-via-dvips-ps2pdf' was introduced
as a handy tool for generating pdf output through dvi file as
intermediate format.  Could you extend this framework so that we can use
dvipdfmx instead of divps+ps2pdf?

The attached patch is my initial try along the direction of the above
idea.  To try this patch, do

(setq TeX-PDF-via-dvips-ps2pdf "Dvipdfmx")

in init.el.  That makes AUCTeX to use dvipdfmx instead of dvips+ps2pdf
when TeX-PDF-mode is on.

I don't care the detail of the actual implementation, so other
approaches are welcome.

Background: Most Japanese (La)TeX users use dvipdfmx, not pdf(la)tex,
for producing pdf for final output.  Unlike pdftex, Japanese tex engine
ptex, jtex and uptex are not capable of direct generation of pdf.
Therefore the use of dvipdfmx is vital for us Japanese users.  (The
LuaTeX-ja project https://osdn.jp/projects/luatex-ja/ aims for direct
pdf output from Japanese tex documents which respects the Japanese
typesetting rule with the same quality as ptex, but is still in beta or
pre-beta stage and will take a long time to reach satisfactory level.)
Dvips+ps2pdf is not popular among the Japanese (La)TeX users.  Dvipdfmx
is preferred over dvips+ps2pdf and is the de facto standard way.

Best regards,
Ikumi Keita

P.S.  I'm not on this ML, so please put me on CC when replying.

diff --git a/tex-buf.el b/tex-buf.el
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -798,9 +798,9 @@
 		    name
 		    'TeX-command-next
 		    (if (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode)
-			"Dvips"
+			TeX-PDF-via-dvips-ps2pdf
 		      TeX-command-Show)))
-	     (list "Dvips" TeX-command-Show))
+	     (list TeX-PDF-via-dvips-ps2pdf TeX-command-Show))
 	    (cdr (assoc (expand-file-name (concat name ".idx"))
 			LaTeX-idx-changed-alist)))
 	   "Index")
@@ -988,6 +988,7 @@
     (setq TeX-sentinel-function
 	  (lambda (_process name)
 	    (message (concat name ": done."))))
+    (TeX-run-set-command name command)
     (if TeX-process-asynchronous
 	(let ((process (start-process name buffer TeX-shell
 				      TeX-shell-command-option command)))
@@ -1020,7 +1021,6 @@
 
 (defun TeX-run-format (name command file)
   "Create a process for NAME using COMMAND to format FILE with TeX."
-  (TeX-run-set-command name command)
   (let ((buffer (TeX-process-buffer-name file))
 	(process (TeX-run-command name command file)))
     ;; Hook to TeX debuger.
@@ -1212,7 +1212,6 @@
 Run command in a buffer (in comint-shell-mode) so that it accepts user
 interaction. If you return to the file buffer after the TeX run,
 Error parsing on \\[next-error] should work with a bit of luck."
-  (TeX-run-set-command name command)
   (require 'comint)
   (let ((default TeX-command-default)
 	(buffer (TeX-process-buffer-name file))
@@ -1363,7 +1362,7 @@
     (message (concat name ": formatted " (TeX-current-pages)))
     (if (with-current-buffer TeX-command-buffer
 	  (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
-	(setq TeX-command-next "Dvips")
+	(setq TeX-command-next TeX-PDF-via-dvips-ps2pdf)
       (setq TeX-command-next TeX-command-Show))))
 
 (defun TeX-current-pages ()
@@ -1423,7 +1422,7 @@
 	t)
     (if (with-current-buffer TeX-command-buffer
 	  (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
-	(setq TeX-command-next "Dvips")
+	(setq TeX-command-next TeX-PDF-via-dvips-ps2pdf)
       (setq TeX-command-next TeX-command-Show))
     nil))
 
@@ -1516,7 +1515,7 @@
 		  (TeX-current-pages))
 	 (if (with-current-buffer TeX-command-buffer
 	       (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
-	     (setq TeX-command-next "Dvips")
+	     (setq TeX-command-next TeX-PDF-via-dvips-ps2pdf)
 	   (setq TeX-command-next TeX-command-Show)))
 	((re-search-forward "^\\(?:LaTeX Warning: Citation\\|\
 Package natbib Warning:.*undefined citations\\)" nil t)
@@ -1524,7 +1523,7 @@
 		  (TeX-current-pages))
 	 (if (with-current-buffer TeX-command-buffer
 	       (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
-	     (setq TeX-command-next "Dvips")
+	     (setq TeX-command-next TeX-PDF-via-dvips-ps2pdf)
 	   (setq TeX-command-next TeX-command-Show)))
 	((re-search-forward "Package longtable Warning: Table widths have \
 changed\\. Rerun LaTeX\\." nil t)
@@ -1553,7 +1552,7 @@
 				 (TeX-current-pages) add-info)))
 	 (if (with-current-buffer TeX-command-buffer
 	       (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
-	     (setq TeX-command-next "Dvips")
+	     (setq TeX-command-next TeX-PDF-via-dvips-ps2pdf)
 	   (setq TeX-command-next TeX-command-Show)))
 	(t
 	 (message "%s%s%s" name ": problems after " (TeX-current-pages))
diff --git a/tex.el b/tex.el
--- a/tex.el
+++ b/tex.el
@@ -153,6 +153,8 @@
      :help "Convert DVI file to PostScript")
     ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil t
      :help "Convert PostScript file to PDF")
+    ("Dvipdfmx" "dvipdfmx %d " TeX-run-command nil t
+     :help "Convert DVI file to PDF")
     ("Index" "makeindex %s" TeX-run-index nil t
      :help "Run makeindex to create index file")
     ("Xindy" "texindy %s" TeX-run-command nil t
@@ -268,6 +270,7 @@
   '(
 					; Add the following line if you want to use htlatex (tex4ht)
 					;    ("\\`htlatex" ("html"))
+    ("\\`dvipdfmx" "pdf")
     )
   "List of regexps and file extensions.
 
_______________________________________________
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to