Subject: Re: bug#71364: Fix Table.el export

From: Pranshu <[email-masked]>
Date: Sat, 08 Jun 2024 12:10:32 +1000

> So you are saying that exporting to latex is basically completely
> broken in the current code?  Is that command use to export only to
> latex, or is the fact that the export is to latex is just one of the
> possibilities?

Yes.  The function that does the escaping is
`table--generate-source-scan-lines', which is a misleading name because
it is only called by table-generate-source when the language is exported
to latex.

>> What the diff does, is that it adds a variable that allows the user to
>> change what will be escaped.  Also as you can see in the above latex
>> table, the backslash had to be escaped in a different way, so using one
>> regexp variable would not be enough.  That is why the solution contains
>> a variable called 'table-source-latex-escape-characters', which is a
>> cons cell with the documentation:
>
> Why would a user need to customize this on the level of characters?
> Shouldn't there be a single boolean that causes latex-specific
> characters to be escape or not to be escaped, all of them or none?
>

The problem with that is that there are latex charecters such as '%',
which is comment, that will cause the whole table to break of not
escaped.

And since the variable is a regexp, it can possibly escape macros, such
as 'LaTeX' -> '\LaTeX'. 

>> A cons cell containing which charecters to escape in the latex source
>> of ‘table-generate-source’.  The head of the list, if non-nil contains a
>> regexp that matches all text that is to be adding a preceding backslash
>> to the matching text. If nil, no non-backslash charecters will be
>> escaped.  The tail, if non-nil, escapes all the backslashes in the latex
>> source.
>
> What is the purpose of the "tail", i.e. why would a user want to
> escape all the backslashes?

Mainly because some people might only use the latex export to turn their
table into a pdf, and escaping backslashes is not as simple as typing
two backslashes.  And also since it was the default behaviour, so those
who have already made tables will not need to escape all those
backslashes to make their documents exportable.

If you feel that is unnecessary, I can modify the diff not include
backslash escaping.

> Thanks.