Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow bidi to be loaded early #29

Open
4 tasks
Udi-Fogiel opened this issue Aug 10, 2023 · 5 comments
Open
4 tasks

Allow bidi to be loaded early #29

Udi-Fogiel opened this issue Aug 10, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@Udi-Fogiel
Copy link

Brief outline of the feature request

Check/indicate

Today, with LaTeX's new hook system it is possible to define \bidi@isloaded in such a way that bidi could be load in any order with respect to other packages. one option could be

\newcommand\bidi@isloaded[1]{
      \@ifpackageloaded{#1}%
            {\input{#1-xetex-bidi.def}}%
            {\AddToHook{package/#1/after}{\input{#1-xetex-bidi.def}}}
}

and removing the the begindocument hook from lodingorder-xetex-bidi.def and also removing the loading of the .def files from ltx-xetex-bidi.def (or moving \bidi@isloaded to there).

This is just a suggestion, I'm not sure if anything else would also be needed, but I hope this demonstrate the idea, it could make things much simpler...

@Udi-Fogiel Udi-Fogiel added the enhancement New feature or request label Aug 10, 2023
@kvafa
Copy link
Owner

kvafa commented Aug 22, 2023

Thanks for the suggestion. This is quite tricky and it needs a lot of testing to make sure that it does not break anything since the bidi package current approach has existed for at least 2 decades and I do not want to break anything for users.

From memory, I was in the past 10 years was thinking of doing something similar; at the time, the package hopatch of Heiko Oberdiek existed and I experimented with it but from memory, it was not working in some cases (sadly, I can not remember those specific cases/examples).

Having said that, I willl look into this when I have time and will release an experimental version so people can test.

@Udi-Fogiel
Copy link
Author

It should not affect old documents, as all the current documents that use bidi have to load packages before bidi is loaded, and in that case the all the .def files will be \input'ed at the same order as they use to.

@Udi-Fogiel
Copy link
Author

But my first suggestion wasn't considering catcodes:

\newcommand*\bidi@restore@catcode{}
\newcommand\bidi@isloaded[1]{
      \@ifpackageloaded{#1}%
            {\input{#1-xetex-bidi.def}}%
            {\AddToHook{package/#1/after}{
               \edef\bidi@restore@catcode{\catcode`\@=\the\catcode`\@}
               \makeatletter
               \input{#1-xetex-bidi.def}
               \bidi@restore@catcode
        }
    }
}

@kvafa
Copy link
Owner

kvafa commented Oct 28, 2023

It should not affect old documents, as all the current documents that use bidi have to load packages before bidi is loaded, and in that case the all the .def files will be \input'ed at the same order as they use to.

It is not that simple.

@Udi-Fogiel
Copy link
Author

It is not that simple.

I know you are currently very busy, but if you can elaborate a little bit more, I'll be happy to learn how could that potentially affect already existing documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants