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

Make ~ active in docstrip's initex mode #636

Closed
vlasakm opened this issue Aug 1, 2021 · 5 comments
Closed

Make ~ active in docstrip's initex mode #636

vlasakm opened this issue Aug 1, 2021 · 5 comments

Comments

@vlasakm
Copy link

vlasakm commented Aug 1, 2021

Brief outline of the enhancement

I am using docstrip.dtx to process a few .ins files with initex. However, recently one of those .ins files started to expect that \catcode`\~=13. I usually make these adjustments before processing the .ins files, like this:

luatex -ini '\let\obeyspaces=\relax \input lipsum.ins'

This is not possible with for the ~ catcode, because that is how docstrip detects, that it is not run under initex:

\ifnum13=\catcode`\~{\egroup\else
  \catcode`\Z=9
  ...
\fi

Would it be possible to set the \catcode of ~ to 13 in this "plain TeX compatibility" piece of code?

LaTeX2e generally cannot add new features without an extreme amount of care to accommodate backwards compatibility. Please do not be offended if your request is closed for being infeasible.

I am perfectly fine with patching around for my dubious use case. I understand that this subtle change is not desirable after such a long time.

Minimal example showing the current behaviour

$ luatex -ini '\let\obeyspaces\relax \input lipsum.ins'
...
! Missing control sequence inserted.

Because of \def~{ }%

Minimal example showing the desired new behaviour

With:

--- a/docstrip.dtx
+++ b/docstrip.dtx
@@ -1018,6 +1018,7 @@
 Z  \catcode`\{=1  \catcode`\}=2
 Z  \catcode`\#=6  \catcode`\^=7
 Z  \catcode`\@=11 \catcode`\^^L=13
+Z  \catcode`\~=13
 Z  \let\bgroup={  \let\egroup=}
 Z
 Z  \dimendef\z@=10 \z@=0pt \chardef\@ne=1 \countdef\m@ne=22 \m@ne=-1
$ luatex -ini '\let\obeyspaces\relax \input lipsum.ins'
(no error)

Context: vlasakm/mmtex#3

@PhelypeOleinik
Copy link
Member

However, recently one of those .ins files started to expect that \catcode`\~=13.

Part of the blame is mine ;-)

I could change lipsum.ins to ensure ~ is active for whatever it needs: at the lipsum side this is a harmless change. Less so for docstrip.

Makes me wonder though: why use initex for unpacking?

@vlasakm
Copy link
Author

vlasakm commented Aug 1, 2021

I could change lipsum.ins to ensure ~ is active for whatever it needs: at the lipsum side this is a harmless change. Less so for docstrip.

That was going to be my second suggestion, if you were so kind to do so. Third option being patching around it myself (I wouldn't want anyone actively maintaining my use case).

I just though that it was inconsistent for docstrip to check for a setting to detect iniTeX, but the setting is not actually needed (and hence not set). That is why this was my first try at remedying the issue at hand.

Makes me wonder though: why use initex for unpacking?

I bootstrap a small TeX distribution (LuaTeX + OpTeX + a few packages) from a few sources. Essentially I do:

# use docstrip.dtx as docstrip.tex and l3docstrip.tex
ln -sf docstrip.dtx docstrip.tex
ln -sf docstrip.dtx l3docstrip.tex

# generate lipsum.ltd.tex
luatex -ini '\let\obeyspaces=\relax \input lipsum.ins'

# generate luamplib.{sty.lua}
luatex -ini '\catcode`\{=1 \catcode`\}=2 \let\obeyspaces\relax \input luamplib.dtx'

# generate some lualibs files
luatex -ini '\catcode`\{=1 \catcode`\}=2 \let\obeyspaces\relax \input lualibs.dtx'

Processing the few .ins files with plain would require me to generate the plain format itself (which requires fonts). Docstrip with initex was good enough for now.

By the way, while bothering you, I believe you can use docstrip.tex instead of l3docstrip.tex :).

@PhelypeOleinik
Copy link
Member

Processing the few .ins files with plain would require me to generate the plain format itself (which requires fonts).

Ah, minimal setups :-)

I'd say providing plain is a must for any TeX distribution (kind of “the basics”), but that's digressing. I'll change the .ins file for lipsum.

@vlasakm
Copy link
Author

vlasakm commented Aug 2, 2021

Thank you very much, @PhelypeOleinik. That solves my issue quite well.

I still think the proposed change would make sense. But not sure if there is a point in pursuing this since it would be one of only backwards incompatible changes in docstrip in a long time AFAICT. (But then again, who uses docstrip with initex to process something other than docstrip itself :)

Leaving the decision on closing the issue on you guys.

PS: @PhelypeOleinik I used to package (TeX Live's) plain LuaTeX as well, but later decided against it. Many things I wasn't really fond of are deeply rooted in -- fonts, eTeX's \languages. But that is a discussion for anonther place :)

@FrankMittelbach
Copy link
Member

I still think the proposed change would make sense. But not sure if there is a point in pursuing this since it would be one of only backwards incompatible changes in docstrip in a long time AFAICT. (But then again, who uses docstrip with initex to process something other than docstrip itself :)

I'm against making changes to docstrip for that. It is soooo core to basically everything (other than ConTeXt) so that it is bound to generate issues and history says it will. Don't think that is worth it. So it should be fixed in lipsum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants