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

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

Re: Having .emacs distinguish betweeen LaTeX and XeLaTeX


From: Haines Brown
Subject: Re: Having .emacs distinguish betweeen LaTeX and XeLaTeX
Date: Sun, 27 May 2012 09:31:33 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

On Sun, May 27, 2012 at 02:16:46PM +0300, Teemu Likonen wrote:
> * Haines Brown [2012-05-27 07:00:44 -0400] wrote:
> 
> > Is it possible to something comparable to this if construction in
> > .emacs init? I know nothing of lisp, but guess it would be something
> > like:
> >
> >    ( if 
> >         (search-forward "\usepackage*fontspec") or
> >         (search-forward "\usepackage*polyglossia")
> >      (setq TeX-engine 'xetex))
> 
> If you know nothing of Lisp this may not help you but I'll paste my
> settings anyway. It could be modified to match your needs.
> 
> 
>     (add-hook 'LaTeX-mode-hook #'tl-latex-mode-hook)
> 
>     (defun tl-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\\>.*}")))
>                   (save-match-data
>                     (if (re-search-forward re 3000 t)
>                         "XeLaTeX"
>                       "LaTeX"))))))
>       (auto-fill-mode 1)
>       (outline-minor-mode 1)
>       (abbrev-mode 1)
>       (setq fill-column 72))

If I understand, this presumes that initially latex is the default 
TeX-engine, but it adds the xelatex engine to the available commands 
if the expression is matched. This expression is way beyond my ken. 

Would it be possible instead to put a comment line just before the 
preamble of a document that contains either the word "latex" or 
"xelatex" (assuming those words do not appear elsewhere in the 
document) and base the forward search on it? Also, for my purposes it 
would probably be more convenient to make xelatex the default 
TeX-engine and if the word "latex" is found it would instead be used 
as the TeX-engine. I assume this would also avoid having to enlarge 
the TeX-command-list because I suppose latex would already be in it.

Haines 



reply via email to

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