From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [PATCH (v3)][ox-latex.el] Allow AUTO argument to org-latex-guess-babel-language. Date: Thu, 06 Jun 2013 23:30:33 +0200 Message-ID: <87txlbylja.fsf_-_@pank.eu> References: <87sj12bwzj.fsf@pank.eu> <8661xvprju.fsf@somewhere.org> <87ehcj9uh7.fsf@pank.eu> <8638sz1e3b.fsf@somewhere.org> <87obbn8c36.fsf@pank.eu> <86wqqae5n4.fsf@somewhere.org> <87ppw26xe2.fsf_-_@pank.eu> <87y5aollyh.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ukhlg-0005gY-0X for emacs-orgmode@gnu.org; Thu, 06 Jun 2013 17:30:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ukhle-00033G-QS for emacs-orgmode@gnu.org; Thu, 06 Jun 2013 17:30:47 -0400 Received: from plane.gmane.org ([80.91.229.3]:40898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ukhle-00033A-H8 for emacs-orgmode@gnu.org; Thu, 06 Jun 2013 17:30:46 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ukhld-0004ly-QB for emacs-orgmode@gnu.org; Thu, 06 Jun 2013 23:30:45 +0200 Received: from 87-57-37-160-dynamic.dk.customer.tdc.net ([87.57.37.160]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 Jun 2013 23:30:45 +0200 Received: from rasmus.pank by 87-57-37-160-dynamic.dk.customer.tdc.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 Jun 2013 23:30:45 +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 Hi, Nicolas Goaziou writes: > Thanks for your patch. Here are a few comments: is the attached patch better? It replaced AUTO with LANG when LANG is recognized and preserve position and LANG is the argument to LANGUAGE. I don't know if this patch uses the most efficient way of replacing AUTO with LANG (see the dotimes). –Rasmus -- C is for Cookie --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Allow-AUTO-argument-to-org-latex-guess-babel-languag.patch >From 8c97851cb499280bee035d835783bbf17943334e Mon Sep 17 00:00:00 2001 From: "rasmus.pank" 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): replace AUTO with language if AUTO is the option of the LaTeX package Babel. * ox-latex.el (org-latex-guess-babel-language): retain case in final replace-match of the function. --- lisp/ox-latex.el | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index ff0ca1d..0628514 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -910,6 +910,9 @@ Insertion of guessed language only happens when Babel package has explicitly been loaded. Then it is added to the rest of package's options. +The argument to Babel may be \"AUTO\" which is then replaced with +the language of the document or `org-export-default-language'. + Return the new header." (let ((language-code (plist-get info :language))) ;; If no language is set or Babel package is not loaded, return @@ -918,16 +921,24 @@ Return the new header." (not (string-match "\\\\usepackage\\[\\(.*\\)\\]{babel}" header))) header (let ((options (save-match-data - (org-split-string (match-string 1 header) ","))) + (org-split-string (match-string 1 header) ",[ \t]*"))) (language (cdr (assoc language-code org-latex-babel-language-alist)))) - ;; 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)) + ;; If LANGUAGE is already loaded, return header without AUTO. + ;; Otherwise, replace AUTO with language or append language if + ;; no AUTO is not present. + (replace-match (mapconcat 'identity + (if language + (cond ((member language options) + (delete "AUTO") options) + ((member "AUTO" options) + (dotimes (n (length options) options) + (if (equal "AUTO" (nth n options)) + (setf (nth n options) language)))) + (t (append options (list language)))) + (delete "AUTO" options)) ",") - 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 --=-=-=--