Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-28 Thread Ihor Radchenko
Juan Manuel Macías  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



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-26 Thread Juan Manuel Macías
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 

>From 483cf69e0ca56c560c3bd53db13887a63d529ec9 Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias 
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



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-26 Thread Ihor Radchenko
Juan Manuel Macías  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



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-24 Thread Juan Manuel Macías
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

>From 7f3ddd0d2e6e06becd0d43575be88b77b8d699a4 Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias 
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



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-24 Thread Ihor Radchenko
Juan Manuel Macías  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



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-23 Thread Juan Manuel Macías
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 

>From 95ce88336f6d2106968250379767ce2fe690fe2c Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias 
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



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-23 Thread Juan Manuel Macías
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 



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-23 Thread Ihor Radchenko
Kai von Fintel  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



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-23 Thread Kai von Fintel



On 23 Jul 2022, at 17:22, Ihor Radchenko wrote:

> Kai von Fintel  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.



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-23 Thread Ihor Radchenko
Kai von Fintel  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



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-23 Thread Kai von Fintel
On 23 Jul 2022, at 16:59, Ihor Radchenko wrote:

> Kai von Fintel  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.



Re: BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-23 Thread Ihor Radchenko
Kai von Fintel  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



BUG Re: [PATCH] ox-latex.el: Unify in one single list Babel and Polyglossia languages alists

2022-07-23 Thread Kai von Fintel
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.