help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to get xetex/xelatex option in the Emacs menu?


From: Tariq
Subject: Re: How to get xetex/xelatex option in the Emacs menu?
Date: Fri, 23 Apr 2010 12:04:23 -0700 (PDT)
User-agent: G2/1.0

On Apr 23, 2:23 pm, Teemu Likonen <tliko...@iki.fi> wrote:
> * 2010-04-23 10:54 (-0700), Tariq wrote:
>
> > I would like to include in one of these menus (preferably under the
> > Command menu) the option to run xetex/xelatex also so that I can use
> > Emacs to compile XeLaTeX files.
>
> You could do it with hook:
>
>     (add-hook 'LaTeX-mode-hook #'my-latex-mode-hook)
>
>     (defun my-latex-mode-hook ()
>       (add-to-list 'TeX-command-list
>                    '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t)))
>
> The following is a fancier version of the hook. It sets XeLaTeX the
> default compiler when it finds fontspec or mathspec package being loaded
> with \usepackage{}.
>
>     (defun my-latex-mode-hook ()
>       (add-to-list 'TeX-command-list
>                    '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
>       (setq TeX-command-default
>             (save-excursion
>               (save-restriction
>                 (widen)
>                 (goto-char (point-min))
>                 (let ((re (concat "^\\s-*\\\\usepackage\\(?:\\[.*\\]\\)?"
>                                   "{.*\\<\\(?:font\\|math\\)spec\\>.*}")))
>                   (if (re-search-forward re 3000 t)
>                       "XeLaTeX"
>                     "LaTeX"))))))

Thank you so much for the code for two hooks. Consider this my naivity
but I cannot tell the difference (if any) in the behaviour of Emacs
when using the first or the second (fancier) hook. Specifically, I see
the appearance of XeLaTeX under the Command menu after opening a .tex
file and this is the case with either code. Similarly, when I select
(in TeXing Options) PDF Mode, I still need to press XeLaTeX in Command
menu.

I got the impression from your description that with the fancier code,
the LaTeX option would execute XeLaTeX if the file has
\usepackage{fontspec} in it. this does not appear to be the case. Most
likely, I am confused about something. What specifically is the
difference in the expected behaviour of these two codes? I would
appreciate if you could elaborate. Regards,

Tariq



reply via email to

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