From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id qLjoC27U5WIZZgEAbAwnHQ (envelope-from ) for ; Sun, 31 Jul 2022 03:01:34 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id EDLLC27U5WKR6wAAauVa8A (envelope-from ) for ; Sun, 31 Jul 2022 03:01:34 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 78269AACC for ; Sun, 31 Jul 2022 03:01:33 +0200 (CEST) Received: from localhost ([::1]:35050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHxKl-0005HG-H9 for larch@yhetil.org; Sat, 30 Jul 2022 21:01:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHxJm-0005H8-7B for emacs-orgmode@gnu.org; Sat, 30 Jul 2022 21:00:30 -0400 Received: from mout01.posteo.de ([185.67.36.65]:35499) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHxJh-000638-PW for emacs-orgmode@gnu.org; Sat, 30 Jul 2022 21:00:29 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id E81E1240026 for ; Sun, 31 Jul 2022 03:00:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1659229220; bh=MtPdpwoIbHR/WUTPEVUQpiL9ukSCBROmBoVcSGnk3UA=; h=From:To:Subject:Date:From; b=KjYAd1PYWavqwoqd1R/mbQhTyzRDuQApgGVtV/rlKE4xSecso/o+F0EL5kea2j7F9 6DvR5UIkvQQwsR40vn8hTp8mbVlH0clY7dp43YcNmcrWINWd/iKjlpKmP9hY8Te7Yp LcO9Y5nMMQB90DudDtDWW2O3EvTk0Br3nteULfWPWjb1Du0v8yH/XeJRsVYjH9rr3P QfjT4pt1W7MN2kxV52zYd0z8gKjkqm+R1Ikx5QNngZfp/ujYmsVBgT23RNGpG19Lgs WWdsVPrkAilYGaQvn7WzSY882jchHM6QXrVp+LFeyLBzNplCh/82PirU/wOOXZRg0B RbLuSwwWk+G8w== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LwNGD1NxPz9rxH for ; Sun, 31 Jul 2022 03:00:20 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [PATCH] ox-latex.el: `org-latex-language-alist' improved Date: Sun, 31 Jul 2022 01:00:18 +0000 Message-ID: <87mtcq14gt.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1659229293; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=qwEL6cnmL5hf3CbDaOheV/WLL3CANn5TM192olDciCI=; b=oWFUMybYm8Q74u/QklG39maHROyzbZI0lcVFI2T1c+9QHqxdalePvOoH/vsNsK5rlKy6i7 YAc5jEEJQKY5pXzb1EB6PI4nzuBUi1nBBMNriyY9vamh3b+8QXmG6SvIovODe7xWGDd4bt RP+iU4G2ULBSITBaaV4a02F71MnXJgSHtFLW5Sq0cDUepYZfw5zWUBOIQ7LRclKmfCLKMJ pJVy0aGLirZTU4BsB8NzEAzAHHkB0hyuK49Uh0yLR+kw7cL4KSj6i5sqMorbx8aywmbx91 9YzbrSsGImssTViLbHG7v1Ic+hH/xhl/d/VCaArfRxTR4ytlv9RXM+AsAQgozQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1659229293; a=rsa-sha256; cv=none; b=G4e1o1VgNNMzhlxjCw1MgSYulBJLo4cFF088C7f8qby7Cj2/bW3YBrt4tFx+QeXPfgPx8W wEafUbFXYBea7efCe55twIR9vj20K+ppvfGR65K9JMFHPmXC1xvt8sGFf3y/h2dvqbEmAm nwJNvalD2xpa7Eum6sdbtriXD++Zsla54izNSXvnY3QjivG4Bu+k1kMCpI0f3X4bi+ZKdv +KuDKmiJtllcoZ9HkvV1hXkYwNsgg6fcJDBiTyMRTtTxJPYsLagJ1lIFtwOQ9aleMfgnAU PmPKip/QPdOPC4JhCEKHPiwz/lnUB4Jd7ha++WScEz06YUussonin3uexBbfJg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=KjYAd1PY; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.12 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=KjYAd1PY; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 78269AACC X-Spam-Score: -4.12 X-Migadu-Scanner: scn0.migadu.com X-TUID: IaaZ6aQ0tZp6 --=-=-= Content-Type: text/plain Hi, I've managed to get some free time to remake this list, following Maxim Nikulin's suggestion (https://list.orgmode.org/orgmode/taeb0a$r62$1@ciao.gmane.io/). It's no longer an anonymous list and I agree it now has a more robust structure with name fields. I have also added the `:lang-name' property, whose value is the actual language name. For example: ("el-polyton" . (:babel "polutonikogreek" :polyglossia "greek" :polyglossia-variant "polytonic" :lang-name "Polytonic Greek")) Thanks to this I think the code for org-latex-guess-babel-language, org-latex-guess-polyglossia-language and org-latex--format-spec is also simpler. Best regards, Juan Manuel --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-lisp-ox-latex.el-org-latex-language-alist-improved.patch Content-Transfer-Encoding: quoted-printable >From b06cdd45198f470a135efad2cd1d8b22ab7e2f22 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Sun, 31 Jul 2022 02:31:08 +0200 Subject: [PATCH] lisp/ox-latex.el: `org-latex-language-alist' improved. * (org-latex-language-alist): Alist between language code and corresponding properties, such as Babel/Polyglossia options and language names. Each element of the list consists of a cons cell, where car is the language code and cdr is a property list. * (org-latex-guess-babel-language): Modified to adapt the function to the new structure of `org-latex-language-alist'. * (org-latex-guess-polyglossia-language): Modified to adapt the function to the new structure of `org-latex-language-alist'. * (org-latex--format-spec): Modified to adapt the function to the new structure of `org-latex-language-alist'. --- lisp/ox-latex.el | 287 +++++++++++++++++++++++------------------------ 1 file changed, 138 insertions(+), 149 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index c56f9d347..669458913 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -173,110 +173,106 @@ ;;; Internal Variables =20 (defconst org-latex-language-alist - ;; TODO: replace this list with a property list (the actual - ;; implementation is not very robust). - '(("am" "amharic" "*") - ("ar" "arabic") - ("ast" "asturian" "*") - ("bg" "bulgarian") - ("bn" "bengali" "*") - ("bo" "tibetan" "*") - ("br" "breton") - ("ca" "catalan") - ("cop" "coptic" "*") - ("cs" "czech") - ("cy" "welsh") - ("da" "danish") - ("de" "ngerman" "german" "german") - ("de-at" "naustrian" "german" "austrian") - ("dsb" "lsorbian" "*") - ("dv" "divehi" "*") - ("el" "greek") - ("el-polyton" "polutonikogreek" "greek" "polytonic") - ("en" "american" "english" "usmax") - ("en-au" "australian" "english" "australian") - ("en-gb" "british" "english" "uk") - ("en-nz" "newzealand" "english" "newzealand") - ("en-us" "american" "english" "usmax") - ("eo" "esperanto") - ("es" "spanish") - ("es-mx" "spanishmx" "spanish" "mexican") - ("et" "estonian") - ("eu" "basque") - ("fa" "farsi") - ("fi" "finnish") - ("fr" "french") - ("fr-ca" "canadien" "french" "canadian") - ("fur" "friulan") - ("ga" "irish") - ("gd" "scottish") - ("gl" "galician") - ("he" "hebrew") - ("hi" "hindi") - ("hr" "croatian") - ("hsb" "uppersorbian" "sorbian" "upper") - ("hu" "magyar") - ("hy" "armenian" "*") - ("ia" "interlingua") - ("id" "bahasai" "*") - ("is" "icelandic") - ("it" "italian") - ("kn" "kannada" "*") - ("la" "latin") - ("la-classic" "classiclatin" "latin" "classic") - ("la-medieval" "medievallatin" "latin" "medieval") - ("la-ecclesiastic" "ecclesiasticlatin" "latin" "ecclesiastic") - ("lo" "lao" "*") - ("lt" "lithuanian") - ("lv" "latvian") - ("ml" "malayalam" "*") - ("mr" "maranthi" "*") - ("nb" "norsk" "norwegian" "bokmal") - ("nl" "dutch") - ("nn" "nynorsk" "norwegian" "nynorsk") - ("no" "norsk") - ("oc" "occitan") - ("pl" "polish") - ("pms" "piedmontese") - ("pt" "portuges") - ("pt-br" "brazilian") - ("rm" "romansh" "*") - ("ro" "romanian") - ("ru" "russian") - ("sa" "sanskrit" "*") - ("sk" "slovak") - ("sl" "slovene") - ("sq" "albanian") - ("sr" "serbian") - ("sv" "swedish") - ("syr" "syriac" "*") - ("ta" "tamil" "*") - ("te" "telugu" "*") - ("th" "thai") - ("tk" "turkmen") - ("tr" "turkish") - ("uk" "ukrainian") - ("ur" "urdu" "*") - ("vi" "vietnamese")) - "Alist between language code and corresponding Babel/Polyglossia option. - -For the names of the languages, the Babel nomenclature is -preferred to that of Polyglossia, in those cases where both -coincide. - -The alist supports three types of members: - -- Members with two elements: CODE BABEL/POLYGLOSSIA OPTION. - -- Members with three elements: CODE BABEL/POLYGLOSSIA OPTION -ASTERISK (the presence of the asterisk indicates that this -language is not loaded in Babel using the old method of ldf -files but using ini files. If Babel is loaded in an Org -document with these languages, the \"AUTO \" argument is just -removed, to avoid compilation errors). - -- Members with four elements (for variants of languages): CODE -BABEL-OPTION POLYGLOSSIA-OPTION POLYGLOSSIA-VARIANT") + '(("am" . (:babel-ini-only "amharic" :polyglossia "amharic" :lang-name "= Amharic")) + ("ar" . (:babel "arabic" :polyglossia "arabic" :lang-name "Arabic")) + ("ast" . (:babel-ini-only "asturian" :polyglossia "asturian" :lang-nam= e "Asturian")) + ("bg" . (:babel "bulgarian" :polyglossia "bulgarian" :lang-name "Bulg= arian")) + ("bn" . (:babel-ini-only "bengali" :polyglossia "bengali" :lang-name = "Bengali")) + ("bo" . (:babel-ini-only "tibetan" :polyglossia "tibetan" :lang-name = "Tibetan")) + ("br" . (:babel "breton" :polyglossia "breton" :lang-name "Breton")) + ("ca" . (:babel "catalan" :polyglossia "catalan" :lang-name "Catalan"= )) + ("cop" . (:babel-ini-only "coptic" :polyglossia "coptic" :lang-name "= Coptic")) + ("cs" . (:babel "czech" :polyglossia "czech" :lang-name "Czech")) + ("cy" . (:babel "welsh" :polyglossia "welsh" :lang-name "Welsh")) + ("da" . (:babel "danish" :polyglossia "danish" :lang-name "Danish")) + ("de" . (:babel "ngerman" :polyglossia "german" :polyglossia-variant = "german" :lang-name "German")) + ("de-at" . (:babel "naustrian" :polyglossia "german" :polyglossia-var= iant "austrian" :lang-name "German")) + ("dsb" . (:babel "lsorbian" :polyglossia "sorbian" :polyglossia-varia= nt "lower" :lang-name "Lower Sorbian")) + ("dv" . (:babel-ini-only "divehi" :polyglossia "divehi" :lang-name "D= ivehi")) + ("el" . (:babel "greek" :polyglossia "greek" :lang-name "Greek")) + ("el-polyton" . (:babel "polutonikogreek" :polyglossia "greek" :polyg= lossia-variant "polytonic" :lang-name "Polytonic Greek")) + ("en" . (:babel "american" :polyglossia "english" :polyglossia-varian= t "usmax" :lang-name "English")) + ("en-au" . (:babel "australian" :polyglossia "english" :polyglossia-v= ariant "australian" :lang-name "English")) + ("en-gb" . (:babel "british" :polyglossia "english" :polyglossia-vari= ant "uk" :lang-name "English")) + ("en-nz" . (:babel "newzealand" :polyglossia "english" :polyglossia-v= ariant "newzealand" :lang-name "English")) + ("en-us" . (:babel "american" :polyglossia "english" :polyglossia-var= iant "usmax" :lang-name "English")) + ("eo" . (:babel "esperanto" :polyglossia "esperanto" :lang-name "Espe= ranto")) + ("es" . (:babel "spanish" :polyglossia "spanish" :lang-name "Spanish"= )) + ("es-mx" . (:babel "spanishmx" :polyglossia "spanish" :polyglossia-va= riant "mexican" :lang-name "Spanish")) + ("et" . (:babel "estonian" :polyglossia "estonian" :lang-name "Estoni= an")) + ("eu" . (:babel "basque" :polyglossia "basque" :lang-name "Basque")) + ("fa" . (:babel "farsi" :polyglossia "farsi" :lang-name "Farsi")) + ("fi" . (:babel "finnish" :polyglossia "finnish" :lang-name "Finnish"= )) + ("fr" . (:babel "french" :polyglossia "french" :lang-name "French")) + ("fr-ca" . (:babel "canadien" :polyglossia "french" :polyglossia-vari= ant "canadian" :lang-name "French")) + ("fur" . (:babel "friulan" :polyglossia "friulan" :lang-name "Friulia= n")) + ("ga" . (:babel "irish" :polyglossia "irish" :lang-name "Irish")) + ("gd" . (:babel "scottish" :polyglossia "scottish" :lang-name "Scotti= sh Gaelic")) + ("gl" . (:babel "galician" :polyglossia "galician" :lang-name "Galici= an")) + ("he" . (:babel "hebrew" :polyglossia "hebrew" :lang-name "Hebrew")) + ("hi" . (:babel "hindi" :polyglossia "hindi" :lang-name "Hindi")) + ("hr" . (:babel "croatian" :polyglossia "croatian" :lang-name "Croati= an")) + ("hsb" . (:babel "uppersorbian" :polyglossia "sorbian" :polyglossia-v= ariant "upper" :lang-name "Upper Sorbian")) + ("hu" . (:babel "magyar" :polyglossia "magyar" :lang-name "Magyar")) + ("hy" . (:babel-ini-only "armenian" :polyglossia "armenian" :lang-nam= e "Armenian")) + ("ia" . (:babel "interlingua" :polyglossia "interlingua" :lang-name "= Interlingua")) + ("id" . (:babel-ini-only "bahasai" :polyglossia "bahasai" :lang-name = "Bahasai")) + ("is" . (:babel "icelandic" :polyglossia "icelandic" :lang-name "Icel= andic")) + ("it" . (:babel "italian" :polyglossia "italian" :lang-name "Italian"= )) + ("kn" . (:babel-ini-only "kannada" :polyglossia "kannada" :lang-name = "Kannada")) + ("la" . (:babel "latin" :polyglossia "latin" :lang-name "Latin")) + ("la-classic" . (:babel "classiclatin" :polyglossia "latin" :polyglos= sia-variant "classic" :lang-name "Classic Latin")) + ("la-medieval" . (:babel "medievallatin" :polyglossia "latin" :polygl= ossia-variant "medieval" :lang-name "Medieval Latin")) + ("la-ecclesiastic" . (:babel "ecclesiasticlatin" :polyglossia "latin"= :polyglossia-variant "ecclesiastic" :lang-name "Ecclesiastic Latin")) + ("lo" . (:babel-ini-only "lao" :polyglossia "lao" :lang-name "Lao")) + ("lt" . (:babel "lithuanian" :polyglossia "lithuanian" :lang-name "Li= thuanian")) + ("lv" . (:babel "latvian" :polyglossia "latvian" :lang-name "Latvian"= )) + ("ml" . (:babel-ini-only "malayalam" :polyglossia "malayalam" :lang-n= ame "Malayalam")) + ("mr" . (:babel-ini-only "maranthi" :polyglossia "maranthi" :lang-nam= e "Maranthi")) + ("nb" . (:babel "norsk" :polyglossia "norwegian" :polyglossia-variant= "bokmal" :lang-name "Norwegian Bokm=C3=A5l")) + ("nl" . (:babel "dutch" :polyglossia "dutch" :lang-name "Dutch")) + ("nn" . (:babel "nynorsk" :polyglossia "norwegian" :polyglossia-varia= nt "nynorsk" :lang-name "Norwegian Nynorsk")) + ("no" . (:babel "norsk" :polyglossia "norsk" :lang-name "Norwegian")) + ("oc" . (:babel "occitan" :polyglossia "occitan" :lang-name "Occitan"= )) + ("pl" . (:babel "polish" :polyglossia "polish" :lang-name "Polish")) + ("pms" . (:babel "piedmontese" :polyglossia "piedmontese" :lang-name = "Piedmontese")) + ("pt" . (:babel "portuges" :polyglossia "portuges" :lang-name "Portug= es")) + ("pt-br" . (:babel "brazilian" :polyglossia "brazilian" :lang-name "P= ortuges")) + ("rm" . (:babel-ini-only "romansh" :polyglossia "romansh" :lang-name = "Romansh")) + ("ro" . (:babel "romanian" :polyglossia "romanian" :lang-name "Romani= an")) + ("ru" . (:babel "russian" :polyglossia "russian" :lang-name "Russian"= )) + ("sa" . (:babel-ini-only "sanskrit" :polyglossia "sanskrit" :lang-nam= e "Sanskrit")) + ("sk" . (:babel "slovak" :polyglossia "slovak" :lang-name "Slovak")) + ("sl" . (:babel "slovene" :polyglossia "slovene" :lang-name "Slovene"= )) + ("sq" . (:babel "albanian" :polyglossia "albanian" :lang-name "Albani= an")) + ("sr" . (:babel "serbian" :polyglossia "serbian" :lang-name "Serbian"= )) + ("sv" . (:babel "swedish" :polyglossia "swedish" :lang-name "Swedish"= )) + ("syr" . (:babel-ini-only "syriac" :polyglossia "syriac" :lang-name "= Syriac")) + ("ta" . (:babel-ini-only "tamil" :polyglossia "tamil" :lang-name "Tam= il")) + ("te" . (:babel-ini-only "telugu" :polyglossia "telugu" :lang-name "T= elugu")) + ("th" . (:babel "thai" :polyglossia "thai" :lang-name "Thai")) + ("tk" . (:babel "turkmen" :polyglossia "turkmen" :lang-name "Turkmen"= )) + ("tr" . (:babel "turkish" :polyglossia "turkish" :lang-name "Turkish"= )) + ("uk" . (:babel "ukrainian" :polyglossia "ukrainian" :lang-name "Ukra= inian")) + ("ur" . (:babel-ini-only "urdu" :polyglossia "urdu" :lang-name "Urdu"= )) + ("vi" . (:babel "vietnamese" :polyglossia "vietnamese" :lang-name "Vi= etnamese")) + "Alist between language code and corresponding properties, such +as Babel/Polyglossia options and language names. + +Each element of the list consists of a cons cell, where car is +the language code and cdr is a property list. Valid keywords for +this list can be: + +- `:babel' the name of the language loaded by the Babel LaTeX package + +- `:poliglosia' the name of the language loaded by the Polyglossia LaTeX p= ackage + +- `:babel-ini-only' the name of the language loaded by Babel + exclusively through the new ini files method. + +- `:polyglossia-variant' the language variant loaded by Polyglossia + +- `:lang-name' the actual name of the language.")) =20 (defconst org-latex-table-matrix-macros '(("bordermatrix" . "\\cr") ("qbordermatrix" . "\\cr") @@ -1619,11 +1615,15 @@ already loaded. =20 Return the new header." (let* ((language-code (plist-get info :language)) - (language (nth 1 (assoc language-code - org-latex-language-alist))) - ;; If no language is set or Babel package is not loaded, return - ;; HEADER as-is. - (header (if (or (not (stringp language-code)) + (plist (cdr + (assoc language-code org-latex-language-alist))) + (language (plist-get plist :babel)) + (language-ini-only (plist-get plist :babel-ini-only)) + ;; If no language is set, or Babel package is not loaded, or + ;; LANGUAGE keyword value is a language served by Babel + ;; exclusively through ini files, return HEADER as-is. + (header (if (or language-ini-only + (not (stringp language-code)) (not (string-match "\\\\usepackage\\[\\(.*\\)\\]{babel}" header))) header (let ((options (save-match-data @@ -1634,22 +1634,13 @@ Return the new header." ;; served in Babel exclusively through ini files are not added ;; to the babel argument, and must be loaded using ;; `\babelprovide'. - (let ((l (assoc language-code org-latex-language-alist))) - ;; Three elements imply that LANGUAGE is served - ;; in Babel only by means of an ini file. - ;; Therefore it will not be added to the Babel - ;; argument. TODO: this should be improved - ;; when `org-latex-language-alist' is replaced - ;; by a more robust list. - (if (and (consp l) (=3D (length l) 3)) - header - (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))))))) + (replace-match + (mapconcat (lambda (option) (if (equal "AUTO" option) language opt= ion)) + (cond ((member language options) (delete "AUTO" options)) + ((member "AUTO" options) options) + (t (append options (list language)))) + ", ") + t nil header 1))))) ;; If `\babelprovide[args]{AUTO}' is present, AUTO is ;; replaced by LANGUAGE. (if (not (string-match "\\\\babelprovide\\[.*\\]{\\(.+\\)}" header)) @@ -1658,7 +1649,9 @@ Return the new header." (when (equal "AUTO" prov) (replace-regexp-in-string (format "\\(\\\\babelprovide\\[.*\\]\\)\\({\\)%s}" prov) - (format "\\1\\2%s}" language) header t)))))) + (format "\\1\\2%s}" + (or language language-ini-only)) + header t)))))) =20 (defun org-latex-guess-polyglossia-language (header info) "Set the Polyglossia language according to the LANGUAGE keyword. @@ -1675,13 +1668,13 @@ replaced with the language of the document or using \setdefaultlanguage and not as an option to the package. =20 Return the new header." - (let ((language (plist-get info :language))) + (let* ((language (plist-get info :language))) ;; If no language is set or Polyglossia is not loaded, return ;; HEADER as-is. (if (or (not (stringp language)) (not (string-match - "\\\\usepackage\\(?:\\[\\([^]]+?\\)\\]\\){polyglossia}\n" - header))) + "\\\\usepackage\\(?:\\[\\([^]]+?\\)\\]\\){polyglossia}\n" + header))) header (let* ((options (org-string-nw-p (match-string 1 header))) (languages (and options @@ -1700,23 +1693,20 @@ Return the new header." (concat "\\usepackage{polyglossia}\n" (mapconcat (lambda (l) - (let ((l (or (assoc l org-latex-language-alist) - l))) - (format (if main-language-set "\\setotherlanguage%s{%s}\n" + (let* ((plist (cdr + (assoc language org-latex-language-alist))) + (polyglossia-variant (plist-get plist :polyglossia-variant)) + (polyglossia-lang (plist-get plist :polyglossia)) + (l (if (equal l language) + polyglossia-lang + l))) + (format (if main-language-set (format "\\setotherlanguage{%s}\n" l) (setq main-language-set t) "\\setmainlanguage%s{%s}\n") - ;; Four elements implies that there is a - ;; variant (4) for LANGUAGE when - ;; declared by Polyglossia (3). - ;; FIXME: This should be improved when - ;; `org-latex-language-alist' is - ;; replaced by a more robust list. - (if (and (consp l) (=3D (length l) 4)) - (format "[variant=3D%s]" (nth 3 l)) + (if polyglossia-variant + (format "[variant=3D%s]" polyglossia-variant) "") - (if (and (consp l) (=3D (length l) 4)) - (nth 2 l) - (nth 1 l))))) + l))) languages "")) t t header 0))))) @@ -1860,12 +1850,11 @@ INFO is a plist used as a communication channel." (defun org-latex--format-spec (info) "Create a format-spec for document meta-data. INFO is a plist used as a communication channel." - (let ((language (let ((lang (plist-get info :language))) - ;; The second element in - ;; `org-latex-language-alist' is always the - ;; language name, regardless of the type of the - ;; alist entry. - (or (nth 1 (assoc-string lang org-latex-language-alist= t)) + (let ((language (let* ((lang (plist-get info :language)) + (plist (cdr + (assoc lang org-latex-language-alist)))) + ;; Here the actual name of the LANGUAGE or LANG is used + (or (plist-get plist :lang-name) lang)))) `((?a . ,(org-export-data (plist-get info :author) info)) (?t . ,(org-export-data (plist-get info :title) info)) --=20 2.37.1 --=-=-=--