emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH (new version)][ox-latex.el] Allow AUTO argument to org-la


From: Nicolas Goaziou
Subject: Re: [O] [PATCH (new version)][ox-latex.el] Allow AUTO argument to org-latex-guess-babel-language.
Date: Wed, 05 Jun 2013 15:35:18 +0200

Hello,

Rasmus <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]