From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH (new version)][ox-latex.el] Allow AUTO argument to org-latex-guess-babel-language. Date: Wed, 05 Jun 2013 15:35:18 +0200 Message-ID: <87y5aollyh.fsf@gmail.com> 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> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkDrx-0002v7-GQ for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 09:35:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkDrs-0007Ae-Kj for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 09:35:17 -0400 Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:54277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkDrs-0007AV-F3 for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 09:35:12 -0400 Received: by mail-wg0-f53.google.com with SMTP id c11so1329898wgh.20 for ; Wed, 05 Jun 2013 06:35:11 -0700 (PDT) In-Reply-To: <87ppw26xe2.fsf_-_@pank.eu> (rasmus@gmx.us's message of "Tue, 04 Jun 2013 11:25:09 +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: Rasmus Cc: emacs-orgmode@gnu.org Hello, Rasmus writes: Thanks for your patch. Here are a few comments: > It changes behavior for your setup in that you can define a LANGUAGE > that isn't a known abbreviation. While I think your patch is overall an improvement, I'm not convinced by this particular point. Indeed #+LANGUAGE: expects a language code as value, not just any string. This is important since latex backend is not the only one to use that keyword. For example, imagine a user in need for german smart quotes. How do you explain to him than #+language: german will not work, but #+language: de will? I think special Babel needs can be handled elsewhere. > (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 You need to punctuate your sentence. > + (remove "AUTO" You can use `delete' instead of `remove': no need to copy the list. > + (org-split-string > + ;; in case of [lang_one, lang_two] > + (replace-regexp-in-string "[ \t\n]*" "" > + (match-string 1 header)) ",")))) There cannot be any "\n" in the value, so you can use "[ \t]+" instead. Also, you don't need the `replace-regexp-in-string' part: (org-split-string (match-string 1 header) ",[ \t]*") > + (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))))) The problem with this implementation is that it will not put LANGUAGE at the same place AUTO was. IOW, there's no difference between: #+LATEX_HEADER: \usepackage[AUTO,danish]{babel} and, #+LATEX_HEADER: \usepackage[danish,AUTO]{babel} although it matters in LaTeX. Regards, -- Nicolas Goaziou