summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/strc-usr.mkxl
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkxl/strc-usr.mkxl')
-rw-r--r--tex/context/base/mkxl/strc-usr.mkxl53
1 files changed, 34 insertions, 19 deletions
diff --git a/tex/context/base/mkxl/strc-usr.mkxl b/tex/context/base/mkxl/strc-usr.mkxl
index 28d398194..9ecb80ebd 100644
--- a/tex/context/base/mkxl/strc-usr.mkxl
+++ b/tex/context/base/mkxl/strc-usr.mkxl
@@ -91,21 +91,16 @@
\installcommandhandler \????userdata {userdata} \????userdata
\installcommandhandler \????userdataalternative {userdataalternative} \????userdataalternative
+\appendtoks
+ \frozen\protected\instance\edefcsname\e!start\currentuserdata\endcsname{\userdata_start_instance{\currentuserdata}}%
+ \frozen\protected\instance\letcsname \e!stop \currentuserdata\endcsname\userdata_stop_instance
+\to \everydefineuserdata
+
\permanent\protected\def\startuserdata
{\begingroup
\let\currentuserdata\empty
\doifelsenextoptionalcs\userdata_start_delayed\userdata_start_indeed}
-% This variant works only when the userdata instance exists while the assignment check
-% can also be used with undefined instances which falls back to the global settings.
-%
-% \def\userdata_start_delayed[#1]%
-% {\ifcsname\nameduserdatahash{\detokenize\expandafter{\normalexpanded{#1}}}\s!parent\endcsname
-% \expandafter\userdata_start_delayed_name
-% \else
-% \expandafter\userdata_start_delayed_parameters
-% \fi[#1]}
-
\def\userdata_start_delayed[#1]%
{\doifelseassignmentcs{#1}%
\userdata_start_delayed_parameters
@@ -121,15 +116,29 @@
\checkuserdataparent
\doifelsenextoptionalcs\userdata_start_delayed_parameters\userdata_start_indeed}
+\protected\tolerant\def\userdata_start_instance#1#*[#2]%
+ {\begingroup
+ \edef\currentuserdata{#1}%
+ \setupcurrentuserdata[#2]%
+ \grabbufferdatadirect
+ % {\s!userdata:\currentuserdata}%
+ {\s!userdata}% unnested, as before
+ {\e!start\currentuserdata}%
+ {\e!stop \currentuserdata}}
+
\def\userdata_start_indeed
- {\grabbufferdatadirect\s!userdata{\csstring\startuserdata}{\csstring\stopuserdata}}
+ {\grabbufferdatadirect
+ % {\s!userdata:\currentuserdata}%
+ {\s!userdata}% unnested, as before
+ {\csstring\startuserdata}%
+ {\csstring\stopuserdata}}
\permanent\protected\def\stopuserdata
- {\userdataparameter\c!before % HH: moved, so we obey the outer spacing
- \dostarttagged\t!userdata\currentuserdata % HH: added, maybe move up ?
+ {\userdataparameter\c!before
+ \dostarttagged\t!userdata\currentuserdata
\begingroup
\useuserdatastyleandcolor\c!style\c!color
- \usealignparameter\userdataparameter % HH: added
+ \usealignparameter\userdataparameter
\edef\currentuserdataalternative{\userdataparameter\c!alternative}%
\ifcsname\currentuserdataalternativehash\s!parent\endcsname \else
\let\currentuserdataalternative\s!default
@@ -139,14 +148,20 @@
\directsetup\p_renderingsetup
\endgroup
\dostoptagged
- \userdataparameter\c!after % HH: moved
+ \userdataparameter\c!after
\endgroup}
-\permanent\protected\def\getuserdata
- {\getbufferdata[\s!userdata]}
+\aliased\let\userdata_stop_instance\stopuserdata
+
+% kind of nested, when we need it:
+%
+% \permanent\tolerant\protected\def\getuserdata [#1]{\normalexpanded{\getbufferdata[\s!userdata:\ifparameter#1\or#1\else\currentuserdata\fi]}}
+% \permanent\tolerant\protected\def\getinlineuserdata[#1]{\normalexpanded{\inlinebuffer [\s!userdata:\ifparameter#1\or#1\else\currentuserdata\fi]}}
+
+% unnested, as before:
-\permanent\protected\def\getinlineuserdata
- {\inlinebuffer[\s!userdata]}
+\permanent\tolerant\protected\def\getuserdata [#1]{\getbufferdata[\s!userdata]}
+\permanent\tolerant\protected\def\getinlineuserdata[#1]{\inlinebuffer [\s!userdata]}
\defineuserdataalternative
[\s!default]