* [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists @ 2021-10-03 15:28 Juan Manuel Macías 2022-07-10 9:25 ` Ihor Radchenko 2022-07-10 10:51 ` Max Nikulin 0 siblings, 2 replies; 50+ messages in thread From: Juan Manuel Macías @ 2021-10-03 15:28 UTC (permalink / raw) To: orgmode [-- Attachment #1: Type: text/plain, Size: 1738 bytes --] 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 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ox-latex.el-Unify-in-one-list-babel-and-polyglossia-.patch --] [-- Type: text/x-patch, Size: 8021 bytes --] From 389a4e43756a7c195c2c1f751b7dc9c03447526d Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias <maciaschain@posteo.net> 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 @@ \f ;;; 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 [-- Attachment #3: test.org --] [-- Type: application/vnd.lotus-organizer, Size: 1525 bytes --] ^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2021-10-03 15:28 [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Juan Manuel Macías @ 2022-07-10 9:25 ` Ihor Radchenko 2022-07-14 12:34 ` Juan Manuel Macías 2022-07-10 10:51 ` Max Nikulin 1 sibling, 1 reply; 50+ messages in thread From: Ihor Radchenko @ 2022-07-10 9:25 UTC (permalink / raw) To: Juan Manuel Macías; +Cc: orgmode Juan Manuel Macías <maciaschain@posteo.net> writes: > 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. Thanks! This looks like an improvement. However, we may need to preserve the old defconsts for the time being and declare them obsolete. Otherwise, the patch looks fine from a cursory look. Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-10 9:25 ` Ihor Radchenko @ 2022-07-14 12:34 ` Juan Manuel Macías 2022-07-14 15:12 ` Max Nikulin 2022-07-17 9:55 ` Ihor Radchenko 0 siblings, 2 replies; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-14 12:34 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode [-- Attachment #1: Type: text/plain, Size: 368 bytes --] Ihor Radchenko writes: > Thanks! > This looks like an improvement. > However, we may need to preserve the old defconsts for the time being > and declare them obsolete. Hi, Ihor, I attach the new version of the patch with both variables declared obsolete. If everything is ok, I can add what is necessary to NEWS and to the Org Manual. Best regards, Juan Manuel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-lisp-ox-latex.el-New-variable-org-latex-language-ali.patch --] [-- Type: text/x-patch, Size: 8306 bytes --] From 9ff77e71a8cd89b883d5ead37909c887178e4402 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias <maciaschain@posteo.net> Date: Thu, 14 Jul 2022 13:42:50 +0200 Subject: [PATCH] * lisp/ox-latex.el: New variable `org-latex-language-alist' (org-latex-language-alist): Unify in a single list `org-latex-polyglossia-language-alist' and `org-latex-babel-language-alist', and make the two variables obsolete. --- lisp/ox-latex.el | 173 ++++++++++++++++++++--------------------------- 1 file changed, 74 insertions(+), 99 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 1aab8ffd5..9e97f38db 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -172,144 +172,115 @@ \f ;;; 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") +(make-obsolete-variable 'org-latex-babel-language-alist + "set `org-latex-language-alist' instead." "9.6") + +(make-obsolete-variable 'org-latex-polyglossia-language-alist + "set `org-latex-language-alist' instead." "9.6") + +(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-mx" "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") @@ -1657,14 +1628,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)))) ", ") @@ -1710,15 +1683,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.36.1 ^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-14 12:34 ` Juan Manuel Macías @ 2022-07-14 15:12 ` Max Nikulin 2022-07-14 15:53 ` Juan Manuel Macías 2022-07-17 9:55 ` Ihor Radchenko 1 sibling, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-14 15:12 UTC (permalink / raw) To: emacs-orgmode On 14/07/2022 19:34, Juan Manuel Macías wrote: > Subject: [PATCH] * lisp/ox-latex.el: New variable `org-latex-language-alist' Writing the previous message I forgot that currently there is no default option for the fontenc package (PdfLaTeX), e.g. T2A for Cyrillic. As a result it is not enough to specify just language to generate PDF file. From my point of view it is better to have single map from language code to various localization options (babel, polyglossia, fontenc). Unfortunately plain list `org-latex-language-alist' does not allow further extensions. Property list would make initialization not so concise, but it would make the map more flexible. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-14 15:12 ` Max Nikulin @ 2022-07-14 15:53 ` Juan Manuel Macías 2022-07-14 18:17 ` Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-14 15:53 UTC (permalink / raw) To: Max Nikulin; +Cc: orgmode Max Nikulin writes: >> Subject: [PATCH] * lisp/ox-latex.el: New variable `org-latex-language-alist' > Writing the previous message I forgot that currently there is no > default option for the fontenc package (PdfLaTeX), e.g. T2A for > Cyrillic. As a result it is not enough to specify just language to > generate PDF file. From my point of view it is better to have single > map from language code to various localization options (babel, > polyglossia, fontenc). Unfortunately plain list > `org-latex-language-alist' does not allow further extensions. Property > list would make initialization not so concise, but it would make the > map more flexible. Sorry, I hadn't seen your other message and I ignored it... What you say makes sense. If I'm not mistaken, there is now nothing like an hypothetical 'org-latex-guess-fontenc', and org defaults to the T1 option. If I remember correctly (because I haven't used pdfLaTeX in ages), the fontenc option for Greek is LGR. And I imagine there will be many more cases. If you or anyone wants to implement that on top of my patch, that's fine with me. I don't have much time to do it right now. However, my opinion is the following: I think we should focus our efforts on finding a satisfactory solution for luatex, according to everything that has been commented in the different sub-threads on the subject of fonts and fallback fonts. And leave the related to pdfLaTeX in second place, if in the end LuaTeX is going to be set as the default engine. In any case, I personally think that org-latex-language-alist, as it is now in this patch, is sufficient. Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-14 15:53 ` Juan Manuel Macías @ 2022-07-14 18:17 ` Juan Manuel Macías 2022-07-15 12:18 ` Max Nikulin 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-14 18:17 UTC (permalink / raw) To: Maxim Nikulin; +Cc: orgmode, Ihor Radchenko Juan Manuel Macías writes: > In any case, I personally think that org-latex-language-alist, as it is > now in this patch, is sufficient. By the way, Maxim. I have been doing some tests with pdfLaTeX. I've known for a while now that it's no longer necessary to load the inputenc package. But it seems that it is not even necessary to load fontenc with the encoding of each language. Try compiling this: #+begin_src latex \documentclass{article} \usepackage[russian,polutonikogreek]{babel} \begin{document} \today Δαρείου καὶ Παρυσάτιδος γίγνονται παῖδες δύο, πρεσβύτερος μὲν Ἀρταξέρξης, νεώτερος δὲ Κῦρος· ἐπεὶ δὲ ἠσθένει Δαρεῖος καὶ ὑπώπτευε τελευτὴν τοῦ βίου, ἐβούλετο τὼ παῖδε ἀμφοτέρω παρεῖναι. \selectlanguage{russian} \today Emacs написан на двух языках: C и Emacs Lisp (Elisp, диалект Лиспа). При этом сам редактор является интерпретатором Elisp. По сути дела, большая часть Emacs написана на языке Elisp, и её можно рассматривать как расширение к основной программе. \end{document} #+end_src In TeX live 2022 the compilation is correct (I think). It seems that Babel (or russian/greek.ldf) loads the font encodings according to the declared languages. From the log: #+begin_src sh (/usr/share/texmf-dist/tex/latex/cyrillic/t2aenc.def (/usr/share/texmf-dist/tex/latex/base/t2aenc.dfu))) (/usr/share/texmf-dist/tex/generic/babel-greek/greek.ldf (/usr/share/texmf-dist/tex/latex/greek-fontenc/lgrenc.def (/usr/share/texmf-dist/tex/latex/greek-inputenc/lgrenc.dfu) (/usr/share/texmf-dist/tex/latex/greek-fontenc/greek-fontenc.def)))) (/usr/share/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def) (./fontenc.aux (/usr/share/texmf-dist/tex/generic/babel/locale/es/babel-spanish.tex) (/usr/share/texmf-dist/tex/latex/cbfonts-fd/lgrcmr.fd)) (/usr/share/texmf-dist/tex/latex/cyrillic/t2acmr.fd) [1{/var/lib/texmf/fonts/ma p/pdftex/updmap/pdftex.map}] (./fontenc.aux) ){/usr/share/texmf-dist/fonts/enc/ dvips/cm-super/cm-super-t2a.enc}</usr/share/texmf-dist/fonts/type1/public/cbfon ts/grmn1000.pfb></usr/share/texmf-dist/fonts/type1/public/cm-super/sfrm1000.pfb #+end_src Is this normal or is it a new Babel feature? If it is a new feature, I can't find it anywhere in the documentation. Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-14 18:17 ` Juan Manuel Macías @ 2022-07-15 12:18 ` Max Nikulin 2022-07-15 14:36 ` Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-15 12:18 UTC (permalink / raw) To: emacs-orgmode On 15/07/2022 01:17, Juan Manuel Macías wrote: > Juan Manuel Macías writes: > >> In any case, I personally think that org-latex-language-alist, as it is >> now in this patch, is sufficient. I agree that the lists should be merged. My point is that with unnamed fields and variable number of them it would not be possible to extend this list with additional fields. So additional step with `make-obsolete-variable' would be required. > By the way, Maxim. I have been doing some tests with pdfLaTeX. I've > known for a while now that it's no longer necessary to load the inputenc > package. But it seems that it is not even necessary to load fontenc with > the encoding of each language. It looks like a promising feature. > In TeX live 2022 the compilation is correct (I think). It seems that > Babel (or russian/greek.ldf) loads the font encodings according to the > declared languages. From the log: > > (/usr/share/texmf-dist/tex/generic/babel/locale/es/babel-spanish.tex) Interesting, Spanish is not mentioned in your document. > Is this normal or is it a new Babel feature? If it is a new feature, I > can't find it anywhere in the documentation. I have tried on Ubuntu-20.04 LTS focal (Latest LTS is 22.04 jammy). Without explicit fontenc it may work, but emits a warning Package babel Warning: No Cyrillic font encoding has been loaded so far. (babel) A font encoding should be declared before babel. (babel) Default `T2A' encoding will be loaded on input line 74. Unfortunately in the case of \usepackage[russian,english]{babel} \selectlanguage{russian} is required, without it compilation fails with ! LaTeX Error: Command \cyrn unavailable in encoding OT1. With \usepackage[T2A]{fontenc} it behaves accordingly to acceptable for non-important documents graceful degradation. Text is readable, but no hyphenation applied. So I consider explicit loading of fontenc as more reliable. > If I'm not mistaken, there is now nothing like > an hypothetical 'org-latex-guess-fontenc', and org defaults to the T1 > option. If I remember correctly (because I haven't used pdfLaTeX in > ages), the fontenc option for Greek is LGR. And I imagine there will be > many more cases. That is why I am suggesting a mapping from language to font encoding. > If you or anyone wants to implement that on top of my > patch, that's fine with me. I do not see a solution "on the top of your patch". Either an additional mapping should be added or your changes should be overwritten by some extensible structure. The former is a step backward in respect to the idea of merging alists, the latter might make unhappy developers of third party packages. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-15 12:18 ` Max Nikulin @ 2022-07-15 14:36 ` Juan Manuel Macías 0 siblings, 0 replies; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-15 14:36 UTC (permalink / raw) To: Max Nikulin; +Cc: orgmode, Ihor Radchenko Max Nikulin writes: > I have tried on Ubuntu-20.04 LTS focal (Latest LTS is 22.04 jammy). > Without explicit fontenc it may work, but emits a warning > > Package babel Warning: No Cyrillic font encoding has been loaded so far. > (babel) A font encoding should be declared before babel. > (babel) Default `T2A' encoding will be loaded on input > line 74. Yeah, that's something I forgot to mention. The warning is from russianb.ldf: ------------- \ifx\cyrillicencoding\undefined \if@uni@ode %\ifdefined\XeTeXrevision % \edef\cyrillicencoding{EU1} %\else\ifdefined\luatexversion % \edef\cyrillicencoding{EU2} %\fi\fi \edef\cyrillicencoding{TU} \else \edef\cyrillicencoding{T2A} \fi \PackageWarning{babel}% {No Cyrillic font encoding has been loaded so far.\MessageBreak A font encoding should be declared before babel.\MessageBreak Default `\cyrillicencoding' encoding will be loaded }% \lowercase\expandafter{\expandafter\input\cyrillicencoding enc.def\relax}% \AtBeginDocument{\@setcyrillicencoding} \fi ------------- But there is no warning in the case of Greek, where the LGR fontencoding is not explicitly indicated either. In any case, I have commented on this issue on the Hispanic TeX mailing list, where Javier Bezos (current Babel maintainer) participates. It would be interesting if he could clarify this for us... > Unfortunately in the case of > > \usepackage[russian,english]{babel} > > \selectlanguage{russian} is required, without it compilation fails with > > ! LaTeX Error: Command \cyrn unavailable in encoding OT1. Yes, this is the case of the example that I put in my previous message (russian as second language). If a explicit babel command is not added, the T2A fontencoding is not loaded. Therefore, you would have to add a selectlanguage{russian} or, at a low level, \fontencoding{T2A}\selectfont > With \usepackage[T2A]{fontenc} it behaves accordingly to acceptable > for non-important documents graceful degradation. Text is readable, > but no hyphenation applied. > > So I consider explicit loading of fontenc as more reliable. Wouldn't it be easier in those cases to just load the fontenc package a second time: #+LaTeX_Header: \usepackage[T1,T2A]{fontenc} According to what Egreg says in this thread (https://tex.stackexchange.com/a/79112), "The only package that's allowed to be loaded multiple times is fontenc". So my logic is as follows: since Org has always loaded fontenc with the T1 option by default, I don't see much point in changing that behavior now that pdfLaTeX is, so to speak, in retirement. And in any case, the user can change (now) the fontencoding via the babel commands or by loading the package a second time. For the record, I'm not opposed to redoing the patch by adding the features you're proposing. Simply, from my point of view, I think it's not worth the effort. But it's just my opinion, and besides, I don't use pdfLaTeX, so I may have a bias here. Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-14 12:34 ` Juan Manuel Macías 2022-07-14 15:12 ` Max Nikulin @ 2022-07-17 9:55 ` Ihor Radchenko 2022-07-17 14:48 ` Juan Manuel Macías 2022-07-19 15:01 ` Juan Manuel Macías 1 sibling, 2 replies; 50+ messages in thread From: Ihor Radchenko @ 2022-07-17 9:55 UTC (permalink / raw) To: Juan Manuel Macías; +Cc: orgmode Juan Manuel Macías <maciaschain@posteo.net> writes: > I attach the new version of the patch with both variables declared > obsolete. Thanks! We usually declare obsolete variables in org-compat.el. > If everything is ok, I can add what is necessary to NEWS and to the Org Manual. I have some minor comments. You can address them and then go ahead with NEWS and manual. For Max's comment, using plist/alist would make things more clear code-wise for future developers. I always find it annoying when I need to go back and forth checking which element should be second or third or forth in the list. Especially if the variable is used all around the codebase. Though this particular case is not such - `org-latex-language-alist' is used just in few places. > +(make-obsolete-variable 'org-latex-babel-language-alist > + "set `org-latex-language-alist' instead." "9.6") > + > +(make-obsolete-variable 'org-latex-polyglossia-language-alist > + "set `org-latex-language-alist' instead." "9.6") > + As I mentioned earlier, please move the obsoletion statements to org-compat. > - "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). Two spaces between sentences please, as in https://orgmode.org/worg/org-contribute.html > ;; 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)) A comment explaining why "3" would be useful. > - (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))))) Again, comment explaining all these 2,3,4 would help. Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-17 9:55 ` Ihor Radchenko @ 2022-07-17 14:48 ` Juan Manuel Macías 2022-07-18 6:44 ` Ihor Radchenko 2022-07-19 15:01 ` Juan Manuel Macías 1 sibling, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-17 14:48 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode, Maxim Nikulin Ihor Radchenko writes: > For Max's comment, using plist/alist would make things more clear > code-wise for future developers. I always find it annoying when I need > to go back and forth checking which element should be second or third or > forth in the list. Especially if the variable is used all around the > codebase. Though this particular case is not such - > `org-latex-language-alist' is used just in few places. I agree with Maxim and with you that an anonymous list is hardly usable for future features. For this new list I followed the style of the previous ones and I admit that I was quite conservative. The problem, imho, is that with the current org implementation I find it difficult to add new features. For example, Babel now has two ways of loading languages: the old one, through ldf files, which is the one that Org implements and that produces the traditional babel syntax; and the new system through ini files, which also incorporates a new syntax with many options and variants. New languages have been defined by ini files, but cannot be loaded by the old syntax. That is the cause of the asterisks in my list: when a language has an asterisk it means that it is only served in babel through an ini file and, therefore, the traditional syntax cannot be used, so it is not implemented for use in babel. And furthermore, the new babel syntax and ini files can only be used with the Unicode TeX engines: XeTeX and LuaTeX. This all looks like a puzzle (I'm getting dizzy just rereading it :-)), and I don't see a clean and sensible way to translate it to Org settings. I also think that the current Org settings for loading languages with Polyglossia or Babel is unhelpful and unclear. Also, it depends on putting explicit LaTeX code in the document. A code that, in the case of Polyglossia, is a fake LaTeX code, because something like this: \usepackage[french,AUTO]{polyglossia} is not really the Polyglossia syntax. And it can lead to confusion. I think this should be reimplemented in the future using a more org-centric syntax, using keywords (somehow keeping the above for backwards compatibility). I don't know, maybe something like this, with a specific keyword for language LaTeX settings: #+latex_language: es variant:mx babel-ini:t other:en,de,el etc. In this case, I think it would make more sense to define a more robust list, an alist or a plist (as Maxim suggested), leaving the door open to a fresh reimplementation of langs in latex export. I can get to work as soon as I have some time and finish with other commitments, that will keep me busy practically all summer. WDYT? Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-17 14:48 ` Juan Manuel Macías @ 2022-07-18 6:44 ` Ihor Radchenko 2022-07-18 10:32 ` Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Ihor Radchenko @ 2022-07-18 6:44 UTC (permalink / raw) To: Juan Manuel Macías; +Cc: orgmode, Maxim Nikulin Juan Manuel Macías <maciaschain@posteo.net> writes: >> For Max's comment, using plist/alist would make things more clear >> code-wise for future developers. I always find it annoying when I need >> to go back and forth checking which element should be second or third or >> forth in the list. Especially if the variable is used all around the >> codebase. Though this particular case is not such - >> `org-latex-language-alist' is used just in few places. > > I agree with Maxim and with you that an anonymous list is hardly usable > for future features. For this new list I followed the style of the > previous ones and I admit that I was quite conservative. The problem, > imho, is that with the current org implementation I find it difficult to > add new features. For example, Babel now has two ways of loading > languages: the old one, through ldf files, which is the one that Org > implements and that produces the traditional babel syntax; and the new > system through ini files, which also incorporates a new syntax with many > options and variants. New languages have been defined by ini files, but > cannot be loaded by the old syntax. That is the cause of the asterisks > in my list: when a language has an asterisk it means that it is only > served in babel through an ini file and, therefore, the traditional > syntax cannot be used, so it is not implemented for use in babel. And > furthermore, the new babel syntax and ini files can only be used with > the Unicode TeX engines: XeTeX and LuaTeX. This all looks like a puzzle > (I'm getting dizzy just rereading it :-)), and I don't see a clean and > sensible way to translate it to Org settings. Do you refer to the paragraph below when saying that Org implementation makes it hard to add new features? The rest of the above paragraph implies that the difficulty is on LaTeX side, not on Org side. In any case, your existing patch is an already an improvement. I do not deem it as requirement to apply the patch. > I also think that the current Org settings for loading languages with > Polyglossia or Babel is unhelpful and unclear. Also, it depends on > putting explicit LaTeX code in the document. A code that, in the case of > Polyglossia, is a fake LaTeX code, because something like this: > > \usepackage[french,AUTO]{polyglossia} > > is not really the Polyglossia syntax. And it can lead to confusion. I hope that Timothy's work on more flexible and configurable template generation can improve things. > I think this should be reimplemented in the future using a more > org-centric syntax, using keywords (somehow keeping the > above for backwards compatibility). I don't know, maybe something like > this, with a specific keyword for language LaTeX settings: > > #+latex_language: es variant:mx babel-ini:t other:en,de,el etc. > > In this case, I think it would make more sense to define a more robust > list, an alist or a plist (as Maxim suggested), leaving the door open to > a fresh reimplementation of langs in latex export. I can get to work as > soon as I have some time and finish with other commitments, that will > keep me busy practically all summer. > > WDYT? This sounds reasonable. Implementing via :options-alist export property will conform more to the overall design (see the docstring of org-export-options-alist - it enables a lot of flexibility in terms of customization, including the option syntax similar to what you proposed). Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-18 6:44 ` Ihor Radchenko @ 2022-07-18 10:32 ` Juan Manuel Macías 2022-07-18 11:01 ` Juan Manuel Macías 2022-07-18 15:37 ` Max Nikulin 0 siblings, 2 replies; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-18 10:32 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode Ihor Radchenko writes: > Do you refer to the paragraph below when saying that Org implementation > makes it hard to add new features? The rest of the above paragraph > implies that the difficulty is on LaTeX side, not on Org side. Sorry for not explaining clearly. Actually I think the problem is not with Org or Babel (LaTeX), but rather with the "translation" from Babel (latex) to Org. Currently the babel interface is more complex, although it is more consistent and robust within LaTeX. The challenge is how to style all of that for an Org user who wants to just get a correct PDF out-of-the-box using a simple and basic syntax (of course, you don't need to translate the whole babel: to use babel with all its power it's better to write the LaTeX code directly). For that reason I think that, for now, it is more practical to keep the old babel syntax on the Org side (as I do in my patch): \usepackage[langs]{babel} which is perfectly valid for pdflatex, lualatex and xelatex (except in the languages that are loaded in babel through ini files). > In any case, your existing patch is an already an improvement. I do not > deem it as requirement to apply the patch. Well, between today and tomorrow I can prepare a new version of the patch with all your suggestions from the previous email incorporated. And for the future I can work on a fresh re-implementation of all this, using the :options-alist export property, as you suggest. For example, something like this: latex-lang: babel(sorbian) variant(upper) provide(hebrew:import,hyphenrules=+) options(bidi=default), others(french,catalan) returns: \usepackage[french,catalan,uppersorbian,bidi=default]{babel} \babelprovide[import,hyphenrules=+]{hebrew} or this (in this case Hebrew is the main language): latex-lang: babel provide(hebrew:main,import,hyphenrules=+) options(bidi=default), others(french,catalan) returns: \usepackage[french,catalan,bidi=default]{babel} \babelprovide[main,import,hyphenrules=+]{hebrew} And the above is equivalent to: latex-lang: babel(hebrew) options(bidi=default,provide=*), others(french,catalan) returns: \usepackage[french,catalan,hebrew,bidi=default,provide=*]{babel} Note that for monolingual documents, now in babel it would be enough to indicate the language in the document class options (only for LuaTeX and XeTeX), so it would be enough to do something like this: #+latex_class: article #+latex_class_options: [french,10pt,draft] #+LaTeX_Header: \usepackage{babel} Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-18 10:32 ` Juan Manuel Macías @ 2022-07-18 11:01 ` Juan Manuel Macías 2022-07-18 15:37 ` Max Nikulin 1 sibling, 0 replies; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-18 11:01 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode Juan Manuel Macías writes: > latex-lang: babel(sorbian) variant(upper) provide(hebrew:import,hyphenrules=+) options(bidi=default), others(french,catalan) > > returns: > > \usepackage[french,catalan,uppersorbian,bidi=default]{babel} > \babelprovide[import,hyphenrules=+]{hebrew} PS: In fact, I think that this new implementation would no longer depend on a list of languages neither for babel nor for polyglossia, since it is not connected to the #+language keyword. The old list would be kept for backwards compatibility. Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-18 10:32 ` Juan Manuel Macías 2022-07-18 11:01 ` Juan Manuel Macías @ 2022-07-18 15:37 ` Max Nikulin 2022-07-18 16:21 ` Juan Manuel Macías 1 sibling, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-18 15:37 UTC (permalink / raw) To: emacs-orgmode On 18/07/2022 17:32, Juan Manuel Macías wrote: > > For example, something like this: > > latex-lang: babel(sorbian) variant(upper) provide(hebrew:import,hyphenrules=+) options(bidi=default), others(french,catalan) > > returns: > > \usepackage[french,catalan,uppersorbian,bidi=default]{babel} > \babelprovide[import,hyphenrules=+]{hebrew} I have never tried so complex babel configuration. Should "latex-lang" options affect ox-latex in any way besides adding \usepackage[...]{babel} and \babelprovide[...]{...}? If not, maybe it is better to use #+latex_header: \usepackage[french,catalan,uppersorbian,bidi=default]{babel} #+latex_header: \babelprovide[import,hyphenrules=+]{hebrew} directly and add default \usepackage[french]{babel} based on "#+language:" only in the case when babel is not loaded through "#+latex_header:". Currently such strategy is implemented for inputenc or some other package. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-18 15:37 ` Max Nikulin @ 2022-07-18 16:21 ` Juan Manuel Macías 0 siblings, 0 replies; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-18 16:21 UTC (permalink / raw) To: Max Nikulin; +Cc: orgmode Max Nikulin writes: > On 18/07/2022 17:32, Juan Manuel Macías wrote: >> For example, something like this: >> latex-lang: babel(sorbian) variant(upper) >> provide(hebrew:import,hyphenrules=+) options(bidi=default), >> others(french,catalan) >> returns: >> \usepackage[french,catalan,uppersorbian,bidi=default]{babel} >> \babelprovide[import,hyphenrules=+]{hebrew} > > I have never tried so complex babel configuration. Should "latex-lang" > options affect ox-latex in any way besides adding > \usepackage[...]{babel} and \babelprovide[...]{...}? If not, maybe it > is better to use I really think not. It's more of a way to have a more or less complete configuration of babel (including font options) in a single line and with a more org-centric syntax. The drawback is that the user would have to know in this case what he is putting, and know the babel options. > #+latex_header: \usepackage[french,catalan,uppersorbian,bidi=default]{babel} > #+latex_header: \babelprovide[import,hyphenrules=+]{hebrew} That's what I would do as a user. I write all my preambles in pure LaTeX and don't let Org write anything before the \begin{document} :-) > directly and add default \usepackage[french]{babel} based on > "#+language:" only in the case when babel is not loaded through > "#+latex_header:". Currently such strategy is implemented for inputenc > or some other package. humm, what do you think about this idea?: If I'm not mistaken, the current behavior is as follows. If in the org document there is this: #+latex_header: \usepackage[english,french,AUTO]{babel} #+language: es it returns: \usepackage[english,french,spanish]{babel} But it could be extended to the new babel syntax, so that: #+latex_header: \usepackage[french,catalan,AUTO,bidi=default]{babel} #+latex_header: \babelprovide[import,hyphenrules=+]{hebrew} #+language: es returns: \usepackage[french,catalan,spanish,bidi=default]{babel} \babelprovide[import,hyphenrules=+]{hebrew} Or, if we want to load the main language via babelprovide (using an ini file instead of an ldf file): #+latex_header: \usepackage[french,catalan,spanish]{babel} #+latex_header: \babelprovide[main,import]{AUTO} #+language: ru returns: \usepackage[french,catalan,spanish]{babel} \babelprovide[main,import]{russian} (in this case french, catalan and spanish are the secondary languages) And this could be extended (in LuaTeX and XeTeX only) to the class options (which is a new babel feature): #+latex_class: article #+latex_class_options: [11pt,draft,AUTO] #+LaTeX_Header: \usepackage{babel} #+language: ru returns: \documentclass[11pt,draft,russian]{article} \usepackage{babel} ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-17 9:55 ` Ihor Radchenko 2022-07-17 14:48 ` Juan Manuel Macías @ 2022-07-19 15:01 ` Juan Manuel Macías 2022-07-19 17:01 ` Max Nikulin 2022-07-23 5:01 ` [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Ihor Radchenko 1 sibling, 2 replies; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-19 15:01 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode [-- Attachment #1: Type: text/plain, Size: 1209 bytes --] Here is a new version of the patch, with the fixes added. Important: I have modified in this patch org-latex-guess-babel-language so that it recognizes the new Babel syntax alongside the old syntax. That is, it is now possible to put: #+LaTeX_Header: \usepackage[arguments,AUTO]{babel} #+LaTeX_Header: \babelprovide[arguments]{AUTO} Languages that are served in Babel *exclusively* via ini files (ie those with an asterisk in the new list) are not added to the Babel argument (they must be loaded via babelprovide). However, the following situation may also occur. A user wants to load the secondary languages via ldf files and the main language via ini file (babelprovide): #+LaTeX_Header: \usepackage[french,english]{babel} #+LaTeX_Header: \babelprovide[main, import]{AUTO} #+language: ru This would produce in LaTeX: \usepackage[french, english, russian]{babel} \babelprovide[main, import]{russian} I have not prevented this behavior as it is correct in Babel: you can load the main language using the 'old style' and then redefine it using babelprovide, which is a complement. Besides, maintaining this behavior is also necessary to preserve backwards compatibility. Best regards, Juan Manuel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-lisp-ox-latex.el-New-variable-org-latex-language-ali.patch --] [-- Type: text/x-patch, Size: 12780 bytes --] From 2f78d6a75849819f1d3aececff70b7ffa4f36c7c Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias <maciaschain@posteo.net> Date: Tue, 19 Jul 2022 16:51:55 +0200 Subject: [PATCH] * lisp/ox-latex.el: New variable `org-latex-language-alist' (org-latex-language-alist): Unify in a single list `org-latex-polyglossia-language-alist' and `org-latex-babel-language-alist', and make the two variables obsolete. However, it may be convenient in the future to replace this list with a more robust one. (see: `https://list.orgmode.org/taeb0a$r62$1@ciao.gmane.io') (org-latex-guess-babel-language): This function has been modified so that the new Babel command `babelprovide' is also recognized. This command is necessary to load the languages served by Babel exclusively through an ini file. Therefore, the new Babel syntax is supported alongside the old one. Note that languages that are served exclusively via an ini file are not added to the Babel argument. --- lisp/org-compat.el | 8 ++ lisp/ox-latex.el | 236 ++++++++++++++++++++++----------------------- 2 files changed, 125 insertions(+), 119 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 6f663cc24..835ec2828 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -880,6 +880,12 @@ context. See the individual commands for more information." 'org-truly-invisible-p "9.6" "Compatibility alias for legacy misspelling of `org-truly-invisible-p'.") +(make-obsolete-variable 'org-latex-babel-language-alist + "set `org-latex-language-alist' instead." "9.6") + +(make-obsolete-variable 'org-latex-polyglossia-language-alist + "set `org-latex-language-alist' instead." "9.6") + ;;;; Obsolete link types (eval-after-load 'ol @@ -888,6 +894,8 @@ context. See the individual commands for more information." (org-link-set-parameters "file+sys"))) ;since Org 9.0 + + \f ;;; Miscellaneous functions diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 1aab8ffd5..2eed44b62 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -172,144 +172,111 @@ \f ;;; 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 + ;; TODO: replace this list with a property list (the actual + ;; implementation is not very robust). + '(("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-mx" "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") @@ -1644,31 +1611,54 @@ 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. +The optional argument to Babel or the mandatory argument to +`\babelprovide' command 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 - ;; HEADER as-is. - (if (or (not (stringp language-code)) - (not (string-match "\\\\usepackage\\[\\(.*\\)\\]{babel}" 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)) + (not (string-match "\\\\usepackage\\[\\(.*\\)\\]{babel}" header))) + header + (let ((options (save-match-data + (org-split-string (match-string 1 header) ",[ \t]*")))) + ;; If LANGUAGE is already loaded, return header + ;; without AUTO. Otherwise, replace AUTO with language or + ;; append language if AUTO is not present. Languages that are + ;; 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) (= (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))))))) + ;; if `\babelprovide[args]{AUTO}' is present, AUTO is + ;; replaced by LANGUAGE. + (if (not (string-match "\\\\babelprovide\\[.*\\]{\\(.+\\)}" 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)))) - ;; 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))))) + (let ((prov (match-string 1 header))) + (when (equal "AUTO" prov) + (replace-regexp-in-string (format + "\\(\\\\babelprovide\\[.*\\]\\)\\({\\)%s}" prov) + (format "\\1\\2%s}" language) header t)))))) (defun org-latex-guess-polyglossia-language (header info) "Set the Polyglossia language according to the LANGUAGE keyword. @@ -1710,15 +1700,23 @@ 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)) + ;; Four elements implies that there is a + ;; variant (4) for LANGUAGE when + ;; declared by Polyglossia (3). TODO: + ;; this should be improved when + ;; `org-latex-language-alist' is + ;; replaced by a more robust list. + (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.37.1 ^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-19 15:01 ` Juan Manuel Macías @ 2022-07-19 17:01 ` Max Nikulin 2022-07-19 19:31 ` Juan Manuel Macías 2022-07-23 5:01 ` [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Ihor Radchenko 1 sibling, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-19 17:01 UTC (permalink / raw) To: emacs-orgmode On 19/07/2022 22:01, Juan Manuel Macías wrote: > + (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)))) > + ", ") In my opinion this code should not attempt to be excessively clever. If user skipped AUTO then do not append language. Test for duplicated options is redundant as well. Such cases may still be a reason to issue a warning (e.g. by `org-lint'). On the other hand I would consider adding babel by default without explicit header. To suppress loading users may add #+latex_header: % \usepackage{babel} I like that you decided to avoid inventing of a DSL just to have org-like options that are translated to to a couple of preamble commands. From my point of view it would not help novices and would make things more complicated for experienced LaTeX users. > #+latex_class: article > #+latex_class_options: [11pt,draft,AUTO] > #+LaTeX_Header: \usepackage{babel} > #+language: ru While AUTO is suitable for \usepackage{babel} and \babelprovide, for class option the placeholder should be clearly associated with babel, e.g. BABEL_LANG instead of AUTO. I am not familiar enough with setting used to generate preview of equations or images from LaTeX source blocks, so I am not completely sure that suggested changes do not affect these features in some negative way. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-19 17:01 ` Max Nikulin @ 2022-07-19 19:31 ` Juan Manuel Macías 2022-07-20 16:12 ` Max Nikulin 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-19 19:31 UTC (permalink / raw) To: Max Nikulin; +Cc: orgmode, Ihor Radchenko Max Nikulin writes: > On 19/07/2022 22:01, Juan Manuel Macías wrote: >> + (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)))) >> + ", ") > > In my opinion this code should not attempt to be excessively clever. > If user skipped AUTO then do not append language. Test for duplicated > options is redundant as well. Such cases may still be a reason to > issue a warning (e.g. by `org-lint'). I completely agree. I've kept that old part of the code for backwards compatibility and because, at the end of the day, it doesn't break anything new. I mean, if a user declares the main language using babelprovide and this code (too intrusive) puts the main language in the Babel argument too (something the user doesn't want in origin), that syntax is supported by Babel. Babel simply takes into account the main language declared with babelprovide, if the 'main' option has been added. But even if it doesn't return any errors, it's unnecessary redundancy. Anyway, yes, it's too intrusive. I am in favor of removing that part, but I don't know if it will have any effect on backwards compatibility. (BTW, I think I didn't explain in this thread the advantages of using babelprovide over the traditional ldf file system. With ini files the user has more control over the loaded language and there are many options, including the ability to associate a font with a script. Furthermore the user can create his own custom ini files, and define his own languages. For example, I could write an ini file with specific values for Spanish, or even an imaginary language. On the one hand, it is an important advance. But on the other hand it adds more fuel to the current great latex pandemic: multiplicity). > On the other hand I would consider adding babel by default without > explicit header. To suppress loading users may add > #+latex_header: % \usepackage{babel} I don't understand this very well. What would happen, then, to users who prefer to use Polyglossia, or those who prefer to explicitly add babel or polyglossia code? > I like that you decided to avoid inventing of a DSL just to have > org-like options that are translated to to a couple of preamble > commands. From my point of view it would not help novices and would > make things more complicated for experienced LaTeX users. Yes, in the end I realized that this was getting into a slippery slope, especially for the reasons you mention... >> #+latex_class: article >> #+latex_class_options: [11pt,draft,AUTO] >> #+LaTeX_Header: \usepackage{babel} >> #+language: ru > > While AUTO is suitable for \usepackage{babel} and \babelprovide, for > class option the placeholder should be clearly associated with babel, > e.g. BABEL_LANG instead of AUTO. What you say makes sense. However, this was ultimately not implemented in the current version of the patch because the argument of org-latex-guess-babel-language is a #+latex_header keyword. > I am not familiar enough with setting used to generate preview of > equations or images from LaTeX source blocks, so I am not completely > sure that suggested changes do not affect these features in some > negative way. I think that shouldn't affect previsualization, because if I remember correctly the preamble used for previews is the value of org-format-latex-header. But I'm not sure... Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-19 19:31 ` Juan Manuel Macías @ 2022-07-20 16:12 ` Max Nikulin 2022-07-20 21:30 ` Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-20 16:12 UTC (permalink / raw) To: emacs-orgmode On 20/07/2022 02:31, Juan Manuel Macías wrote: > Max Nikulin writes: > >> On 19/07/2022 22:01, Juan Manuel Macías wrote: >>> + (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)))) >>> + ", ") >> >> In my opinion this code should not attempt to be excessively clever. >> If user skipped AUTO then do not append language. Test for duplicated >> options is redundant as well. Such cases may still be a reason to >> issue a warning (e.g. by `org-lint'). > > I completely agree. I've kept that old part of the code for backwards > compatibility and because, at the end of the day, it doesn't break > anything new. I am sorry, I missed the old code below the added lines. >> On the other hand I would consider adding babel by default without >> explicit header. To suppress loading users may add >> #+latex_header: % \usepackage{babel} > > I don't understand this very well. What would happen, then, to users who > prefer to use Polyglossia, or those who prefer to explicitly add babel > or polyglossia code? Certainly if polyglossia or explicit babel related commands are detected then default babel configuration is not added to preamble. The idea is to add babel if a user have not expressed her intentions explicitly. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-20 16:12 ` Max Nikulin @ 2022-07-20 21:30 ` Juan Manuel Macías 2022-07-21 14:36 ` Max Nikulin 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-20 21:30 UTC (permalink / raw) To: Max Nikulin; +Cc: orgmode, Ihor Radchenko Max Nikulin writes: >>> On the other hand I would consider adding babel by default without >>> explicit header. To suppress loading users may add >>> #+latex_header: % \usepackage{babel} >> I don't understand this very well. What would happen, then, to users >> who >> prefer to use Polyglossia, or those who prefer to explicitly add babel >> or polyglossia code? > > Certainly if polyglossia or explicit babel related commands are > detected then default babel configuration is not added to preamble. > The idea is to add babel if a user have not expressed her intentions > explicitly. Ah, I see. I think it's a nice idea. I guess a basic babel setup would be added to preamble. Something like: #+language: lang --> \usepackage[lang]{babel} But I think also users who use custom preamble templates included in org-latex-classes or those who load the entire preamble via an external file (a .sty or .tex file) will want to avoid this. Maybe it would be nice to add a defcustom, with the following values: - load babel with the value of #+language, when there is no explicit code from babel (default?) - load polyglossia, idem but for polyglossia - nil - any other arbitrary string? If the user loads babel or polyglossia explicitly, with AUTO and all that, then the current rules in org-latex-guess-babel/polyglossia-language would be applied. WDYT? Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-20 21:30 ` Juan Manuel Macías @ 2022-07-21 14:36 ` Max Nikulin 2022-07-21 15:39 ` Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-21 14:36 UTC (permalink / raw) To: emacs-orgmode On 21/07/2022 04:30, Juan Manuel Macías wrote: > Max Nikulin writes: > > #+language: lang > > --> \usepackage[lang]{babel} > > But I think also users who use custom preamble templates included in > org-latex-classes or those who load the entire preamble via an external > file (a .sty or .tex file) will want to avoid this. Maybe it would be > nice to add a defcustom, with the following values: A custom variable may be convenient, however originally I considered only per-document configuration. If a user do not like babel added by default then there are some alternatives as #+latex_header: \usepackage[AUTO]{polyglossia} or #+latex_header: % \usepackage{babel} % suppress babel and polyglossia Certainly with the following variant #+latex_header: % \usepackage{polyglossia} % no babel or polyglossia The commented out command is a kind a hack, but I consider it as acceptable for advanced users who have custom classes or who need to compile document without babel (or polyglossia) for some reason. If you feel that defcustom should be added as well, variants may be - nil to suppress babel and polyglossia - 'babel or 'polyglossia symbols to get language from #+language: keyword or from LANGUAGE or LANG environment. Unsure which LC_... variable may have greater priority. - string for exact latex code added to preamble. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-21 14:36 ` Max Nikulin @ 2022-07-21 15:39 ` Juan Manuel Macías 2022-07-22 12:16 ` Max Nikulin 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-21 15:39 UTC (permalink / raw) To: Max Nikulin; +Cc: orgmode, Ihor Radchenko Max Nikulin writes: > The commented out command is a kind a hack, but I consider it as > acceptable for advanced users who have custom classes or who need to > compile document without babel (or polyglossia) for some reason. Yes, I think the ability to control this per document is also necessary. I would vote for a custom variable, at the global level (I agree with the options you suggest) and at the document level, to economize, perhaps this would be enough to avoid the code of both babel and polyglossia: #+latex_header: NOLANG (BTW, in the current version of my patch I'm afraid the commit message is malformed, and there's an asterisk where it shouldn't be, apologies). Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-21 15:39 ` Juan Manuel Macías @ 2022-07-22 12:16 ` Max Nikulin 2022-07-22 12:49 ` Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-22 12:16 UTC (permalink / raw) To: emacs-orgmode On 21/07/2022 22:39, Juan Manuel Macías wrote: > Max Nikulin writes: > > I would vote for a custom variable, at the global level (I agree with > the options you suggest) and at the document level, to economize, > perhaps this would be enough to avoid the code of both babel and > polyglossia: > > #+latex_header: NOLANG Form my point of view it is unnecessary magic. Originally #+latex_header is intended for valid LaTeX code and "% \usepackage{babel} % disable" does not make code invalid (being a kind of magic though). If you consider such cast as too verbose then even #+options: latex-l10n:nil might be better. I am unsure if babel or polyglossia are parsed as strings or as symbols in such context. I am still against a DSL for "#+options:" to generate complex babel commands in favor of explicit "#+latex_header:". On 18/07/2022 23:21, Juan Manuel Macías wrote: >> \documentclass[11pt,draft,russian]{article} >> \usepackage{babel} I have realized that it resembles \documentstyle[russian,epsfig,wrapfig,12pt]{article} from the previous century and LaTeX-2.09. Due to lack of support in babel, several alternatives to add Russian language existed and one of them required the \documentstyle option. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-22 12:16 ` Max Nikulin @ 2022-07-22 12:49 ` Juan Manuel Macías 2022-07-22 14:07 ` Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-22 12:49 UTC (permalink / raw) To: Max Nikulin; +Cc: orgmode, Ihor Radchenko Max Nikulin writes: > Form my point of view it is unnecessary magic. Originally #+latex_header > is intended for valid LaTeX code OK, so why not just: #+latex_header: % NOLANG ? I think this has in its favor: a) it is simple and obvious to remember; b) it's a single string, and of course c) it's valid LaTeX code. And it can be easily controlled from org-latex-guess-babel/polyglossia-language with a conditional. Anyway, whatever the choice, I would vote for Org not to load babel or polyglossia by default, and for the default option of the custom variable that handles that globally to be nil. For example, I'm in the group of users that load babel using an external preamble (a .tex or a .sty file or a 'latex-class'), and frankly I don't want to have to add a new line to all my documents to prevent Org from reloading babel for me and return an error on the compilation. Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-22 12:49 ` Juan Manuel Macías @ 2022-07-22 14:07 ` Juan Manuel Macías 2022-07-23 15:19 ` Max Nikulin 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-22 14:07 UTC (permalink / raw) To: Maxim Nikulin; +Cc: orgmode Juan Manuel Macías writes: > OK, so why not just: > > #+latex_header: % NOLANG > > ? Forget this. On second thought, I think that the option you proposed "#+LaTeX_Header: % \usepackage{babel}" is much better. (I don't know where my head was and I didn't remember there was a string-match, so your suggestion is the shortest way. However, the line would have to be (with arguments): #+LaTeX_Header: % \usepackage[something]{babel} or #+LaTeX_Header: % \usepackage[something]{polyglossia} or modify the regexp in org-latex-guess-babel/polyglossia-language. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-22 14:07 ` Juan Manuel Macías @ 2022-07-23 15:19 ` Max Nikulin 2022-07-23 17:15 ` Improvements in the default LaTeX preamble (was: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists) Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-23 15:19 UTC (permalink / raw) To: emacs-orgmode On 22/07/2022 21:07, Juan Manuel Macías wrote: > > Forget this. On second thought, I think that the option you proposed > "#+LaTeX_Header: % \usepackage{babel}" is much better. > > (I don't know where my head was and I didn't remember there was a > string-match, so your suggestion is the shortest way. However, the line > would have to be (with arguments): > > #+LaTeX_Header: % \usepackage[something]{babel} > > or > > #+LaTeX_Header: % \usepackage[something]{polyglossia} > > or modify the regexp in org-latex-guess-babel/polyglossia-language. It was you who suggested \documentclass[russian]{article} \usepackage{babel} At least at first glance it works in texlive-2019 (Ubuntu-20.04), so it is not a feature from the latest release. Unless commented out, "#+latex_header: \usepackage{babel}" may be considered as an instruction to add value of #+language: to \documentclass option. I do not expect that adjusted regexp will cause a problem. > Anyway, whatever the choice, I would vote for Org not to load babel or > polyglossia by default, and for the default option of the custom > variable that handles that globally to be nil. For example, I'm in the > group of users that load babel using an external preamble (a .tex or a > .sty file or a 'latex-class'), and frankly I don't want to have to add a > new line to all my documents to prevent Org from reloading babel for me > and return an error on the compilation. Doesn't the purpose of a custom variable is to set it to a suitable value in the init file making it unnecessary adding configuration to each org file? I did not expected that setting it to e.g. nil will be real burden for users like you. My vote is to configure babel by default if it is possible to provide default preamble that allows reasonable quality of PDF for simple Org documents with no explicit configuration. Ideally, the following should be possible out of the box. When no advanced features are involved, user should be able to just export document to e.g. having printed version of their notes during a meeting, to send a summary to the boss. etc. It should be possible for users completely ignorant in respect to LaTeX. Likely language is not enough and e.g. paper size should be guessed (LC_PAPER?) as well. If a document require careful tuning then a couple of extra lines in the org file or a couple of additional custom variables in the init file should not be a problem. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Improvements in the default LaTeX preamble (was: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists) 2022-07-23 15:19 ` Max Nikulin @ 2022-07-23 17:15 ` Juan Manuel Macías 2022-07-24 12:06 ` Improvements in the default LaTeX preamble: templates? " Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-23 17:15 UTC (permalink / raw) To: Max Nikulin; +Cc: orgmode Max Nikulin writes: > My vote is to configure babel by default if it is possible to provide > default preamble that allows reasonable quality of PDF for simple Org > documents with no explicit configuration. > > Ideally, the following should be possible out of the box. When no > advanced features are involved, user should be able to just export > document to e.g. having printed version of their notes during a > meeting, to send a summary to the boss. etc. It should be possible for > users completely ignorant in respect to LaTeX. > > Likely language is not enough and e.g. paper size should be guessed > (LC_PAPER?) as well. > > If a document require careful tuning then a couple of extra lines in > the org file or a couple of additional custom variables in the init > file should not be a problem. I think that my position, after all these discussions here and in other threads, needs a couple of clarifications: - I am in favor of Org producing a consistent "standard" preamble for LaTeX out-of-the-box, so that users get a technically optimal PDF without messing with LaTeX code. This would include not only issues related to document languages (babel and polyglossia) but also fonts (especially XelaTeX and LuaLaTeX support), page layout (with geometry package), publishing support and some other things that can be proposed here. In this regard, I have changed the subject of this thread, if that's okay with you. - I can agree that all of the above is by default. But it seems essential to me that there is at least the possibility of giving all that a nil value at a global level, for users who need more control and want to write (La)TeX code or want to load the entire preamble from an external document (a .tex file or a .sty file) . Which is not incompatible with document-level control and fine-tuning (*only* if the above is enabled). Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Improvements in the default LaTeX preamble: templates? (was: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists) 2022-07-23 17:15 ` Improvements in the default LaTeX preamble (was: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists) Juan Manuel Macías @ 2022-07-24 12:06 ` Juan Manuel Macías 2022-07-25 9:31 ` Ihor Radchenko 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-24 12:06 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode, Maxim Nikulin Ihor Radchenko writes: > Adding things like paper size is a much more debatable topic. > Considering the number of expected developments in this area, including > the earlier discussion on XeLaTeX/LuaTeX and preamble generation by TEC, > adding the new specific defaults will need to be a subject of extensive > discussion and testing. I do not see much point delaying this patch, > which provides an immediate improvement in the codebase, until we > complete all that. I agree that adding more elements to the standard preamble is a complex matter. LaTeX is already horribly complex and multiple, and it is difficult to satisfy all kinds of users with a standard code. It occurred to me that an alternative to modifying Org's code in this regard could be to have some kind of "LaTeX template library". I think Pandoc has something similar too, if I remember correctly. Those templates could be on Org or provided by third parties somewhere else, like Worg. In Org, we also have a great system for creating LaTeX documents templates, which is the org-latex-classes list. A large number of elements could be defined in a 'single' class for any type of document. Some time ago I shared here a function I wrote (it's a bit raw and little tested) to be able to convert a LaTeX document (the preamble) into a lisp expression to be added to org-latex-classes: https://list.orgmode.org/87czgly8x8.fsf@posteo.net/ On the one hand Org would offer a more or less basic preamble out of the box and on the other hand there could be a "org-latex-classes library" (extensible by users) that would support a multitude of LaTeX document types or users. This would include preamble types with a bunch of components: page layout, fonts, lua code, custom LaTeX commands, custom lua functions, article types, book types, etc. It would suffice to add: #+latex_class: foo and the magic is done. Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: Improvements in the default LaTeX preamble: templates? (was: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists) 2022-07-24 12:06 ` Improvements in the default LaTeX preamble: templates? " Juan Manuel Macías @ 2022-07-25 9:31 ` Ihor Radchenko 2022-07-25 10:45 ` Improvements in the default LaTeX preamble: templates? Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Ihor Radchenko @ 2022-07-25 9:31 UTC (permalink / raw) To: Juan Manuel Macías; +Cc: orgmode, Maxim Nikulin Juan Manuel Macías <maciaschain@posteo.net> writes: > I agree that adding more elements to the standard preamble is a complex > matter. LaTeX is already horribly complex and multiple, and it is > difficult to satisfy all kinds of users with a standard code. It > occurred to me that an alternative to modifying Org's code in this > regard could be to have some kind of "LaTeX template library". I think > Pandoc has something similar too, if I remember correctly. Those > templates could be on Org or provided by third parties somewhere else, > like Worg. In Org, we also have a great system for creating LaTeX > documents templates, which is the org-latex-classes list. A large number > of elements could be defined in a 'single' class for any type of > document. LaTeX is just one export backend to worry about. From broader perspective, we can have a generic template library. ox.el currently allows export backends to define document template as a function, which is the most generic way. However, we can come up with something more customizable - customizable in a consistent way, in contrast to the current disarray with various export backends approaching the boilerplate code differently. TEC is working on something along these lines. See https://tecosaur.github.io/emacs-config/config.html#cleverer-preamble Note that we also have inner templates that apply to individual exported elements. Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: Improvements in the default LaTeX preamble: templates? 2022-07-25 9:31 ` Ihor Radchenko @ 2022-07-25 10:45 ` Juan Manuel Macías 0 siblings, 0 replies; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-25 10:45 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode, Maxim Nikulin Ihor Radchenko writes: > LaTeX is just one export backend to worry about. From broader > perspective, we can have a generic template library. Nice idea, I agree. I was targeting LaTeX specifically because of the questions that have been raised in this thread and other parallel threads. And because LaTeX is an extremely complex beast. And it has become much more complex over the years[1]. No two LaTeX documents are alike just as no two LaTeX users are alike. Just take a look at tex.stackexchange.com to realize that reality... (ConTeXt can be a good alternative for those who don't want to mess with the complexity of LaTeX. In ConTeXt you don't need to load a package for everything ---modules at most, but that's another story---, so almost everything is out-of-the-box there). [1] And there is also the problem of multiplicity: three TeX engines coexisting at the same time, LaTeX2ε coexisting with LaTeX 3, etc. > TEC is working on something along these lines. See > https://tecosaur.github.io/emacs-config/config.html#cleverer-preamble Thanks for the pointer! I did not know it and it seems to me a tremendously interesting work. I'll keep an eye on it. In my workflow, I am used to writing the configuration of a LaTeX document (aka, "the preamble") through .sty files that I build according to the requirements of each project. That is, I write my own packages. That's probably why I have a bias of opinion here (I use LaTeX for typesetting and editorial production, so I need more control), but I tend to think that a LaTeX preamble is something so ductile that achieving a certain degree of automation is an arduous task. At least one automation that covers all possible use cases. That's where I got the idea of being able to have a library of templates to cover different types of documents, even the most idiosyncratic ones. Or, at least, that they can serve as an inspiration to other users. Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-19 15:01 ` Juan Manuel Macías 2022-07-19 17:01 ` Max Nikulin @ 2022-07-23 5:01 ` Ihor Radchenko 2022-07-23 13:44 ` BUG " Kai von Fintel ` (2 more replies) 1 sibling, 3 replies; 50+ messages in thread From: Ihor Radchenko @ 2022-07-23 5:01 UTC (permalink / raw) To: Juan Manuel Macías; +Cc: orgmode Juan Manuel Macías <maciaschain@posteo.net> writes: > Here is a new version of the patch, with the fixes added. Thanks! Considering that the followup discussion deviated from the substance of the patch towards related design issues, I have decided to marge the patch as is. We can decide on handling AUTO staff later - it would be a major change to remove and the details of an alternative are not yet worked out. Applied onto main via 97cfb959d after adding some double spaces between sentences and upcasing the beginning of some sentences. Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 5:01 ` [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Ihor Radchenko @ 2022-07-23 13:44 ` Kai von Fintel 2022-07-23 13:59 ` Ihor Radchenko 2022-07-23 14:11 ` Juan Manuel Macías 2022-07-23 15:29 ` Max Nikulin 2 siblings, 1 reply; 50+ messages in thread From: Kai von Fintel @ 2022-07-23 13:44 UTC (permalink / raw) To: yantar92; +Cc: emacs-orgmode, maciaschain I believe that that this patch has made it impossible to export to latex, because the function =org-latex--format-spec= in =ox-latex.el= still refers to the old variables, which are now not bound: > Debugger entered--Lisp error: (void-variable org-latex-babel-language-alist) > org-latex--format-spec( etc. — Kai. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 13:44 ` BUG " Kai von Fintel @ 2022-07-23 13:59 ` Ihor Radchenko 2022-07-23 14:07 ` Kai von Fintel 0 siblings, 1 reply; 50+ messages in thread From: Ihor Radchenko @ 2022-07-23 13:59 UTC (permalink / raw) To: Kai von Fintel; +Cc: emacs-orgmode, maciaschain Kai von Fintel <fintel@mit.edu> writes: > I believe that that this patch has made it impossible to export to latex, because the function =org-latex--format-spec= in =ox-latex.el= still refers to the old variables, which are now not bound: > >> Debugger entered--Lisp error: (void-variable org-latex-babel-language-alist) >> org-latex--format-spec( org-latex-babel-language-alist is the new variable introduced in the patch. You seem to be loading "mixed" Org versions - built-in + latest. Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 13:59 ` Ihor Radchenko @ 2022-07-23 14:07 ` Kai von Fintel 2022-07-23 14:22 ` Ihor Radchenko 0 siblings, 1 reply; 50+ messages in thread From: Kai von Fintel @ 2022-07-23 14:07 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode, maciaschain On 23 Jul 2022, at 16:59, Ihor Radchenko wrote: > Kai von Fintel <fintel@mit.edu> writes: > >> I believe that that this patch has made it impossible to export to latex, because the function =org-latex--format-spec= in =ox-latex.el= still refers to the old variables, which are now not bound: >> >>> Debugger entered--Lisp error: (void-variable org-latex-babel-language-alist) >>> org-latex--format-spec( > > org-latex-babel-language-alist is the new variable introduced in the > patch. You seem to be loading "mixed" Org versions - built-in + latest. No, I’m looking just at the HEAD version of =ox-latex.el= at https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox-latex.el The new variable is =org-latex-language-alist=, defined on line 175f. But, =org-latex—format-spec=, defined on line 1860ff, uses the old variable names: (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))) (or (cdr (assoc-string lang org-latex-babel-language-alist t)) (nth 1 (assoc-string lang org-latex-polyglossia-language-alist t)) lang)))) This borks my latex exports. — Kai. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 14:07 ` Kai von Fintel @ 2022-07-23 14:22 ` Ihor Radchenko 2022-07-23 14:39 ` Kai von Fintel 0 siblings, 1 reply; 50+ messages in thread From: Ihor Radchenko @ 2022-07-23 14:22 UTC (permalink / raw) To: Kai von Fintel; +Cc: emacs-orgmode, maciaschain Kai von Fintel <fintel@mit.edu> writes: >>>> Debugger entered--Lisp error: (void-variable org-latex-babel-language-alist) >>>> org-latex--format-spec( >> >> org-latex-babel-language-alist is the new variable introduced in the >> patch. You seem to be loading "mixed" Org versions - built-in + latest. > > No, I’m looking just at the HEAD version of =ox-latex.el= at https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox-latex.el > > The new variable is =org-latex-language-alist=, defined on line 175f. > > But, =org-latex—format-spec=, defined on line 1860ff, uses the old variable names: > > (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))) > (or (cdr (assoc-string lang org-latex-babel-language-alist t)) > (nth 1 (assoc-string lang org-latex-polyglossia-language-alist t)) > lang)))) > > This borks my latex exports. This is unrelated to the error you are seeing. void-variable error is thrown for org-latex-babel-language-alist, so I still suggest checking the place in your config where you are loading Org. However, you did raise an important omission in the patch - the variable value was lost in the patch. It was not supposed to happen. I now restored (in 127e7fee4) the defconst statements and moved them into org-compat.el. Thus, they can be used by third-party code for the time being. Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 14:22 ` Ihor Radchenko @ 2022-07-23 14:39 ` Kai von Fintel 2022-07-23 14:50 ` Ihor Radchenko 2022-07-23 14:53 ` Juan Manuel Macías 0 siblings, 2 replies; 50+ messages in thread From: Kai von Fintel @ 2022-07-23 14:39 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode, maciaschain On 23 Jul 2022, at 17:22, Ihor Radchenko wrote: > Kai von Fintel <fintel@mit.edu> writes: > >>>>> Debugger entered--Lisp error: (void-variable org-latex-babel-language-alist) >>>>> org-latex--format-spec( >>> >>> org-latex-babel-language-alist is the new variable introduced in the >>> patch. You seem to be loading "mixed" Org versions - built-in + latest. >> >> No, I’m looking just at the HEAD version of =ox-latex.el= at https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox-latex.el >> >> The new variable is =org-latex-language-alist=, defined on line 175f. >> >> But, =org-latex—format-spec=, defined on line 1860ff, uses the old variable names: >> >> (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))) >> (or (cdr (assoc-string lang org-latex-babel-language-alist t)) >> (nth 1 (assoc-string lang org-latex-polyglossia-language-alist t)) >> lang)))) >> >> This borks my latex exports. > > This is unrelated to the error you are seeing. void-variable error is > thrown for org-latex-babel-language-alist, so I still suggest checking > the place in your config where you are loading Org. > > However, you did raise an important omission in the patch - the variable > value was lost in the patch. It was not supposed to happen. I now > restored (in 127e7fee4) the defconst statements and moved them into > org-compat.el. Thus, they can be used by third-party code for the time > being. Thanks, Ihor. Your change fixed my issue. I do think that the code on lines 1864 and 1865 of =ox-latex.el= (https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox-latex.el#n1864) should not use the old variable names. Since you’ve now defined the old variables in =org-compat.el=, my exports work, so I’m ok for the moment. But I don’t understand why they are still used in the definition of =org-latex--format-spec=. But of course I’m far from familiar with the org code base. — Kai. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 14:39 ` Kai von Fintel @ 2022-07-23 14:50 ` Ihor Radchenko 2022-07-23 15:53 ` Juan Manuel Macías 2022-07-23 14:53 ` Juan Manuel Macías 1 sibling, 1 reply; 50+ messages in thread From: Ihor Radchenko @ 2022-07-23 14:50 UTC (permalink / raw) To: Kai von Fintel, Juan Manuel Macías; +Cc: emacs-orgmode, maciaschain Kai von Fintel <fintel@mit.edu> writes: >>> (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))) >>> (or (cdr (assoc-string lang org-latex-babel-language-alist t)) >>> (nth 1 (assoc-string lang org-latex-polyglossia-language-alist t)) >>> lang)))) >>> >>> This borks my latex exports. > ... > Thanks, Ihor. Your change fixed my issue. > > I do think that the code on lines 1864 and 1865 of =ox-latex.el= (https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox-latex.el#n1864) should not use the old variable names. Since you’ve now defined the old variables in =org-compat.el=, my exports work, so I’m ok for the moment. But I don’t understand why they are still used in the definition of =org-latex--format-spec=. > > But of course I’m far from familiar with the org code base. Hmm. You are actually right. Juan, can you please take a look. It looks like you missed "org-latex--format-spec" in the patch. It should use the new org-latex-language-alist variable instead. Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 14:50 ` Ihor Radchenko @ 2022-07-23 15:53 ` Juan Manuel Macías 2022-07-24 7:15 ` Ihor Radchenko 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-23 15:53 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Kai von Fintel, orgmode [-- Attachment #1: Type: text/plain, Size: 372 bytes --] Hi Ihor and Kai, Ihor Radchenko writes: > Hmm. You are actually right. > Juan, can you please take a look. It looks like you missed > "org-latex--format-spec" in the patch. It should use the new > org-latex-language-alist variable instead. Attached a new patch to fix (I hope) the org-latex-language-alist issue in org-latex--format-spec. Best regards, Juan Manuel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-lisp-ox-latex.el-Fix-obsolete-variables-for-babel-an.patch --] [-- Type: text/x-patch, Size: 1554 bytes --] From 95ce88336f6d2106968250379767ce2fe690fe2c Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias <maciaschain@posteo.net> Date: Sat, 23 Jul 2022 17:42:50 +0200 Subject: [PATCH] lisp/ox-latex.el: Fix obsolete variables for babel and polyglossia * (org-latex--format-spec): Use the new variable `org-latex-language-alist' --- lisp/ox-latex.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 6cd751409..ee059d5ce 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1860,10 +1860,12 @@ 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))) - (or (cdr (assoc-string lang org-latex-babel-language-alist t)) - (nth 1 (assoc-string lang org-latex-polyglossia-language-alist t)) - lang)))) + (let ((language (let* ((lang (plist-get info :language)) + (l (assoc lang org-latex-language-alist))) + (cond ((and (consp l) (= (length l) 4)) + (nth 2 (assoc-string lang org-latex-language-alist t))) + ((and (consp l) (< (length l) 4)) + (nth 1 (assoc-string lang org-latex-language-alist t))))))) `((?a . ,(org-export-data (plist-get info :author) info)) (?t . ,(org-export-data (plist-get info :title) info)) (?s . ,(org-export-data (plist-get info :subtitle) info)) -- 2.37.1 ^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 15:53 ` Juan Manuel Macías @ 2022-07-24 7:15 ` Ihor Radchenko 2022-07-24 11:29 ` Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Ihor Radchenko @ 2022-07-24 7:15 UTC (permalink / raw) To: Juan Manuel Macías; +Cc: Kai von Fintel, orgmode Juan Manuel Macías <maciaschain@posteo.net> writes: >> Hmm. You are actually right. >> Juan, can you please take a look. It looks like you missed >> "org-latex--format-spec" in the patch. It should use the new >> org-latex-language-alist variable instead. > > Attached a new patch to fix (I hope) the org-latex-language-alist issue > in org-latex--format-spec. Thanks! > + (let ((language (let* ((lang (plist-get info :language)) > + (l (assoc lang org-latex-language-alist))) > + (cond ((and (consp l) (= (length l) 4)) > + (nth 2 (assoc-string lang org-latex-language-alist t))) > + ((and (consp l) (< (length l) 4)) > + (nth 1 (assoc-string lang org-latex-language-alist t))))))) Can you please add the comments, similar to what I requested earlier. These magic length of 4 may be hard to grasp otherwise. Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-24 7:15 ` Ihor Radchenko @ 2022-07-24 11:29 ` Juan Manuel Macías 2022-07-26 11:58 ` Ihor Radchenko 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-24 11:29 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode [-- Attachment #1: Type: text/plain, Size: 549 bytes --] Ihor Radchenko writes: > Can you please add the comments, similar to what I requested earlier. > These magic length of 4 may be hard to grasp otherwise. Hi Ihor, Here is the new patch. I have realized that it is not necessary to put a cond, since in this case it is only necessary to obtain the name of the language for the metadata, so this new patch is simpler. Anyway, I think I'm going to prioritize working on a new org-latex-language-alist that is a plist, to avoid all this stuff about numbers and lengths... Best regards, Juan Manuel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-lisp-ox-latex.el-Fix-obsolete-variables-for-babel-an.patch --] [-- Type: text/x-patch, Size: 1497 bytes --] From 7f3ddd0d2e6e06becd0d43575be88b77b8d699a4 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias <maciaschain@posteo.net> Date: Sun, 24 Jul 2022 13:20:25 +0200 Subject: [PATCH] lisp/ox-latex.el: Fix obsolete variables for babel and polyglossia * (org-latex--format-spec): Use the new variable `org-latex-language-alist'. --- lisp/ox-latex.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 6cd751409..aea602982 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1860,10 +1860,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))) - (or (cdr (assoc-string lang org-latex-babel-language-alist t)) - (nth 1 (assoc-string lang org-latex-polyglossia-language-alist t)) - lang)))) + (let ((language (let ((lang (plist-get info :language)) + ;; Here it would suffice to obtain the second + ;; element, which always returns the name + ;; language name in `org-latex-language-alist' + (nth 1 (assoc-string lang org-latex-language-alist t)))))) `((?a . ,(org-export-data (plist-get info :author) info)) (?t . ,(org-export-data (plist-get info :title) info)) (?s . ,(org-export-data (plist-get info :subtitle) info)) -- 2.37.1 ^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-24 11:29 ` Juan Manuel Macías @ 2022-07-26 11:58 ` Ihor Radchenko 2022-07-26 16:19 ` Juan Manuel Macías 0 siblings, 1 reply; 50+ messages in thread From: Ihor Radchenko @ 2022-07-26 11:58 UTC (permalink / raw) To: Juan Manuel Macías; +Cc: orgmode Juan Manuel Macías <maciaschain@posteo.net> writes: > Here is the new patch. I have realized that it is not necessary to put a > cond, since in this case it is only necessary to obtain the name of the > language for the metadata, so this new patch is simpler. Thanks for the update! The patch has some misplaced parenthesis. > - (let ((language (let ((lang (plist-get info :language))) > - (or (cdr (assoc-string lang org-latex-babel-language-alist t)) > - (nth 1 (assoc-string lang org-latex-polyglossia-language-alist t)) > - lang)))) > + (let ((language (let ((lang (plist-get info :language)) > + ;; Here it would suffice to obtain the second > + ;; element, which always returns the name > + ;; language name in `org-latex-language-alist' > + (nth 1 (assoc-string lang org-latex-language-alist t)))))) Your (nth 1 ...) sexp is inside the let definition: (let ((lang ...) (nth 1 ..)) nil) Please pay attention to the compiler warnings. Also, the original code contained the clause: (or (get lang from the alist1) (get lang from the alist2) lang ; Fallback to provided language if not known. ) Your variant does not have the fallback part. Is it intentional? Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-26 11:58 ` Ihor Radchenko @ 2022-07-26 16:19 ` Juan Manuel Macías 2022-07-28 12:36 ` Ihor Radchenko 0 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-26 16:19 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode [-- Attachment #1: Type: text/plain, Size: 782 bytes --] Hi Ihor, A thousand apologies for my horrible carelessness with the parentheses. I should have checked the code. Here goes the patch again corrected. I hope it's alright now. Ihor Radchenko writes: > Also, the original code contained the clause: > (or (get lang from the alist1) > (get lang from the alist2) > lang ; Fallback to provided language if not known. > ) > > Your variant does not have the fallback part. Is it intentional? Yes, I removed it because I thought it was not necessary, because after all the user must put a supported language as the value of #+language. Anyway, in case it breaks something backwards I have replaced it. Now the or expression is: (or (nth 1 (assoc-string lang org-latex-language-alist t)) lang) Best regards, Juan Manuel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-lisp-ox-latex.el-Remove-Babel-and-Polyglossia-alists.patch --] [-- Type: text/x-patch, Size: 1324 bytes --] From 483cf69e0ca56c560c3bd53db13887a63d529ec9 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias <maciaschain@posteo.net> Date: Tue, 26 Jul 2022 18:01:52 +0200 Subject: [PATCH] lisp/ox-latex.el: Remove Babel and Polyglossia alists * (org-latex--format-spec): The new variable is now `org-latex-language-alist' --- lisp/ox-latex.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 121a3f84c..14728f0ba 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1861,8 +1861,10 @@ INFO is a plist used as a communication channel." "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))) - (or (cdr (assoc-string lang org-latex-babel-language-alist t)) - (nth 1 (assoc-string lang org-latex-polyglossia-language-alist t)) + ;; Here it would suffice to obtain the second + ;; element, which always returns the name + ;; language name in `org-latex-language-alist' + (or (nth 1 (assoc-string lang org-latex-language-alist t)) lang)))) `((?a . ,(org-export-data (plist-get info :author) info)) (?t . ,(org-export-data (plist-get info :title) info)) -- 2.37.1 ^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-26 16:19 ` Juan Manuel Macías @ 2022-07-28 12:36 ` Ihor Radchenko 0 siblings, 0 replies; 50+ messages in thread From: Ihor Radchenko @ 2022-07-28 12:36 UTC (permalink / raw) To: Juan Manuel Macías; +Cc: orgmode Juan Manuel Macías <maciaschain@posteo.net> writes: > A thousand apologies for my horrible carelessness with the parentheses. > I should have checked the code. Here goes the patch again corrected. I > hope it's alright now. Thanks! Applied onto main via d37c0ee5f after adding full stop after sentences in the commit message and amending some wording. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d37c0ee5fa7dc4be4bbe3aa9b6f4e79d4b1e638d Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 14:39 ` Kai von Fintel 2022-07-23 14:50 ` Ihor Radchenko @ 2022-07-23 14:53 ` Juan Manuel Macías 1 sibling, 0 replies; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-23 14:53 UTC (permalink / raw) To: Kai von Fintel; +Cc: orgmode, Ihor Radchenko Hi Kai, Kai von Fintel writes: > I do think that the code on lines 1864 and 1865 of =ox-latex.el= > (https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox-latex.el#n1864) > should not use the old variable names. Since you’ve now defined the > old variables in =org-compat.el=, my exports work, so I’m ok for the > moment. But I don’t understand why they are still used in the > definition of =org-latex--format-spec=. I think you're right. My bad, sorry for that: I have not accounted for `org-latex--format-spec' in my patch. I will send a new patch soon to fix this. Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 5:01 ` [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Ihor Radchenko 2022-07-23 13:44 ` BUG " Kai von Fintel @ 2022-07-23 14:11 ` Juan Manuel Macías 2022-07-23 14:25 ` Ihor Radchenko 2022-07-23 15:29 ` Max Nikulin 2 siblings, 1 reply; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-23 14:11 UTC (permalink / raw) To: Ihor Radchenko; +Cc: orgmode Ihor Radchenko writes: > Thanks! Considering that the followup discussion deviated from the > substance of the patch towards related design issues, I have decided to > marge the patch as is. We can decide on handling AUTO staff later - it > would be a major change to remove and the details of an alternative are > not yet worked out. > > Applied onto main via 97cfb959d after adding some double spaces > between sentences and upcasing the beginning of some sentences. Thanks, Ihor. And sorry again for my typos... If it's okay with you, I can send another patch with the updated information in NEWS and the Manual. And we can continue the subsequent discussion related of babel, polyglossia et alii in another thread. Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 14:11 ` Juan Manuel Macías @ 2022-07-23 14:25 ` Ihor Radchenko 0 siblings, 0 replies; 50+ messages in thread From: Ihor Radchenko @ 2022-07-23 14:25 UTC (permalink / raw) To: Juan Manuel Macías; +Cc: orgmode Juan Manuel Macías <maciaschain@posteo.net> writes: > Ihor Radchenko writes: > > Thanks, Ihor. And sorry again for my typos... No problem. > If it's okay with you, I can send another patch with the updated > information in NEWS and the Manual. And we can continue the subsequent > discussion related of babel, polyglossia et alii in another thread. Sure. Or you can keep the same thread, probably changing the subject to something people can notice better (M-x message-change-subject). Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 5:01 ` [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Ihor Radchenko 2022-07-23 13:44 ` BUG " Kai von Fintel 2022-07-23 14:11 ` Juan Manuel Macías @ 2022-07-23 15:29 ` Max Nikulin 2022-07-24 7:23 ` Ihor Radchenko 2 siblings, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-23 15:29 UTC (permalink / raw) To: emacs-orgmode On 23/07/2022 12:01, Ihor Radchenko wrote: > Juan Manuel Macías writes: > >> Here is a new version of the patch, with the fixes added. > > Thanks! Considering that the followup discussion deviated from the > substance of the patch towards related design issues, I believed that the subject of discussion is how much values should be added to the alist in addition to babel and polyglossia options: fontenc, paper size, etc. I hope, not so much third party packages use the changed variables, so committing the patch can hardly be harmful even in the case of additional change of the list format in future. ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-23 15:29 ` Max Nikulin @ 2022-07-24 7:23 ` Ihor Radchenko 0 siblings, 0 replies; 50+ messages in thread From: Ihor Radchenko @ 2022-07-24 7:23 UTC (permalink / raw) To: Max Nikulin; +Cc: emacs-orgmode Max Nikulin <manikulin@gmail.com> writes: > On 23/07/2022 12:01, Ihor Radchenko wrote: >> Juan Manuel Macías writes: >> >>> Here is a new version of the patch, with the fixes added. >> >> Thanks! Considering that the followup discussion deviated from the >> substance of the patch towards related design issues, > > I believed that the subject of discussion is how much values should be > added to the alist in addition to babel and polyglossia options: > fontenc, paper size, etc. Adding things like paper size is a much more debatable topic. Considering the number of expected developments in this area, including the earlier discussion on XeLaTeX/LuaTeX and preamble generation by TEC, adding the new specific defaults will need to be a subject of extensive discussion and testing. I do not see much point delaying this patch, which provides an immediate improvement in the codebase, until we complete all that. > I hope, not so much third party packages use the changed variables, so > committing the patch can hardly be harmful even in the case of > additional change of the list format in future. This alist is rather internal variable representing current defaults. I am not even sure how it can be useful for third-party packages. It should not be modified by packages either (defconst). Best, Ihor ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2021-10-03 15:28 [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Juan Manuel Macías 2022-07-10 9:25 ` Ihor Radchenko @ 2022-07-10 10:51 ` Max Nikulin 2022-07-15 15:38 ` Juan Manuel Macías 1 sibling, 1 reply; 50+ messages in thread From: Max Nikulin @ 2022-07-10 10:51 UTC (permalink / raw) To: emacs-orgmode On 03/10/2021 22:28, Juan Manuel Macías wrote: > 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' I would consider structures with named fields (alists or plists) for a case of adding some additional settings (Font name? But it is rather defcustom than defconst) ("es" . (:babel "spanishmx" :poliglossia "spanish" :poliglossia-variant "mexican") ^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists 2022-07-10 10:51 ` Max Nikulin @ 2022-07-15 15:38 ` Juan Manuel Macías 0 siblings, 0 replies; 50+ messages in thread From: Juan Manuel Macías @ 2022-07-15 15:38 UTC (permalink / raw) To: Max Nikulin; +Cc: orgmode, Ihor Radchenko Max Nikulin writes: > I would consider structures with named fields (alists or plists) for a > case of adding some additional settings (Font name? But it is rather > defcustom than defconst) > > ("es" . (:babel "spanishmx" :poliglossia "spanish" > :poliglossia-variant "mexican") I was paying more attention to the fontenc issue and I had forgotten to comment this. I think your proposal to use a property list makes sense. But I don't quite see what new settings could be added without overcomplicating things. Babel in its latest versions has several ways to load languages, and many new commands to select fonts or associate font families to a specific language or script. But they don't work with pdfLaTeX, so the only thing I could think of is to keep the old babel method, valid for all TeX engines, according to which, if a user puts in an org document: #+language: es #+latex_header: \usepackage[foo,AUTO]{babel} it returns: \usepackage[foo,spanish]{babel} which is valid for all flavors of TeX. And I think that this way, as Org was doing so far, it will satisfy most users. But given the syntactical variety that babel now has (polyglossia is simpler), I don't see how all of that could be 'translated' to Org via Org settings. I think this is one of those cases where it's easier for the user to just build the LaTeX preamble writing LaTeX code or create a new 'class' for org-latex-classes. The problem with Org writing the preamble for the user is that it will never satisfy all users. That is why I think it is necessary for this 'automatic' preamble to be as basic and elementary as possible (I, for example, always write the preamble from scratch or write my own sty files). Otherwise we run the risk of converting, or wanting to convert, Org into a clone of LaTeX, but less flexible than LaTeX. I agree that most Org users (like most Pandoc users) just want to produce a clean pdf without messing with LaTeX. But if users want to do more things in LaTeX, they should know some LaTeX, even if they prefer to use a lightweight markup language as a latex 'interface'. That's why I think it's great that in Org you can enter arbitrary LaTeX (or html) code anywhere and at many levels. I think this is the real killer feature of Org. I don't know if I'm explaining myself... But this reflection of mine (which, of course, is debatable) would take us further, and this is not the case here. Other than that, your idea of using a property list sounds good to me. What happens is that I do not see a clear advantage (at least in the short term). Best regards, Juan Manuel ^ permalink raw reply [flat|nested] 50+ messages in thread
end of thread, other threads:[~2022-07-28 12:38 UTC | newest] Thread overview: 50+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-10-03 15:28 [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Juan Manuel Macías 2022-07-10 9:25 ` Ihor Radchenko 2022-07-14 12:34 ` Juan Manuel Macías 2022-07-14 15:12 ` Max Nikulin 2022-07-14 15:53 ` Juan Manuel Macías 2022-07-14 18:17 ` Juan Manuel Macías 2022-07-15 12:18 ` Max Nikulin 2022-07-15 14:36 ` Juan Manuel Macías 2022-07-17 9:55 ` Ihor Radchenko 2022-07-17 14:48 ` Juan Manuel Macías 2022-07-18 6:44 ` Ihor Radchenko 2022-07-18 10:32 ` Juan Manuel Macías 2022-07-18 11:01 ` Juan Manuel Macías 2022-07-18 15:37 ` Max Nikulin 2022-07-18 16:21 ` Juan Manuel Macías 2022-07-19 15:01 ` Juan Manuel Macías 2022-07-19 17:01 ` Max Nikulin 2022-07-19 19:31 ` Juan Manuel Macías 2022-07-20 16:12 ` Max Nikulin 2022-07-20 21:30 ` Juan Manuel Macías 2022-07-21 14:36 ` Max Nikulin 2022-07-21 15:39 ` Juan Manuel Macías 2022-07-22 12:16 ` Max Nikulin 2022-07-22 12:49 ` Juan Manuel Macías 2022-07-22 14:07 ` Juan Manuel Macías 2022-07-23 15:19 ` Max Nikulin 2022-07-23 17:15 ` Improvements in the default LaTeX preamble (was: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists) Juan Manuel Macías 2022-07-24 12:06 ` Improvements in the default LaTeX preamble: templates? " Juan Manuel Macías 2022-07-25 9:31 ` Ihor Radchenko 2022-07-25 10:45 ` Improvements in the default LaTeX preamble: templates? Juan Manuel Macías 2022-07-23 5:01 ` [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists Ihor Radchenko 2022-07-23 13:44 ` BUG " Kai von Fintel 2022-07-23 13:59 ` Ihor Radchenko 2022-07-23 14:07 ` Kai von Fintel 2022-07-23 14:22 ` Ihor Radchenko 2022-07-23 14:39 ` Kai von Fintel 2022-07-23 14:50 ` Ihor Radchenko 2022-07-23 15:53 ` Juan Manuel Macías 2022-07-24 7:15 ` Ihor Radchenko 2022-07-24 11:29 ` Juan Manuel Macías 2022-07-26 11:58 ` Ihor Radchenko 2022-07-26 16:19 ` Juan Manuel Macías 2022-07-28 12:36 ` Ihor Radchenko 2022-07-23 14:53 ` Juan Manuel Macías 2022-07-23 14:11 ` Juan Manuel Macías 2022-07-23 14:25 ` Ihor Radchenko 2022-07-23 15:29 ` Max Nikulin 2022-07-24 7:23 ` Ihor Radchenko 2022-07-10 10:51 ` Max Nikulin 2022-07-15 15:38 ` Juan Manuel Macías
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.