emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ox-latex: fix `org-latex-guess-babel-language'
@ 2022-11-14 22:46 Juan Manuel Macías
  2022-11-15  1:54 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Juan Manuel Macías @ 2022-11-14 22:46 UTC (permalink / raw)
  To: orgmode

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

If the user puts a string other than AUTO as an argument to
`\babelprovide', it gives an error when exporting. For example:

`#+LaTeX_Header: \babelprovide[<options>]{hebrew}'

I am attaching a patch to fix that behaviour.

Best regards,

Juan Manuel 


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ox-latex.el-fix-org-latex-guess-babel-language.patch --]
[-- Type: text/x-patch, Size: 1450 bytes --]

From 6dcba41f58b355296c3cacf97be9508581e1a10a Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias <maciaschain@posteo.net>
Date: Mon, 14 Nov 2022 23:33:16 +0100
Subject: [PATCH] lisp/ox-latex.el: fix `org-latex-guess-babel-language'

* (org-latex-guess-babel-language): If the user puts a string other
than AUTO as an argument to `\babelprovide', it gives an error when
exporting. For example:

`#+LaTeX_Header: \babelprovide[onchar=ids,import]{hebrew}'
---
 lisp/ox-latex.el | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9bdb9fb63..095f6b51c 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1669,12 +1669,13 @@ Return the new header."
     (if (not (string-match "\\\\babelprovide\\[.*\\]{\\(.+\\)}" header))
 	header
       (let ((prov (match-string 1 header)))
-	(when (equal "AUTO" prov)
-	  (replace-regexp-in-string (format
-				     "\\(\\\\babelprovide\\[.*\\]\\)\\({\\)%s}" prov)
-				    (format "\\1\\2%s}"
-					    (or language language-ini-only))
-				    header t))))))
+	(if (equal "AUTO" prov)
+	    (replace-regexp-in-string (format
+				       "\\(\\\\babelprovide\\[.*\\]\\)\\({\\)%s}" prov)
+				      (format "\\1\\2%s}"
+					      (or language language-ini-only))
+				      header t)
+	  header)))))
 
 (defun org-latex-guess-polyglossia-language (header info)
   "Set the Polyglossia language according to the LANGUAGE keyword.
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ox-latex: fix `org-latex-guess-babel-language'
  2022-11-14 22:46 [PATCH] ox-latex: fix `org-latex-guess-babel-language' Juan Manuel Macías
@ 2022-11-15  1:54 ` Ihor Radchenko
  2022-11-17 14:48   ` Juan Manuel Macías
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2022-11-15  1:54 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

Juan Manuel Macías <maciaschain@posteo.net> writes:

> If the user puts a string other than AUTO as an argument to
> `\babelprovide', it gives an error when exporting. For example:
>
> `#+LaTeX_Header: \babelprovide[<options>]{hebrew}'
>
> I am attaching a patch to fix that behaviour.

Thanks!
Could you also add a test to testing/lisp/test-ox-latex.el?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ox-latex: fix `org-latex-guess-babel-language'
  2022-11-15  1:54 ` Ihor Radchenko
@ 2022-11-17 14:48   ` Juan Manuel Macías
  2022-11-18  8:31     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Juan Manuel Macías @ 2022-11-17 14:48 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: orgmode

Hi, Ihor, sorry for the late replay,

Ihor Radchenko writes:

>> If the user puts a string other than AUTO as an argument to
>> `\babelprovide', it gives an error when exporting. For example:
>>
>> `#+LaTeX_Header: \babelprovide[<options>]{hebrew}'
>>
>> I am attaching a patch to fix that behaviour.
>
> Thanks!
> Could you also add a test to testing/lisp/test-ox-latex.el?

I'm afraid I'm not going to be able to do it in the short term, because
these days I'm going through a serious family problem, my mother is
admitted to the hospital, and I don't think I'm going to have time to
attend to this list.

Best regards,

Juan Manuel 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ox-latex: fix `org-latex-guess-babel-language'
  2022-11-17 14:48   ` Juan Manuel Macías
@ 2022-11-18  8:31     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-11-18  8:31 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

Juan Manuel Macías <maciaschain@posteo.net> writes:

>> Thanks!
>> Could you also add a test to testing/lisp/test-ox-latex.el?
>
> I'm afraid I'm not going to be able to do it in the short term, because
> these days I'm going through a serious family problem, my mother is
> admitted to the hospital, and I don't think I'm going to have time to
> attend to this list.

Sorry to hear this.

I applied your patch as is. It is anyway an improvement.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fcf63fb31

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-18  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-14 22:46 [PATCH] ox-latex: fix `org-latex-guess-babel-language' Juan Manuel Macías
2022-11-15  1:54 ` Ihor Radchenko
2022-11-17 14:48   ` Juan Manuel Macías
2022-11-18  8:31     ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).