From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tariq Newsgroups: gmane.emacs.help Subject: Re: How to get xetex/xelatex option in the Emacs menu? Date: Fri, 23 Apr 2010 12:04:23 -0700 (PDT) Organization: http://groups.google.com Message-ID: <52ac7ffb-26b3-4d04-b722-3802190ca554@j17g2000yqa.googlegroups.com> References: <87ljcem3jb.fsf@mithlond.arda> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1273063722 23927 80.91.229.12 (5 May 2010 12:48:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 5 May 2010 12:48:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 05 14:48:41 2010 connect(): No such file or directory Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O9e1o-0000wb-CQ for geh-help-gnu-emacs@m.gmane.org; Wed, 05 May 2010 14:48:40 +0200 Original-Received: from localhost ([127.0.0.1]:54295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9e1n-00060E-9z for geh-help-gnu-emacs@m.gmane.org; Wed, 05 May 2010 08:48:39 -0400 Original-Path: usenet.stanford.edu!postnews.google.com!j17g2000yqa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 54 Original-NNTP-Posting-Host: 70.33.84.130 Original-X-Trace: posting.google.com 1272049463 18539 127.0.0.1 (23 Apr 2010 19:04:23 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 23 Apr 2010 19:04:23 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j17g2000yqa.googlegroups.com; posting-host=70.33.84.130; posting-account=j4-J0goAAACTdeq3UQ6SnmoX2cXrehae User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100401 Ubuntu/9.10 (karmic) Firefox/3.5.9,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:177843 X-Mailman-Approved-At: Tue, 04 May 2010 16:56:02 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:73433 Archived-At: On Apr 23, 2:23=A0pm, Teemu Likonen 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: > > =A0 =A0 (add-hook 'LaTeX-mode-hook #'my-latex-mode-hook) > > =A0 =A0 (defun my-latex-mode-hook () > =A0 =A0 =A0 (add-to-list 'TeX-command-list > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'("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{}. > > =A0 =A0 (defun my-latex-mode-hook () > =A0 =A0 =A0 (add-to-list 'TeX-command-list > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'("XeLaTeX" "%`xelatex%(mode)%' %t= " TeX-run-TeX nil t)) > =A0 =A0 =A0 (setq TeX-command-default > =A0 =A0 =A0 =A0 =A0 =A0 (save-excursion > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (save-restriction > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (widen) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (goto-char (point-min)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let ((re (concat "^\\s-*\\\\usepackage\\= (?:\\[.*\\]\\)?" > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "{.*\= \<\\(?:font\\|math\\)spec\\>.*}"))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (re-search-forward re 3000 t) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "XeLaTeX" > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "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