From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Haines Brown Newsgroups: gmane.emacs.help Subject: Re: Having .emacs distinguish betweeen LaTeX and XeLaTeX Date: Sun, 27 May 2012 09:31:33 -0400 Message-ID: <20120527133133.GY4844@histomat.net> References: <87mx4tkhwj.fsf@engels.HistoricalMaterialism.info> <87d35pzxep.fsf@mithlond.arda> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1338141707 7358 80.91.229.3 (27 May 2012 18:01:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 27 May 2012 18:01:47 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Teemu Likonen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 27 20:01:46 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SYhme-0004Ym-CD for geh-help-gnu-emacs@m.gmane.org; Sun, 27 May 2012 20:01:40 +0200 Original-Received: from localhost ([::1]:41210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYhme-000381-5P for geh-help-gnu-emacs@m.gmane.org; Sun, 27 May 2012 14:01:40 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYdgP-0005NE-DL for help-gnu-emacs@gnu.org; Sun, 27 May 2012 09:38:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SYdgN-0003Th-JM for help-gnu-emacs@gnu.org; Sun, 27 May 2012 09:38:56 -0400 Original-Received: from smtp.omnis.com ([216.239.128.26]:31656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYdgN-0003Tc-DP for help-gnu-emacs@gnu.org; Sun, 27 May 2012 09:38:55 -0400 Original-Received: from mail-hub-a.omnis.com (mail-hub-a.omnis.com [216.239.128.241]) by smtp.omnis.com (Postfix) with ESMTP id 0BC45457583; Sun, 27 May 2012 06:32:39 -0700 (PDT) Original-Received: from engels.HistoricalMaterialism.info (64-252-187-241.adsl.snet.net [64.252.187.241]) (Authenticated sender: brownh@historicalmaterialism.info) by mail-hub-a.omnis.com (Postfix) with ESMTPSA id 927224CEE14; Sun, 27 May 2012 06:32:38 -0700 (PDT) Original-Received: from haines by engels.HistoricalMaterialism.info with local (Exim 4.72) (envelope-from ) id 1SYdZF-0006xn-8W; Sun, 27 May 2012 09:31:33 -0400 Content-Disposition: inline In-Reply-To: <87d35pzxep.fsf@mithlond.arda> X-Operating-System: GNU/Linux 2.6.32-5-686-bigmem Debian squeeze X-URL: www.historicalMaterialism.info User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: clamav-milter 0.97.4 at mail-hub-a.omnis.com X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 216.239.128.26 X-Mailman-Approved-At: Sun, 27 May 2012 14:01:32 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85020 Archived-At: 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