[Top][All Lists]

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

[AUCTeX-devel] Re: xelatex and pdftex (a new mode)

From: Ralf Angeli
Subject: [AUCTeX-devel] Re: xelatex and pdftex (a new mode)
Date: Sun, 20 Jul 2008 11:00:18 +0200

* Uwe Brauer (2008-07-17) writes:

> So I suggest to add a xelatex mode, with the same functionality as the
> pdflatex mode, when calling the viewer automatically xpdf starts and
> not xdvi.

Attached there are some proposed changes implementing an XeTeX minor
mode, similar to Omega mode.

The minor mode assumes that one will always want to generate PDF output
when XeTeX is used.  Therefore activating XeTeX mode will also activate
PDF mode.  (The PDF mode lighter will not show up, though.)  Does
anybody think it would be useful if XeTeX could also be used without PDF
mode?  I didn't find a real use case for that because there are no
viewers for XDV files.  But I am not sure if there are
PostScript-related workflows as with regular LaTeX where the direct
generation of PDF is not wanted.

I'm not really happy with the minor mode approach, because the AUCTeX
minor modes are becoming a bit numerous and the logic for dealing with
their interaction becomes difficult to manage.  But until we get
configurable tool chains, this is probably still the best way to go.
(LuaTeX mode, anybody?)

Please comment on the implementation, before I commit it.

--- tex.el.~5.624.~     2008-07-16 22:11:15.000000000 +0200
+++ tex.el      2008-07-20 10:41:46.000000000 +0200
@@ -411,6 +411,7 @@
            (TeX-style-check LaTeX-command-style)))
     ("%(PDF)" (lambda ()
                (if (and (not TeX-Omega-mode)
+                        (not TeX-XeTeX-mode)
                         (or TeX-PDF-mode
@@ -426,12 +427,12 @@
                   " -interaction=nonstopmode")))
     ("%(o?)" (lambda () (if TeX-Omega-mode "o" "")))
-    ("%(tex)" (lambda () (if TeX-Omega-mode
-                            TeX-Omega-command
-                          TeX-command)))
-    ("%(latex)" (lambda () (if TeX-Omega-mode
-                              LaTeX-Omega-command
-                            LaTeX-command)))
+    ("%(tex)" (lambda () (cond (TeX-Omega-mode TeX-Omega-command)
+                              (TeX-XeTeX-mode TeX-XeTeX-command)
+                              (t TeX-command))))
+    ("%(latex)" (lambda () (cond (TeX-Omega-mode LaTeX-Omega-command)
+                                (TeX-XeTeX-mode LaTeX-XeTeX-command)
+                                (t LaTeX-command))))
     ("%(execopts)" ConTeXt-expand-options)
     ("%S" TeX-source-correlate-expand-options)
     ("%dS" TeX-source-specials-view-expand-options)
@@ -582,7 +583,7 @@
        (val (ad-get-arg 1)))
     ;; Instead of checking for each mode explicitely `minor-mode-list'
     ;; could be used.  But this may make the byte compiler pop up.
-    (when (memq var '(TeX-PDF-mode
+    (when (memq var '(TeX-PDF-mode TeX-XeTeX-mode
                      TeX-source-correlate-mode TeX-interactive-mode
                      TeX-Omega-mode TeX-fold-mode LaTeX-math-mode))
       (if (symbol-value val) (funcall var 1) (funcall var 0)))))
@@ -834,7 +835,8 @@
                (and (boundp 'LaTeX-math-mode) LaTeX-math-mode "M")
                (and TeX-interactive-mode "I")
                (and TeX-source-correlate-mode "S"))))
-         (setq mode-name (concat (and TeX-PDF-mode "PDF")
+         (setq mode-name (concat (and TeX-PDF-mode (not TeX-XeTeX-mode) "PDF")
+                                 (and TeX-XeTeX-mode "Xe")
                                  (when (> (length trailing-flags) 0)
                                    (concat "/" trailing-flags))))
@@ -1196,10 +1198,14 @@
   :group 'TeX-command
   (when TeX-Omega-mode
     (setq TeX-PDF-mode nil))
+  ;; Disable TeX XeTeX mode if TeX PDF mode is disabled
+  (when (and (not TeX-PDF-mode) TeX-XeTeX-mode)
+    (TeX-XeTeX-mode -1))
   (setq TeX-PDF-mode-parsed nil)
   (TeX-set-mode-name nil nil t)
   (setq TeX-output-extension
        (if TeX-PDF-mode "pdf" "dvi")))
+(put 'TeX-XeTeX-mode 'safe-local-variable 'TeX-booleanp)
 (defun TeX-global-PDF-mode (&optional arg)
   "Toggle default for `TeX-PDF-mode'."
@@ -1270,6 +1276,26 @@
   (TeX-set-mode-name 'TeX-Omega-mode t t))
 (defalias 'tex-omega-mode 'TeX-Omega-mode)
+(defcustom TeX-XeTeX-command "xetex"
+  "Command to run plain TeX on XeTeX."
+  :group 'TeX-command
+  :type 'string)
+(defcustom LaTeX-XeTeX-command "xelatex"
+  "Command to run LaTeX on XeTeX."
+  :group 'TeX-command
+  :type 'string)
+(define-minor-mode TeX-XeTeX-mode
+  "Minor mode for using the XeTeX engine."
+  nil nil nil
+  :group 'TeX-command
+  (when TeX-XeTeX-mode
+    (TeX-PDF-mode 1)
+    (when TeX-Omega-mode (TeX-Omega-mode -1)))
+  (TeX-set-mode-name 'TeX-XeTeX-mode t t))
+(defalias 'tex-xetex-mode 'TeX-XeTeX-mode)
 ;;; Commands
 (defgroup TeX-command-name nil
@@ -3627,6 +3653,7 @@
     (define-key map "\C-c%"    'TeX-comment-or-uncomment-paragraph)
     (define-key map "\C-c\C-t\C-o"   'TeX-Omega-mode)
+    (define-key map "\C-c\C-t\C-x"   'TeX-XeTeX-mode)
     (define-key map "\C-c\C-t\C-p"   'TeX-PDF-mode)
     (define-key map "\C-c\C-t\C-i"   'TeX-interactive-mode)
     (define-key map "\C-c\C-t\C-s"   'TeX-source-correlate-mode)
@@ -3721,6 +3748,9 @@
        [ "Use Omega" TeX-Omega-mode
         :style toggle :selected TeX-Omega-mode
         :help "Use the Omega engine for compiling"]
+       [ "Use XeTeX" TeX-XeTeX-mode
+        :style toggle :selected TeX-XeTeX-mode
+        :help "Use the XeTeX engine for compiling"]
        [ "PDF Mode" TeX-PDF-mode
         :style toggle :selected TeX-PDF-mode
         :active (not TeX-Omega-mode)

reply via email to

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