From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qAXNEXrMWWHA3AAAgWs5BA (envelope-from ) for ; Sun, 03 Oct 2021 17:30:02 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id aJ2IDXrMWWFhAQAA1q6Kng (envelope-from ) for ; Sun, 03 Oct 2021 15:30:02 +0000 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 64C1F10175 for ; Sun, 3 Oct 2021 17:30:00 +0200 (CEST) Received: from localhost ([::1]:36066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mX3R9-00058I-IQ for larch@yhetil.org; Sun, 03 Oct 2021 11:29:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX3Pm-00055S-Rn for emacs-orgmode@gnu.org; Sun, 03 Oct 2021 11:28:35 -0400 Received: from mout02.posteo.de ([185.67.36.66]:57413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX3Pj-000818-1T for emacs-orgmode@gnu.org; Sun, 03 Oct 2021 11:28:34 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 4286A240101 for ; Sun, 3 Oct 2021 17:28:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1633274908; bh=vpamf9RmHwa6PnNw6eCKSx9ccrSIG5ED8Aai46Eamc8=; h=From:To:Subject:Date:From; b=EttK4lEz3ZLDzd6zUOwh0ExsNqd0ASFdOOBAXb30RxTGRGfzuAOtoeCntOGAyBYVB 65mJiJoymG3tcHd154WU3Pkg+oBp94RkhPrrM60KSdpmM1Heh7moRnmLhl/bUwxAhv KFE8i8ICHhFqR1QDYzEOykJYwNM7ueHt2dX/+1J8ZWmdSmKIXS+8kRhpEw6TNH5vx4 fjCaggy4805q7XOiyOMY6PzBGkLrz6jmSeayKh6yMC7R26CxyZDQciYVGQXgf9nGpY cYe5K4QNNKQa4VVeXutxVoSMbedV6++So5ExoHZooJvPxpVZGv/Zhj030bE53XkEtz U9HnXxxAq6Aew== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HMnmq4TnGz6tmD for ; Sun, 3 Oct 2021 17:28:27 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Date: Sun, 03 Oct 2021 15:28:26 +0000 Message-ID: <87sfxiw2jp.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633275000; 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=J3m1fCHp9cVoAb1G2UqGwkbJK+ZYTdxHTjuDy04f/OY=; b=bpmoACTw9jJy+26v9ONcGptVjsYhkkOXLaSuZhrtr3gVY4jS2rqugx48X9BHAeDJ78spJF y9Et1HAcZhTFjwyKo2DwlwgQbg+PDlTamssEOxyhJwxvRvPttvh4XZZjW4njDQqdD4KwWV zYa8xz1Uf9ZXGOXSvPXoP03koGxZIDo1wDlHts1ku+1fiBMl5i6kH7JIQDAM7c9dUijPkb PWqM2lZY+Ic5t3tfEGjvt1kdyZxJB5Nh/RHqOl1Allq6WvepSieAhhOn2Mk0++2EUbUm5A 9nuDMv7aAS/lYm5UNM/5n2pmmQE334C5fnw06GjeHsDd0fEnj3rFVfrnha1JMg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633275000; a=rsa-sha256; cv=none; b=V252hs61eqw3uc+Rszq5X6ZofaVlqBPoTV2k+SP/Ut4px32Yr0cCb1wydk53R4gNYARxAW dtrLkLHbcvL50gLL/HVj2wvtvUxU/0vSssZy4SEg1RnW1tGf9ja4ZPAPvf2ZDF0nNZMl2R fc/cojzPukF3wmaD0uaQqOIh2mO9+euIEUnvHAgSBSQt5KtT2aMYyrPS92fZj+DqxsG/37 zcRGrrxEMblLXZiNRwMFdOWg/WcVBS5d0ZKk8Q8Zgh/avm0UubeHLmGEStHM4QNPvGQwUC MqkJdV+8XMr8H6UPPhapYrjH5ZOCI2/XSff7l2a8adE6Z1VmjRtyo/mpGD4zbw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=EttK4lEz; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -4.21 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=EttK4lEz; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 64C1F10175 X-Spam-Score: -4.21 X-Migadu-Scanner: scn1.migadu.com X-TUID: UVOMgI9Os2jU --=-=-= Content-Type: text/plain Hi all, I'm attaching a patch with a proposal to unify in a single constant (named `org-latex-language-alist') `org-latex-polyglossia-language-alist' and `org-latex-babel-language-alist', along with some necessary (minor) modifications in `org-latex-guess-polyglossia-language' and `org-latex-guess-babel-language' The new list, which is not exhaustive, is built taking as a reference the documentation of Babel and Polyglossia in their latest versions within TeX live 2021. It also assumes the latest improvements in the babel package (on the current state of the art regarding the babel and polyglossia packages, see this previous thread: https://list.orgmode.org/87wnmv4s87.fsf@posteo.net/). I have also corrected some minor inconsistencies in the previous two lists. This new alist supports three types of members: - Members with two elements: CODE BABEL/POLYGLOSSIA-OPTION. i.e.: ("ar" "arabic") - 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. The new babel method with ini files is not supported, for backward compatibility with 'old' ldf method). i.e. ("bo" "tibetan" "*") - Members with four elements (for variants of languages): CODE BABEL-OPTION POLYGLOSSIA-OPTION POLYGLOSSIA-VARIANT i.e. ("es" "spanishmx" "spanish" "mexican") ==> babel: \usepackage[mexican]{babel} ==> polyglossia: \usepackage{polyglossia} \setmainlanguage[variant=mexican]{spanish} I also attach an Org document for testing. Best regards, Juan Manuel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ox-latex.el-Unify-in-one-list-babel-and-polyglossia-.patch >From 389a4e43756a7c195c2c1f751b7dc9c03447526d Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Sun, 3 Oct 2021 16:55:31 +0200 Subject: [PATCH] ox-latex.el: Unify in one list babel and polyglossia language alists * lisp/ox-latex.el (org-latex-language-alist): Unify in a single list `org-latex-polyglossia-language-alist' and `org-latex-babel-language-alist' --- lisp/ox-latex.el | 167 +++++++++++++++++++---------------------------- 1 file changed, 68 insertions(+), 99 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 3e3967033..de03470fa 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -160,144 +160,109 @@ ;;; Internal Variables -(defconst org-latex-babel-language-alist - '(("af" . "afrikaans") - ("bg" . "bulgarian") - ("ca" . "catalan") - ("cs" . "czech") - ("cy" . "welsh") - ("da" . "danish") - ("de" . "germanb") - ("de-at" . "naustrian") - ("de-de" . "ngerman") - ("el" . "greek") - ("en" . "english") - ("en-au" . "australian") - ("en-ca" . "canadian") - ("en-gb" . "british") - ("en-ie" . "irish") - ("en-nz" . "newzealand") - ("en-us" . "american") - ("es" . "spanish") - ("et" . "estonian") - ("eu" . "basque") - ("fi" . "finnish") - ("fr" . "french") - ("fr-ca" . "canadien") - ("gl" . "galician") - ("hr" . "croatian") - ("hu" . "hungarian") - ("id" . "indonesian") - ("is" . "icelandic") - ("it" . "italian") - ("la" . "latin") - ("ms" . "malay") - ("nl" . "dutch") - ("nb" . "norsk") - ("nn" . "nynorsk") - ("no" . "norsk") - ("pl" . "polish") - ("pt" . "portuguese") - ("pt-br" . "brazilian") - ("ro" . "romanian") - ("ru" . "russian") - ("sa" . "sanskrit") - ("sb" . "uppersorbian") - ("sk" . "slovak") - ("sl" . "slovene") - ("sq" . "albanian") - ("sr" . "serbian") - ("sv" . "swedish") - ("ta" . "tamil") - ("tr" . "turkish") - ("uk" . "ukrainian")) - "Alist between language code and corresponding Babel option.") - -(defconst org-latex-polyglossia-language-alist - '(("am" "amharic") +(defconst org-latex-language-alist + '(("am" "amharic" "*") ("ar" "arabic") - ("ast" "asturian") + ("ast" "asturian" "*") ("bg" "bulgarian") - ("bn" "bengali") - ("bo" "tibetan") + ("bn" "bengali" "*") + ("bo" "tibetan" "*") ("br" "breton") ("ca" "catalan") - ("cop" "coptic") + ("cop" "coptic" "*") ("cs" "czech") ("cy" "welsh") ("da" "danish") - ("de" "german" "german") - ("de-at" "german" "austrian") - ("de-de" "german" "german") - ("dsb" "lsorbian") - ("dv" "divehi") + ("de" "ngerman" "german" "german") + ("de-at" "naustrian" "german" "austrian") + ("dsb" "lsorbian" "*") + ("dv" "divehi" "*") ("el" "greek") - ("en" "english" "usmax") - ("en-au" "english" "australian") - ("en-gb" "english" "uk") - ("en-nz" "english" "newzealand") - ("en-us" "english" "usmax") + ("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" "spanishmx" "spanish" "mexican") ("et" "estonian") ("eu" "basque") ("fa" "farsi") ("fi" "finnish") ("fr" "french") - ("fu" "friulan") + ("fr-ca" "canadien" "french" "canadian") + ("fur" "friulan") ("ga" "irish") ("gd" "scottish") ("gl" "galician") ("he" "hebrew") ("hi" "hindi") ("hr" "croatian") - ("hsb" "usorbian") + ("hsb" "uppersorbian" "sorbian" "upper") ("hu" "magyar") - ("hy" "armenian") + ("hy" "armenian" "*") ("ia" "interlingua") - ("id" "bahasai") + ("id" "bahasai" "*") ("is" "icelandic") ("it" "italian") - ("kn" "kannada") - ("la" "latin" "modern") - ("la-classic" "latin" "classic") - ("la-medieval" "latin" "medieval") - ("la-modern" "latin" "modern") - ("lo" "lao") + ("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") - ("nko" "nko") + ("ml" "malayalam" "*") + ("mr" "maranthi" "*") + ("nb" "norsk" "norwegian" "bokmal") ("nl" "dutch") - ("nn" "nynorsk") + ("nn" "nynorsk" "norwegian" "nynorsk") ("no" "norsk") ("oc" "occitan") ("pl" "polish") ("pms" "piedmontese") ("pt" "portuges") ("pt-br" "brazilian") - ("rm" "romansh") + ("rm" "romansh" "*") ("ro" "romanian") ("ru" "russian") - ("sa" "sanskrit") - ("se" "samin") + ("sa" "sanskrit" "*") ("sk" "slovak") - ("sl" "slovenian") + ("sl" "slovene") ("sq" "albanian") ("sr" "serbian") ("sv" "swedish") - ("syr" "syriac") - ("ta" "tamil") - ("te" "telugu") + ("syr" "syriac" "*") + ("ta" "tamil" "*") + ("te" "telugu" "*") ("th" "thai") ("tk" "turkmen") ("tr" "turkish") ("uk" "ukrainian") - ("ur" "urdu") + ("ur" "urdu" "*") ("vi" "vietnamese")) - "Alist between language code and corresponding Polyglossia option.") + "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") (defconst org-latex-table-matrix-macros '(("bordermatrix" . "\\cr") ("qbordermatrix" . "\\cr") @@ -1409,14 +1374,16 @@ Return the new header." header (let ((options (save-match-data (org-split-string (match-string 1 header) ",[ \t]*"))) - (language (cdr (assoc-string language-code - org-latex-babel-language-alist t)))) + (language (nth 1 (assoc language-code + org-latex-language-alist)))) ;; 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)) + ((let ((l (assoc language-code org-latex-language-alist))) + (and (consp l) (= (length l) 3))) (delete "AUTO" options)) ((member "AUTO" options) options) (t (append options (list language)))) ", ") @@ -1462,15 +1429,17 @@ Return the new header." (concat "\\usepackage{polyglossia}\n" (mapconcat (lambda (l) - (let ((l (or (assoc l org-latex-polyglossia-language-alist) + (let ((l (or (assoc l org-latex-language-alist) l))) (format (if main-language-set "\\setotherlanguage%s{%s}\n" (setq main-language-set t) "\\setmainlanguage%s{%s}\n") - (if (and (consp l) (= (length l) 3)) - (format "[variant=%s]" (nth 2 l)) + (if (and (consp l) (= (length l) 4)) + (format "[variant=%s]" (nth 3 l)) "") - (nth 1 l)))) + (if (and (consp l) (= (length l) 4)) + (nth 2 l) + (nth 1 l))))) languages "")) t t header 0))))) -- 2.32.0 --=-=-= Content-Type: application/vnd.lotus-organizer Content-Disposition: attachment; filename=test.org Content-Transfer-Encoding: base64 IyArTGFUZVhfSGVhZGVyOiBcdXNlcGFja2FnZVtBVVRPXXtwb2x5Z2xvc3NpYX0KCiMgK0xhVGVY X0hlYWRlcjogXHVzZXBhY2thZ2Vbb3RoZXJsYW5nLEFVVE9de2JhYmVsfQoKIyArbGFuZ3VhZ2U6 IGFtCiMgK2xhbmd1YWdlOiBhcgojICtsYW5ndWFnZTogYXN0CiMgK2xhbmd1YWdlOiBiZwojICts YW5ndWFnZTogYm4KIyArbGFuZ3VhZ2U6IGJvCiMgK2xhbmd1YWdlOiBicgojICtsYW5ndWFnZTog Y2EKIyArbGFuZ3VhZ2U6IGNvc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