emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: n.goaziou@gmail.com
Cc: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <877gi0dyxx.fsf_-_@pank.home> (raw)
In-Reply-To: <87zjuzvhuw.fsf@gmail.com> (Nicolas Goaziou's message of "Sun, 09 Jun 2013 09:55:03 +0200")

[-- Attachment #1: Type: text/plain, Size: 351 bytes --]

Nicolas Goaziou <n.goaziou@gmail.com> 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.

–Rasmus

-- 
May contains speling mistake

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-AUTO-argument-to-org-latex-guess-babel-languag.patch --]
[-- Type: text/x-patch, Size: 2947 bytes --]

From 7f1cc30ccbedfa7c5689dbf8408011e64db75230 Mon Sep 17 00:00:00 2001
From: "rasmus.pank" <rasmus.pank@gmail.com>
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


  reply	other threads:[~2013-06-11 23:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31 22:33 [PATCH][ox-latex.el] Allow AUTO argument to org-latex-guess-babel-language Rasmus
2013-06-01  5:31 ` Achim Gratz
2013-06-01 13:59   ` Rasmus
2013-06-01 14:07     ` Rasmus
2013-06-03  7:44 ` Sebastien Vauban
2013-06-03 13:47   ` Rasmus
2013-06-03 14:08     ` Sebastien Vauban
2013-06-03 15:10       ` Rasmus
2013-06-04  6:45         ` Sebastien Vauban
2013-06-04  9:25           ` [PATCH (new version)][ox-latex.el] " Rasmus
2013-06-05 13:35             ` Nicolas Goaziou
2013-06-06  7:46               ` Sebastien Vauban
2013-06-06  9:28                 ` Rasmus
2013-06-06  9:36               ` Rasmus
2013-06-06 21:30               ` [PATCH (v3)][ox-latex.el] " Rasmus
2013-06-07 12:35                 ` Nicolas Goaziou
2013-06-07 13:16                   ` Rasmus
2013-06-07 13:25                     ` Nicolas Goaziou
2013-06-07 15:26                   ` Rasmus
2013-06-09  7:55                     ` Nicolas Goaziou
2013-06-11 23:12                       ` Rasmus [this message]
2013-06-12 13:27                         ` [PATCH (v5)][ox-latex.el] " Nicolas Goaziou
2013-06-12 14:32                           ` Rasmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877gi0dyxx.fsf_-_@pank.home \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).