From 4de4fde0a5ba6d0eb8a9898e7e262f3f8fa5c6ea 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): ignore AUTO if it is the argument to (the LaTeX package) babel. * ox-latex.el (org-lat ex-guess-babel-language): if LANGUAGE: mylang and mylang is not a member =`org-latex-inputenc-alist'= use mylang (rather than discard it). * ox-latex.el (org-latex-guess-babel-language): retain case in final regexp of function. --- lisp/ox-latex.el | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index ff0ca1d..09a9103 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 @@ -917,17 +920,26 @@ Return the new header." (if (or (not (stringp language-code)) (not (string-match "\\\\usepackage\\[\\(.*\\)\\]{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)))) - ;; If LANGUAGE is already loaded, return header. Otherwise, + (let ((options (save-match-data + ;; As with `org-latex-guess-inputenc' it only works with + ;; uppercase "AUTO + (remove "AUTO" + (org-split-string + ;; in case of [lang_one, lang_two] + (replace-regexp-in-string "[ \t\n]*" "" + (match-string 1 header)) ",")))) + (language (or + (cdr (assoc language-code + org-latex-babel-language-alist)) + language-code))) + ;; If LANGUAGE is already loaded, return header without AUTO. Otherwise, ;; append LANGUAGE to other options. - (if (member language options) header - (replace-match (mapconcat 'identity - (append options (list language)) - ",") - nil nil header 1)))))) + (replace-match (mapconcat 'identity + (if (member language options) + options + (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