From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: [PATCH][ox-latex.el] Allow AUTO argument to org-latex-guess-babel-language. Date: Sat, 01 Jun 2013 00:33:36 +0200 Message-ID: <87sj12bwzj.fsf@pank.eu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiXtS-0006IG-OB for emacs-orgmode@gnu.org; Fri, 31 May 2013 18:34:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiXtN-0002L8-SJ for emacs-orgmode@gnu.org; Fri, 31 May 2013 18:33:54 -0400 Received: from plane.gmane.org ([80.91.229.3]:49543) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiXtN-0002Kx-Ku for emacs-orgmode@gnu.org; Fri, 31 May 2013 18:33:49 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UiXtM-00083T-9I for emacs-orgmode@gnu.org; Sat, 01 Jun 2013 00:33:48 +0200 Received: from dynamic-adsl-94-34-191-111.clienti.tiscali.it ([94.34.191.111]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 01 Jun 2013 00:33:48 +0200 Received: from rasmus by dynamic-adsl-94-34-191-111.clienti.tiscali.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 01 Jun 2013 00:33:48 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit This patch allows ox-latex to make a guess on which language to use if babel is a default package. See the head of the patch. Two notes on the funcion: 1. As far as I remember, if more than one language is loaded the order is not neutral one one should issue a \selectlanguage{LANG}. 2. Perhaps it should look for babel /and/ pologlossya or whatever the package the xelatex and perhaps lualatex uses. Any thoughs? –Rasmus -- Together we'll stand, divided we'll fall --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Allow-AUTO-argument-to-org-latex-guess-babel-languag.patch >From dde65056267bcb4c1bfe23c2e66f570739bb72c7 Mon Sep 17 00:00:00 2001 From: "rasmus" Date: Sat, 1 Jun 2013 00:20:18 +0200 Subject: [PATCH] Allow AUTO argument to org-latex-guess-babel-language. * ox-latex.el (org-latex-guess-babel-language): ignore AUTO if argument. * ox-latex.el (org-lat ex-guess-babel-language): use language if is not in =`org-latex-inputenc-alist'=. * ox-latex.el (org-latex-guess-babel-language): retain case in final regexp of function. Behavior changes: 1. =("AUTO" "babel" t)= works like ("AUTO" "inputenc" t) in =`org-latex-default-packages-alist'=. I.e. the default language is choosen. 2. if #+LANGUAGE: mylang then then \usepackage[mylang]{babel} in outpu. TINYCHANGE --- lisp/ox-latex.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 3a01693..033d318 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -929,19 +929,21 @@ Return the new header." ;; If no language is set or Babel package is not loaded, return ;; HEADER as-is. (if (or (not (stringp language-code)) - (not (string-match "\\\\usepackage\\[\\(.*\\)\\]{babel}" header))) + (not (string-match "\\\\usepackage\\[\\(AUTO\\)?,?\\(.*\\)\\]{babel}" header))) header (let ((options (save-match-data - (org-split-string (match-string 1 header) ","))) - (language (cdr (assoc language-code - org-latex-babel-language-alist)))) + (org-split-string (match-string 2 header) ","))) + (language (or + (cdr (assoc language-code + org-latex-babel-language-alist)) + language-code))) ;; If LANGUAGE is already loaded, return header. Otherwise, ;; append LANGUAGE to other options. (if (member language options) header (replace-match (mapconcat 'identity (append options (list language)) ",") - nil nil header 1)))))) + t nil header 1)))))) (defun org-latex--find-verb-separator (s) "Return a character not used in string S. -- 1.8.3 --=-=-=--