Subject: Re: bug#42799: 12.2.0; reftex?: R2L, Hebrew: automatically labeling does not work for sections

From: Arash Esbati <[email-masked]>
Date: Mon, 10 Aug 2020 21:56:54 +0200

Hi Uwe,

Uwe Brauer <[email-masked]> writes:

> I am not sure whether this is more of a reftex bug. It is my
> understanding that even then, sending a Auctex bug is maybe correct if
> not tell me and I will resend the bug report to the GNU emacs bug mailing list.
> [...]
>
> Running LaTeX-section before \setRL and writing Introduction inserts
>  \section{Introduction}
>  \label{sec:introduction}
>
> Doing the same after \setRL
>
> LaTeX-section
> now inserting the hebrew word mavo מבוא either by turning in the
> X-window environment globally a hebrew keyboard, or much better, running 
> (set-input-method "hebrew" t) 
> in the minibuffer or 
>   (set-input-method "hebrew-phonetic-qwerty" t)
>
> And then typing the word מאוא
> results in 
>
> \section{מבוא}
> \label{sec:}
>
> But is should be 
>
> \section{מבוא}
> \label{sec:מבוא}

I don't think this is a bug in RefTeX, more a documented feature.
Looking at the manual, it says[1]:

    3.1 Creating Labels
    [...]
    1. A label can be derived from context. This means, RefTeX takes the
       context of the label definition and constructs a label from
       that\footnote{Note that the context may contain constructs which
       are invalid in labels. RefTeX will therefore strip the accent
       from accented Latin-1 characters and remove everything else which
       is not valid in labels. This mechanism is safe, but may not be
       satisfactory for non-western languages. Check the following
       variables if you need to change things:
       reftex-translate-to-ascii-function,
       reftex-derive-label-parameters, reftex-label-illegal-re,
       reftex-abbrev-parameters.[2]}

Not heavily tested but it should be sufficient to tweak
`reftex-label-illegal-re', maybe something like this:

    (setq reftex-label-illegal-re "[^-a-zA-Z0-9_+=:;,.א-ת]")

Want to give it a roll?

Best, Arash

Footnotes:
[1]  https://www.gnu.org/software/auctex/manual/reftex.html#SEC12

[2]  https://www.gnu.org/software/auctex/manual/reftex.html#FOOT1