summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/optex/base/prefixed.opm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-10-19 21:11:48 +0000
committerKarl Berry <karl@freefriends.org>2020-10-19 21:11:48 +0000
commit491012922a13d8238adcfe81ceefe4d9852a6a2a (patch)
tree66919b72b696a53e80f448ff3f8bdd7c0e32cba5 /Master/texmf-dist/tex/luatex/optex/base/prefixed.opm
parentad4dbe382ae954f9cf663f99f601a309e1b57dd9 (diff)
optex (19oct20)
git-svn-id: svn://tug.org/texlive/trunk@56710 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/optex/base/prefixed.opm')
-rw-r--r--Master/texmf-dist/tex/luatex/optex/base/prefixed.opm55
1 files changed, 35 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/luatex/optex/base/prefixed.opm b/Master/texmf-dist/tex/luatex/optex/base/prefixed.opm
index a409a44697c..f3ed071be03 100644
--- a/Master/texmf-dist/tex/luatex/optex/base/prefixed.opm
+++ b/Master/texmf-dist/tex/luatex/optex/base/prefixed.opm
@@ -37,10 +37,10 @@
\_def \_pkglabel{}
\_def \_public {\_xargs \_publicA}
-\_def \_publicA #1{\_ea\_let \_ea#1\_csname \_pkglabel _\_csstring #1\_endcsname}
+\_def \_publicA #1{\_ea\_let \_ea#1\_csname _\_csstring #1\_endcsname}
\_def \_private {\_xargs \_privateA}
-\_def \_privateA #1{\_ea\_let \_csname \_pkglabel _\_csstring #1\_endcsname =#1}
+\_def \_privateA #1{\_ea\_let \_csname _\_csstring #1\_endcsname =#1}
\_public \public \private \xargs \ea ;
@@ -71,30 +71,40 @@
\_doc -----------------------------
The `\_mathsbon` and `\_mathsboff` are defined in `math-macros.opm` file.
- Now, we define the macro \`\_namespace` `{<pkg label>}` for package writers, see
- section~\ref[pkg-namespace].
+ Now, we define the macros
+ \`\_namespace` `{<pkg label>}`, \`\_resetnamespace` `{<pkg label>}`, \`\_endnamespace`,
+ \`\_nspublic` and \`\_nsprivate`
+ for package writers, see section~\ref[pkg-namespace].
\_cod -----------------------------
+\_def \_pkglabel{}
\_def\_namespace #1{%
\_ifcsname namesp:#1\_endcsname \_errmessage
{The name space "#1" is used already, it cannot be used twice}%
\_endinput
- \_else
- \_ea \_gdef \_csname namesp:#1\_endcsname {}%
- \_gdef \_pkglabel{_#1}%
- \_directlua{
- callback.register("process_input_buffer",
+ \_else \_resetnamespace{#1}\_fi
+}
+\_def\_resetnamespace #1{%
+ \_ea \_gdef \_csname namesp:#1\_endcsname {}%
+ \_gdef \_pkglabel{_#1}%
+ \_directlua{
+ callback.register_x("process_input_buffer",
function (str)
return string.gsub(str, "\_nbb[.]([a-zA-Z])", "\_nbb _#1_\_pcent 1")
end )
- }%
- \_gdef \_endcode {%
- \_ifmathsb \_mathsbon \_else \_mthsboff \_fi
- \_gdef \_pkglabel{_#1}%
- \_global \_let \_endcode=\_endinput
- \_endinput }%
- \_fi
+ }%
}
+\_def\_endnamespace {%
+ \_ifmathsb \_mathsbon \_else \_mathsboff \_fi
+ \_gdef \_pkglabel{}%
+}
+
+\_def \_nspublic {\_xargs \_nspublicA}
+\_def \_nspublicA #1{\_ea\_let \_ea#1\_csname \_pkglabel _\_csstring #1\_endcsname}
+
+\_def \_nsprivate {\_xargs \_nsprivateA}
+\_def \_nsprivateA #1{\_ea\_let \_csname \_pkglabel _\_csstring #1\_endcsname =#1}
+
\_endcode %----------------------------------------------------
@@ -222,14 +232,19 @@ is declared at the beginning of the macro file then all occurrences of
The macro writer can write (and backward can read his/her code) simply with
`\.foo`, `\.bar` control sequences and `\_<pkg>_foo`, `\_<pkg>_bar`
control sequences are processed internally.
-The scope of the \^`\_namespace` command ends at the \^`\_endcode` command
+The scope of the \^`\_namespace` command ends at the \^`\_endnamespace` command
or when another \^`\_namespace` is used. This command checks
if the same package label is not declared by the \^`\_namespace` twice.
-The \^`\public` macro does `\let\foo = \_<pkg>_foo` when
-\^`\_namespace{<pkg>}` is declared. And the \^`\private` macro does reverse
+The \^`\_nspublic` macro does `\let\foo = \_<pkg>_foo` when
+\^`\_namespace{<pkg>}` is declared. And the \^`\_nsprivate` macro does reverse
operation to it. Example: you can define `\def\.macro{...}` and then
-set it to the user name space by `\_public \macro;`.
+set it to the user name space by `\_nspublic \macro;`.
+
+Don't load another packages (which are using their own name space) inside your
+name space. Do load them before your \^`\_namespace`~`{<pkg>}` is
+initialized. Or close your name space by \^`\_endnamespace` and open it again
+(after other packages are loaded) by \^`\_resetnamespace`~`{<pkg>}`.
If the package writer needs to declare a control
sequence by \^`\newif`, then there is an exception of the rule described above. Use