>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