From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [PATCH (v5)][ox-latex.el] Allow AUTO argument to org-latex-guess-babel-language. Date: Wed, 12 Jun 2013 01:12:26 +0200 Message-ID: <877gi0dyxx.fsf_-_@pank.home> 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> <87txlbylja.fsf_-_@pank.eu> <87r4gew128.fsf@gmail.com> <8738sux7pw.fsf@pank.eu> <87zjuzvhuw.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmXjx-0003R8-TN for emacs-orgmode@gnu.org; Tue, 11 Jun 2013 19:12:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UmXjv-0007S0-9u for emacs-orgmode@gnu.org; Tue, 11 Jun 2013 19:12:37 -0400 Received: from mout.gmx.net ([212.227.17.22]:49631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmXjv-0007Rp-0g for emacs-orgmode@gnu.org; Tue, 11 Jun 2013 19:12:35 -0400 In-Reply-To: <87zjuzvhuw.fsf@gmail.com> (Nicolas Goaziou's message of "Sun, 09 Jun 2013 09:55:03 +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: n.goaziou@gmail.com Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Nicolas Goaziou writes: > The patch looks good, but the feature needs to be documented. I think > you could add a paragraph in `org-latex-classes' docstring, below the > first reference to "AUTO". v5! Documentation added. Let me know if more stuff needs to be polished. =E2=80=93Rasmus --=20 May contains speling mistake --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Allow-AUTO-argument-to-org-latex-guess-babel-languag.patch >From 7f1cc30ccbedfa7c5689dbf8408011e64db75230 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. * (org-latex-classes): updated documentation with respect to =`org-latex-guess-babel-language'= --- lisp/ox-latex.el | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index df3de4c..d409cf8 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -261,6 +261,14 @@ replaced with a coding system derived from `buffer-file-coding-system'. See also the variable `org-latex-inputenc-alist' for a way to influence this mechanism. +Likewise, if your header contains \"\\usepackage[AUTO]{babel}\", +AUTO will be replaced with the export language as specified by +the LANGUAGE keyword or `org-export-default-language'. Note that +constructions such as +\"\\usepackage[french, AUTO, english]{babel}\" +are permitted. For more information refer to +`org-latex-guess-babel-language'. + The sectioning structure ------------------------ @@ -910,6 +918,10 @@ 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' +unless language in question is already loaded. + 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 +930,19 @@ 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)) - ",") - nil nil header 1)))))) + ;; If LANGUAGE is already loaded, return header without AUTO. + ;; Otherwise, replace AUTO with language or append language if + ;; AUTO is not present. + (replace-match + (mapconcat (lambda (option) (if (equal "AUTO" option) language option)) + (cond ((member language options) (delete "AUTO" options)) + ((member "AUTO" options) options) + (t (append options (list language)))) + ", ") + t nil header 1))))) (defun org-latex--find-verb-separator (s) "Return a character not used in string S. -- 1.8.3 --=-=-=--