diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2015-04-03 20:15:06 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2015-04-03 20:15:06 +0200 |
commit | f1cde6067499874bf126dfc6f5bedb598f117073 (patch) | |
tree | da8b4e8f480df5e4caa8149253ee6711b918784c /tex | |
parent | d48764d88ac59aa9b0130f1049892296a3eb4684 (diff) | |
download | context-f1cde6067499874bf126dfc6f5bedb598f117073.tar.gz |
2015-04-03 20:04:00
Diffstat (limited to 'tex')
207 files changed, 2141 insertions, 1291 deletions
diff --git a/tex/context/base/anch-bar.mkiv b/tex/context/base/anch-bar.mkiv index 844655155..b5df21a07 100644 --- a/tex/context/base/anch-bar.mkiv +++ b/tex/context/base/anch-bar.mkiv @@ -89,7 +89,7 @@ \advance\c_anch_sidebars_level\plusone \global\advance\c_anch_sidebars_n\plusone \c_anch_sidebars_current\c_anch_sidebars_n\relax % relax needed - \doifassignmentelse{#1} + \doifelseassignment{#1} {\edef\currentsidebar{\the\c_anch_sidebars_level}% \checksidebarparent \setupcurrentsidebar[#1]} @@ -213,7 +213,7 @@ \ifx\m_anch_marginrules_kind\empty \anch_sidebars_start[\v!margin][]% \else - \doifassignmentelse\m_anch_marginrules_kind + \doifelseassignment\m_anch_marginrules_kind {\anch_sidebars_start[\v!margin][#1]}% {\anch_marginrules_check{#1}% \anch_sidebars_start[\v!margin:#1][\c!level=#1]}% diff --git a/tex/context/base/anch-pgr.lua b/tex/context/base/anch-pgr.lua index dc1597665..b5c2ae628 100644 --- a/tex/context/base/anch-pgr.lua +++ b/tex/context/base/anch-pgr.lua @@ -17,16 +17,11 @@ local lpegmatch = lpeg.match local jobpositions = job.positions local formatters = string.formatters -local scanners = tokens.scanners -local scanstring = scanners.string -local scaninteger = scanners.integer -local scandimen = scanners.dimen - -local scanners = interfaces.scanners - local commands = commands local context = context +local implement = interfaces.implement + local report_graphics = logs.reporter("graphics") local f_b_tag = formatters["b:%s"] @@ -610,18 +605,19 @@ backgrounds.point = f_point backgrounds.pair = f_pair backgrounds.path = f_path --- scanners.fetchmultipar = function() -- n anchor page --- context(fetchmultipar(scanstring(),scanstring(),scaninteger())) --- end --- --- scanners.fetchmultishape = function() -- n anchor page --- context(fetchmultipar(scanstring(),scanstring(),scaninteger(),true)) --- end - -- n anchor page -scanners.fetchmultipar = tokens.compile { actions = { fetchmultipar, context }, arguments = { "string", "string", "integer" } } -scanners.fetchmultishape = tokens.compile { actions = { fetchmultipar, context }, arguments = { "string", "string", "integer", true } } +implement { + name = "fetchmultipar", + actions = { fetchmultipar, context }, + arguments = { "string", "string", "integer" } +} + +implement { + name = "fetchmultishape", + actions = { fetchmultipar, context }, + arguments = { "string", "string", "integer", true } +} local f_template_a = [[ path posboxes[], posregions[] ; @@ -640,73 +636,62 @@ posregions[%s] := (%p,%p)--(%p,%p)--(%p,%p)--(%p,%p)--cycle ; f_template_a = formatters[f_template_a] f_template_b = formatters[f_template_b] -scanners.fetchposboxes = function() -- tags anchor page -- no caching (yet) / todo: anchor, page - local tags = scanstring() - local anchor = scanstring() - local page = scaninteger() - local collected = jobpositions.collected - if type(tags) == "string" then - tags = utilities.parsers.settings_to_array(tags) - end - local list, nofboxes = { }, 0 - for i=1,#tags do - local tag= tags[i] - local c = collected[tag] - if c then - local r = c.r - if r then - r = collected[r] +implement { + name = "fetchposboxes", + arguments = { "string", "string", "integer" }, + actions = function(tags,anchor,page) -- no caching (yet) / todo: anchor, page + local collected = jobpositions.collected + if type(tags) == "string" then + tags = utilities.parsers.settings_to_array(tags) + end + local list, nofboxes = { }, 0 + for i=1,#tags do + local tag= tags[i] + local c = collected[tag] + if c then + local r = c.r if r then - local rx, ry, rw, rh, rd = r.x, r.y, r.w, r.h, r.d - local cx = c.x - rx - local cy = c.y - ry - local cw = cx + c.w - local ch = cy + c.h - local cd = cy - c.d - nofboxes = nofboxes + 1 - list[nofboxes] = f_template_b( - nofboxes,c.p, - nofboxes,cx,ch,cw,ch,cw,cd,cx,cd, - nofboxes,0,rh,rw,rh,rw,rd,0,rd - ) + r = collected[r] + if r then + local rx, ry, rw, rh, rd = r.x, r.y, r.w, r.h, r.d + local cx = c.x - rx + local cy = c.y - ry + local cw = cx + c.w + local ch = cy + c.h + local cd = cy - c.d + nofboxes = nofboxes + 1 + list[nofboxes] = f_template_b( + nofboxes,c.p, + nofboxes,cx,ch,cw,ch,cw,cd,cx,cd, + nofboxes,0,rh,rw,rh,rw,rd,0,rd + ) + end end + else + print("\n missing",tag) end - else - print("\n missing",tag) end + context(f_template_a(nofboxes,list)) end - context(f_template_a(nofboxes,list)) -end +} local doifelse = commands.doifelse --- function commands.doifelsemultipar(n,page,obeyhang) --- local data = pbg[n] --- if not data then --- data = calculatemultipar(n,obeyhang) --- pbg[n] = data --- end --- if page then --- doifelse(data and data[page] and true) --- else --- doifelse(data and next(data) and true) --- end --- end - -scanners.doifelserangeonpage = function() -- first last page - local first = scanstring() - local last = scanstring() - local page = scaninteger() - local collected = jobpositions.collected - local f = collected[first] - if not f or f.p == true then - doifelse(false) - return - end - local l = collected[last] - if not l or l.p == true then - doifelse(false) - return +implement { + name = "doifelserangeonpage", + arguments = { "string", "string", "integer" }, + actions = function(first,last,page) + local collected = jobpositions.collected + local f = collected[first] + if not f or f.p == true then + doifelse(false) + return + end + local l = collected[last] + if not l or l.p == true then + doifelse(false) + return + end + doifelse(page >= f.p and page <= l.p) end - doifelse(page >= f.p and page <= l.p) -end +} diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index 50574e3ab..8523cde82 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -43,13 +43,15 @@ \expandafter\gobbleoneargument \fi} -\unexpanded\def\doifpositionactionelse#1% +\unexpanded\def\doifelsepositionaction#1% {\ifcsname\??positionaction#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doifpositionactionelse\doifelsepositionaction + \unexpanded\def\dopositionaction#1% {\edef\currentpositionaction{#1}% \ifcsname\??positionaction\currentpositionaction\endcsname @@ -57,7 +59,7 @@ \fi} \def\anch_positions_action_indeed - {\doifpositionelse\currentpositionaction + {\doifelseposition\currentpositionaction \anch_positions_action_indeed_yes \anch_positions_action_indeed_nop} diff --git a/tex/context/base/anch-pos.lua b/tex/context/base/anch-pos.lua index 059da81e2..77e36e85e 100644 --- a/tex/context/base/anch-pos.lua +++ b/tex/context/base/anch-pos.lua @@ -1143,7 +1143,7 @@ end local doif = commands.doif local doifelse = commands.doifelse -scanners.doifpositionelse = function() -- name +scanners.doifelseposition = function() -- name doifelse(collected[scanstring()]) end @@ -1151,21 +1151,21 @@ scanners.doifposition = function() -- name doif(collected[scanstring()]) end -scanners.doifpositiononpageelse = function() -- name page -- probably always realpageno +scanners.doifelsepositiononpage = function() -- name page -- probably always realpageno local c = collected[scanstring()] local p = scaninteger() doifelse(c and c.p == p) end -scanners.doifoverlappingelse = function() -- one two +scanners.doifelseoverlapping = function() -- one two doifelse(overlapping(scanstring(),scanstring())) end -scanners.doifpositionsonsamepageelse = function() -- list +scanners.doifelsepositionsonsamepage = function() -- list doifelse(onsamepage(scanstring())) end -scanners.doifpositionsonthispageelse = function() -- list +scanners.doifelsepositionsonthispage = function() -- list doifelse(onsamepage(scanstring(),tostring(texgetcount("realpageno")))) end diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv index f35261742..5d9c2fd34 100644 --- a/tex/context/base/anch-pos.mkiv +++ b/tex/context/base/anch-pos.mkiv @@ -311,9 +311,12 @@ %D \doifpositionelse {identifier} {found action} {not found action} %D \stoptyping -\unexpanded\def\doifpositionelse #1{\clf_doifpositionelse {#1}} \unexpanded\def\doifposition #1{\clf_doifposition {#1}} -\unexpanded\def\doifpositiononpageelse#1#2{\clf_doifpositiononpageelse{#1}#2\relax} +\unexpanded\def\doifelseposition #1{\clf_doifelseposition {#1}} +\unexpanded\def\doifelsepositiononpage#1#2{\clf_doifelsepositiononpage{#1}#2\relax} + +\let\doifpositionelse \doifelseposition +\let\doifpositiononpageelse\doifelsepositiononpage %D \macros %D {xypos} @@ -421,7 +424,9 @@ %D {action when not overlapping} %D \stoptyping -\unexpanded\def\doifoverlappingelse#1#2{\clf_doifoverlappingelse{#1}{#2}} +\unexpanded\def\doifelseoverlapping#1#2{\clf_doifelseoverlapping{#1}{#2}} + +\let\doifoverlappingelse\doifelseoverlapping %D \macros %D {doifpositionsonsamepageelse, @@ -439,11 +444,16 @@ %D {action when not on this page} %D \stoptyping -\unexpanded\def\doifpositionsonsamepageelse#1{\clf_doifpositionsonsamepageelse{#1}} -\unexpanded\def\doifpositionsonthispageelse#1{\clf_doifpositionsonthispageelse{#1}} +\unexpanded\def\doifelsepositionsonsamepage#1{\clf_doifelsepositionsonsamepage{#1}} +\unexpanded\def\doifelsepositionsonthispage#1{\clf_doifelsepositionsonthispage{#1}} + +\let\doifpositionsonsamepageelse\doifelsepositionsonsamepage +\let\doifpositionsonthispageelse\doifelsepositionsonthispage %D Moved here: \unexpanded\def\doifelsepositionsused{\clf_doifelsepositionsused} +\let\doifpositionsusedelse\doifelsepositionsused + \protect \endinput diff --git a/tex/context/base/anch-snc.mkiv b/tex/context/base/anch-snc.mkiv index 77ebc3e0e..27769fbf9 100644 --- a/tex/context/base/anch-snc.mkiv +++ b/tex/context/base/anch-snc.mkiv @@ -51,6 +51,8 @@ \def\doifelselastsyncposition#1#2% {\doifelse{\lastsyncclass\lastsyncposition}{#1#2}} +\let\doiflastsyncpositionelse\doifelselastsyncposition + \def\dodosyncposition#1#2#3% {\letgvalue{\s!reset:\s!syncpos:#1}\relax \letgvalue{\s!preset:\s!syncpos:#1}\relax @@ -74,7 +76,7 @@ \!!counta\zerocount \!!countc\zerocount \doloop - {\doifpositionelse{\s!syncpos:#1:\recurselevel} + {\doifelseposition{\s!syncpos:#1:\recurselevel} {\!!dimenb\MPy{\s!syncpos:#1:\recurselevel}\relax \!!countb\MPp{\s!syncpos:#1:\recurselevel}\relax \ifnum\!!countb=\!!counta % same page diff --git a/tex/context/base/attr-col.lua b/tex/context/base/attr-col.lua index 1b9a65520..d6e751d89 100644 --- a/tex/context/base/attr-col.lua +++ b/tex/context/base/attr-col.lua @@ -568,9 +568,9 @@ end -- interface -implement { name = "enablecolor", actions = colors.enable } -implement { name = "enabletransparency", actions = transparencies.enable } -implement { name = "enablecolorintents", actions = colorintents.enable } +implement { name = "enablecolor", once = true, actions = colors.enable } +implement { name = "enabletransparency", once = true, actions = transparencies.enable } +implement { name = "enablecolorintents", once = true, actions = colorintents.enable } --------- { name = "registercolor", actions = { colors .register, context }, arguments = "string" } --------- { name = "registertransparency", actions = { transparencies.register, context }, arguments = { ... } } diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index 90e957fd1..f54675022 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -313,7 +313,7 @@ \unexpanded\def\doinsertobject#1#2% {\begingroup - \doifobjectreferencefoundelse{#1}{#2} + \doifelseobjectreferencefound{#1}{#2} {\dogetobjectreference{#1}{#2}\m_back_object_reference \pdfrefxform\m_back_object_reference}% \donothing diff --git a/tex/context/base/bibl-bib.mkiv b/tex/context/base/bibl-bib.mkiv index 0a410987f..80d04099b 100644 --- a/tex/context/base/bibl-bib.mkiv +++ b/tex/context/base/bibl-bib.mkiv @@ -648,7 +648,7 @@ \fi\fi} \def\dotypesetbibtexpublication - {\doifbibreferencefoundelse\currentbibtexsessiontag + {\doifelsebibreferencefound\currentbibtexsessiontag {\global\advance\bibtexcounter\plusone \ctxlua{bibtex.hacks.registerplaced("\currentbibtexsessiontag")}% \let\currentlist\currentbibtexsession @@ -680,13 +680,13 @@ \unexpanded\def\bibtexcitation[#1]% {\edef\currentbibtexsession{#1}% - \strictdoifnextoptionalelse\dobibtexcitation\dobibtexref} + \strictdoifelsenextoptional\dobibtexcitation\dobibtexref} \def\dobibtexref#1% {\dodobibtexcitation[#1][]} \def\dobibtexcitation[#1]% - {\strictdoifnextoptionalelse{\dodobibtexcitation[#1]}{\dodobibtexcitation[#1][]}} + {\strictdoifelsenextoptional{\dodobibtexcitation[#1]}{\dodobibtexcitation[#1][]}} \def\dodobibtexcitation[#1][#2]% {\dontleavehmode @@ -702,7 +702,7 @@ \def\dowhatevercitation#1#2% {\processcommalist[#2]\dobibtexcitationindeed \setupinteraction[\c!style=]% use flag instead - \doifassignmentelse{#1} + \doifelseassignment{#1} {\getparameters[\??pb\??pb][\c!alternative=,\c!extras=,#1]% \edef\currentbibtexvariant{\@@pb@@pbalternative}% \ifx\currentbibtexvariant\empty @@ -808,7 +808,7 @@ % helpers -\def\doifbibtexinteractionelse +\unexpanded\def\doifelsebibtexinteraction {\iflocation \edef\temp{\bibtexcitationparameter\c!interaction}% \ifx\temp\v!stop @@ -820,6 +820,8 @@ \@EA\secondoftwoarguments \fi} +\let\doifbibtexinteractionelse\doifelsebibtexinteraction + % variants % todo: lastsep here @@ -837,23 +839,23 @@ \fi} \def\inbibtexlink#1#2% - {\doifreferencefoundelse{\bibtexrefprefix#1} + {\doifelsereferencefound{\bibtexrefprefix#1} {\goto{#2}[\bibtexrefprefix#1]} {!#1!}} \def\dobibtexgotolink#1#2% - {\doifreferencefoundelse{\bibtexrefprefix#1} + {\doifelsereferencefound{\bibtexrefprefix#1} {\goto{#2}[\bibtexrefprefix#1]} {!#1!}} \def\dobibattexlink#1#2% - {\doifreferencefoundelse{\bibtexrefprefix#1} + {\doifelsereferencefound{\bibtexrefprefix#1} {\at{#2}[\bibtexrefprefix#1]} {!#1!}} \def\dobibtexurllink#1#2% {\expanded{\useURL[bibtex:url:#1][#2]}% - \doifbibtexinteractionelse + \doifelsebibtexinteraction {\goto{\url[bibtex:url:#1]}[url(bibtex:url:#1)]} {\url[bibtex:url:#1]}} diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv index 8ceffe2f3..4c9e83fdf 100644 --- a/tex/context/base/bibl-tra.mkiv +++ b/tex/context/base/bibl-tra.mkiv @@ -450,8 +450,8 @@ \unexpanded\def\bibinsertmonth#1#2#3% {\bibdoifelse\@@pb@month - {#1\doifnumberelse\@@pb@month - {\doifconversiondefinedelse\@@pbmonthconversion + {#1\doifelsenumber\@@pb@month + {\doifelseconversiondefined\@@pbmonthconversion {\convertnumber\@@pbmonthconversion\@@pb@month}{\@@pb@month}}% {\@@pb@month}#2}% {#3}} @@ -686,7 +686,7 @@ \unexpanded\def\dostartpublication[#1]% {\begingroup - \doifassignmentelse{#1}% + \doifelseassignment{#1}% {\getparameters[\??pb][k=\s!unknown,t=article,n=,s=,a=,y=,o=,u=,#1]}% {\getparameters[\??pb][k=#1,t=article,n=,s=,a=,y=,o=,u=]}% \ctxlua{bibtex.hacks.register(\!!bs\@@pbk\!!es,\!!bs\@@pbs\!!es)}% @@ -717,12 +717,14 @@ \def\bibgetvaru#1{\csname pbd:#1\endcsname\pluseight} \def\bibgetvard#1{\csname pbd:#1\endcsname\plusnine } -\unexpanded\def\doifbibreferencefoundelse#1% +\unexpanded\def\doifelsebibreferencefound#1% {\preloadbiblist - \doifdefinedelse{pbd:#1} + \doifelsedefined{pbd:#1} \firstoftwoarguments {\showmessage\m!publications{5}{#1,\the\inputlineno}\secondoftwoarguments}} +\let\doifbibreferencefoundelse\doifelsebibreferencefound + %D \macros{bib@crossref} %D %D \type{\crossref} is used in database files to point to another @@ -878,7 +880,7 @@ % we'll define proper handlers later \unexpanded\def\doplacepublicationindeed#1% - {\doifbibreferencefoundelse{#1} + {\doifelsebibreferencefound{#1} {\global\advance\bibtexcounter\plusone \def\currentpublicationkey{#1}% \ctxlua{bibtex.hacks.registerplaced("#1")}% @@ -932,13 +934,13 @@ %D in included data from the \type{.bib} file). \unexpanded\def\cite - {\strictdoifnextoptionalelse\dodocite\dobibref} + {\strictdoifelsenextoptional\dodocite\dobibref} \unexpanded\def\dobibref#1% {\docite[#1][]} \unexpanded\def\dodocite[#1]% - {\strictdoifnextoptionalelse{\docite[#1]}{\docite[#1][]}} + {\strictdoifelsenextoptional{\docite[#1]}{\docite[#1][]}} \unexpanded\def\docite[#1][#2]% {\begingroup @@ -953,7 +955,7 @@ \unexpanded\def\dowhatevercite#1#2% {\processcommalist[#2]\docitation \setupinteraction[\c!style=]% - \doifassignmentelse + \doifelseassignment {#1}% {\getparameters[LO][\c!alternative=,\c!extras=,#1]% \edef\@@currentalternative{\LOalternative}% @@ -1007,7 +1009,7 @@ \unexpanded\def\getcitedata#1[#2]#3[#4]#5to#6% {\bgroup \dofetchapublication{#4}% - \doifdefinedelse{\??pb @bib#2}% + \doifelsedefined{\??pb @bib#2}% {\xdef#6{\getvalue{\??pb @bib#2}}}% {\xdef#6{\getvalue{\??pb @#2}}}% \egroup} @@ -1139,7 +1141,7 @@ %D but it will do for now. \unexpanded\def\docurrentbibauthor#1,#2% - {\doifemptyelse{#2} + {\doifelseempty{#2} {\def\currentbibauthor{#1\bibalternative{otherstext}}} {\expandafter\ifx\csname\??pv\@@currentalternative authoretallimit\endcsname\relax \edef\currentbibauthor{#1\bibalternative{andtext}#2}% @@ -1154,7 +1156,7 @@ %D \type{\doglobal } \unexpanded\def\robustaddtocommalist#1#2% {item} \cs - {\robustdoifinsetelse{#1}#2\resetglobal + {\robustdoifelseinset{#1}#2\resetglobal {\dodoglobal\xdef#2{\ifx#2\empty\else#2,\fi#1}}} %D \macros{donormalbibauthoryear} @@ -1165,7 +1167,7 @@ \unexpanded\def\donormalbibauthoryear#1% {\def\myauthor{Xxxxxxxxxx}% \def\myyear{0000}% - \doifbibreferencefoundelse{#1} + \doifelsebibreferencefound{#1} {\def\myauthor{{\bibgetvara{#1}}}% \def\myyear {\bibgetvary{#1}}}% {}% @@ -1181,7 +1183,7 @@ \unexpanded\def\docompressbibauthoryear#1% {\def\myauthor{Xxxxxxxxxx}% \def\myyear {0000}% - \doifbibreferencefoundelse{#1} + \doifelsebibreferencefound{#1} {\xdef\myauthor{\bibgetvara{#1}}% \xdef\myyear {\bibgetvary{#1}}} {}% @@ -1202,7 +1204,7 @@ %D information in the correct item of \type{\thebibyears} \unexpanded\def\checkifmyauthoralreadyexists - {\doifemptyelsevalue{thebibauthors} + {\doifelseemptyvalue{thebibauthors} {\global\bibitemwanted \plusone \global\bibitemcounter\plusone \xdef\thebibauthors{{\myauthor}}} @@ -1250,9 +1252,9 @@ %D Beware, we can have cites without reference match. -\unexpanded\def\gotobiblink#1[#2]{\doifreferencefoundelse{\bibrefprefix#2}{\goto{#1}[\bibrefprefix#2]}{#1}} -\unexpanded\def\atbiblink [#1]{\doifreferencefoundelse{\bibrefprefix#1}{\at [\bibrefprefix#1]}{#1}} -\unexpanded\def\inbiblink [#1]{\doifreferencefoundelse{\bibrefprefix#1}{\expanded{\goto{\currentreferencetext}}[\bibrefprefix#1]}{#1}} +\unexpanded\def\gotobiblink#1[#2]{\doifelsereferencefound{\bibrefprefix#2}{\goto{#1}[\bibrefprefix#2]}{#1}} +\unexpanded\def\atbiblink [#1]{\doifelsereferencefound{\bibrefprefix#1}{\at [\bibrefprefix#1]}{#1}} +\unexpanded\def\inbiblink [#1]{\doifelsereferencefound{\bibrefprefix#1}{\expanded{\goto{\currentreferencetext}}[\bibrefprefix#1]}{#1}} %D \macros{bibauthoryearref,bibauthoryearsref,bibauthorref,bibyearref} %D @@ -1260,7 +1262,7 @@ %D \type{\ixbibauthoryearref} stores the data in the macros %D \type{\currentbibauthor} and \type{\currentbibyear}. -\unexpanded\def\doifbibinteractionelse +\unexpanded\def\doifelsebibinteraction {\iflocation \edef\test{\bibalternative\c!interaction}% \ifx\test\v!stop @@ -1272,8 +1274,10 @@ \expandafter\secondoftwoarguments \fi} +\let\doifbibinteractionelse\doifelsebibinteraction + \unexpanded\def\bibmaybeinteractive#1#2% - {\doifbibinteractionelse{\gotobiblink{#2}[#1]}{#2}} + {\doifelsebibinteraction{\gotobiblink{#2}[#1]}{#2}} \unexpanded\def\bibauthoryearref[#1]% {\ixbibauthoryear{#1}% @@ -1338,7 +1342,7 @@ \unexpanded\def\dobibshortref#1% {\bibinsertrefsep - \doifbibreferencefoundelse{#1} + \doifelsebibreferencefound{#1} {\gotobiblink{\bibgetvars{#1}}[#1]} {}} @@ -1349,7 +1353,7 @@ \unexpanded\def\dobibserialref#1% {\bibinsertrefsep - \doifbibreferencefoundelse{#1} + \doifelsebibreferencefound{#1} {\gotobiblink{\bibgetvarn{#1}}[#1]} {}} @@ -1363,7 +1367,7 @@ \gotobiblink{#1}[#1]} \unexpanded\def\bibgotoDOI#1#2% - {\doifbibinteractionelse + {\doifelsebibinteraction {\useURL[bibfooDoi#1][#2]% \useURL[bibfoo#1][http://dx.doi.org/#2]% \goto{\url[bibfooDoi#1]}[url(bibfoo#1)]} @@ -1376,7 +1380,7 @@ \unexpanded\def\dobibdoiref#1% {\bibinsertrefsep - \doifbibreferencefoundelse{#1} + \doifelsebibreferencefound{#1} {\expanded{\bibgotoDOI{#1}{\bibgetvaro{#1}}}} {}} @@ -1386,13 +1390,13 @@ \bibalternative\v!right} \unexpanded\def\bibgotoURL#1#2% - {\doifbibinteractionelse + {\doifelsebibinteraction {\useURL[bibfoo#1][#2]\goto{\url[bibfoo#1]}[url(bibfoo#1)]} {\hyphenatedurl{#2}}} \unexpanded\def\dobiburlref#1% {\bibinsertrefsep - \doifbibreferencefoundelse{#1} + \doifelsebibreferencefound{#1} {\expanded{\bibgotoURL{#1}{\bibgetvaru{#1}}}} {}} @@ -1403,7 +1407,7 @@ \unexpanded\def\dobibtyperef#1% {\bibinsertrefsep - \doifbibreferencefoundelse{#1} + \doifelsebibreferencefound{#1} {\gotobiblink{\bibgetvart{#1}}[#1]} {}} @@ -1414,7 +1418,7 @@ \unexpanded\def\dobibpageref#1% {\bibinsertrefsep - \doifbibinteractionelse + \doifelsebibinteraction {\atbiblink[#1]} {{\referencingfalse\at[#1]}}} @@ -1425,7 +1429,7 @@ \unexpanded\def\dobibdata#1% {\bibinsertrefsep - \doifbibreferencefoundelse{#1} + \doifelsebibreferencefound{#1} {\dotypesetapublication{#1}} {}} @@ -1476,7 +1480,7 @@ \unexpanded\def\dobibauthornumref#1% {\bibinsertrefsep - \doifbibreferencefoundelse{#1} + \doifelsebibreferencefound{#1} {\begingroup \cite[\c!left=,\c!right=,\c!alternative=\v!author][#1]% \bibalternative\c!inbetween diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua index 77d278489..1ad3c905a 100644 --- a/tex/context/base/buff-ini.lua +++ b/tex/context/base/buff-ini.lua @@ -552,7 +552,7 @@ implement { name = "gettexbuffer", actions = gettexbuffer, arguments = "stri implement { name = "runbuffer", actions = { runbuffer, context }, - arguments = { "string", "boolean" } + arguments = { "string", true } } implement { diff --git a/tex/context/base/buff-ini.mkiv b/tex/context/base/buff-ini.mkiv index d11a6db97..24bb729e1 100644 --- a/tex/context/base/buff-ini.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -25,6 +25,8 @@ \def\doifelsebuffer#1% {\clf_doifelsebuffer{#1}} +\let\doifbufferelse\doifelsebuffer + \unexpanded\def\resetbuffer {\dosingleempty\buff_reset} @@ -235,7 +237,7 @@ \def\buff_save[#1][#2]% {\begingroup - \doifassignmentelse{#1} + \doifelseassignment{#1} {\setupcurrentsavebuffer[#1]}% {\setupcurrentsavebuffer[\c!list={#1},\c!file=#2]}% \clf_savebuffer{\directsavebufferparameter\c!list}{\directsavebufferparameter\c!file}{\directsavebufferparameter\c!prefix}% diff --git a/tex/context/base/buff-par.mkvi b/tex/context/base/buff-par.mkvi index 5efff5125..fb14f017c 100644 --- a/tex/context/base/buff-par.mkvi +++ b/tex/context/base/buff-par.mkvi @@ -131,6 +131,8 @@ \unexpanded\def\doifelseparallel#name#instance% {\ctxcommand{doifelseparallel("#name","#instance")}} +\let\doifparallelelse\doifelseparallel + \unexpanded\def\resetparallel {\dodoubleempty\buff_parallel_reset} diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index 9a1c769d2..a6bacb04f 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -104,7 +104,7 @@ \let\buff_verbatim_set_line_margin\relax \def\buff_verbatim_set_line_margin_indeed - {\hskip\doifoddpageelse{\typingparameter\c!oddmargin}{\typingparameter\c!evenmargin}\relax} + {\hskip\doifelseoddpage{\typingparameter\c!oddmargin}{\typingparameter\c!evenmargin}\relax} \def\buff_verbatim_initialize_typing_one {\switchtobodyfont[\typingparameter\c!bodyfont]% can be low level call @@ -281,7 +281,7 @@ {\dontleavehmode \bgroup \edef\currenttype{#1}% - \doifnextoptionalcselse\buff_verbatim_type_yes\buff_verbatim_type_nop} + \doifelsenextoptionalcs\buff_verbatim_type_yes\buff_verbatim_type_nop} \def\buff_verbatim_type_yes[#1]% {\setupcurrenttype[#1]% @@ -297,7 +297,7 @@ \edef\currenttype{#1}% \lettypeparameter\c!lines\v!hyphenated \let\specialobeyedspace\specialstretchedspace - \doifnextoptionalcselse\buff_verbatim_type_yes\buff_verbatim_type_nop} + \doifelsenextoptionalcs\buff_verbatim_type_yes\buff_verbatim_type_nop} \def\buff_verbatim_type_one {\ifx\next\bgroup @@ -505,7 +505,7 @@ \def\buff_verbatim_typing_start_yes[#1]% {\typingparameter\c!before \startpacked[\v!blank] - \doifassignmentelse{#1} + \doifelseassignment{#1} {\setupcurrenttyping[#1]} {\doifinset\v!continue{#1}{\lettypingparameter\c!continue\v!yes}}% \buff_verbatim_setup_line_numbering @@ -605,7 +605,7 @@ \setuptyping[#1][#2]% \buff_verbatim_type_file_checked{#1}{#3}% \else\iffirstargument - \doifassignmentelse{#1} + \doifelseassignment{#1} {\setuptyping[\v!file][#1] \buff_verbatim_type_file_checked\v!file{#3}} {\buff_verbatim_type_file_checked{#1}{#3}}% @@ -630,6 +630,8 @@ \expandafter\firstoftwoarguments \fi} +\let\doiftypingfileelse\doifelsetypingfile + \def\buff_verbatim_type_file_indeed#1#2% category name {\edef\currenttyping{#1}% \typingparameter\c!before @@ -786,7 +788,7 @@ \setuptyping[\v!buffer][#2]% \processcommalist[#1]{\buff_verbatim_type_buffer_indeed\v!buffer}% [name] [settings] \else\iffirstargument - \doifassignmentelse{#1} + \doifelseassignment{#1} {\setuptyping[\v!buffer][#1]% \buff_verbatim_type_buffer_indeed\v!buffer\empty}% [settings] {\processcommalist[#1]{\buff_verbatim_type_buffer_indeed\v!buffer}}% [name] @@ -846,7 +848,7 @@ \setuptyping[\v!buffer][#2]% \processcommalist[#1]{\buff_verbatim_process_indeed\v!buffer}% [name] [settings] \else\iffirstargument - \doifassignmentelse{#1} + \doifelseassignment{#1} {\setuptyping[\v!buffer][#1]% \buff_verbatim_process_indeed\v!buffer\empty}% [settings] {\processcommalist[#1]{\buff_verbatim_process_indeed\v!buffer}}% [name] diff --git a/tex/context/base/bxml-apa.mkiv b/tex/context/base/bxml-apa.mkiv index 7665d829c..6513a71c2 100644 --- a/tex/context/base/bxml-apa.mkiv +++ b/tex/context/base/bxml-apa.mkiv @@ -342,7 +342,7 @@ \bibxmlsetup{bibtex:apa:common:author-editors-crossref-year} \bibxmldoif {title} { \bgroup\it\bibxmlflush{title}\/\egroup - \doifmodeelse {bibtex:apa:edited-book} { + \doifelsemode {bibtex:apa:edited-book} { \bibxmldoifelse {volume} { \bibtexspace Number\nonbreakablespace\bibxmlflush{volume} \bibxmldoifelse {series} { @@ -396,7 +396,7 @@ \bibxmldoifelse {title} { \bgroup\it\bibxmlflush{title}\/\egroup } { - \doifmodeelse {bibtex:apa:edited-book} { + \doifelsemode {bibtex:apa:edited-book} { \bibxmldoifelse {volume} { \bibtexspace number\nonbreakablespace\bibxmlflush{volume} \bibxmldoifelse {series} { diff --git a/tex/context/base/catc-act.mkiv b/tex/context/base/catc-act.mkiv index df228c203..8c7935d4d 100644 --- a/tex/context/base/catc-act.mkiv +++ b/tex/context/base/catc-act.mkiv @@ -39,10 +39,10 @@ \setnewconstant\c_syst_catcodes_hack\tildeasciicode % also defined in catc-ini.mkiv -\normalprotected\def\defineactivecharacter #1#2 #3% uses \doifnumberelse which is not yet defined +\normalprotected\def\defineactivecharacter #1#2 #3% uses \doifelsenumber which is not yet defined {\c_syst_catcodes_c\uccode\c_syst_catcodes_hack - \if#1"\uccode\c_syst_catcodes_hack\expandafter\doifnumberelse\expandafter{\string#1#2}\empty #1#2\else - \uccode\c_syst_catcodes_hack\expandafter\doifnumberelse\expandafter{\string#1#2}\empty`#1#2\fi + \if#1"\uccode\c_syst_catcodes_hack\expandafter\doifelsenumber\expandafter{\string#1#2}\empty #1#2\else + \uccode\c_syst_catcodes_hack\expandafter\doifelsenumber\expandafter{\string#1#2}\empty`#1#2\fi \catcode\uccode\c_syst_catcodes_hack\activecatcode \uppercase{\def\m_syst_catcodes_temp{~}}% brrr \uccode\c_syst_catcodes_hack\c_syst_catcodes_c diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index e810977ab..f18b422f2 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -149,12 +149,12 @@ \settrue\indisplaychemical \forgetall \ifsecondargument - \doifassignmentelse{#1} + \doifelseassignment{#1} {\setupcurrentchemical[#1]}% same as \currentchemical {\edef\currentchemical{#1}% \setupcurrentchemical[#2]}% \else\iffirstargument - \doifassignmentelse{#1} + \doifelseassignment{#1} {\setupcurrentchemical[#1]}% same as \currentchemical {\edef\currentchemical{#1}}% \fi\fi diff --git a/tex/context/base/cldf-ini.lua b/tex/context/base/cldf-ini.lua index 43d5cebd1..da284ba5e 100644 --- a/tex/context/base/cldf-ini.lua +++ b/tex/context/base/cldf-ini.lua @@ -311,9 +311,10 @@ local registerfunction, unregisterfunction, reservefunction, knownfunctions, cal interfaces.storedscanners = interfaces.storedscanners or { } local storedscanners = interfaces.storedscanners + storage.register("interfaces/storedscanners", storedscanners, "interfaces.storedscanners") - interfaces.scanners = table.setmetatablenewindex(function(t,k,v) + local interfacescanners = table.setmetatablenewindex(function(t,k,v) if storedscanners[k] then -- report_cld("warning: scanner %a is already set",k) -- os.exit() @@ -323,11 +324,13 @@ local registerfunction, unregisterfunction, reservefunction, knownfunctions, cal -- todo: allocate slot here and pass it storedscanners[k] = true -- report_cld("installing interface scanner: %s",k) - context("\\installctxfunction{clf_%s}{interfaces.scanners.%s}",k,k) + context("\\installctxscanner{clf_%s}{interfaces.scanners.%s}",k,k) end rawset(t,k,v) end) + interfaces.scanners = interfacescanners + -- else -- by now this is obsolete -- -- local luafunctions, noffunctions = { }, 0 @@ -426,6 +429,25 @@ function commands.ctxfunction(code,namespace) context(registerfunction(code,namespace)) end +function commands.ctxscanner(name,code,namespace) + local n = registerfunction(code,namespace) + if storedscanners[name] then + storedscanners[name] = n + end + context(n) +end + +local function dummy() end + +function commands.ctxresetter(name) + return function() + if storedscanners[name] then + rawset(interfacescanners,name,dummy) + context.resetctxscanner("clf_" .. name) + end + end +end + function context.trialtypesetting() return texgetcount("@@trialtypesetting") ~= 0 end diff --git a/tex/context/base/cldf-scn.lua b/tex/context/base/cldf-scn.lua index e87736033..3d29f4087 100644 --- a/tex/context/base/cldf-scn.lua +++ b/tex/context/base/cldf-scn.lua @@ -6,32 +6,35 @@ if not modules then modules = { } end modules ['cldf-scn'] = { license = "see context related readme files" } -local load, type = load, type +local load, type = load, type -local formatters = string.formatters -local char = string.char -local concat = table.concat +local formatters = string.formatters +local char = string.char +local concat = table.concat -local lpegmatch = lpeg.match -local p_unquoted = lpeg.Cs(lpeg.patterns.unquoted) +local lpegmatch = lpeg.match +local p_unquoted = lpeg.Cs(lpeg.patterns.unquoted) -local f_action_f = formatters["action%s(%s)"] -local f_action_s = formatters["local action%s = action[%s]"] -local f_command = formatters["local action = tokens._action\n%\nt\nreturn function(%s) return %s end"] +local f_action_f = formatters["action%s(%s)"] +local f_action_s = formatters["local action%s = action[%s]"] +local f_command = formatters["local action = tokens._action\n%\nt\nreturn function(%s) return %s end"] -local interfaces = interfaces -local commands = commands -local scanners = interfaces.scanners +local interfaces = interfaces +local commands = commands +local scanners = interfaces.scanners -local compile = tokens.compile or function() end +local compile = tokens.compile or function() end -local report = logs.reporter("interfaces","implementor") +local dummy = function() end + +local report = logs.reporter("interfaces","implementor") function interfaces.implement(specification) local actions = specification.actions local name = specification.name local arguments = specification.arguments - local scope = specification.scope + local private = specification.scope == "private" + local once = specification.once if not actions then if name then report("error: no actions for %a",name) @@ -40,15 +43,48 @@ function interfaces.implement(specification) end return end - local scanner = compile(specification) - if not name or name == "" then + if name == "" then + name = nil + end + local scanner + local resetter = once and name and commands.ctxresetter(name) + if resetter then + local scan = compile(specification) + if private then + scanner = function() + resetter() + return scan() + end + else + scanner = function() + commands[name] = dummy + resetter() + return scan() + end + end + else + scanner = compile(specification) + end + if not name then return scanner end - local command = nil + if scanners[name] and not specification.overload then + report("warning: 'scanners.%s' is redefined",name) + end + scanners[name] = scanner + if private then + return + end + local command + if once then + if type(actions) == "function" then + actions = { actions } + elseif #actions == 1 then + actions = { actions[1] } + end + end if type(actions) == "function" then command = actions - elseif actions == context then - command = context elseif #actions == 1 then command = actions[1] else @@ -91,17 +127,19 @@ function interfaces.implement(specification) command = f_command(f,args,command) command = load(command) if command then - command = command() + if resetter then + local cmd = command() + command = function() + commands[name] = dummy + resetter() + cmd() + end + else + command = command() + end end tokens._action = nil end - if scanners[name] and not specification.overload then - report("warning: 'scanners.%s' is redefined",name) - end - scanners[name] = scanner - if scope == "private" then - return - end if commands[name] and not specification.overload then report("warning: 'commands.%s' is redefined",name) end diff --git a/tex/context/base/colo-grp.mkiv b/tex/context/base/colo-grp.mkiv index 11b759062..e296bbc33 100644 --- a/tex/context/base/colo-grp.mkiv +++ b/tex/context/base/colo-grp.mkiv @@ -65,7 +65,7 @@ \processcommalist[#3]{\colo_groups_define_entry{#1}{#2}}} \def\colo_groups_define_checked[#1][#2][#3]% - {\doifinstringelse{:}{#2} + {\doifelseinstring{:}{#2} {\colo_groups_define_normal[#1][\v!rgb][#2]} {\doloop % inherited {\ifcsname\??colorgroup#2:\recurselevel\endcsname diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua index 35c72ef47..d9eeef3b7 100644 --- a/tex/context/base/colo-ini.lua +++ b/tex/context/base/colo-ini.lua @@ -951,12 +951,12 @@ implement { local ctx_doifelse = commands.doifelse implement { - name = "doifdrawingblackelse", + name = "doifelsedrawingblack", actions = function() ctx_doifelse(isblack(texgetattribute(a_color))) end } implement { - name = "doifblackelse", + name = "doifelseblack", actions = { isblack, ctx_doifelse }, arguments = "integer" } diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 621b7a303..0aca8ee1b 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -367,7 +367,7 @@ {\dodoubleargument\colo_palets_define} \unexpanded\def\colo_palets_define[#1][#2]% todo - {\doifassignmentelse{#2} + {\doifelseassignment{#2} {%\colo_helpers_show_message\m!colors6{#1}% \let\m_colo_palets_tmp\empty \setevalue{\??colorpaletspecification#1}{#2}% @@ -382,7 +382,7 @@ % {\colo_palets_define_two{#1}[#2]}% \def\colo_palets_define_one#1#2% get rid of { } - {\doifassignmentelse{#2} % catch empty entries + {\doifelseassignment{#2} % catch empty entries {\colo_palets_define_two{#1}[#2]} {\colo_palets_define_three{#1}{#2}}} @@ -880,7 +880,7 @@ %D command. Later on we will explain the use of palets. We %D define ourselves a color conditional first. -\def\doifcolorelse#1% +\def\doifelsecolor#1% {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname \expandafter\firstoftwoarguments \else\ifcsname\??colorattribute#1\endcsname @@ -889,6 +889,8 @@ \doubleexpandafter\secondoftwoarguments \fi\fi} +\let\doifcolorelse\doifelsecolor + \def\doifcolor#1% {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname \expandafter\firstofoneargument @@ -989,7 +991,7 @@ \to \everysetupcolors \def\colo_palets_define_set#1#2#3% - {\doifassignmentelse{#3}% \definepalet[test][xx={y=.4}] + {\doifelseassignment{#3}% \definepalet[test][xx={y=.4}] {\definecolor[\??colorpalet#1:#2][#3]% \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_palet_ca{#1}{#2}}% \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_palet_cs{#1}{#2}}% @@ -1089,8 +1091,14 @@ \def\colorvalue #1{\clf_formatcolor\thecolorattribute{#1}{\colorformatseparator}} \def\grayvalue #1{\clf_formatgray \thecolorattribute{#1}{\colorformatseparator}} -\def\doifblackelse #1{\clf_doifblackelse\thecolorattribute{#1} } -\def\doifdrawingblackelse {\clf_doifdrawingblackelse} +\def\doifelseblack #1{\clf_doifelseblack\thecolorattribute{#1} } +\def\doifelsedrawingblack {\clf_doifelsedrawingblack} + +\let\doifblackelse \doifelseblack +\let\doifdrawingblackelse \doifelsedrawingblack + +\let\doifblackelse \doifelseblack +\let\doifdrawingblackelse\doifelsedrawingblack %D \macros %D {forcecolorhack} diff --git a/tex/context/base/colo-run.mkiv b/tex/context/base/colo-run.mkiv index 5084fdd35..16f54c3b5 100644 --- a/tex/context/base/colo-run.mkiv +++ b/tex/context/base/colo-run.mkiv @@ -46,7 +46,7 @@ \gdef\colo_show_palet[#1][#2]% {\ifcsname\??colorpalet#1\endcsname - \doifinsetelse\v!vertical{#2} \colo_palets_show_vertical \colo_palets_show_horizontal [#1][#2]% + \doifelseinset\v!vertical{#2} \colo_palets_show_vertical \colo_palets_show_horizontal [#1][#2]% \fi} \gdef\colo_palets_show_vertical[#1][#2]% @@ -58,7 +58,7 @@ \setuppalet[#1] \tabskip\zeropoint \def\colo_palets_show_palet##1% - {\doifinsetelse\v!number{#2}{##1\hskip.5em}{}& + {\doifelseinset\v!number{#2}{##1\hskip.5em}{}& \color[##1]{\vrule\s!width3em\s!height\strutht\s!depth\strutdp}% \graycolor[##1]{\vrule\s!width3em\s!height\strutht\s!depth\strutdp}& \doifinset\v!value{#2}{\hskip.5em\colorvalue{##1}}\crcr} @@ -155,7 +155,7 @@ \gdef\colo_groups_show[#1][#2]% {\doifcolor{#1:1} - {\doifinsetelse\v!vertical{#2} \colo_groups_show_vertical \colo_groups_show_horizontal [#1][#2]}} + {\doifelseinset\v!vertical{#2} \colo_groups_show_vertical \colo_groups_show_horizontal [#1][#2]}} \gdef\colo_groups_show_horizontal[#1][#2]% {\vbox @@ -177,7 +177,7 @@ \hbox {\doifinset\v!name{#2} {\strut - \doifinsetelse\v!value{#2} + \doifelseinset\v!value{#2} {\raise3\lineheight\hbox{#1\hskip.5em}} {#1}% \hskip.5em}% diff --git a/tex/context/base/cont-log.mkiv b/tex/context/base/cont-log.mkiv index 9e148690a..598140d32 100644 --- a/tex/context/base/cont-log.mkiv +++ b/tex/context/base/cont-log.mkiv @@ -94,8 +94,8 @@ {\dontleavehmode \begingroup C\kern -.0667\emwidth\getscaledglyph{.8}\empty{O\kern -.0667\emwidth N\kern - -.0549\emwidth T\doifitalicelse{\kern-.1\emwidth}{\kern-.1667\emwidth}\lower.5\exheight\hbox - {E}\doifitalicelse\empty{\kern-.11em}X\kern-.055\emwidth T}% + -.0549\emwidth T\doifelseitalic{\kern-.1\emwidth}{\kern-.1667\emwidth}\lower.5\exheight\hbox + {E}\doifelseitalic\empty{\kern-.11em}X\kern-.055\emwidth T}% \endgroup} %D The \METAFONT\ and \METAPOST\ logos adapt themselves to the current fontsize, an diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 0eae7d27d..f4900cb6e 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2015.04.01 12:00} +\newcontextversion{2015.04.03 20:01} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 93a090e6a..246c94b88 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 257fd1712..ff7b7985a 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2015.04.01 12:00} +\edef\contextversion{2015.04.03 20:01} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua index 93cf0400e..19714c900 100644 --- a/tex/context/base/core-con.lua +++ b/tex/context/base/core-con.lua @@ -290,7 +290,7 @@ implement { name = "second", actions = { date, context }, arguments = "'%S implement { name = "textime", actions = { textime, context } } implement { - name = "doifleapyearelse", + name = "doifelseleapyear", actions = { isleapyear, commands.doifelse }, arguments = "integer" } @@ -1206,7 +1206,7 @@ local function currentdate(str,currentlanguage) -- second argument false : no la elseif mnemonic then context.labeltext(monthmnem(month)) else - context.labeltext(monthmnem(month)) + context.labeltext(monthname(month)) end elseif tag == "mm" then context("%02i",month) diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv index 19a81685e..2d4fca473 100644 --- a/tex/context/base/core-con.mkiv +++ b/tex/context/base/core-con.mkiv @@ -293,8 +293,10 @@ %D %D The number of days is available in the macro \type {\numberofdays}. -\def\doifleapyearelse#1% - {\clf_doifleapyearelse\numexpr#1\relax} +\def\doifelseleapyear#1% + {\clf_doifelseleapyear\numexpr#1\relax} + +\let\doifleapyearelse\doifelseleapyear \unexpanded\def\getdayspermonth#1#2% {\edef\numberofdays{\clf_nofdays\numexpr#1\relax\numexpr#2\relax}} @@ -453,7 +455,7 @@ \def\currenttimespecification{h,:,m} \unexpanded\def\currenttime - {\doifnextoptionalelse\syst_converters_current_time_yes\syst_converters_current_time_nop} + {\doifelsenextoptional\syst_converters_current_time_yes\syst_converters_current_time_nop} \unexpanded\def\syst_converters_current_time_yes[#1]% {\calculatecurrenttime @@ -537,7 +539,7 @@ \fi} \def\syst_converters_define_conversion_indeed#1#2#3% - {\doifinstringelse{,}{\detokenize{#3}} + {\doifelseinstring{,}{\detokenize{#3}} {\clf_defineconversion{#2}{\detokenize{#3}}% a set e.g. of symbols \setgvalue{\??conversion#1}{\syst_converters_checked_conversion{#2}}} {\setgvalue{\??conversion#1}{#3}}} @@ -567,7 +569,7 @@ % if we have definitions that are not matched at the lua end .. eventually we might do % that when more shows up -\def\doifconversiondefinedelse#1% +\def\doifelseconversiondefined#1% {\ifcsname\??conversion\currentlanguage#1\endcsname \expandafter\firstoftwoarguments \else\ifcsname\??conversion#1\endcsname @@ -583,6 +585,9 @@ \expandafter\secondoftwoarguments \fi} +\let\doifconversiondefinedelse\doifelseconversiondefined +\let\doifconversionnumberelse \doifelseconversionnumber + %D Handy. \setvalue{\??conversionwords\v!one }{1} diff --git a/tex/context/base/core-ctx.lua b/tex/context/base/core-ctx.lua index e9d3eddce..a99680778 100644 --- a/tex/context/base/core-ctx.lua +++ b/tex/context/base/core-ctx.lua @@ -302,7 +302,7 @@ local function resolve(name) -- used a few times later on end local processfile = commands.processfile -local doifinputfileelse = commands.doifinputfileelse +local doifelseinputfile = commands.doifelseinputfile function commands.processfile(name,maxreadlevel) -- overloaded local prepname = resolve(name) @@ -312,12 +312,12 @@ function commands.processfile(name,maxreadlevel) -- overloaded return processfile(name,maxreadlevel) end -function commands.doifinputfileelse(name,depth) +function commands.doifelseinputfile(name,depth) local prepname = resolve(name) if prepname then - return doifinputfileelse(prepname,0) + return doifelseinputfile(prepname,0) end - return doifinputfileelse(name,depth) + return doifelseinputfile(name,depth) end function commands.preparedfile(name) diff --git a/tex/context/base/core-dat.lua b/tex/context/base/core-dat.lua index 242d362d0..ca6ec4373 100644 --- a/tex/context/base/core-dat.lua +++ b/tex/context/base/core-dat.lua @@ -13,7 +13,8 @@ replaces the twopass data mechanism.</p> local tonumber, tostring, type = tonumber, tostring, type -local context, commands = context, commands +local context = context +local commands = commands local trace_datasets = false trackers.register("job.datasets" , function(v) trace_datasets = v end) local trace_pagestates = false trackers.register("job.pagestates", function(v) trace_pagestates = v end) @@ -33,6 +34,8 @@ local v_yes = interfaces.variables.yes local new_latelua = nodes.pool.latelua +local implement = interfaces.implement + local collected = allocate() local tobesaved = allocate() @@ -138,7 +141,7 @@ function datasets.getdata(name,tag,key,default) return default end -function commands.setdataset(settings) +local function setdataset(settings) settings.convert = true local name, tag = setdata(settings) if settings.delay ~= v_yes then @@ -150,7 +153,7 @@ function commands.setdataset(settings) end end -function commands.datasetvariable(name,tag,key) +local function datasetvariable(name,tag,key) local t = collected[name] if t == nil then if trace_datasets then @@ -175,6 +178,25 @@ function commands.datasetvariable(name,tag,key) end end +implement { + name = "setdataset", + actions = setdataset, + arguments = { + { + { "name" }, + { "tag" }, + { "delay" }, + { "data" }, + } + } +} + +implement { + name = "datasetvariable", + actions = datasetvariable, + arguments = { "string", "string", "string" } +} + --[[ldx-- <p>We also provide an efficient variant for page states.</p> --ldx]]-- @@ -245,7 +267,7 @@ function pagestates.realpage(name,tag,default) return default end -function commands.setpagestate(settings) +local function setpagestate(settings) local name, tag, data = setstate(settings) if type(tag) == "number" then context(new_latelua(formatters["job.pagestates.extend(%q,%i)"](name,tag))) @@ -254,7 +276,7 @@ function commands.setpagestate(settings) end end -function commands.pagestaterealpage(name,tag) +local function pagestaterealpage(name,tag) local t = collected[name] t = t and (t[tag] or t[tonumber(tag)]) if t then @@ -262,8 +284,32 @@ function commands.pagestaterealpage(name,tag) end end -function commands.setpagestaterealpageno(name,tag) +local function setpagestaterealpageno(name,tag) local t = collected[name] t = t and (t[tag] or t[tonumber(tag)]) texsetcount("realpagestateno",t or texgetcount("realpageno")) end + +implement { + name = "setpagestate", + actions = setpagestate, + arguments = { + { + { "name" }, + { "tag" }, + { "delay" }, + } + } +} + +implement { + name = "pagestaterealpage", + actions = pagestaterealpage, + arguments = { "string", "string" } +} + +implement { + name = "setpagestaterealpageno", + actions = setpagestaterealpageno, + arguments = { "string", "string" } +} diff --git a/tex/context/base/core-dat.mkiv b/tex/context/base/core-dat.mkiv index 5aef39d69..26b1f14b5 100644 --- a/tex/context/base/core-dat.mkiv +++ b/tex/context/base/core-dat.mkiv @@ -51,26 +51,26 @@ \def\syst_datasets_set_named[#1][#2][#3]% {\begingroup \edef\currentdataset{#1}% - \ctxcommand{setdataset{ - name = "\currentdataset", - tag = \!!bs#2\!!es, - delay = "\datasetparameter\c!delay", - data = \!!bs#3\!!es - }}% + \clf_setdataset + name {\currentdataset}% + tag {#2}% + delay {\datasetparameter\c!delay}% + data {#3}% + \relax \endgroup} \def\syst_datasets_set_indexed[#1][#2][#3]% {\begingroup \edef\currentdataset{#1}% - \ctxcommand{setdataset{ - name = "\currentdataset", - delay = "\datasetparameter\c!delay", - data = \!!bs#2\!!es - }}% + \clf_setdataset + name {\currentdataset}% + delay {\datasetparameter\c!delay}% + data {#2}% + \relax \endgroup} \def\datasetvariable#1#2#3% - {\ctxcommand{datasetvariable("#1","#2","#3")}} + {\clf_datasetvariable{#1}{#2}{#3}} \installcorenamespace{pagestate} @@ -85,17 +85,17 @@ \def\syst_pagestates_set[#1][#2]% {\begingroup \edef\currentpagestate{#1}% - \ctxcommand{setpagestate{ - name = "\currentpagestate", - tag = \!!bs#2\!!es, - delay = "\pagestateparameter\c!delay", - }}% + \clf_setpagestate + name {\currentpagestate}% + tag {#2}% + delay {\pagestateparameter\c!delay}% + \relax \endgroup} \def\pagestaterealpage#1#2% - {\ctxcommand{pagestaterealpage("#1","#2")}} + {\clf_pagestaterealpage{#1}{#2}} \def\setpagestaterealpageno#1#2% - {\ctxcommand{setpagestaterealpageno("#1","#2")}} + {\clf_setpagestaterealpageno{#1}{#2}} \protect diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv index 41a2a17aa..bebc1bef0 100644 --- a/tex/context/base/core-env.mkiv +++ b/tex/context/base/core-env.mkiv @@ -258,17 +258,20 @@ \expandafter#1% \fi} -\unexpanded\def\doifmodeelse {\syst_modes_check\firstoftwoarguments\secondoftwoarguments} +\unexpanded\def\doifelsemode {\syst_modes_check\firstoftwoarguments\secondoftwoarguments} \unexpanded\def\doifmode {\syst_modes_check\firstofoneargument\gobbleoneargument} \unexpanded\def\doifnotmode {\syst_modes_check\gobbleoneargument\firstofoneargument} \unexpanded\def\startmode [#1]{\syst_modes_check\donothing\syst_modes_stop_yes{#1}} \unexpanded\def\startnotmode [#1]{\syst_modes_check\syst_modes_stop_nop\donothing{#1}} -\unexpanded\def\doifallmodeselse {\syst_modes_check_all\firstoftwoarguments\secondoftwoarguments} +\unexpanded\def\doifelseallmodes {\syst_modes_check_all\firstoftwoarguments\secondoftwoarguments} \unexpanded\def\doifallmodes {\syst_modes_check_all\firstofoneargument\gobbleoneargument} \unexpanded\def\doifnotallmodes {\syst_modes_check_all\gobbleoneargument\firstofoneargument} \unexpanded\def\startallmodes [#1]{\syst_modes_check_all\donothing\syst_modes_stop_all_yes{#1}} \unexpanded\def\startnotallmodes[#1]{\syst_modes_check_all\syst_modes_stop_all_nop\donothing{#1}} +\let\doifmodeelse \doifelsemode +\let\doifallmodeselse \doifelseallmodes + \unexpanded\def\stopmode {} % no relax \unexpanded\def\stopnotmode {} % no relax \unexpanded\def\stopallmodes {} % no relax @@ -349,7 +352,7 @@ \unexpanded\def\startmodeset {\pushmacro\c_syst_modes_set_done \setfalse\c_syst_modes_set_done - \doifnextoptionalcselse\syst_modes_set_start\syst_modes_set_quit} + \doifelsenextoptionalcs\syst_modes_set_start\syst_modes_set_quit} \def\syst_modes_set_start[#1]% {\edef\m_mode_case{#1}% @@ -369,10 +372,10 @@ \def\syst_modes_set_yes#1% {\settrue\c_syst_modes_set_done #1% - \doifnextoptionalcselse\syst_modes_set_start\syst_modes_set_quit} + \doifelsenextoptionalcs\syst_modes_set_start\syst_modes_set_quit} \def\syst_modes_set_nop#1% - {\doifnextoptionalcselse\syst_modes_set_start\syst_modes_set_quit} + {\doifelsenextoptionalcs\syst_modes_set_start\syst_modes_set_quit} \def\syst_modes_set_quit#1\stopmodeset {\popmacro\c_syst_modes_set_done} @@ -398,8 +401,8 @@ % % \letvalue{\e!stop\v!setups}\relax -\unexpanded\def\setups{\doifnextbgroupelse\syst_setups_a\syst_setups_b} % {..} or [..] -\unexpanded\def\setup {\doifnextbgroupelse\syst_setups \syst_setups_c} % {..} or [..] +\unexpanded\def\setups{\doifelsenextbgroup\syst_setups_a\syst_setups_b} % {..} or [..] +\unexpanded\def\setup {\doifelsenextbgroup\syst_setups \syst_setups_c} % {..} or [..] \def\syst_setups_a #1{\processcommacommand[#1]\syst_setups} % {..} \def\syst_setups_b[#1]{\processcommacommand[#1]\syst_setups} % [..] @@ -514,13 +517,15 @@ \let\directsetup\syst_setups \let\texsetup \syst_setups % nicer than \directsetup and more en par with xmlsetup and luasetup -\unexpanded\def\doifsetupselse#1% to be done: grid +\unexpanded\def\doifelsesetups#1% to be done: grid {\ifcsname\??setup:#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doifsetupselse\doifelsesetups + \unexpanded\def\doifsetups#1% to be done: grid {\ifcsname\??setup:#1\endcsname \expandafter\firstofoneargument @@ -591,11 +596,11 @@ % Is doglobal still relevant? Maybe always global? Or never? Anyway, it will become obsolete. -\unexpanded\def\startluasetups {\begingroup\doifnextoptionalcselse\syst_setups_start_lua_a\syst_setups_start_lua_b} \let\stopluasetups \relax -\unexpanded\def\startxmlsetups {\begingroup\doifnextoptionalcselse\syst_setups_start_xml_a\syst_setups_start_xml_b} \let\stopxmlsetups \relax -\unexpanded\def\startrawsetups {\begingroup\doifnextoptionalcselse\syst_setups_start_raw_a\syst_setups_start_raw_b} \let\stoprawsetups \relax -\unexpanded\def\startlocalsetups{\begingroup\doifnextoptionalcselse\syst_setups_start_loc_a\syst_setups_start_loc_b} \let\stoplocalsetups \relax -\unexpanded\def\startsetups {\begingroup\doifnextoptionalcselse\syst_setups_start_tex_a\syst_setups_start_tex_b} \let\stopsetups \relax +\unexpanded\def\startluasetups {\begingroup\doifelsenextoptionalcs\syst_setups_start_lua_a\syst_setups_start_lua_b} \let\stopluasetups \relax +\unexpanded\def\startxmlsetups {\begingroup\doifelsenextoptionalcs\syst_setups_start_xml_a\syst_setups_start_xml_b} \let\stopxmlsetups \relax +\unexpanded\def\startrawsetups {\begingroup\doifelsenextoptionalcs\syst_setups_start_raw_a\syst_setups_start_raw_b} \let\stoprawsetups \relax +\unexpanded\def\startlocalsetups{\begingroup\doifelsenextoptionalcs\syst_setups_start_loc_a\syst_setups_start_loc_b} \let\stoplocalsetups \relax +\unexpanded\def\startsetups {\begingroup\doifelsenextoptionalcs\syst_setups_start_tex_a\syst_setups_start_tex_b} \let\stopsetups \relax \def\syst_setups_start_lua_indeed#1#2#3\stopluasetups {\endgroup\dodoglobal\expandafter\def\csname\??setup#1:#2\expandafter\endcsname\expandafter##\expandafter1\expandafter{#3}} \def\syst_setups_start_xml_indeed#1#2#3\stopxmlsetups {\endgroup\dodoglobal\expandafter\def\csname\??setup#1:#2\expandafter\endcsname\expandafter##\expandafter1\expandafter{#3}} @@ -737,6 +742,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doifvariableelse\doifelsevariable + \unexpanded\def\doifvariable#1#2% {\ifcsname\??variables#1:#2\endcsname \expandafter\firstofoneargument @@ -764,6 +771,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doifemptyvariableelse\doifelseemptyvariable + \unexpanded\def\doifemptyvariable#1#2% {\edef\m_syst_string_one{\csname\??variables\ifcsname\??variables#1:#2\endcsname#1:#2\else:\fi\endcsname}% \ifx\m_syst_string_one\empty @@ -787,12 +796,14 @@ \unexpanded\def\setupenv {\dotripleargument\syst_variables_set[\getrawparameters][\s!environment]} -\unexpanded\def\doifenvelse{\doifelsevariable \s!environment} +\unexpanded\def\doifelseenv{\doifelsevariable \s!environment} \unexpanded\def\doifenv {\doifvariable \s!environment} \unexpanded\def\doifnotenv {\doifnotvariable \s!environment} \def\env {\getvariable \s!environment} \def\envvar {\getvariabledefault\s!environment} +\let\doifenvelse\doifelseenv + %D \macros %D {defineselector,setupselector,select,directselect} %D diff --git a/tex/context/base/core-sys.mkiv b/tex/context/base/core-sys.mkiv index cb712fd7c..f61c74743 100644 --- a/tex/context/base/core-sys.mkiv +++ b/tex/context/base/core-sys.mkiv @@ -279,12 +279,12 @@ \let\directhighlight\typo_highlights_indeed \unexpanded\def\defineexpandable - {\doifnextoptionalelse + {\doifelsenextoptional {\syst_basics_define_yes\def}% {\syst_basics_define_nop\def}} \unexpanded\def\define - {\doifnextoptionalelse + {\doifelsenextoptional {\syst_basics_define_yes{\unexpanded\def}}% {\syst_basics_define_nop{\unexpanded\def}}} diff --git a/tex/context/base/core-two.mkiv b/tex/context/base/core-two.mkiv index 30fd27f3d..5a791dea2 100644 --- a/tex/context/base/core-two.mkiv +++ b/tex/context/base/core-two.mkiv @@ -116,6 +116,7 @@ \unexpanded\def\doifelseintwopassdata #1#2{\clf_doifelseintwopassdata{#1}{#2}} + \let\doifintwopassdataelse \doifelseintwopassdata \let\getfromtwopassdata \findtwopassdata \protect \endinput diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv index 7a1aef5cc..4e06fa15f 100644 --- a/tex/context/base/enco-ini.mkiv +++ b/tex/context/base/enco-ini.mkiv @@ -71,7 +71,7 @@ \let\dodefineaccentcommand\enco_define_accent_command % used at the lua end \unexpanded\def\definecharacter#1 #2 % - {\doifnumberelse{\string#2} + {\doifelsenumber{\string#2} {\setevalue{\string#1}{\utfchar{#2}}} % or {\expandafter\chardef\csname#1\endcsname#2\relax} {\setuvalue{\string#1}{#2}}} @@ -459,10 +459,10 @@ \unexpanded\def\periods {\dontleavehmode \hbox\bgroup - \doifnextoptionalelse\enco_periods_yes\enco_periods_nop} + \doifelsenextoptional\enco_periods_yes\enco_periods_nop} \unexpanded\def\enco_periods_yes[#1]% - {\doifassignmentelse{#1} + {\doifelseassignment{#1} {\setupcurrentperiods[#1]% \scratchcounter\periodsparameter\c!n} {\doifelsenothing{#1} diff --git a/tex/context/base/file-ini.lua b/tex/context/base/file-ini.lua index f47feca55..2a0271a9d 100644 --- a/tex/context/base/file-ini.lua +++ b/tex/context/base/file-ini.lua @@ -47,6 +47,6 @@ local function istexfile(name) end implement { name = "splitfilename", actions = splitfilename, arguments = "string" } -implement { name = "doifparentfileelse", actions = { isparentfile, commands_doifelse }, arguments = "string" } -implement { name = "doifpathexistelse", actions = { lfs.isdir, commands_doifelse }, arguments = "string" } -implement { name = "doiffileexistelse", actions = { istexfile, commands_doifelse }, arguments = "string" } +implement { name = "doifelseparentfile", actions = { isparentfile, commands_doifelse }, arguments = "string" } +implement { name = "doifelsepathexist", actions = { lfs.isdir, commands_doifelse }, arguments = "string" } +implement { name = "doifelsefileexist", actions = { istexfile, commands_doifelse }, arguments = "string" } diff --git a/tex/context/base/file-ini.mkvi b/tex/context/base/file-ini.mkvi index 4cc6ef62a..cb9f18cf9 100644 --- a/tex/context/base/file-ini.mkvi +++ b/tex/context/base/file-ini.mkvi @@ -125,7 +125,7 @@ \def\inputgivenfile#name{\normalinput{#name}} %D \macros -%D {doiffileelse} +%D {doifelsefile} %D %D The next alternative only looks if a file is present. No %D loading is done. This one obeys the standard \TEX\ lookup. @@ -134,13 +134,19 @@ %D \doiffileelse {filename} {found} {not found} %D \stoptyping -\unexpanded\def\doiffileelse {\clf_doiffileexistelse} -\unexpanded\def\doifpathelse {\clf_doifpathexistelse} -\unexpanded\def\doiffile #name{\clf_doiffileexistelse{#name}\firstofoneargument\gobbleoneargument} -\unexpanded\def\doifnotfile #name{\clf_doiffileexistelse{#name}\gobbleoneargument\firstofoneargument} +\unexpanded\def\doifelsefile {\clf_doifelsefileexist} +\unexpanded\def\doifelsepath {\clf_doifelsepathexist} +\unexpanded\def\doiffile #name{\clf_doifelsefileexist{#name}\firstofoneargument\gobbleoneargument} +\unexpanded\def\doifnotfile #name{\clf_doifelsefileexist{#name}\gobbleoneargument\firstofoneargument} -\let\doiffileexistselse\doiffileelse -\let\doifpathexistselse\doifpathelse +\let\doiffileelse\doifelsefile +\let\doifpathelse\doifelsepath + +\let\doifelsefileexists\doifelsefile +\let\doifelsepathexists\doifelsepath + +\let\doiffileexistselse\doifelsefileexists +\let\doifpathexistselse\doifelsepathexists %D \macros %D {doifparentfileelse} @@ -151,7 +157,9 @@ \ifx\outputfilename\undefined \def\outputfilename{\jobname} \fi -\unexpanded\def\doifparentfileelse{\clf_doifparentfileelse} +\unexpanded\def\doifelseparentfile{\clf_doifelseparentfile} + +\let\doifparentfileelse\doifelseparentfile %D \macros %D {splitfilename} @@ -218,7 +226,7 @@ \fi} \unexpanded\def\doinputonce#name% - {\doonlyonce{#name}{\doiffileelse{#name}{\inputgivenfile{#name}}\donothing}} + {\doonlyonce{#name}{\doifelsefile{#name}{\inputgivenfile{#name}}\donothing}} \unexpanded\def\doendinputonce#name% {\ifcsname\??fileonce#name\endcsname diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua index d90dcc271..e8ccb045b 100644 --- a/tex/context/base/file-job.lua +++ b/tex/context/base/file-job.lua @@ -89,7 +89,7 @@ implement { } implement { - name = "doifinputfileelse", + name = "doifelseinputfile", arguments = "string", actions = function(name) ctx_doifelse(findctxfile(name) ~= "") diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi index 74cf8147f..b3aa2e85d 100644 --- a/tex/context/base/file-job.mkvi +++ b/tex/context/base/file-job.mkvi @@ -21,8 +21,10 @@ % processing -\unexpanded\def\doifinputfileelse#name% - {\clf_doifinputfileelse{#name}} +\unexpanded\def\doifelseinputfile#name% + {\clf_doifelseinputfile{#name}} + +\let\doifinputfileelse\doifelseinputfile \unexpanded\def\processfile#name% {\clf_processfile{#name}} @@ -105,7 +107,7 @@ \global\everybye\emptytoks \the\everygoodbye \global\everygoodbye\emptytoks - \doifsometokselse\everynotabene{\writeline\the\everynotabene\writeline}\donothing + \doifelsesometoks\everynotabene{\writeline\the\everynotabene\writeline}\donothing \normalend} % tex's \end \unexpanded\def\starttext {\clf_starttext} @@ -129,20 +131,20 @@ \unexpanded\def\processfileonce#name{\clf_processfileonce{#name}} \unexpanded\def\processfilenone#name{\clf_processfilenone{#name}} -\unexpanded\def\project {\doifnextoptionalcselse\useproject \syst_structure_arg_project} -\unexpanded\def\product {\doifnextoptionalcselse\useproduct \syst_structure_arg_product} -\unexpanded\def\component {\doifnextoptionalcselse\usecomponent \syst_structure_arg_component} -\unexpanded\def\environment{\doifnextoptionalcselse\useenvironment\syst_structure_arg_environment} +\unexpanded\def\project {\doifelsenextoptionalcs\useproject \syst_structure_arg_project} +\unexpanded\def\product {\doifelsenextoptionalcs\useproduct \syst_structure_arg_product} +\unexpanded\def\component {\doifelsenextoptionalcs\usecomponent \syst_structure_arg_component} +\unexpanded\def\environment{\doifelsenextoptionalcs\useenvironment\syst_structure_arg_environment} \def\syst_structure_arg_project #name {\clf_useproject {#name}} \def\syst_structure_arg_product #name {\clf_useproduct {#name}} \def\syst_structure_arg_component #name {\clf_usecomponent {#name}} \def\syst_structure_arg_environment#name {\clf_useenvironment{#name}} -\unexpanded\def\startproject {\doifnextoptionalcselse\syst_structure_start_opt_project \syst_structure_start_arg_project } -\unexpanded\def\startproduct {\doifnextoptionalcselse\syst_structure_start_opt_product \syst_structure_start_arg_product } -\unexpanded\def\startcomponent {\doifnextoptionalcselse\syst_structure_start_opt_component \syst_structure_start_arg_component } -\unexpanded\def\startenvironment{\doifnextoptionalcselse\syst_structure_start_opt_environment\syst_structure_start_arg_environment} +\unexpanded\def\startproject {\doifelsenextoptionalcs\syst_structure_start_opt_project \syst_structure_start_arg_project } +\unexpanded\def\startproduct {\doifelsenextoptionalcs\syst_structure_start_opt_product \syst_structure_start_arg_product } +\unexpanded\def\startcomponent {\doifelsenextoptionalcs\syst_structure_start_opt_component \syst_structure_start_arg_component } +\unexpanded\def\startenvironment{\doifelsenextoptionalcs\syst_structure_start_opt_environment\syst_structure_start_arg_environment} \def\syst_structure_start_arg_project #name {\clf_startproject {#name}} \def\syst_structure_start_arg_product #name {\clf_startproduct {#name}} diff --git a/tex/context/base/file-mod.lua b/tex/context/base/file-mod.lua index ff54dfe97..7f3763c5d 100644 --- a/tex/context/base/file-mod.lua +++ b/tex/context/base/file-mod.lua @@ -214,16 +214,18 @@ function environment.useluamodule(list) end end +local strings = interfaces.strings + implement { name = "usemodules", actions = environment.usemodules, - arguments = { "string", "string" } + arguments = strings[2] } implement { - name = "doifolderversionelse", + name = "doifelseolderversion", actions = function(one,two) commands.doifelse(comparedversion(one,two) >= 0) end, - arguments = { "string", "string" } + arguments = strings[2] } implement { @@ -231,3 +233,10 @@ implement { actions = environment.useluamodule, arguments = "string" } + +implement { + name = "loadluamodule", + actions = function(name) dofile(resolvers.findctxfile(name)) end, -- hack + arguments = "string" +} + diff --git a/tex/context/base/file-mod.mkvi b/tex/context/base/file-mod.mkvi index d4fd3d3bc..f043a68e8 100644 --- a/tex/context/base/file-mod.mkvi +++ b/tex/context/base/file-mod.mkvi @@ -46,7 +46,7 @@ \edef\currentmodule {#name}% \def \currentmoduleparameters{#parameters}% \else\ifsecondargument - \doifassignmentelse{#name} + \doifelseassignment{#name} {\let\currentmodulecategory \empty \edef\currentmodule {#category}% \edef\currentmoduleparameters{#name}} @@ -74,7 +74,7 @@ \newtoks\everysetupmodule \unexpanded\def\startmodule - {\doifnextoptionalcselse\syst_modules_start_yes\syst_modules_start_nop} + {\doifelsenextoptionalcs\syst_modules_start_yes\syst_modules_start_nop} \def\syst_modules_start_yes[#name]% {\pushmacro\currentmodule @@ -124,8 +124,8 @@ \def\currentmoduleparameter{\moduleparameter\currentmodule} % no need for inlining -\unexpanded\def\useluamodule [#name]{\ctxlua{dofile(resolvers.findctxfile("#name"))}} -\unexpanded\def\luaenvironment #name {\ctxlua{dofile(resolvers.findctxfile("#name"))}} +\unexpanded\def\useluamodule [#name]{\clf_loadluamodule{#1}} % why not use useluamodule +\unexpanded\def\luaenvironment #name {\clf_loadluamodule{#1}} % \usemodule[newmml] % \usemodule[newmml][a=b] @@ -205,10 +205,13 @@ %D %D The version pattern is \type {yyyy.mm.dd} (with mm and dd being optional). -\unexpanded\def\doifolderversionelse#parent#child{\clf_doifolderversionelse{#parent}{#child}} -\unexpanded\def\doifoldercontextelse #child{\clf_doifolderversionelse{#child}{}} +\unexpanded\def\doifelseolderversion#parent#child{\clf_doifelseolderversion{#parent}{#child}} +\unexpanded\def\doifelseoldercontext #child{\clf_doifelseolderversion{#child}{}} -%D Relatively new: +\let\doifolderversionelse\doifelseolderversion +\let\doifoldercontextelse\doifelseoldercontext + +%D Relatively new (no need for a speedup here): \unexpanded\def\syst_modules_direct_lua#1#2% {\edef\m_module_command_command {#1}% @@ -251,8 +254,8 @@ \ctxlua{#2(\!!bs#3\!!es,\!!bs#4\!!es)}% \directsetup{module:#1:stop}} -\def\installmodulecommandluaone #1#2{\unexpanded\def#1{\normalexpanded{\syst_modules_one_lua {\strippedcsname#1}{#2}}}} -\def\installmodulecommandluatwo #1#2{\unexpanded\def#1{\normalexpanded{\syst_modules_two_lua {\strippedcsname#1}{#2}}}} +\def\installmodulecommandluaone#1#2{\unexpanded\def#1{\normalexpanded{\syst_modules_one_lua{\strippedcsname#1}{#2}}}} +\def\installmodulecommandluatwo#1#2{\unexpanded\def#1{\normalexpanded{\syst_modules_two_lua{\strippedcsname#1}{#2}}}} % obsolete % diff --git a/tex/context/base/file-res.lua b/tex/context/base/file-res.lua index a1c4986b5..08a3e22af 100644 --- a/tex/context/base/file-res.lua +++ b/tex/context/base/file-res.lua @@ -166,7 +166,7 @@ implement { } implement { - name = "doiflocfileelse", + name = "doifelselocfile", actions = { getreadfilename, isfile, commands.doifelse }, arguments = { "'loc'","'.'", "string" }, } diff --git a/tex/context/base/file-res.mkvi b/tex/context/base/file-res.mkvi index 2799254d2..17f4cf44c 100644 --- a/tex/context/base/file-res.mkvi +++ b/tex/context/base/file-res.mkvi @@ -145,7 +145,9 @@ %D \doiflocfileelse {filename} {before loading} {not found} %D \stoptyping -\unexpanded\def\doiflocfileelse#name{\clf_doiflocfileelse{#name}} +\unexpanded\def\doifelselocfile#name{\clf_doifelselocfile{#name}} \def\locfilename #name{\clf_locfilename {#name}} +\let\doiflocfileelse\doifelselocfile + \protect \endinput diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua index 68dab3c46..6ab89c909 100644 --- a/tex/context/base/font-ext.lua +++ b/tex/context/base/font-ext.lua @@ -7,19 +7,17 @@ if not modules then modules = { } end modules ['font-ext'] = { } local next, type, byte = next, type, string.byte -local gmatch, concat, format = string.gmatch, table.concat, string.format -local utfchar = utf.char -local commands, context = commands, context -local fonts, utilities = fonts, utilities +local context = context +local fonts = fonts +local utilities = utilities -local trace_protrusion = false trackers.register("fonts.protrusion", function(v) trace_protrusion = v end) -local trace_expansion = false trackers.register("fonts.expansion", function(v) trace_expansion = v end) +local trace_protrusion = false trackers.register("fonts.protrusion", function(v) trace_protrusion = v end) +local trace_expansion = false trackers.register("fonts.expansion", function(v) trace_expansion = v end) local report_expansions = logs.reporter("fonts","expansions") local report_protrusions = logs.reporter("fonts","protrusions") - --- todo: byte(..) => 0xHHHH +local report_opbd = logs.reporter("fonts","otf opbd") --[[ldx-- <p>When we implement functions that deal with features, most of them @@ -42,6 +40,8 @@ local getparameters = utilities.parsers.getparameters local setmetatableindex = table.setmetatableindex +local implement = interfaces.implement + -- -- -- -- -- -- -- shared -- -- -- -- -- -- @@ -79,10 +79,6 @@ expansions.vectors = vectors classes.preset = { stretch = 2, shrink = 2, step = .5, factor = 1 } -function commands.setupfontexpansion(class,settings) - getparameters(classes,class,'preset',settings) -end - classes['quality'] = { stretch = 2, shrink = 2, step = .5, vector = 'default', factor = 1 } @@ -172,7 +168,11 @@ registerafmfeature { fonts.goodies.register("expansions", function(...) return fonts.goodies.report("expansions", trace_expansion, ...) end) -local report_opbd = logs.reporter("fonts","otf opbd") +implement { + name = "setupfontexpansion", + arguments = { "string", "string" }, + actions = function(class,settings) getparameters(classes,class,'preset',settings) end +} -- -- -- -- -- -- -- protrusion @@ -191,10 +191,6 @@ local vectors = protrusions.vectors classes.preset = { factor = 1, left = 1, right = 1 } -function commands.setupfontprotrusion(class,settings) - getparameters(classes,class,'preset',settings) -end - classes['pure'] = { vector = 'pure', factor = 1 } @@ -489,6 +485,12 @@ registerafmfeature { fonts.goodies.register("protrusions", function(...) return fonts.goodies.report("protrusions", trace_protrusion, ...) end) +implement { + name = "setupfontprotrusion", + arguments = { "string", "string" }, + actions = function(class,settings) getparameters(classes,class,'preset',settings) end +} + -- -- -- local function initializenostackmath(tfmdata,value) @@ -893,7 +895,10 @@ local new_special = nodes.pool.special local new_glyph = nodes.pool.glyph local hpack_node = node.hpack -function fonts.helpers.addprivate(tfmdata,name,characterdata) +local helpers = fonts.helpers +local currentfont = font.current + +function helpers.addprivate(tfmdata,name,characterdata) local properties = tfmdata.properties local privates = properties.privates local lastprivate = properties.lastprivate @@ -917,7 +922,7 @@ function fonts.helpers.addprivate(tfmdata,name,characterdata) return lastprivate end -function fonts.helpers.getprivatenode(tfmdata,name) +local function getprivatenode(tfmdata,name) local properties = tfmdata.properties local privates = properties and properties.privates if privates then @@ -939,12 +944,18 @@ function fonts.helpers.getprivatenode(tfmdata,name) end end -function fonts.helpers.hasprivate(tfmdata,name) +helpers.getprivatenode = getprivatenode + +function helpers.hasprivate(tfmdata,name) local properties = tfmdata.properties local privates = properties and properties.privates return privates and privates[name] or false end -function commands.getprivatechar(name) - context(fonts.helpers.getprivatenode(fontdata[font.current()],name)) -end +implement { + name = "getprivatechar", + arguments = "string", + actions = function(name) + context(getprivatenode(fontdata[currentfont()],name)) + end +} diff --git a/tex/context/base/font-fea.mkvi b/tex/context/base/font-fea.mkvi index 90da7b0fc..5f6f1b5d5 100644 --- a/tex/context/base/font-fea.mkvi +++ b/tex/context/base/font-fea.mkvi @@ -143,11 +143,11 @@ % hashing at this end is slower -\unexpanded\def\addfeature {\doifnextoptionalcselse\font_feature_add_yes \font_feature_add_nop } -\unexpanded\def\subtractfeature {\doifnextoptionalcselse\font_feature_subtract_yes \font_feature_subtract_nop } -\unexpanded\def\replacefeature {\doifnextoptionalcselse\font_feature_replace_yes \font_feature_replace_nop } -\unexpanded\def\resetandaddfeature{\doifnextoptionalcselse\font_feature_reset_add_yes\font_feature_reset_add_nop} -\unexpanded\def\feature {\doifnextoptionalcselse\font_feature_yes \font_feature_nop } +\unexpanded\def\addfeature {\doifelsenextoptionalcs\font_feature_add_yes \font_feature_add_nop } +\unexpanded\def\subtractfeature {\doifelsenextoptionalcs\font_feature_subtract_yes \font_feature_subtract_nop } +\unexpanded\def\replacefeature {\doifelsenextoptionalcs\font_feature_replace_yes \font_feature_replace_nop } +\unexpanded\def\resetandaddfeature{\doifelsenextoptionalcs\font_feature_reset_add_yes\font_feature_reset_add_nop} +\unexpanded\def\feature {\doifelsenextoptionalcs\font_feature_yes \font_feature_nop } \unexpanded\def\font_feature_add_yes [#feature]{\edef\m_font_feature_asked{#feature}\font_feature_add} \unexpanded\def\font_feature_add_nop #feature{\edef\m_font_feature_asked{#feature}\font_feature_add} @@ -326,6 +326,8 @@ \def\doifelsecurrentfonthasfeature#feature% {\clf_doifelsecurrentfonthasfeature{#feature}} +\let\doifcurrentfonthasfeatureelse\doifelsecurrentfonthasfeature + % new: \clf_registerlanguagefeatures diff --git a/tex/context/base/font-fil.mkvi b/tex/context/base/font-fil.mkvi index 0f1d27564..1a20d1cd8 100644 --- a/tex/context/base/font-fil.mkvi +++ b/tex/context/base/font-fil.mkvi @@ -89,11 +89,11 @@ \def\font_basics_define_font_synonym_nop {\expandafter\let\csname\??fontfile\m_font_name\endcsname\m_font_file - \doifnextoptionalcselse\font_basics_define_font_synonym_nop_opt\font_basics_define_font_synonym_nop_nil} + \doifelsenextoptionalcs\font_basics_define_font_synonym_nop_opt\font_basics_define_font_synonym_nop_nil} \def\font_basics_define_font_synonym_yes {\expandafter\let\csname\??fontfile\fontclass\m_font_name\endcsname\m_font_file - \doifnextoptionalcselse\font_basics_define_font_synonym_yes_opt\font_basics_define_font_synonym_yes_nil} + \doifelsenextoptionalcs\font_basics_define_font_synonym_yes_opt\font_basics_define_font_synonym_yes_nil} \def\font_basics_define_font_synonym_nop_opt[#specification]% {\let\p_features \undefined @@ -241,6 +241,8 @@ \doubleexpandafter\secondoftwoarguments \fi\fi} +\let\doiffontsynonymelse\doifelsefontsynonym + %D \macros %D {tracedfontname} %D diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua index b021004fe..51fe6d0a1 100644 --- a/tex/context/base/font-gds.lua +++ b/tex/context/base/font-gds.lua @@ -834,6 +834,7 @@ implement { implement { name = "enablefontcolorschemes", + once = true, actions = colorschemes.enable } diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi index dc3c491d2..c780ee997 100644 --- a/tex/context/base/font-ini.mkvi +++ b/tex/context/base/font-ini.mkvi @@ -363,7 +363,7 @@ \let\thedefinedfont\relax % not to be confused with \everydefinefont \unexpanded\def\definedfont - {\doifnextoptionalcselse\font_basics_defined_font_yes\font_basics_defined_font_nop} + {\doifelsenextoptionalcs\font_basics_defined_font_yes\font_basics_defined_font_nop} \def\font_basics_defined_font_yes[#specification]% {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly @@ -899,7 +899,7 @@ \fi} \def\font_basics_define_font_a[#name][#specification][#settings]% [name][spec][1.6 | line=10pt | setup_id] - {\doifsetupselse{#settings}% + {\doifelsesetups{#settings}% {\setuvalue{#name}{\font_basics_define_font_with_setups {#name}{#specification}{#settings}}} {\setuvalue{#name}{\font_basics_define_font_with_parameters{#name}{#specification}{#settings}}}} @@ -1405,19 +1405,19 @@ {\font_basics_define_body_font_a[bwhatever][\s!rm][]} \unexpanded\def\font_basics_define_body_font_a[#whatever]% - {\doifnumberelse{#whatever}% + {\doifelsenumber{#whatever}% \font_basics_define_body_font_body \font_basics_define_body_font_name [#whatever]} \unexpanded\def\font_basics_define_body_font_body[#body][#style][#specification]% - {\doifassignmentelse{#specification} + {\doifelseassignment{#specification} \font_basics_define_body_font_body_assignment \font_basics_define_body_font_body_identifier [#body][#style][#specification]}% \unexpanded\def\font_basics_define_body_font_name[#name][#style][#specification]% - {\doifassignmentelse{#specification} + {\doifelseassignment{#specification} \font_basics_define_body_font_name_assignment \font_basics_define_body_font_name_identifier [#name][#style][#specification]}% @@ -1678,13 +1678,13 @@ \fi} \def\font_helpers_set_font_check_size#option% - {\doifnumberelse{#option}{\font_helpers_check_bodyfont_environment{#option}{#option}}\donothing} + {\doifelsenumber{#option}{\font_helpers_check_bodyfont_environment{#option}{#option}}\donothing} \def\font_helpers_set_font_set_font#method#option% method=1: set, method=2: switch {\doifsomething{#option}{\font_helpers_set_font_set_font_option{#method}{#option}}} \def\font_helpers_set_font_set_font_option#method#option% - {\doifnumberelse{#option}% + {\doifelsenumber{#option}% \font_helpers_set_font_set_font_option_body \font_helpers_set_font_set_font_option_keyword {#method}{#option}{#option}} @@ -2141,7 +2141,7 @@ % \newtoks \everyswitchtobodyfont \unexpanded\def\setupbodyfont - {\doifnextoptionalcselse\font_basics_setupbodyfont_yes\font_basics_setupbodyfont_nop} + {\doifelsenextoptionalcs\font_basics_setupbodyfont_yes\font_basics_setupbodyfont_nop} \def\font_basics_setupbodyfont_nop {\restoreglobalbodyfont @@ -2264,7 +2264,7 @@ %D \stoptyping \unexpanded\def\switchstyleonly - {\doifnextoptionalcselse\font_basics_switch_style_only_opt\font_basics_switch_style_only_arg} + {\doifelsenextoptionalcs\font_basics_switch_style_only_opt\font_basics_switch_style_only_arg} \def\font_basics_switch_style_only_arg#name% stupid version {\font_helpers_set_current_font_style{\csname\??fontshortstyle\checkedstrippedcsname#name\endcsname}% diff --git a/tex/context/base/font-sel.mkvi b/tex/context/base/font-sel.mkvi index 94cd14929..820d211eb 100644 --- a/tex/context/base/font-sel.mkvi +++ b/tex/context/base/font-sel.mkvi @@ -102,7 +102,7 @@ {\dodoubleargument\selectfont_preset_define} \def\selectfont_preset_define[#name][#settings]% - {\doifassignmentelse{#settings} + {\doifelseassignment{#settings} {\setvalue{\??selectfontpreset#name}{\setupcurrentselectfont[#settings]}} {\setvalue{\??selectfontpreset#name}{\csname\??selectfontpreset#settings\endcsname}}} @@ -325,7 +325,7 @@ {\doquadrupleempty\selectfont_family_define} \def\selectfont_family_define[#typeface][#style][#family][#settings]% - {\doifassignmentelse{#settings} + {\doifelseassignment{#settings} {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},#settings]} {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},\c!preset={#settings}]}% \clf_definefontfamily\selectfont_index\relax} @@ -334,7 +334,7 @@ {\doquadrupleempty\selectfont_fallback_define} \def\selectfont_fallback_define[#typeface][#style][#family][#settings]% - {\doifassignmentelse{#settings} + {\doifelseassignment{#settings} {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},#settings]} {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},\c!preset={#settings}]}% \edef\p_selectfont_style{\expandnamespacevalue\??selectfontstyle{#style}\s!rm}% diff --git a/tex/context/base/font-set.mkvi b/tex/context/base/font-set.mkvi index 9b1c733c1..b185b2659 100644 --- a/tex/context/base/font-set.mkvi +++ b/tex/context/base/font-set.mkvi @@ -47,7 +47,7 @@ \globallet\font_preloads_reset_nullfont\relax} \def\font_preload_check_mode - {\doifmodeelse{lmmath} + {\doifelsemode{lmmath} {\def\m_font_fallback_name{modern-designsize-virtual}}% this will stay {\def\m_font_fallback_name{modern-designsize}}% % this might become 'modern' \glet\font_preload_check_mode\relax} @@ -103,7 +103,7 @@ \font_preloads_zero_stage} \unexpanded\def\font_preloads_first_stage % % *nofonts -> *preloadfonts - {\doifmodeelse{*preloadfonts} + {\doifelsemode{*preloadfonts} {\font_preload_default_fonts \writestatus\m!fonts{preloading latin modern fonts (first stage)}} {\writestatus\m!fonts{latin modern fonts are not preloaded}}} diff --git a/tex/context/base/font-sty.mkvi b/tex/context/base/font-sty.mkvi index 03fa598c2..673cf25ae 100644 --- a/tex/context/base/font-sty.mkvi +++ b/tex/context/base/font-sty.mkvi @@ -279,7 +279,7 @@ {\groupedcommand{\font_styles_use_defined{#name}}{}} % or {\font_styles_apply_grouped{#name}} \setvalue{\??styleargument3}#specification% - {\doifassignmentelse{#specification}\font_styles_assignment\font_styles_direct{#specification}} + {\doifelseassignment{#specification}\font_styles_assignment\font_styles_direct{#specification}} \def\font_styles_assignment#specification{\groupedcommand{\font_styles_use_generic{#specification}}{}} \def\font_styles_direct #specification{\groupedcommand{\definedfont[#specification]}{}} @@ -311,7 +311,7 @@ {\font_styles_use_defined{#name}} \setvalue{\??styleenvironment3}#specification% - {\doifassignmentelse{#specification}\font_styles_start_assignment\font_styles_start_direct{#specification}} + {\doifelseassignment{#specification}\font_styles_start_assignment\font_styles_start_direct{#specification}} \def\font_styles_start_assignment#specification{\font_styles_use_generic{#specification}} \def\font_styles_start_direct #specification{\definedfont[#specification]\relax} diff --git a/tex/context/base/font-sym.mkvi b/tex/context/base/font-sym.mkvi index 1badf338f..a21bea0ba 100644 --- a/tex/context/base/font-sym.mkvi +++ b/tex/context/base/font-sym.mkvi @@ -110,12 +110,14 @@ %D The next macro can be used to make decisions based on the shape: -\def\doifitalicelse#yes#nop% +\def\doifelseitalic#yes#nop% {\ifx\fontalternative\s!sl#yes\else \ifx\fontalternative\s!it#yes\else \ifx\fontalternative\s!bs#yes\else \ifx\fontalternative\s!bi#yes\else#nop\fi\fi\fi\fi} +\let\doifitalicelse\doifelseitalic + %D For an example of usage of the following command, %D see \type {cont-log.tex}. %D @@ -169,13 +171,13 @@ \unexpanded\def\getnamedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\clf_fontchar{#character}}} \unexpanded\def\getnamedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_fontchar{#character}}} -\unexpanded\def\getglyphstyled #fontname#character{{\setstyledsymbolicfont{#fontname}\doifnumberelse{#character}\char\donothing#character}} -\unexpanded\def\getglyphdirect #fontname#character{{\setdirectsymbolicfont{#fontname}\doifnumberelse{#character}\char\donothing#character}} +\unexpanded\def\getglyphstyled #fontname#character{{\setstyledsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}} +\unexpanded\def\getglyphdirect #fontname#character{{\setdirectsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}} % this one is wrong: \unexpanded\def\getscaledglyph#scale#name#content% - {{\setscaledstyledsymbolicfont\fontbody{#scale}{#name}\doifnumberelse{#content}\char\donothing#content}} + {{\setscaledstyledsymbolicfont\fontbody{#scale}{#name}\doifelsenumber{#content}\char\donothing#content}} \let\getglyph \getglyphstyled % old \let\getrawglyph \getglyphdirect % old @@ -234,7 +236,7 @@ %D \macros{doiffontcharelse} -\unexpanded\def\doiffontcharelse#specification#unicode% this could be a direct lua call +\unexpanded\def\doifelsefontchar#specification#unicode% this could be a direct lua call {\begingroup \font_basics_define_font_without_parameters{thedefinedfont}{#specification}% \iffontchar\font#unicode\relax @@ -243,4 +245,6 @@ \endgroup\expandafter\secondoftwoarguments \fi} +\let\doiffontcharelse\doifelsefontchar + \protect \endinput diff --git a/tex/context/base/font-tra.mkiv b/tex/context/base/font-tra.mkiv index 6b9fb1f47..d251b8b69 100644 --- a/tex/context/base/font-tra.mkiv +++ b/tex/context/base/font-tra.mkiv @@ -95,7 +95,9 @@ %D \doiffontpresentelse{adam-lindsay-modern-serif}{YES}{NO} %D \stoptyping -\unexpanded\def\doiffontpresentelse#1{\ctxcommand{doifelse(fonts.names.exists("#1"))}} +\unexpanded\def\doifelsefontpresent#1{\ctxcommand{doifelse(fonts.names.exists("#1"))}} + +\let\doiffontpresentelse\doifelsefontpresent % experimental, maybe this becomes a module diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv index 9b9333fa9..9566bb0a1 100644 --- a/tex/context/base/grph-fig.mkiv +++ b/tex/context/base/grph-fig.mkiv @@ -45,7 +45,7 @@ {\ifsecondargument \grph_buffers_typeset_indeed[#1][#2]% \else\iffirstargument - \doifassignmentelse{#1} + \doifelseassignment{#1} {\grph_buffers_typeset_indeed[\jobname][#1]}% {\grph_buffers_typeset_indeed[#1][]}% \else @@ -53,7 +53,7 @@ \fi\fi} \def\grph_buffers_typeset_indeed[#1][#2]% we could use the via files - {\doifnot{#1}{*}{\xdef\lasttypesetbuffer{\ctxcommand{runbuffer("#1",true)}}}% + {\doifnot{#1}{*}{\xdef\lasttypesetbuffer{\clf_runbuffer{#1}}}% \ifcase\c_grph_buffers_mode % typesetonly \or diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv index 1f1c0054d..fa2efeccc 100644 --- a/tex/context/base/grph-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -184,14 +184,14 @@ \def\grph_include_use[#1][#2][#3][#4]% {\doifelsenothing{#1} {\doifsomething{#2} - {\doifassignmentelse{#3} + {\doifelseassignment{#3} {\grph_include_use_indeed{#2}{#2}{#3}{#4}} {\grph_include_use_indeed{#2}{#2}\empty{#4}}}} {\doifelsenothing{#2} - {\doifassignmentelse{#3} + {\doifelseassignment{#3} {\grph_include_use_indeed{#1}{#1}\empty{#3}} {\grph_include_use_indeed{#1}{#1}{#3}{#4}}} - {\doifassignmentelse{#3} + {\doifelseassignment{#3} {\grph_include_use_indeed{#1}{#2}\empty{#3}} {\grph_include_use_indeed{#1}{#2}{#3}{#4}}}}} @@ -641,7 +641,7 @@ \externalfigure[#1][#2,\c!display=,\c!mask=,\c!object=\v!no]% \stopnointerference} -\unexpanded\def\doiffigureelse#1% +\unexpanded\def\doifelsefigure#1% {\getfiguredimensions[#1]% so data is available ! \ifcase\figurestatus \expandafter\secondoftwoarguments @@ -649,6 +649,8 @@ \expandafter\firstoftwoarguments \fi} +\let\doiffigureelse\doifelsefigure + % No placement, handy for preprocessing: \unexpanded\def\registerexternalfigure diff --git a/tex/context/base/grph-trf.mkiv b/tex/context/base/grph-trf.mkiv index d907c1b0c..fca5c7cf6 100644 --- a/tex/context/base/grph-trf.mkiv +++ b/tex/context/base/grph-trf.mkiv @@ -108,7 +108,7 @@ \edef\currentscale{#1}% \setupcurrentscale[#2]% \else\iffirstargument - \doifassignmentelse{#1} + \doifelseassignment{#1} {\let\currentscale\empty \setupcurrentscale[#1]} {\edef\currentscale{#1}}% @@ -318,11 +318,11 @@ \def\m_grph_scale_factor_set{\v!max,\v!fit,\v!broad,\v!auto} % can be an \edef \def\grph_scale_by_factor - {\doifinsetelse\p_factor\m_grph_scale_factor_set + {\doifelseinset\p_factor\m_grph_scale_factor_set \grph_scale_by_factor_a - {\doifinsetelse\p_hfactor\m_grph_scale_factor_set + {\doifelseinset\p_hfactor\m_grph_scale_factor_set \grph_scale_by_factor_b - {\doifinsetelse\p_wfactor\m_grph_scale_factor_set + {\doifelseinset\p_wfactor\m_grph_scale_factor_set \grph_scale_by_factor_c \grph_scale_by_factor_d}}} @@ -1080,18 +1080,18 @@ {\boxcursor\box\nextbox} \setvalue{\??rotatepreset\v!left}% - {\edef\p_rotation_rotation{\doifoddpageelse{90}{270}}} + {\edef\p_rotation_rotation{\doifelseoddpage{90}{270}}} \setvalue{\??rotatepreset\v!right}% - {\edef\p_rotation_rotation{\doifoddpageelse{270}{90}}} + {\edef\p_rotation_rotation{\doifelseoddpage{270}{90}}} \setvalue{\??rotatepreset\v!inner}% {\signalrightpage - \doifrightpageelse{\def\p_rotation_rotation{270}}{\def\p_rotation_rotation{90}}} + \doifelserightpage{\def\p_rotation_rotation{270}}{\def\p_rotation_rotation{90}}} \setvalue{\??rotatepreset\v!outer}% {\signalrightpage - \doifrightpageelse{\def\p_rotation_rotation{90}}{\def\p_rotation_rotation{270}}} + \doifelserightpage{\def\p_rotation_rotation{90}}{\def\p_rotation_rotation{270}}} \setvalue{\??rotatepreset\v!default}% {\edef\p_rotation_rotation{\realnumber{\p_rotation_rotation}}}% get rid of leading zeros and spaces diff --git a/tex/context/base/hand-ini.mkiv b/tex/context/base/hand-ini.mkiv index 16c8b0746..fd18e3221 100644 --- a/tex/context/base/hand-ini.mkiv +++ b/tex/context/base/hand-ini.mkiv @@ -42,8 +42,8 @@ \unexpanded\def\setupfontexpansion {\dodoubleargument\font_expansion_setup } \unexpanded\def\setupfontprotrusion{\dodoubleargument\font_protrusion_setup} -\def\font_expansion_setup [#1][#2]{\ctxcommand{setupfontexpansion ("#1","#2")}} -\def\font_protrusion_setup[#1][#2]{\ctxcommand{setupfontprotrusion("#1","#2")}} +\def\font_expansion_setup [#1][#2]{\clf_setupfontexpansion {#1}{#2}} +\def\font_protrusion_setup[#1][#2]{\clf_setupfontprotrusion{#1}{#2}} % \setupfontprotrusion[quality-upright][vector=quality] % \setupfontprotrusion[quality-slanted][vector=quality,right=1.5] diff --git a/tex/context/base/lang-ini.mkiv b/tex/context/base/lang-ini.mkiv index 3391c6510..335d6d1c9 100644 --- a/tex/context/base/lang-ini.mkiv +++ b/tex/context/base/lang-ini.mkiv @@ -213,13 +213,15 @@ \def\installedlanguages{\clf_installedlanguages} -\unexpanded\def\doiflanguageelse#1% +\unexpanded\def\doifelselanguage#1% {\ifcsname\??language#1\c!state\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doiflanguageelse\doifelselanguage + \def\reallanguagetag#1% {\ifcsname\??languagelinked#1\endcsname\csname\??languagelinked#1\endcsname\else#1\fi} @@ -229,8 +231,8 @@ {\dodoubleargument\lang_basics_install} \def\lang_basics_install[#1][#2]% - {\doifassignmentelse{#2} - {\doiflanguageelse{#1} + {\doifelseassignment{#2} + {\doifelselanguage{#1} {\getparameters[\??language#1][#2]} {\setvalue{\??languagelinked#1}{#1}% \lang_basics_install_indeed{#1}{#1}% @@ -250,7 +252,7 @@ %D used dutch mnemonics in the dutch version, but nowadays %D conform a standard. -\unexpanded\def\doifpatternselse#1% +\unexpanded\def\doifelsepatterns#1% {\begingroup % will change \lang_basics_set_current[#1]% \ifnum\normallanguage>\zerocount @@ -259,6 +261,8 @@ \endgroup\expandafter\secondoftwoarguments \fi} +\let\doifpatternselse\doifelsepatterns + %D \macros %D {setuplanguage} %D @@ -561,7 +565,7 @@ \lang_basics_switch_asked} \unexpanded\def\language - {\doifnextoptionalcselse\lang_basics_set_current\normallanguage} + {\doifelsenextoptionalcs\lang_basics_set_current\normallanguage} \let\setlanguage\language % we make these synonyms diff --git a/tex/context/base/luat-ini.mkiv b/tex/context/base/luat-ini.mkiv index 37d84ccce..22f96cd7c 100644 --- a/tex/context/base/luat-ini.mkiv +++ b/tex/context/base/luat-ini.mkiv @@ -131,14 +131,15 @@ % seldom used so no need for speedy variants: -\def\doifdocumentargumentelse #1{\doifsomethingelse{\clf_getdocumentargument{#1}}} +\def\doifelsedocumentargument #1{\doifelsesomething{\clf_getdocumentargument{#1}}} \def\doifdocumentargument #1{\doifsomething {\clf_getdocumentargument{#1}}} \def\doifnotdocumentargument #1{\doifnothing {\clf_getdocumentargument{#1}}} -\def\doifdocumentfilenameelse #1{\doifsomethingelse{\clf_getdocumentfilename\numexpr#1\relax}} +\def\doifelsedocumentfilename #1{\doifelsesomething{\clf_getdocumentfilename\numexpr#1\relax}} \def\doifdocumentfilename #1{\doifsomething {\clf_getdocumentfilename\numexpr#1\relax}} \def\doifnotdocumentfilename #1{\doifnothing {\clf_getdocumentfilename\numexpr#1\relax}} -\let\doifelsedocumentargument\doifdocumentargumentelse +\let\doifdocumentargumentelse\doifelsedocumentargument +\let\doifdocumentfilenameelse\doifelsedocumentfilename %D A handy helper: @@ -265,7 +266,18 @@ {\if\noexpand#1\letterbackslash\else#1\fi} \normalprotected\def\installctxfunction#1#2% - {\global\expandafter\chardef\csname\??luafunction\checkedstrippedcsname#1\endcsname\ctxcommand{ctxfunction("#2",true)}\relax - \expandafter\xdef\csname\checkedstrippedcsname#1\endcsname{\noexpand\luafunction\csname\??luafunction\checkedstrippedcsname#1\endcsname}} + {\edef\m_syst_name{\checkedstrippedcsname#1}% + \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxfunction("#2",true)}\relax + \expandafter\xdef\csname\m_syst_name\endcsname{\noexpand\luafunction\csname\??luafunction\m_syst_name\endcsname}} + +\normalprotected\def\installctxscanner#1#2% + {\edef\m_syst_name{\checkedstrippedcsname#1}% + \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name","#2",true)}\relax + \expandafter\xdef\csname\m_syst_name\endcsname{\noexpand\luafunction\csname\??luafunction\m_syst_name\endcsname}} + +\normalprotected\def\resetctxscanner#1% + {\edef\m_syst_name{\checkedstrippedcsname#1}% + \global\expandafter\chardef\csname\??luafunction\m_syst_name\endcsname\zerocount + \global\expandafter\let\csname\m_syst_name\endcsname\relax} \protect \endinput diff --git a/tex/context/base/luat-mac.lua b/tex/context/base/luat-mac.lua index 15bc14132..8e2524dce 100644 --- a/tex/context/base/luat-mac.lua +++ b/tex/context/base/luat-mac.lua @@ -388,7 +388,7 @@ end -- \normalexpanded -- {\def\yes[#one]#two\csname\e!stop#stoptag\endcsname{\command_yes[#one]{#two}}% -- \def\nop #one\csname\e!stop#stoptag\endcsname{\command_nop {#one}}}% --- \doifnextoptionalelse\yes\nop} +-- \doifelsenextoptional\yes\nop} -- ]])) -- -- print(macros.preprocessed([[ diff --git a/tex/context/base/lxml-aux.lua b/tex/context/base/lxml-aux.lua index 19c5968b7..f6816ccb6 100644 --- a/tex/context/base/lxml-aux.lua +++ b/tex/context/base/lxml-aux.lua @@ -16,7 +16,7 @@ local report_xml = logs.reporter("xml") local xml = xml -local xmlconvert, xmlcopy, xmlname = xml.convert, xml.copy, xml.name +local xmlcopy, xmlname = xml.copy, xml.name local xmlinheritedconvert = xml.inheritedconvert local xmlapplylpath = xml.applylpath local xmlfilter = xml.filter @@ -167,6 +167,8 @@ local function redo_ni(d) end end +xml.reindex = redo_ni + local function xmltoelement(whatever,root) if not whatever then return nil diff --git a/tex/context/base/lxml-ini.lua b/tex/context/base/lxml-ini.lua index 8506e1096..6feaa8500 100644 --- a/tex/context/base/lxml-ini.lua +++ b/tex/context/base/lxml-ini.lua @@ -6,11 +6,14 @@ if not modules then modules = { } end modules ['lxml-ini'] = { license = "see context related readme files" } -local xml = xml -local lxml = lxml +local xml = xml +local lxml = lxml + +-- this defines an extra scanner lxmlid: local scanners = tokens.scanners local scanstring = scanners.string +local getid = lxml.id scanners.lxmlid = function() return getid(scanstring()) end @@ -18,6 +21,8 @@ local implement = interfaces.implement -- lxml.id +implement { name = "lxmlid", actions = lxml.getid, arguments = "string" } + implement { name = "xmldoif", actions = lxml.doif, arguments = { "string", "string" } } implement { name = "xmldoifnot", actions = lxml.doifnot, arguments = { "string", "string" } } implement { name = "xmldoifelse", actions = lxml.doifelse, arguments = { "string", "string" } } diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv index 728bfcd00..114128899 100644 --- a/tex/context/base/lxml-ini.mkiv +++ b/tex/context/base/lxml-ini.mkiv @@ -193,20 +193,6 @@ % these are expandable! todo: \xmldoifelseattribute -%def\xmldoif #1#2{\clf_xmldoif {#1}{#2}} -%def\xmldoifnot #1#2{\clf_xmldoifnot {#1}{#2}} -%def\xmldoifelse #1#2{\clf_xmldoifelse {#1}{#2}} -%def\xmldoiftext #1#2{\clf_xmldoiftext {#1}{#2}} -%def\xmldoifnottext #1#2{\clf_xmldoifnottext {#1}{#2}} -%def\xmldoifelsetext #1#2{\clf_xmldoifelsetext {#1}{#2}} - -%def\xmldoifempty #1#2{\clf_xmldoifempty {#1}{#2}} -%def\xmldoifnotempty #1#2{\clf_xmldoifnotempty {#1}{#2}} -%def\xmldoifelseempty #1#2{\clf_xmldoifelseempty {#1}{#2}} -%def\xmldoifselfempty #1{\clf_xmldoifselfempty {#1}} -%def\xmldoifnotselfempty #1{\clf_xmldoifnotselfempty {#1}} -%def\xmldoifelseselfempty #1{\clf_xmldoifelseselfempty{#1}} - \let\xmldoif \clf_xmldoif \let\xmldoifnot \clf_xmldoifnot \let\xmldoifelse \clf_xmldoifelse @@ -221,6 +207,10 @@ \let\xmldoifnotselfempty \clf_xmldoifnotselfempty \let\xmldoifelseselfempty \clf_xmldoifelseselfempty +\let\xmldoiftextelse \xmldoifelsetext +\let\xmldoifemptyelse \xmldoifelseempty +\let\xmldoifselfemptyelse \xmldoifelseselfempty + % \startxmlsetups xml:include % \xmlinclude{main}{include}{filename|href} % \stopxmlsetups @@ -372,8 +362,11 @@ % processing instructions -\def\xmlcontextdirective#1% kind class key value - {\executeifdefined{xml#1directive}\gobblethreearguments} +\unexpanded\def\xmlinstalldirective#1#2% + {\clf_xmlinstalldirective{#1}{\checkedstrippedcsname#2}} + +% \def\xmlcontextdirective#1% kind class key value +% {\executeifdefined{xml#1directive}\gobblethreearguments} % setting up xml: % @@ -421,6 +414,8 @@ %def\xmlvalue #1#2{\ifcsname\??xmlmapvalue#1:#2\endcsname\csname\??xmlmapvalue#1:#2\expandafter\expandafter\gobbleoneargument\expandafter\endcsname\else\expandafter\firstofoneargument\fi} \def\xmldoifelsevalue #1#2{\ifcsname\??xmlmapvalue#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} +\let\xmldoifvalueelse\xmldoifelsevalue + \let\xmlmapval\xmlmapvalue \let\xmlval \xmlvalue @@ -487,6 +482,16 @@ \let\processxmlfile \processXMLfile \let\xmldata \XMLdata +\unexpanded\def\xmlsetinjectors[#1]% + {\clf_xmlsetinjectors{#1}} + +\unexpanded\def\xmlresetinjectors + {\clf_xmlresetinjectors{}} + +\def\xmlinjector#1{\executeifdefined{#1}\donothing} + +\let\xmlapplyselectors\clf_xmlapplyselectors + \protect \endinput % \newcount\charactersactiveoffset \charactersactiveoffset="10000 diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua index 383c06aa0..82495383e 100644 --- a/tex/context/base/lxml-tex.lua +++ b/tex/context/base/lxml-tex.lua @@ -24,26 +24,40 @@ local basename, dirname, joinfile = file.basename, file.dirname, file.join lxml = lxml or { } local lxml = lxml -local catcodenumbers = catcodes.numbers -local ctxcatcodes = catcodenumbers.ctxcatcodes -- todo: use different method -local notcatcodes = catcodenumbers.notcatcodes -- todo: use different method - -local commands = commands -local context = context -local contextsprint = context.sprint -- with catcodes (here we use fast variants, but with option for tracing) - -local xmlelements, xmlcollected, xmlsetproperty = xml.elements, xml.collected, xml.setproperty -local xmlwithelements = xml.withelements -local xmlserialize, xmlcollect, xmltext, xmltostring = xml.serialize, xml.collect, xml.text, xml.tostring -local xmlapplylpath = xml.applylpath -local xmlunprivatized, xmlprivatetoken, xmlprivatecodes = xml.unprivatized, xml.privatetoken, xml.privatecodes -local xmlstripelement = xml.stripelement -local xmlinclusion, xmlinclusions = xml.inclusion, xml.inclusions -local xmlcontent = xml.content +local catcodenumbers = catcodes.numbers +local ctxcatcodes = catcodenumbers.ctxcatcodes -- todo: use different method +local notcatcodes = catcodenumbers.notcatcodes -- todo: use different method + +local commands = commands +local context = context +local contextsprint = context.sprint -- with catcodes (here we use fast variants, but with option for tracing) + +local implement = interfaces.implement + +local xmlelements = xml.elements +local xmlcollected = xml.collected +local xmlsetproperty = xml.setproperty +local xmlwithelements = xml.withelements +local xmlserialize = xml.serialize +local xmlcollect = xml.collect +local xmltext = xml.text +local xmltostring = xml.tostring +local xmlapplylpath = xml.applylpath +local xmlunprivatized = xml.unprivatized +local xmlprivatetoken = xml.privatetoken +local xmlprivatecodes = xml.privatecodes +local xmlstripelement = xml.stripelement +local xmlinclusion = xml.inclusio +local xmlinclusions = xml.inclusions +local xmlcontent = xml.content local variables = interfaces and interfaces.variables or { } local settings_to_hash = utilities.parsers.settings_to_hash +local settings_to_set = utilities.parsers.settings_to_set +local options_to_hash = utilities.parsers.options_to_hash +local options_to_array = utilities.parsers.options_to_array + local insertbeforevalue = utilities.tables.insertbeforevalue local insertaftervalue = utilities.tables.insertaftervalue @@ -593,30 +607,49 @@ local function tex_element(e,handlers) end end +-- <?context-directive foo ... ?> +-- <?context-foo-directive ... ?> + local pihandlers = { } xml.pihandlers = pihandlers -local category = P("context-") * C((1-P("-"))^1) * P("-directive") local space = S(" \n\r") local spaces = space^0 local class = C((1-space)^0) local key = class +local rest = C(P(1)^0) local value = C(P(1-(space * -1))^0) - -local parser = category * spaces * class * spaces * key * spaces * value - -pihandlers[#pihandlers+1] = function(str) - if str then - local a, b, c, d = lpegmatch(parser,str) - if d then - contextsprint(ctxcatcodes,"\\xmlcontextdirective{",a,"}{",b,"}{",c,"}{",d,"}") +local category = P("context-") * ( + C((1-P("-"))^1) * P("-directive") + + P("directive") * spaces * key + ) + +local c_parser = category * spaces * value -- rest +local k_parser = class * spaces * key * spaces * rest --value + +implement { + name = "xmlinstalldirective", + arguments = { "string", "string" }, + actions = function(name,csname) + if csname then + local keyvalueparser = k_parser / context[csname] + local keyvaluechecker = function(category,rest,e) + lpegmatch(keyvalueparser,rest) + end + pihandlers[name] = keyvaluechecker end end -end +} local function tex_pi(e,handlers) local str = e.dt[1] - for i=1,#pihandlers do - pihandlers[i](str) + if str and str ~= "" then + local category, rest = lpegmatch(c_parser,str) + if category and rest and #rest > 0 then + local handler = pihandlers[category] + if handler then + handler(category,rest,e) + end + end end end @@ -1826,3 +1859,180 @@ function lxml.tobuffer(id,pattern,name,unescaped) buffers.erase(name) end end + +-- relatively new: + +local permitted = nil +local ctx_xmlinjector = context.xmlinjector + +xml.pihandlers["injector"] = function(category,rest,e) + local options = options_to_array(rest) + local action = options[1] + if not action then + return + end + local n = #options + if n > 1 then + local category = options[2] + if category == "*" then + ctx_xmlinjector(action) + elseif permitted then + if n == 2 then + if permitted[category] then + ctx_xmlinjector(action) + end + else + for i=2,n do + local category = options[i] + if category == "*" or permitted[category] then + ctx_xmlinjector(action) + return + end + end + end + end + else + ctx_xmlinjector(action) + end +end + +local pattern = P("context-") * C((1-lpeg.patterns.whitespace)^1) * C(P(1)^1) + +function lxml.applyselectors(id) + local root = getid(id) + local function filter(e) + local dt = e.dt + local ndt = #dt + local done = false + for i=1,ndt do + local dti = dt[i] + if type(dti) == "table" then + if dti.tg == "@pi@" then + local text = dti.dt[1] + local what, rest = lpegmatch(pattern,text) + if what == "select" then + local categories = options_to_hash(rest) + if categories["begin"] then + local okay = false + for k, v in next, permitted do + if categories[k] then + okay = true + break + end + end + if not okay then + for j=i,ndt do + local dtj = dt[j] + if type(dtj) == "table" then + local tg = dtj.tg + if tg == "@pi@" then + local text = dtj.dt[1] + local what, rest = lpegmatch(pattern,text) + if what == "select" then + local categories = options_to_hash(rest) + if categories["end"] then + break + else + -- error + end + end + else + dtj.tg = "@cm@" + end + end + end + end + end + elseif what == "include" then + local categories = options_to_hash(rest) + if categories["begin"] then + local okay = false + for k, v in next, permitted do + if categories[k] then + okay = true + break + end + end + if okay then + for j=i,ndt do + local dtj = dt[j] + if type(dtj) == "table" then + local tg = dtj.tg + if tg == "@cm@" then + local content = dtj.dt[1] + local element = root and xml.toelement(content,root) + dt[j] = element + element.__p__ = dt -- needs checking + done = true + elseif tg == "@pi@" then + local text = dti.dt[1] + local what, rest = lpegmatch(pattern,text) + if what == "include" then + local categories = options_to_hash(rest) + if categories["end"] then + break + else + -- error + end + end + end + end + end + break + end + end + else + filter(dti) + end + end + if done then + -- probably not needed + xml.reindex(dt) + end + end + end + end + xmlwithelements(root,filter) +end + +function xml.setinjectors(set) + local s = settings_to_set(set) + if permitted then + for k, v in next, s do + permitted[k] = true + end + else + permitted = s + end +end + +function xml.resetinjectors(set) + if permitted and set and set ~= "" then + local s = settings_to_set(set) + for k, v in next, s do + if v then + permitted[k] = nil + end + end + else + permitted = nil + end +end + +implement { + name = "xmlsetinjectors", + actions = xml.setinjectors, + arguments = "string" +} + +implement { + name = "xmlresetinjectors", + actions = xml.resetinjectors, + arguments = "string" +} + +implement { + name = "xmlapplyselectors", + actions = lxml.applyselectors, + arguments = "string" +} diff --git a/tex/context/base/m-hemistich.mkiv b/tex/context/base/m-hemistich.mkiv index 685b1670f..7a849d415 100644 --- a/tex/context/base/m-hemistich.mkiv +++ b/tex/context/base/m-hemistich.mkiv @@ -33,7 +33,7 @@ \unexpanded\def\dodohemistiches#1[#2]#3#4% {\dontleavehmode \begingroup - \doifassignmentelse{#2} + \doifelseassignment{#2} {\edef\currenthemistich{#1}% \setupcurrenthemistich[#2]} {\def\currenthemistich{#2}}% diff --git a/tex/context/base/m-oldfun.mkiv b/tex/context/base/m-oldfun.mkiv index 1c5a1d29d..3f2ec0263 100644 --- a/tex/context/base/m-oldfun.mkiv +++ b/tex/context/base/m-oldfun.mkiv @@ -131,7 +131,7 @@ \unexpanded\def\DroppedCaps#1#2#3#4#5#6#7% does not yet handle accented chars {\defconvertedargument\asciia{#7}% \defconvertedcommand \asciib{\DroppedString}% - \doifinstringelse\asciia\asciib + \doifelseinstring\asciia\asciib {\noindentation \dontleavehmode \checkindentation % redo this one diff --git a/tex/context/base/m-oldnum.mkiv b/tex/context/base/m-oldnum.mkiv index 55ee59027..382c56eb6 100644 --- a/tex/context/base/m-oldnum.mkiv +++ b/tex/context/base/m-oldnum.mkiv @@ -100,7 +100,7 @@ \unexpanded\def\digits {\bgroup \let~@% - \doifnextbgroupelse\dodigits{\doifnextcharelse\normalmathshift\domathdigits\grabdigit}} + \doifelsenextbgroup\dodigits{\doifelsenextchar\normalmathshift\domathdigits\grabdigit}} \def\dodigits#1% {\grabdigit#1\relax} @@ -158,13 +158,13 @@ \chardef\powerdigits\plusone \else \savedigit\collecteddigits#1% - %\doifnumberelse{#1} + %\doifelsenumber{#1} % {\savedigit\collecteddigits#1} % {\def\saveddigits{#1}}% \fi\fi\fi \else \savedigit\savedpowerdigits#1% - %\doifnumberelse{#1} + %\doifelsenumber{#1} % {\savedigit\savedpowerdigits#1} % {\def\saveddigits{#1}}% \fi\fi\fi\fi diff --git a/tex/context/base/m-spreadsheet.mkiv b/tex/context/base/m-spreadsheet.mkiv index 5e0499184..914a2b57a 100644 --- a/tex/context/base/m-spreadsheet.mkiv +++ b/tex/context/base/m-spreadsheet.mkiv @@ -88,6 +88,8 @@ \unexpanded\def\doifelsespreadsheetcell {\dosingleempty\module_spreadsheet_doifelse_cell} +\let\doifspreadsheetcellelse\doifelsespreadsheetcell + \unexpanded\def\module_spreadsheet_doifelse_cell[#1]#2#3% {\ctxlua{moduledata.spreadsheets.doifelsecell("#1",\number#2,\number#3)}} @@ -118,7 +120,7 @@ \let\stoprow \module_spreadsheet_row_stop \let\startcell\module_spreadsheet_cell_start \let\stopcell \module_spreadsheet_cell_stop - \doifassignmentelse{#1} + \doifelseassignment{#1} {\module_spreadsheet_start \directsetup{spreadsheet:before:\currentspreadsheet}% \bTABLE[\c!align=\v!flushright,#1]} @@ -136,7 +138,7 @@ \unexpanded\def\module_spreadsheet_row_stop {\eTR} \unexpanded\def\module_spreadsheet_cell_start - {\doifnextoptionalelse\module_spreadsheet_cell_start_yes\module_spreadsheet_cell_start_nop} + {\doifelsenextoptional\module_spreadsheet_cell_start_yes\module_spreadsheet_cell_start_nop} \unexpanded\def\module_spreadsheet_cell_start_yes[#1]#2\stopcell {\bTD[#1]\getspr{#2}\eTD} diff --git a/tex/context/base/m-steps.mkvi b/tex/context/base/m-steps.mkvi index a07ece3ae..c9c5a0636 100644 --- a/tex/context/base/m-steps.mkvi +++ b/tex/context/base/m-steps.mkvi @@ -98,7 +98,7 @@ \def\module_steps_start_chart[#name][#settings]% {\startnointerference \iffirstargument - \doifassignmentelse{#name} + \doifelseassignment{#name} {\let\currentSTEPchart\empty \xdef\module_steps_flush_chart{\module_steps_chart[][#name]}} {\edef\currentSTEPchart{#name}% diff --git a/tex/context/base/m-visual.mkiv b/tex/context/base/m-visual.mkiv index 504c0d0c5..486e9859e 100644 --- a/tex/context/base/m-visual.mkiv +++ b/tex/context/base/m-visual.mkiv @@ -161,7 +161,7 @@ {\freezerandomseed \let\endstrut\relax \let\begstrut\relax - \doifinsetelse{#1}{\v!left,\v!right} + \doifelseinset{#1}{\v!left,\v!right} {\fakewords{2}{4}} {\fakewords{4}{10}}}% {\doifinset{#1}{\v!left,\v!right} diff --git a/tex/context/base/math-arr.mkiv b/tex/context/base/math-arr.mkiv index 6824c362e..0e3a53f32 100644 --- a/tex/context/base/math-arr.mkiv +++ b/tex/context/base/math-arr.mkiv @@ -63,7 +63,7 @@ \setvalue{\??matharrowsettings\v!big }{\def\m_math_arrows_extra{20}} \setvalue{\??matharrowsettings\v!normal }{} \setvalue{\??matharrowsettings }{} -\setvalue{\??matharrowsettings\s!unknown}{\doifnumberelse\p_math_spacing{\let\m_math_arrows_extra\p_math_spacing}\donothing} +\setvalue{\??matharrowsettings\s!unknown}{\doifelsenumber\p_math_spacing{\let\m_math_arrows_extra\p_math_spacing}\donothing} \def\math_arrows_construct#1#2#3#4#5% hm, looks like we do a double mathrel (a bit cleaned up .. needs checking) {\begingroup diff --git a/tex/context/base/math-frc.mkiv b/tex/context/base/math-frc.mkiv index 6b7b91d7b..cbe342b66 100644 --- a/tex/context/base/math-frc.mkiv +++ b/tex/context/base/math-frc.mkiv @@ -464,7 +464,7 @@ %D \getbuffer \unexpanded\def\cfrac - {\doifnextoptionalcselse\math_cfrac_yes\math_cfrac_nop} + {\doifelsenextoptionalcs\math_cfrac_yes\math_cfrac_nop} \def\math_cfrac_nop {\math_cfrac_indeed[cc]} \def\math_cfrac_yes[#1]{\math_cfrac_indeed[#1cc]} diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index c59ab1849..a724bda58 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -166,7 +166,7 @@ \installswitchcommandhandler \??mathematics {mathematics} \??mathematics \unexpanded\def\startmathematics % no grouping, if ever then also an optional second - {\doifnextoptionalcselse\math_mathematics_start_yes\math_mathematics_start_nop} + {\doifelsenextoptionalcs\math_mathematics_start_yes\math_mathematics_start_nop} \unexpanded\def\math_mathematics_start_yes[#1]% {\pushmacro\currentmathematics @@ -347,6 +347,11 @@ \unexpanded\def\doifelseutfmathbelow #1{\clf_doifelseutfmathbelow {#1}} \unexpanded\def\doifelseutfmathfiller#1{\clf_doifelseutfmathfiller{#1}} +\let\doifutfmathaccentelse \doifelseutfmathaccent +\let\doifutfmathaboveelse \doifelseutfmathabove +\let\doifutfmathbelowelse \doifelseutfmathbelow +\let\doifutfmathfillerelse \doifelseutfmathfiller + %D Not used that much: \installcorenamespace{mathcodecommand} diff --git a/tex/context/base/math-map.lua b/tex/context/base/math-map.lua index 7b1ede666..add6afa4c 100644 --- a/tex/context/base/math-map.lua +++ b/tex/context/base/math-map.lua @@ -53,11 +53,7 @@ local report_remapping = logs.reporter("mathematics","remapping") mathematics = mathematics or { } local mathematics = mathematics -local scanners = tokens.scanners -local scanstring = scanners.string -local scaninteger = scanners.integer - -local scanners = interfaces.scanners +local implement = interfaces.implement -- Unfortunately some alphabets have gaps (thereby troubling all applications that -- need to deal with math). Somewhat strange considering all those weird symbols that @@ -623,26 +619,38 @@ function mathematics.syncname(alphabet) texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet]) end -scanners.setmathattribute = function() -- alphabet style - local data = alphabets[scanstring()] or regular - data = data[scanstring()] or data.tf - texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet]) -end +implement { + name = "setmathattribute", + arguments = { "string", "string" }, + actions = function(alphabet,style) + local data = alphabets[alphabet] or regular + data = data[style] or data.tf + texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet]) + end +} -scanners.setmathstyle = function() -- style - local r = mathremap[texgetattribute(mathalphabet)] - local alphabet = r and r.alphabet or "regular" - local data = alphabets[alphabet][scanstring()] - texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet]) -end +implement { + name = "setmathstyle", + arguments = "string", + actions = function(style) + local r = mathremap[texgetattribute(mathalphabet)] + local alphabet = r and r.alphabet or "regular" + local data = alphabets[alphabet][style] + texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet]) + end +} -scanners.setmathalphabet = function() -- alphabet - -- local r = mathremap[mathalphabet] - local r = mathremap[texgetattribute(mathalphabet)] - local style = r and r.style or "tf" - local data = alphabets[scanstring()][style] - texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet]) -end +implement { + name = "setmathalphabet", + arguments = "string", + actions = function(alphabet) + -- local r = mathremap[mathalphabet] + local r = mathremap[texgetattribute(mathalphabet)] + local style = r and r.style or "tf" + local data = alphabets[alphabet][style] + texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet]) + end +} local islcgreek = regular_tf.lcgreek local isucgreek = regular_tf.ucgreek diff --git a/tex/context/base/math-rad.mkvi b/tex/context/base/math-rad.mkvi index 2115ab9a4..c52fd8e93 100644 --- a/tex/context/base/math-rad.mkvi +++ b/tex/context/base/math-rad.mkvi @@ -28,7 +28,7 @@ \def\root#1\of{\rootradical{#1}} % #2 -\unexpanded\def\sqrt{\doifnextoptionalcselse\rootwithdegree\rootwithoutdegree} +\unexpanded\def\sqrt{\doifelsenextoptionalcs\rootwithdegree\rootwithoutdegree} \unexpanded\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird {\normalexpanded{\rootradical{\normalunexpanded{#1}}{\noexpand\triggermathstyle{\normalmathstyle}\normalunexpanded{#2}}}} @@ -62,7 +62,7 @@ \unexpanded\def\math_radical_handle#tag% {\begingroup \edef\currentmathradical{#tag}% - \doifnextoptionalcselse\math_radical_degree_yes\math_radical_degree_nop} + \doifelsenextoptionalcs\math_radical_degree_yes\math_radical_degree_nop} \def\math_radical_alternative{\csname\??mathradicalalternative\mathradicalparameter\c!alternative\endcsname} diff --git a/tex/context/base/meta-imp-txt.mkiv b/tex/context/base/meta-imp-txt.mkiv index 9687f6cd4..7069d21a4 100644 --- a/tex/context/base/meta-imp-txt.mkiv +++ b/tex/context/base/meta-imp-txt.mkiv @@ -104,7 +104,7 @@ \unexpanded\def\getshapecharacteristics {\doglobal\increment\currentshapetext - \doifdefinedelse{parlines:\currentshapetext} + \doifelsedefined{parlines:\currentshapetext} {\global\parlines \getvalue{parlines:\currentshapetext}% \global\chardef\parfirst \getvalue{parfirst:\currentshapetext}% \global\parvoffset \getvalue{parvoffset:\currentshapetext}% diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 5628a6744..d0c5896f4 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -600,7 +600,7 @@ \def\meta_prepare_variable_yes {\defconvertedcommand\ascii\m_meta_current_variable % otherwise problems - \doifcolorelse \ascii % with 2\bodyfontsize + \doifelsecolor \ascii % with 2\bodyfontsize {\meta_prepare_variable_color} {\begingroup \setbox\b_meta_variable_box\hbox{\scratchdimen\m_meta_current_variable sp}% @@ -817,7 +817,7 @@ %D %D Experimental. -\def\m_meta_page_prefix{\doifoddpageelse oe} +\def\m_meta_page_prefix{\doifelseoddpage oe} \def\overlaypagestamp {\m_meta_page_prefix:\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor} diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv index 4f4d0de3f..d28022164 100644 --- a/tex/context/base/meta-pag.mkiv +++ b/tex/context/base/meta-pag.mkiv @@ -94,7 +94,7 @@ \def\freezeMPpagelayout {\edef\MPonrightpage{\doifbothsides {tru}{tru}{fals}e}% - \edef\MPonoddpage {\doifoddpageelse {tru}{fals}e}} + \edef\MPonoddpage {\doifelseoddpage {tru}{fals}e}} %D We need to freeze the pagelayout before the backgrounds %D are build, because the overlay will temporarily become diff --git a/tex/context/base/meta-tex.lua b/tex/context/base/meta-tex.lua index 771841924..d5af74f63 100644 --- a/tex/context/base/meta-tex.lua +++ b/tex/context/base/meta-tex.lua @@ -163,3 +163,34 @@ end -- test("@j","1.2e+102") -- test("@j","1.23e+102") -- test("@j","1.234e+102") + +local f_textext = formatters[ [[textext("%s")]] ] +local f_mthtext = formatters[ [[textext("\mathematics{%s}")]] ] +local f_exptext = formatters[ [[textext("\mathematics{%s\times10^{%s}}")]] ] + +local mpprint = mp.print + +function mp.format(fmt,str) + fmt = lpegmatch(cleaner,fmt) + mpprint(f_textext(formatters[fmt](metapost.untagvariable(str,false)))) +end + +function mp.formatted(fmt,num) -- svformat + fmt = lpegmatch(cleaner,fmt) + mpprint(f_textext(formatters[fmt](tonumber(num) or num))) +end + +function mp.graphformat(fmt,num) -- nvformat + fmt = lpegmatch(cleaner,fmt) + local number = tonumber(num) + if number then + local base, exponent = lpegmatch(enumber,number) + if base and exponent then + mpprint(f_exptext(base,exponent)) + else + mpprint(f_mthtext(num)) + end + else + mpprint(f_textext(tostring(num))) + end +end diff --git a/tex/context/base/meta-tex.mkiv b/tex/context/base/meta-tex.mkiv index 431ae6ffe..6ba75f355 100644 --- a/tex/context/base/meta-tex.mkiv +++ b/tex/context/base/meta-tex.mkiv @@ -68,7 +68,7 @@ \unexpanded\def\definetextext[#1]% {\def\currenttextext{#1}% - \doifnextoptionalcselse\meta_textext_define_one\meta_textext_define_zero} + \doifelsenextoptionalcs\meta_textext_define_one\meta_textext_define_zero} \def\meta_textext_define_one {\setvalue{\??graphictexarguments1:\currenttextext}} \def\meta_textext_define_zero{\setvalue{\??graphictexarguments0:\currenttextext}} @@ -79,7 +79,7 @@ {textext.drt("\mpsometxt#1{\ctxlua{metapost.escaped(\!!bs#2\!!es)}}")} \unexpanded\def\mpsometxt % no _ catcode - {\doifnextoptionalcselse\meta_some_txt_indeed_yes\meta_some_txt_indeed_nop} + {\doifelsenextoptionalcs\meta_some_txt_indeed_yes\meta_some_txt_indeed_nop} \def\meta_some_txt_indeed_yes[#1]% {\def\currenttextext{#1}% diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index d21ff3a76..4006f9f1e 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -19,15 +19,8 @@ local mplib, metapost, lpdf, context = mplib, metapost, lpdf, context local context = context local context_setvalue = context.setvalue -local scanners = tokens.scanners -local scanstring = scanners.string -local scaninteger = scanners.integer -local scandimen = scanners.dimen -local setters = tokens.setters -local setmacro = setters.macro - -local compilescanner = tokens.compile -local scanners = interfaces.scanners +local implement = interfaces.implement +local setmacro = interfaces.setmacro local texgetbox = tex.getbox local texsetbox = tex.setbox @@ -305,8 +298,8 @@ end metapost.settext = settext metapost.gettext = gettext -scanners.mpsettext = compilescanner { actions = settext, arguments = { "integer", "integer" } } -- box slot -scanners.mpgettext = compilescanner { actions = gettext, arguments = { "integer", "integer" } } -- box slot +implement { name = "mpsettext", actions = settext, arguments = { "integer", "integer" } } -- box slot +implement { name = "mpgettext", actions = gettext, arguments = { "integer", "integer" } } -- box slot -- rather generic pdf, so use this elsewhere too it no longer pays -- off to distinguish between outline and fill (we now have both @@ -522,18 +515,21 @@ metapost.checktexts = checktexts local factor = 65536*(7227/7200) -function metapost.edefsxsy(wd,ht,dp) -- helper for figure - local hd = ht + dp - context_setvalue("sx",wd ~= 0 and factor/wd or 0) - context_setvalue("sy",hd ~= 0 and factor/hd or 0) -end +-- function metapost.edefsxsy(wd,ht,dp) -- helper for figure +-- local hd = ht + dp +-- context_setvalue("sx",wd ~= 0 and factor/wd or 0) +-- context_setvalue("sy",hd ~= 0 and factor/hd or 0) +-- end -scanners.mpsetsxsy = function() -- wd ht dp - local wd = scandimen() - local hd = scandimen() + scandimen() - setmacro("sx",wd ~= 0 and factor/wd or 0) - setmacro("sy",hd ~= 0 and factor/hd or 0) -end +implement { + name = "mpsetsxsy", + arguments = { "dimen", "dimen", "dimen" }, + actions = function(wd,ht,dp) + local hd = ht + dp + setmacro("sx",wd ~= 0 and factor/wd or 0) + setmacro("sy",hd ~= 0 and factor/hd or 0) + end +} local function sxsy(wd,ht,dp) -- helper for text local hd = ht + dp diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index 17a7a5224..b69d7f370 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -721,7 +721,7 @@ \edef#2{##1}% #3[##2]% \else\iffirstargument - \doifassignmentelse{##1} + \doifelseassignment{##1} {\let#2\empty #3[##1]}% {\edef#2{##1}}% @@ -898,6 +898,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doifcommandhandlerelse\doifelsecommandhandler + \unexpanded\def\doifcommandhandler#1#2% namespace name {\ifcsname#1#2:\s!parent\endcsname \expandafter\firstofoneargument @@ -958,13 +960,13 @@ \unexpanded\def\syst_helpers_double_empty#1#2#3% {\syst_helpers_argument_reset - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_double_empty_one_yes_mult#2#3}% {\syst_helpers_double_empty_one_nop_mult#1}} \def\syst_helpers_double_empty_one_yes_mult#1#2[#3]% {\firstargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\secondargumenttrue#2[{#3}]}% {\syst_helpers_double_empty_two_nop_mult#1{#3}}} @@ -1031,19 +1033,19 @@ \unexpanded\def\syst_helpers_triple_empty#1#2#3#4% {\syst_helpers_argument_reset - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_triple_empty_one_yes_mult#2#3#4}% {\syst_helpers_triple_empty_one_nop_mult#1}} \def\syst_helpers_triple_empty_one_yes_mult#1#2#3[#4]% {\firstargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_triple_empty_two_yes_mult#2#3{#4}}% {\syst_helpers_triple_empty_two_nop_mult#1{#4}}} \def\syst_helpers_triple_empty_two_yes_mult#1#2#3[#4]% {\secondargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\thirdargumenttrue#2[{#3}][{#4}]}% {\syst_helpers_triple_empty_three_nop_mult#1{#3}{#4}}} diff --git a/tex/context/base/mult-ini.mkiv b/tex/context/base/mult-ini.mkiv index 319a8fe03..1dd5a696a 100644 --- a/tex/context/base/mult-ini.mkiv +++ b/tex/context/base/mult-ini.mkiv @@ -365,7 +365,7 @@ {\bgroup \ifcsname\m!prefix!#2\endcsname\else\setgvalue{\m!prefix!#2}{#2}\fi \catcode\endoflineasciicode\activecatcode - \doifinsetelse{#1}{\currentresponses,all}\mult_messages_start_yes\mult_messages_start_nop{#2}} + \doifelseinset{#1}{\currentresponses,all}\mult_messages_start_yes\mult_messages_start_nop{#2}} \def\mult_messages_start_yes#1#2\stopmessages {\clf_setinterfacemessages{#1}{#2}% @@ -386,6 +386,8 @@ \unexpanded\def\showmessage #1#2#3{\clf_showmessage{#1}{#2}{#3}} \unexpanded\def\writestatus #1#2{\clf_writestatus{#1}{#2}} +\let\doifmessageelse\doifelsemessage + %D \macros %D {ifshowwarnings, ifshowmessages} %D diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index 0a3d9f55b..1ad0f9ebb 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -92,9 +92,10 @@ return { -- maybe a different class -- "startmode", "stopmode", "startnotmode", "stopnotmode", "startmodeset", "stopmodeset", - "doifmode", "doifmodeelse", "doifnotmode", + "doifmode", "doifelsemode", "doifmodeelse", "doifnotmode", "startmodeset","stopmodeset", - "startallmodes", "stopallmodes", "startnotallmodes", "stopnotallmodes", "doifallmodes", "doifallmodeselse", "doifnotallmodes", + "startallmodes", "stopallmodes", "startnotallmodes", "stopnotallmodes", + "doifallmodes", "doifelseallmodes", "doifallmodeselse", "doifnotallmodes", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", @@ -145,8 +146,8 @@ return { "startcontextdefinitioncode", "stopcontextdefinitioncode", "texdefinition", -- - "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "fastsetup", - "doifelsecommandhandler","doifnotcommandhandler","doifcommandhandler", + "doifelsesetups", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "fastsetup", + "doifelsecommandhandler", "doifcommandhandlerelse", "doifnotcommandhandler", "doifcommandhandler", -- "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", @@ -228,18 +229,29 @@ return { "scratchleftskip", "scratchrightskip", "scratchtopskip", "scratchbottomskip", -- "doif", "doifnot", "doifelse", - "doifinset", "doifnotinset", "doifinsetelse", - "doifnextcharelse", "doifnextoptionalelse", "doifnextoptionalcselse", "doiffastoptionalcheckelse", - "doifnextbgroupelse", "doifnextbgroupcselse", - "doifnextparenthesiselse", - "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", + "doifinset", "doifnotinset", + "doifelseinset", "doifinsetelse", + "doifelsenextchar", "doifnextcharelse", + "doifelsenextoptional", "doifnextoptionalelse", + "doifelsenextoptionalcs", "doifnextoptionalcselse", + "doifelsefastoptionalcheck", "doiffastoptionalcheckelse", + "doifelsenextbgroup", "doifnextbgroupelse", + "doifelsenextbgroupcs", "doifnextbgroupcselse", + "doifelsenextparenthesis", "doifnextparenthesiselse", + "doifelseundefined", "doifundefinedelse", + "doifelsedefined", "doifdefinedelse", + "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", - "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", - "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", - "doifdimensionelse", "doifnumberelse", "doifnumber", "doifnotnumber", - "doifcommonelse", "doifcommon", "doifnotcommon", - "doifinstring", "doifnotinstring", "doifinstringelse", - "doifassignmentelse", "docheckassignment", + "doifnothing", "doifsomething", + "doifelsenothing", "doifnothingelse", + "doifelsesomething", "doifsomethingelse", + "doifvaluenothing", "doifvaluesomething", + "doifelsevaluenothing", "doifvaluenothingelse", + "doifelsedimension", "doifdimensionelse", + "doifelsenumber", "doifnumberelse", "doifnumber", "doifnotnumber", + "doifelsecommon", "doifcommonelse", "doifcommon", "doifnotcommon", + "doifinstring", "doifnotinstring", "doifelseinstring", "doifinstringelse", + "doifelseassignment", "doifassignmentelse", "docheckassignment", -- "tracingall", "tracingnone", "loggingall", -- @@ -308,7 +320,7 @@ return { -- "modulonumber", "dividenumber", -- - "getfirstcharacter", "doiffirstcharelse", + "getfirstcharacter", "doifelsefirstchar", "doiffirstcharelse", -- "startnointerference", "stopnointerference", -- @@ -359,7 +371,10 @@ return { "triggersmallstyle", "triggeruncrampedsmallstyle", "triggercrampedsmallstyle", "triggerbigstyle", "triggeruncrampedbigstyle", "triggercrampedbigstyle", -- - "luaexpr", "expdoifelse", "expdoif", "expdoifnot", "expdoifcommonelse", "expdoifinsetelse", + "luaexpr", + "expelsedoif", "expdoif", "expdoifnot", + "expdoifelsecommon", "expdoifcommonelse", + "expdoifelseinset", "expdoifinsetelse", -- "ctxdirectlua", "ctxlatelua", "ctxsprint", "ctxwrite", "ctxcommand", "ctxdirectcommand", "ctxlatecommand", "ctxreport", "ctxlua", "luacode", "lateluacode", "directluacode", diff --git a/tex/context/base/node-bck.lua b/tex/context/base/node-bck.lua index 4b7b4a064..4e78e720a 100644 --- a/tex/context/base/node-bck.lua +++ b/tex/context/base/node-bck.lua @@ -178,5 +178,19 @@ nodes.handlers.alignbackgrounds = function(head) local head, done = add_alignbac -- elsewhere: needs checking -tasks.appendaction("shipouts","normalizers","nodes.handlers.backgrounds") -tasks.appendaction("shipouts","normalizers","nodes.handlers.alignbackgrounds") +-- tasks.appendaction("shipouts","normalizers","nodes.handlers.backgrounds") +-- tasks.appendaction("shipouts","normalizers","nodes.handlers.alignbackgrounds") + +interfaces.implement { + name = "enablebackgroundboxes", + once = true, + actions = nodes.tasks.enableaction, + arguments = { "'shipouts'", "'nodes.handlers.backgrounds'" } +} + +interfaces.implement { + name = "enablebackgroundalign", + once = true, + actions = nodes.tasks.enableaction, + arguments = { "'shipouts'", "'nodes.handlers.alignbackgrounds'" } +} diff --git a/tex/context/base/node-bck.mkiv b/tex/context/base/node-bck.mkiv index 25739c560..ff0de6a5d 100644 --- a/tex/context/base/node-bck.mkiv +++ b/tex/context/base/node-bck.mkiv @@ -21,14 +21,6 @@ \registerctxluafile{node-bck}{1.001} -\def\node_backgrounds_boxes_initialize % will move to lua - {\ctxlua{nodes.tasks.enableaction("shipouts","nodes.handlers.backgrounds")}% - \glet\node_backgrounds_boxes_initialize\donothing} - -\def\node_backgrounds_align_initialize % will move to lua - {\ctxlua{nodes.tasks.enableaction("shipouts","nodes.handlers.alignbackgrounds")}% - \glet\node_backgrounds_align_initialize\donothing} - % \backgroundvbox[green] {\input tufte } \par % \backgroundvbox[blue] {\input ward } \par % \backgroundvbox[red] {\input knuth } \par @@ -71,7 +63,7 @@ % \def\node_backgrounds_boxes_add#1[#2]% % {\begingroup -% \node_backgrounds_boxes_initialize +% \clf_enablebackgroundboxes % \dousecolorparameter{#2}% % \normalexpanded{\endgroup#1 % attr \backgroundattribute \plusone @@ -82,13 +74,13 @@ % more efficient: \def\node_backgrounds_boxes_add#1[#2]% - {\node_backgrounds_boxes_initialize + {\clf_enablebackgroundboxes #1\backgroundcolorattr{#2}} % less argument carry over: % % \def\node_backgrounds_boxes_add#1[#2]% -% {\node_backgrounds_boxes_initialize#1% +% {\clf_enablebackgroundboxes#1% % \ifcsname\??colorattribute\currentcolorprefix#2\endcsname % \thebackgroundcolorattr{\currentcolorprefix#2}% % \else\ifcsname\??colorattribute#2\endcsname diff --git a/tex/context/base/node-fin.lua b/tex/context/base/node-fin.lua index e1618d1f7..84c5b9a2f 100644 --- a/tex/context/base/node-fin.lua +++ b/tex/context/base/node-fin.lua @@ -50,6 +50,8 @@ local numbers = attributes.numbers local a_trigger = attributes.private('trigger') local triggering = false +local implement = interfaces.implement + local starttiming = statistics.starttiming local stoptiming = statistics.stoptiming local loadstripped = utilities.lua.loadstripped @@ -60,6 +62,9 @@ local unsetvalue = attributes.unsetvalue function states.enabletriggering () triggering = true end function states.disabletriggering() triggering = false end +implement { name = "enablestatetriggering", actions = states.enabletriggering } +implement { name = "disablestatetriggering", actions = states.disabletriggering } + nodes.plugindata = nil -- inheritance: -0x7FFFFFFF -- we can best use nil and skip ! diff --git a/tex/context/base/node-fin.mkiv b/tex/context/base/node-fin.mkiv index 8c0189094..7c95699dd 100644 --- a/tex/context/base/node-fin.mkiv +++ b/tex/context/base/node-fin.mkiv @@ -61,12 +61,12 @@ \stopinheritattributes} \def\enableattributeinheritance - {\ctxlua{attributes.states.enabletriggering()}% + {\clf_enablestatetriggering \let\attributedcopy\doattributedcopy \let\attributedbox \doattributedbox} \def\disableattributeinheritance - {\ctxlua{attributes.states.disabletriggering()}% + {\clf_disablestatetriggering \let\attributedcopy\copy \let\attributedbox \box} diff --git a/tex/context/base/node-ini.mkiv b/tex/context/base/node-ini.mkiv index 5fc519069..d04e647de 100644 --- a/tex/context/base/node-ini.mkiv +++ b/tex/context/base/node-ini.mkiv @@ -35,7 +35,7 @@ \registerctxluafile{node-acc}{1.001} % experimental %registerctxluafile{node-prp}{1.001} % makes no sense (yet) -\doiffileelse{node-ppt.lua}{\registerctxluafile{node-ppt}{1.001}}{} +\doifelsefile{node-ppt.lua}{\registerctxluafile{node-ppt}{1.001}}{} \newcount\c_node_tracers_show_box % box number diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua index d14f4a6da..fc3043516 100644 --- a/tex/context/base/node-ref.lua +++ b/tex/context/base/node-ref.lua @@ -712,7 +712,7 @@ implement { } implement { - name = "injectcurrentreference_dimensions", + name = "injectcurrentreferencehtdp", actions = references.injectcurrentset, arguments = { "dimen", "dimen" }, } diff --git a/tex/context/base/node-rul.lua b/tex/context/base/node-rul.lua index ddbd3963b..736b67a7f 100644 --- a/tex/context/base/node-rul.lua +++ b/tex/context/base/node-rul.lua @@ -451,6 +451,7 @@ implement { implement { name = "enablerules", + once = true, actions = nodes.rules.enable } @@ -469,5 +470,6 @@ implement { implement { name = "enableshifts", + once = true, actions = nodes.shifts.enable } diff --git a/tex/context/base/node-rul.mkiv b/tex/context/base/node-rul.mkiv index e1c8c8413..7fa0473a5 100644 --- a/tex/context/base/node-rul.mkiv +++ b/tex/context/base/node-rul.mkiv @@ -133,13 +133,16 @@ \unexpanded\def\node_rules_direct#1% {\groupedcommand{\node_rules_set{#1}}\relax} -\unexpanded\def\node_rules_set - {\clf_enablerules % will be moved to lua - \glet\node_rules_set\node_rules_set_indeed - \node_rules_set} - -\unexpanded\def\node_rules_set_indeed#1% maybe reverse the 1000 (also maybe use more attributes instead of settings) - {\edef\currentbar{#1}% +% \unexpanded\def\node_rules_set +% {\clf_enablerules % will be moved to lua +% \glet\node_rules_set\node_rules_set_indeed +% \node_rules_set} +% +%\unexpanded\def\node_rules_set_indeed#1% maybe reverse the 1000 (also maybe use more attributes instead of settings) + +\unexpanded\def\node_rules_set#1% maybe reverse the 1000 (also maybe use more attributes instead of settings) + {\clf_enablerules % will be relaxed + \edef\currentbar{#1}% \expandafter\let\expandafter\c_node_rules_index\csname\??barindex#1\endcsname \advance\c_node_rules_index\plusone \usebarstyleandcolor\c!foregroundstyle\c!foregroundcolor @@ -293,21 +296,16 @@ \unexpanded\def\node_shifts_redefine#1% {\def\currentshift{#1}\node_shifts_define} -\unexpanded\def\node_shifts_set - {\clf_enableshifts - \glet\node_shifts_set\node_shifts_set_indeed - \node_shifts_set} - -% \unexpanded\def\node_shifts_direct#1% -% {\doisolatedgroupedalign{\node_shifts_set{#1}}\donothing} - -\unexpanded\def\node_shifts_direct#1% - {\groupedcommand - {\begingroup\dostartisolation\begingroup\node_shifts_set{#1}} - {\endgroup\dostopisolation\endgroup}} +% \unexpanded\def\node_shifts_set +% {\clf_enableshifts +% \glet\node_shifts_set\node_shifts_set_indeed +% \node_shifts_set} +% +% \def\node_shifts_set_indeed#1% todo: check parent ! -\def\node_shifts_set_indeed#1% todo: check parent ! - {\def\currentshift{#1}% +\unexpanded\def\node_shifts_set#1% todo: check parent ! + {\clf_enableshifts + \def\currentshift{#1}% \expandafter\let\expandafter\c_node_shifts_index\csname\??shiftindex#1\endcsname \advance\c_node_shifts_index\plusone \attribute\shiftedattribute\numexpr @@ -324,6 +322,14 @@ \unexpanded\def\stopshift {\endgroup} +% \unexpanded\def\node_shifts_direct#1% +% {\doisolatedgroupedalign{\node_shifts_set{#1}}\donothing} + +\unexpanded\def\node_shifts_direct#1% + {\groupedcommand + {\begingroup\dostartisolation\begingroup\node_shifts_set{#1}} + {\endgroup\dostopisolation\endgroup}} + \setupshifts [\c!method=0, \c!continue=\v!no, diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv index 721561323..ef299f51d 100644 --- a/tex/context/base/pack-box.mkiv +++ b/tex/context/base/pack-box.mkiv @@ -436,7 +436,7 @@ \def\pack_ornament_text[#1][#2]% {\bgroup - \doifassignmentelse{#1} + \doifelseassignment{#1} {\letdummyparameter\c!alternative\v!a \getdummyparameters[#1]% \doifelse{\directdummyparameter\c!alternative}\v!a diff --git a/tex/context/base/pack-com.mkiv b/tex/context/base/pack-com.mkiv index 735f04714..7f3fcb538 100644 --- a/tex/context/base/pack-com.mkiv +++ b/tex/context/base/pack-com.mkiv @@ -191,19 +191,19 @@ \edef\currentcombination{#1}% \edef\currentcombinationspec{#2}% \ifx\currentcombinationspec\empty - \doifassignmentelse{#1}% + \doifelseassignment{#1}% {\let\currentcombination\empty \setupcurrentcombination[#1]% \edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}} - {\doifinstringelse{*}\currentcombination + {\doifelseinstring{*}\currentcombination {\edef\currentcombinationspec{\currentcombination*\plusone*}% \let\currentcombination\empty} - {\doifnumberelse\currentcombination + {\doifelsenumber\currentcombination {\edef\currentcombinationspec{\currentcombination*\plusone*}% \let\currentcombination\empty} {\edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}}}}% \else - \doifassignmentelse{#2}% + \doifelseassignment{#2}% {\setupcurrentcombination[#2]% \edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}} {\edef\currentcombinationspec{\currentcombinationspec*\plusone*}}% @@ -629,12 +629,12 @@ \unexpanded\def\placepairedbox[#1]% {\bgroup \edef\currentpairedbox{#1}% - \doifnextoptionalcselse\pack_pairedboxes_place\pack_pairedboxes_place_indeed} + \doifelsenextoptionalcs\pack_pairedboxes_place\pack_pairedboxes_place_indeed} \unexpanded\def\startplacepairedbox[#1]% {\bgroup \edef\currentpairedbox{#1}% - \doifnextoptionalcselse\pack_pairedboxes_place\pack_pairedboxes_place_indeed} + \doifelsenextoptionalcs\pack_pairedboxes_place\pack_pairedboxes_place_indeed} \unexpanded\def\stopplacepairedbox {} diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv index e7954931c..45113f286 100644 --- a/tex/context/base/pack-lyr.mkiv +++ b/tex/context/base/pack-lyr.mkiv @@ -226,7 +226,7 @@ \else\ifthirdargument \pack_layers_set_indeed[#1][#2][#3]% \else - \doifassignmentelse{#2} + \doifelseassignment{#2} {\pack_layers_set_indeed[#1][][#2]}% {\pack_layers_set_indeed[#1][#2][]}% \fi\fi} @@ -320,7 +320,7 @@ {\dodoubleargument\pack_layers_define_preset} \def\pack_layers_define_preset[#1][#2]% - {\doifassignmentelse{#2} + {\doifelseassignment{#2} {\setvalue{\??layerpreset#1}{\setupcurrentlayer[#2]}} {\setvalue{\??layerpreset#1}{\csname\??layerpreset#2\endcsname}}} @@ -507,6 +507,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doiflayerdataelse\doifelselayerdata + %D \macros %D {flushlayer} %D @@ -666,7 +668,7 @@ \pack_layers_positioned_box_nop \fi % todo: method=offset => overlayoffset right/down (handy for backgrounds with offset) - \doifoverlayelse{#2}% + \doifelseoverlay{#2}% {\setlayoutcomponentattribute{\v!layer:#2}}% \resetlayoutcomponentattribute % we have conflicting demands: some mechanisms want ll anchoring .. I need to figure this out diff --git a/tex/context/base/pack-mis.mkvi b/tex/context/base/pack-mis.mkvi index c5b218599..420f9440a 100644 --- a/tex/context/base/pack-mis.mkvi +++ b/tex/context/base/pack-mis.mkvi @@ -46,7 +46,7 @@ \unexpanded\def\pack_placement#tag% {\bgroup \edef\currentplacement{#tag}% - \doifnextoptionalcselse\pack_placement_yes\pack_placement_nop} + \doifelsenextoptionalcs\pack_placement_yes\pack_placement_nop} \def\pack_placement_yes[#settings]% {\setupcurrentplacement[#settings]% diff --git a/tex/context/base/pack-mrl.mkiv b/tex/context/base/pack-mrl.mkiv index ad3a1364f..071059565 100644 --- a/tex/context/base/pack-mrl.mkiv +++ b/tex/context/base/pack-mrl.mkiv @@ -40,7 +40,7 @@ \unexpanded\def\blackrule {\hbox\bgroup - \doifnextoptionalcselse\pack_black_rule_pickup\pack_black_rule_indeed} + \doifelsenextoptionalcs\pack_black_rule_pickup\pack_black_rule_indeed} \def\pack_black_rule_pickup[#1]% {\setupcurrentblackrules[#1]% @@ -96,7 +96,7 @@ \unexpanded\def\blackrules % probably never used {\hbox\bgroup - \doifnextoptionalcselse\pack_black_rules_pickup\pack_black_rules_indeed} + \doifelsenextoptionalcs\pack_black_rules_pickup\pack_black_rules_indeed} \def\pack_black_rules_pickup[#1]% {\setupcurrentblackrules[#1]% diff --git a/tex/context/base/pack-obj.lua b/tex/context/base/pack-obj.lua index dc6a8d0df..d1cc5bafc 100644 --- a/tex/context/base/pack-obj.lua +++ b/tex/context/base/pack-obj.lua @@ -12,10 +12,8 @@ reusable components.</p> --ldx]]-- local context = context -local commands = commands -local compilescanner = tokens.compile -local scanners = interfaces.scanners +local implement = interfaces.implement local allocate = utilities.storage.allocate @@ -65,43 +63,31 @@ jobobjects.get = getobject jobobjects.number = getobjectnumber jobobjects.page = getobjectpage --- interface - -commands.saveobject = saveobject -commands.setobject = setobject - -function commands.objectnumber(tag,default) - context(getobjectnumber(tag,default)) -end - -function commands.objectpage(tag,default) - context(getobjectpage (tag,default)) -end - -function commands.doifobjectreferencefoundelse(tag) - commands.doifelse(getobject(tag)) -end - --- new - -scanners.saveobject = saveobject +implement { + name = "saveobject", + actions = saveobject +} -scanners.setobject = compilescanner { +implement { + name = "setobject", actions = setobject, arguments = { "string", "integer", "integer" } } -scanners.objectnumber = compilescanner { +implement { + name = "objectnumber", actions = { getobjectnumber, context }, arguments = { "string", "string" }, } -scanners.objectpage = compilescanner { +implement { + name = "objectpage", actions = { getobjectpage, context }, arguments = { "string", "string" }, } -scanners.doifobjectreferencefoundelse = compilescanner { +implement { + name = "doifelseobjectreferencefound", actions = { jobobjects.get, commands.doifelse }, arguments = "string" } diff --git a/tex/context/base/pack-obj.mkiv b/tex/context/base/pack-obj.mkiv index 180ed83b2..605dd3b9e 100644 --- a/tex/context/base/pack-obj.mkiv +++ b/tex/context/base/pack-obj.mkiv @@ -399,14 +399,17 @@ %D \doifobjectreferencefoundelse{class}{object}{do then}{do else} %D \stoptyping -\unexpanded\def\doifobjectfoundelse#1#2% +\unexpanded\def\doifelseobjectfound#1#2% {\ifcsname\??objects#1::#2\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} -\unexpanded\def\doifobjectreferencefoundelse#1#2% - {\clf_doifobjectreferencefoundelse{#1::#2}} +\unexpanded\def\doifelseobjectreferencefound#1#2% + {\clf_doifelseobjectreferencefound{#1::#2}} + +\let\doifobjectfoundelse \doifelseobjectfound +\let\doifobjectreferencefoundelse\doifelseobjectreferencefound \protect \endinput diff --git a/tex/context/base/pack-pos.mkiv b/tex/context/base/pack-pos.mkiv index f92ceb78a..c52c01ca4 100644 --- a/tex/context/base/pack-pos.mkiv +++ b/tex/context/base/pack-pos.mkiv @@ -62,7 +62,7 @@ \edef\currentpositioning{#1}% \setupcurrentpositioning[#2]% \else\iffirstargument - \doifassignmentelse{#1} + \doifelseassignment{#1} {\let\currentpositioning\empty \setupcurrentpositioning[#1]}% {\edef\currentpositioning{#1}}% diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv index 2875f0f18..7fde68c8d 100644 --- a/tex/context/base/pack-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -496,13 +496,15 @@ %D For testing we provide: -\def\doifoverlayelse#1% only tests external overlays +\def\doifelseoverlay#1% only tests external overlays {\ifcsname\??overlay#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doifoverlayelse\doifelseoverlay + %D The content of the box will be (temporary) saved in a box. We also have an %D extra box for backgrounds. @@ -845,7 +847,7 @@ \def\pack_framed_start_framed[#1]% {\bgroup - \doifassignmentelse{#1}\pack_framed_start_framed_yes\pack_framed_start_framed_nop{#1}} + \doifelseassignment{#1}\pack_framed_start_framed_yes\pack_framed_start_framed_nop{#1}} \def\pack_framed_start_framed_yes#1% {\advance\c_pack_framed_nesting\plusone @@ -2616,7 +2618,7 @@ \dodoubleempty\pack_framed_text_start_indeed} \def\pack_framed_text_start_indeed[#1][#2]% - {\doifassignmentelse{#1} + {\doifelseassignment{#1} {\pack_framed_text_start_continue\empty{#1}} {\pack_framed_text_start_continue{#1}{#2}}} diff --git a/tex/context/base/page-bck.mkiv b/tex/context/base/page-bck.mkiv index bfdbd56c1..01de48e8c 100644 --- a/tex/context/base/page-bck.mkiv +++ b/tex/context/base/page-bck.mkiv @@ -140,13 +140,15 @@ {\edef\currentotrbackground{\??layoutbackgrounds#1}% \page_backgrounds_check_background} -\def\doifsomebackgroundelse#1% +\def\doifelsesomebackground#1% {\ifcsname\??layoutbackgrounds#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doifsomebackgroundelse\doifelsesomebackground + \def\doifsomebackground#1% {\ifcsname\??layoutbackgrounds#1\endcsname \expandafter\firstofoneargument @@ -277,7 +279,7 @@ \page_backgrounds_set_boxes \setbox#1\vbox {\offinterlineskip - \doifmarginswapelse{\copy\leftbackground}{\copy\rightbackground}% + \doifelsemarginswap{\copy\leftbackground}{\copy\rightbackground}% \box#1}% \fi} @@ -343,7 +345,7 @@ {\dontcomplain \swapmargins \ifconditional\swapbackgroundmargins - \doifmarginswapelse \donothing + \doifelsemarginswap \donothing {\swapmacros\v!rightmargin\v!leftmargin \swapmacros\v!rightedge \v!leftedge}% \fi @@ -501,7 +503,7 @@ \unexpanded\def\page_backgrounds_setup_double[#1][#2][#3]% if needed we can speed this up {\global\settrue\c_page_backgrounds_some \def\page_backgrounds_setup_step##1% - {\doifinsetelse{##1}\v_page_backgrounds_double_set + {\doifelseinset{##1}\v_page_backgrounds_double_set {\page_backgrounds_setup_and_check{##1}{#3}} {\def\page_backgrounds_setup_step_nested####1{\page_backgrounds_setup_and_check{##1####1}{#3}}% \processcommacommand[#2]\page_backgrounds_setup_step_nested}}% @@ -510,7 +512,7 @@ \unexpanded\def\page_backgrounds_setup_single[#1][#2][#3]% {\global\settrue\c_page_backgrounds_some - \doifcommonelse{#1}\v_page_backgrounds_single_set + \doifelsecommon{#1}\v_page_backgrounds_single_set {\def\page_backgrounds_setup_step##1{\page_backgrounds_setup_and_check{##1}{#2}}% \processcommacommand[#1]\page_backgrounds_setup_step \the\everybackgroundssetup}% diff --git a/tex/context/base/page-brk.mkiv b/tex/context/base/page-brk.mkiv index 600819b1b..f9c933052 100644 --- a/tex/context/base/page-brk.mkiv +++ b/tex/context/base/page-brk.mkiv @@ -134,11 +134,11 @@ \endgroup} \installpagebreakmethod \s!unknown - {\doifinstringelse{+}\page_breaks_current_option + {\doifelseinstring{+}\page_breaks_current_option {\page_otr_flush_all_floats \page_otr_command_next_page \dorecurse\page_breaks_current_option\page_otr_insert_dummy_page} - {\doifnumberelse\page_breaks_current_option + {\doifelsenumber\page_breaks_current_option {\page_otr_flush_all_floats \page_otr_command_next_page \doloop @@ -222,11 +222,11 @@ \installpagebreakmethod \v!even {\page - \doifoddpageelse\page_reset_marks_and_insert_dummy\donothing} + \doifelseoddpage\page_reset_marks_and_insert_dummy\donothing} \installpagebreakmethod \v!odd {\page - \doifoddpageelse\donothing\page_reset_marks_and_insert_dummy} + \doifelseoddpage\donothing\page_reset_marks_and_insert_dummy} \installpagebreakmethod \v!quadruple % not yet ok inside columnsets {\ifdoublesided diff --git a/tex/context/base/page-flw.mkiv b/tex/context/base/page-flw.mkiv index ec1fa636d..56fe32e5b 100644 --- a/tex/context/base/page-flw.mkiv +++ b/tex/context/base/page-flw.mkiv @@ -80,14 +80,14 @@ \def\textflowcollector#1% {\csname\??textflowbox#1\endcsname} -\unexpanded\def\doiftextflowcollectorelse#1% +\unexpanded\def\doifelsetextflowcollector#1% {\ifcsname\??textflowbox#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} -\unexpanded\def\doiftextflowelse#1% +\unexpanded\def\doifelsetextflow#1% {\ifcsname\??textflowbox#1\endcsname \ifvoid\csname\??textflowbox#1\endcsname \doubleexpandafter\secondoftwoarguments @@ -98,6 +98,9 @@ \expandafter\secondoftwoarguments \fi} +\let\doiftextflowcollectorelse\doifelsetextflowcollector +\let\doiftextflowelse \doifelsetextflow + % \unexpanded\def\doiftextflow#1% % {\doiftextflowelse{#1}\firstofoneargument\gobbleoneargument} diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv index e523ee9d7..3f5afeb40 100644 --- a/tex/context/base/page-imp.mkiv +++ b/tex/context/base/page-imp.mkiv @@ -163,7 +163,7 @@ \donetrue \fi \else % testen, aangepast / expanded nodig ? - \normalexpanded{\doifinsetelse{\the\shippedoutpages}{\pagestoshipout}}\donetrue\donefalse + \normalexpanded{\doifelseinset{\the\shippedoutpages}{\pagestoshipout}}\donetrue\donefalse \fi \ifdone \setbox\shipoutscratchbox\hbox{#1}% @@ -1351,7 +1351,7 @@ \doifelse{#1}\v!page {\let\page_boxes_apply_shift_print\page_boxes_apply_shift}{\let\page_boxes_apply_shift_print\gobbleoneargument}% \doifelse{#1}\v!paper{\let\page_boxes_apply_shift_paper\page_boxes_apply_shift}{\let\page_boxes_apply_shift_paper\gobbleoneargument}% \else\ifsecondargument - \doifinsetelse{#1}{\v!page,\v!paper} + \doifelseinset{#1}{\v!page,\v!paper} {\setuppageshift[#1][#2][#2]} {\setuppageshift[\v!page][#1][#2]}% \else\iffirstargument diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv index 08fc6b33a..1f3ea74ae 100644 --- a/tex/context/base/page-ini.mkiv +++ b/tex/context/base/page-ini.mkiv @@ -235,7 +235,7 @@ \the\everyafterpagebody \egroup} -\def\doiftopofpageelse +\def\doifelsetopofpage {\ifdim\pagegoal=\maxdimen \expandafter\firstoftwoarguments \else\ifdim\pagegoal=\vsize @@ -244,6 +244,8 @@ \doubleexpandafter\secondoftwoarguments \fi\fi} +\let\doiftopofpageelse\doifelsetopofpage + % %D Idea: % % \newinsert\thispageinsert % <- installinsertion diff --git a/tex/context/base/page-inj.mkvi b/tex/context/base/page-inj.mkvi index 912471b23..03472fe55 100644 --- a/tex/context/base/page-inj.mkvi +++ b/tex/context/base/page-inj.mkvi @@ -47,11 +47,11 @@ \dodoubleempty\page_injections_direct} \def\page_injections_direct[#1][#2]% name parameters | settings parameters | name | parameters - {\doifassignmentelse{#1} - {\doifassignmentelse{#2} + {\doifelseassignment{#1} + {\doifelseassignment{#2} {\page_injections_direct_settings_parameters{#1}{#2}} {\page_injections_direct_parameters {#1}}} - {\doifassignmentelse{#2} + {\doifelseassignment{#2} {\page_injections_direct_name_parameters {#1}{#2}} {\page_injections_direct_name {#1}}}} diff --git a/tex/context/base/page-ins.mkiv b/tex/context/base/page-ins.mkiv index a63de0b26..5845f9930 100644 --- a/tex/context/base/page-ins.mkiv +++ b/tex/context/base/page-ins.mkiv @@ -82,13 +82,15 @@ \insert#1{\unvbox#1}% \fi} -\unexpanded\def\doifinsertionelse#1% +\unexpanded\def\doifelseinsertion#1% {\ifcsname\??insertionnumber#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doifinsertionelse\doifelseinsertion + % \unexpanded\def\startinsertion[#1]% % {\insert\csname\??insertionnumber#1\endcsname\bgroup} % diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv index fc864719b..a1bb35027 100644 --- a/tex/context/base/page-lay.mkiv +++ b/tex/context/base/page-lay.mkiv @@ -154,13 +154,15 @@ \fi \to \everysetuplayout -\def\doiflayoutdefinedelse#1% +\def\doifelselayoutdefined#1% {\ifcsname\namedlayouthash{#1}\c!state\endcsname % maybe a helper \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doiflayoutdefinedelse\doifelselayoutdefined + \def\layoutdistance#1#2{\ifdim\zeropoint<#1#2\else\zeropoint\fi} \def\page_layouts_set_dimensions @@ -365,7 +367,7 @@ \ifx\currentlayouttarget\empty % invalid target \else - \doifassignmentelse{#2} + \doifelseassignment{#2} {\definelayouttarget[#1][#2]} {\setevalue{\??layoutpaper#1}{#2}% \setevalue{\??layoutprint#1}{#3}}% @@ -390,9 +392,9 @@ \unexpanded\def\page_paper_setup_size[#1][#2]% {\iffirstargument - \doifassignmentelse{#1} + \doifelseassignment{#1} {\page_paper_setup_size_settings[#1]} - {\doifassignmentelse{#2} + {\doifelseassignment{#2} {\page_paper_setup_size_settings_by_name[#1][#2]} {\page_paper_setup_size_change_size[#1][#2]}}% \else @@ -1027,7 +1029,7 @@ \unexpanded\def\startlayout[#1]% {\page \globalpushmacro\currentlayout - \doiflayoutdefinedelse{#1}{\setuplayout[#1]}\donothing} % {\setuplayout[\currentlayout]}} + \doifelselayoutdefined{#1}{\setuplayout[#1]}\donothing} % {\setuplayout[\currentlayout]}} \unexpanded\def\stoplayout {\page @@ -1121,13 +1123,15 @@ % #single #left #right -\def\doifoddpageelse +\def\doifelseoddpage {\ifodd\pagenoshift \expandafter\page_layouts_if_odd_else_yes \else \expandafter\page_layouts_if_odd_else_nop \fi} +\let\doifoddpageelse\doifelseoddpage + \def\page_layouts_if_odd_else_yes {\ifodd\realpageno \expandafter\secondoftwoarguments @@ -1142,9 +1146,7 @@ \expandafter\secondoftwoarguments \fi} -\let\doifonevenpaginaelse\doifoddpageelse - -\def\page_layouts_if_odd_else_again#1{\doifoddpageelse} +\def\page_layouts_if_odd_else_again#1{\doifelseoddpage} \def\doifbothsidesoverruled {\ifdoublesided @@ -1171,7 +1173,7 @@ \def\settexthoffset % name will change {\texthoffset\doifbothsides\backspace\backspace{\dimexpr\paperwidth-\backspace-\makeupwidth\relax}} - + % The next hack is too tricky as we may shipout more pages: % % \def\freezepagestatechecks @@ -1199,11 +1201,13 @@ \def\goleftonpage % name will change (we could cache) {\hskip-\dimexpr\leftmargindistance+\leftmarginwidth+\leftedgedistance+\leftedgewidth\relax} -\def\doifmarginswapelse#1#2% +\def\doifelsemarginswap#1#2% {\doifbothsides{#1}{#1}{#2}} +\let\doifmarginswapelse\doifelsemarginswap + \def\swapmargins % name will change - {\doifmarginswapelse\relax\doswapmargins} + {\doifelsemarginswap\relax\doswapmargins} \def\doswapmargins % name will change {\let\swapmargins \relax % to prevent local swapping @@ -1221,7 +1225,7 @@ {\ifsinglesided \expandafter\firstoftwoarguments \else - \expandafter\doifoddpageelse + \expandafter\doifelseoddpage \fi} \def\outermarginwidth {\rightorleftpageaction\rightmarginwidth \leftmarginwidth } diff --git a/tex/context/base/page-lin.mkvi b/tex/context/base/page-lin.mkvi index 7fbde3df8..73f8fe460 100644 --- a/tex/context/base/page-lin.mkvi +++ b/tex/context/base/page-lin.mkvi @@ -196,10 +196,10 @@ \ifx\m_argument\v!empty \let\currentlinenumbering\empty \else - \doifassignmentelse{#1} + \doifelseassignment{#1} {\let\currentlinenumbering\empty \setupcurrentlinenumbering[#1]} - {\doifnumberelse\m_argument + {\doifelsenumber\m_argument {\let\currentlinenumbering\empty \letlinenumberingparameter\c!start\m_argument} {\let\currentlinenumbering\m_argument}}% @@ -219,7 +219,7 @@ \else \c_page_lines_mode\plusone \ifx\m_argument\v!empty \else - \doifassignmentelse{#2} + \doifelseassignment{#2} {\setupcurrentlinenumbering[#2]} {\doifnumber\m_argument {\letlinenumberingparameter\c!start\m_argument}}% @@ -541,15 +541,17 @@ \let\m_page_lines_to \empty \unexpanded\def\doifelsesamelinereference#1#2#3% - {\doifreferencefoundelse{lr:b:#1} + {\doifelsereferencefound{lr:b:#1} {\edef\m_page_lines_from{\currentreferencelinenumber}% - \doifreferencefoundelse{lr:e:#1} + \doifelsereferencefound{lr:e:#1} {\edef\m_page_lines_to{\currentreferencelinenumber}% %[\m_page_lines_from,\m_page_lines_to] \ifx\m_page_lines_from\m_page_lines_to#2\else#3\fi} {#2}} {#2}} +\let\doifsamelinereferenceelse\doifelsesamelinereference + \unexpanded\def\inline#1[#2]% {\doifelsenothing{#1} {\doifelsesamelinereference{#2} diff --git a/tex/context/base/page-mak.mkvi b/tex/context/base/page-mak.mkvi index 9b596b9e5..ee144f20a 100644 --- a/tex/context/base/page-mak.mkvi +++ b/tex/context/base/page-mak.mkvi @@ -45,7 +45,7 @@ \appendtoks \setuevalue{\e!start\currentmakeup\e!makeup}{\startmakeup[\currentmakeup]}% \setuevalue{\e!stop \currentmakeup\e!makeup}{\stopmakeup}% - \doiflayoutdefinedelse\currentmakeup\donothing{\definelayout[\currentmakeup]}% new + \doifelselayoutdefined\currentmakeup\donothing{\definelayout[\currentmakeup]}% new \to \everydefinemakeup %D The \type{\start}||\type{\stop} macros are used for both diff --git a/tex/context/base/page-mix.mkiv b/tex/context/base/page-mix.mkiv index f69f6ac0e..b545e8f4c 100644 --- a/tex/context/base/page-mix.mkiv +++ b/tex/context/base/page-mix.mkiv @@ -365,7 +365,7 @@ \csname\??mixedcolumnsstart\currentmixedcolumnsmethod\endcsname} \def\page_mix_start_columns_b[#1][#2]% - {\doifassignmentelse{#1}% + {\doifelseassignment{#1}% {\let\currentmixedcolumns\empty \page_mix_error_b} {\edef\currentmixedcolumns{#1}% @@ -799,11 +799,11 @@ % \unexpanded\def\page_mix_command_flush_top_insertions % {\page_one_command_flush_top_insertions} -% \unexpanded\def\page_mix_place_float_top -% {\showmessage\m!columns4\empty\page_one_place_float_here} +\unexpanded\def\page_mix_place_float_top + {\showmessage\m!columns4\empty\page_one_place_float_here} -% \unexpanded\def\page_mix_place_float_bottom -% {\showmessage\m!columns5\empty\page_one_place_float_here} +\unexpanded\def\page_mix_place_float_bottom + {\showmessage\m!columns5\empty\page_one_place_float_here} \unexpanded\def\page_mix_place_float_here {\page_one_place_float_here} diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv index 0063b3311..8db5a4773 100644 --- a/tex/context/base/page-mul.mkiv +++ b/tex/context/base/page-mul.mkiv @@ -1430,7 +1430,7 @@ % \stopcolumns % \def\backgroundfinishcolumnbox - % {\doifinsetelse\@@kloffset{\v!none,\v!overlay} + % {\doifelseinset\@@kloffset{\v!none,\v!overlay} % {\let\@@kloffset\!!zeropoint} % {\scratchdimen\@@kloffset % \advance\scratchdimen -\@@klrulethickness diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv index 3f9dcd7c6..196f6e5a2 100644 --- a/tex/context/base/page-one.mkiv +++ b/tex/context/base/page-one.mkiv @@ -496,12 +496,12 @@ \def\page_one_place_float_bottom {\page_one_place_float_otherwise} \def\page_one_place_float_otherwise - {\doifinsetelse\v!here\floatlocationmethod + {\doifelseinset\v!here\floatlocationmethod \page_one_place_float_otherwise_here \page_one_place_float_otherwise_else} \def\page_one_place_float_otherwise_here - {\doifinsetelse\v!always\floatlocationmethod + {\doifelseinset\v!always\floatlocationmethod {\page[\v!preference]% \page_otr_command_check_if_float_fits \ifconditional\c_page_floats_room @@ -525,7 +525,7 @@ \fi}} \def\page_one_place_float_otherwise_else - {\doifinsetelse\v!always\floatlocationmethod + {\doifelseinset\v!always\floatlocationmethod {\page_otr_command_check_if_float_fits \ifconditional\c_page_floats_room \page_one_place_float_auto_top_bottom diff --git a/tex/context/base/page-pst.mkiv b/tex/context/base/page-pst.mkiv index 704289246..93188f9fa 100644 --- a/tex/context/base/page-pst.mkiv +++ b/tex/context/base/page-pst.mkiv @@ -57,7 +57,7 @@ \unexpanded\setvalue{\e!start\v!postponing}% {\bgroup \obeylines - \doifnextoptionalelse{\egroup\page_postponed_blocks_start}{\egroup\page_postponed_blocks_start[0]}} + \doifelsenextoptional{\egroup\page_postponed_blocks_start}{\egroup\page_postponed_blocks_start[0]}} \unexpanded\setvalue{\e!stop\v!postponing}% {\ctxcommand{registerpostponedblock("\currentpostponedpage")}\relax} diff --git a/tex/context/base/page-run.mkiv b/tex/context/base/page-run.mkiv index 7affedcbe..9adcb23c7 100644 --- a/tex/context/base/page-run.mkiv +++ b/tex/context/base/page-run.mkiv @@ -299,8 +299,8 @@ end \unexpanded\gdef\showmargins {\starttabulate - \NC asynchrone \NC \doifoddpageelse {odd} {even} \NC \NR - \NC synchrone \NC \doifrightpageelse {right} {left} \NC \NR + \NC asynchrone \NC \doifelseoddpage {odd} {even} \NC \NR + \NC synchrone \NC \doifelserightpage {right} {left} \NC \NR \NC right margin \NC \the\rightmarginwidth \NC \NR \NC left margin \NC \the\leftmarginwidth \NC \NR \NC outer margin \NC \the\outermarginwidth \NC \NR diff --git a/tex/context/base/page-sel.mkvi b/tex/context/base/page-sel.mkvi index cb9bcb509..ee25a37db 100644 --- a/tex/context/base/page-sel.mkvi +++ b/tex/context/base/page-sel.mkvi @@ -56,7 +56,7 @@ {\dotripleempty\page_selectors_insert} \def\page_selectors_insert[#filename][#emptylist][#settings]% - {\doifassignmentelse{#emptylist} + {\doifelseassignment{#emptylist} {\page_selectors_insert_indeed[#filename][][#emptylist]} {\page_selectors_insert_indeed[#filename][#emptylist][#settings]}} diff --git a/tex/context/base/page-set.mkiv b/tex/context/base/page-set.mkiv index 0617a71df..8f63dd74e 100644 --- a/tex/context/base/page-set.mkiv +++ b/tex/context/base/page-set.mkiv @@ -2184,11 +2184,11 @@ \def\dodefinecolumntextarea[#1][#2][#3]% y=0 is mogelijke en handig ! {\ifthirdargument - \doifinsetelse{#2}{\v!both,\v!fixed} + \doifelseinset{#2}{\v!both,\v!fixed} {\definecolumntextarea[#1][\v!left ][\c!type=#2,#3]% \definecolumntextarea[#1][\v!right][\c!type=#2,#3]} {\doifelse{#2}\v!next - {\doifoddpageelse + {\doifelseoddpage {\definecolumntextarea[#1][\v!right][\c!type=#2,#3]} {\definecolumntextarea[#1][\v!left ][\c!type=#2,#3]}} {\presetlocalframed @@ -2214,7 +2214,7 @@ {\setupcolumntextarea[#1][\v!left ][#3]% \setupcolumntextarea[#1][\v!right][#3]} {\doifelse{#2}\v!next - {\doifoddpageelse + {\doifelseoddpage {\setupcolumntextarea[#1][\v!right][#3]} {\setupcolumntextarea[#1][\v!left][#3]}} {\getparameters[\??mt#1#2][#3]}}% @@ -2385,7 +2385,7 @@ {\setvalue{\??mt#1\v!left }{#3}% \setvalue{\??mt#1\v!right}{#3}} {\doifelse{#2}\v!next - {\doifoddpageelse + {\doifelseoddpage {\setvalue{\??mt#1\v!right}{#3}}% {\setvalue{\??mt#1\v!left }{#3}}}% {\setvalue{\??mt#1#2}{#3}}}% diff --git a/tex/context/base/page-sid.mkiv b/tex/context/base/page-sid.mkiv index 3f6e7a45c..cbdb95fc3 100644 --- a/tex/context/base/page-sid.mkiv +++ b/tex/context/base/page-sid.mkiv @@ -207,6 +207,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doifsidefloatelse\doifelsesidefloat + % \def\page_sides_flush_floats_indeed % {\global\advance\d_page_sides_vsize-\d_page_sides_bottomskip % \begingroup diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi index 93e893eef..76143a018 100644 --- a/tex/context/base/page-txt.mkvi +++ b/tex/context/base/page-txt.mkvi @@ -253,7 +253,7 @@ %D only when double sided typesetting is enabled. \unexpanded\def\page_layouts_process_element_double - {\doifoddpageelse + {\doifelseoddpage \page_layouts_process_element_double_odd \page_layouts_process_element_double_even} @@ -378,6 +378,9 @@ \doubleexpandafter\firstoftwoarguments \fi\fi} +\let\doiflayouttextlineelse\doifelselayouttextline +\let\doiflayoutsomelineelse\doifelselayoutsomeline + \newconditional\resyncaftertextline \setvalue{\??layouttextsline\v!normal}{\page_layouts_place_text_line_indeed} diff --git a/tex/context/base/phys-dim.mkiv b/tex/context/base/phys-dim.mkiv index d3aae0114..232edc2fc 100644 --- a/tex/context/base/phys-dim.mkiv +++ b/tex/context/base/phys-dim.mkiv @@ -251,7 +251,7 @@ \settrue\c_phys_units_dospace} \unexpanded\def\digits - {\doifnextbgroupelse\phys_digits_argument\phys_digits_spaced} + {\doifelsenextbgroup\phys_digits_argument\phys_digits_spaced} \def\phys_digits_argument#1% {\phys_digits_indeed{#1}} @@ -579,7 +579,7 @@ \let\unitsNstartindeed\unitsNstart \unexpanded\def\unitsNstart - {\doifnextcharelse\unitsNstop\gobbleoneargument\unitsNstartindeed} + {\doifelsenextchar\unitsNstop\gobbleoneargument\unitsNstartindeed} % End of hack. diff --git a/tex/context/base/ppchtex.mkiv b/tex/context/base/ppchtex.mkiv index 0f42f91ce..d1167d414 100644 --- a/tex/context/base/ppchtex.mkiv +++ b/tex/context/base/ppchtex.mkiv @@ -100,11 +100,11 @@ \newconstant\chemicaldrawingmode -\doifdefinedelse{beginpicture} % PiCTeX - {\doifdefinedelse{startMPdrawing} +\doifelsedefined{beginpicture} % PiCTeX + {\doifelsedefined{startMPdrawing} {\chemicaldrawingmode\plustwo } % MetaPost {\chemicaldrawingmode\zerocount}} % raw - {\doifdefinedelse{psaxes} + {\doifelsedefined{psaxes} {\chemicaldrawingmode\plusone } % PSTricks {\chemicaldrawingmode\plusthree}} % unknown @@ -387,7 +387,7 @@ {\def\maxchemical{#1}} \def\doifchemicalnumber#1#2#3% - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\ifnum#1>\maxchemical\relax \writestatus{ppchtex}{number #1 is skipped}% \else @@ -682,7 +682,7 @@ \edef\@@chemicaltop {\the\!!countc}% \edef\@@chemicalbottom{\the\!!countd}% % - \doifinsetelse\v!on{\@@chemicalframe,\@@chemicalaxis} + \doifelseinset\v!on{\@@chemicalframe,\@@chemicalaxis} {\def\@@chemicalborder{\chemicalframe}} {\def\@@chemicalborder{\normalchemicalframe}}% % @@ -867,14 +867,14 @@ \def\chemicalrepeat {1} \def\redoprocesschemical[#1#2]% - {\doifinstringelse{#1}{0123456789.} + {\doifelseinstring{#1}{0123456789.} {\edef\chemicalrepeat{\chemicalrepeat#1}% \redoprocesschemical[#2]} {\processchemical[#1#2]% \def\chemicalrepeat{1}}} \def\doprocesschemical[#1#2]#3% - {\doifinstringelse{#1}{0123456789.} + {\doifelseinstring{#1}{0123456789.} {\def\chemicalrepeat{#1}% \redoprocesschemical[#2]} {#3}} @@ -891,9 +891,9 @@ \divide\dimen0 by \@@localchemicalscale \!!counta=\dimen0 \def\doprocess[##1##2]% - {\doifinstringelse{##1}{128} + {\doifelseinstring{##1}{128} {\edef\chemicaloffset{\the\!!counta}} - {\doifinstringelse{##1}{456} + {\doifelseinstring{##1}{456} {\edef\chemicaloffset{-\the\!!counta}} {\doifelse{##1}{0} {\edef\chemicaloffset{0}} @@ -917,9 +917,9 @@ \dimen0=.25\wd0 \divide\dimen0 by \@@localchemicalscale \!!counta=\dimen0 - \doifinstringelse{#1}{128} + \doifelseinstring{#1}{128} {\edef\chemicaloffset{\the\!!counta}} - {\doifinstringelse{#1}{456} + {\doifelseinstring{#1}{456} {\edef\chemicaloffset{-\the\!!counta}} {\doifelse{#1}{0} {\edef\chemicaloffset{0}} @@ -959,7 +959,7 @@ \setvalue{\s!angle4.#1}{\dosetchemicalangle{#5}}} \def\chemicalrotate[#1]% - {\doifdefinedelse{\s!mirror#1} + {\doifelsedefined{\s!mirror#1} {\getvalue{\s!rotate\chemicalrotation.#1\getvalue{\s!mirror#1}}% \getvalue{\s!angle\chemicalrotation.#1\getvalue{\s!mirror#1}}} {\getvalue{\s!rotate\chemicalrotation.#1}% @@ -984,7 +984,7 @@ \def\processchemicalrotation#1% {\def\doprocess[##1##2]% - {\doifnumberelse{##1} + {\doifelsenumber{##1} {\def\chemicalrotation{##1}} {\unknownchemical{ROT#1}}}% \doprocess[#1]} @@ -1067,9 +1067,11 @@ \def\dodoifsinglelocation#1#2\\#3% {\ifx#2\relax#3\fi} -\def\doifsinglelocationelse#1% +\def\doifelsesinglelocation#1% {\expandafter\dodoifsinglelocationelse#1\relax\\} +\let\doifsinglelocationelse\doifelsesinglelocation + \def\putchemicaltext#1#2% {\enablechemicalspecials \ifchemicalpicture @@ -1706,7 +1708,7 @@ \newif\ifinnerchemical \def\dosimplechemical#1#2#3% - {\doifdefinedelse{\??chemical\c!location} + {\doifelsedefined{\??chemical\c!location} {\writestatus{ppchtex}{the {}{}-alternative is not permitted here}} {\ifinnerchemical \let\chemicalsign = \chemicalinnersign @@ -2065,7 +2067,7 @@ HIGH=>\sethighsubscripts, LOW=>\setlowsubscripts, \s!default=>, - \s!unknown=>\doifdefinedelse{\s!executechemical#1} + \s!unknown=>\doifelsedefined{\s!executechemical#1} {\def\chemicalrotation{1}% \def\chemicaloffset{0}% \doifdefined{\s!executechemical#1} @@ -2260,9 +2262,9 @@ {\dosingleargument\dodefinechemical} \def\getpredefinedchemical#1% - {\doifdefinedelse{\??chemical#1} + {\doifelsedefined{\??chemical#1} {\getvalue{\??chemical#1}} - {\doifdefinedelse{#1} + {\doifelsedefined{#1} {\getvalue{#1}} {\writestatus{ppchtex}{unknown chemical definition #1}}}} diff --git a/tex/context/base/publ-imp-apa.mkvi b/tex/context/base/publ-imp-apa.mkvi index 3651fd036..402dbdeab 100644 --- a/tex/context/base/publ-imp-apa.mkvi +++ b/tex/context/base/publ-imp-apa.mkvi @@ -734,7 +734,7 @@ \stoptexdefinition \starttexdefinition btx:apa:title-if-not-placed - \doifmodeelse {btx:apa:title-placed} { + \doifelsemode {btx:apa:title-placed} { \resetmode{btx:apa:title-placed} } { \btxdoif {title} { @@ -775,8 +775,8 @@ \texdefinition{btx:format:inject} {internal(\currentbtxinternal)} { - \doifsetupselse{apa:list:sameauthor} { - \btxdoifsameaspreviouselse {author} { + \doifelsesetups{apa:list:sameauthor} { + \btxdoifelsesameasprevious {author} { \fastsetup{apa:list:sameauthor} } { \texdefinition{btx:apa:author-or-editor} {author} @@ -814,7 +814,7 @@ % we probably don't want this before the parenthesis. \starttexdefinition btx:apa:leftparenthesis-or-comma - \doifmodeelse {btx:apa:editionset-is-empty} { + \doifelsemode {btx:apa:editionset-is-empty} { \btxleftparenthesis \resetmode{btx:apa:editionset-is-empty} } { diff --git a/tex/context/base/publ-imp-definitions.mkvi b/tex/context/base/publ-imp-definitions.mkvi index 9485335ce..8dfa931b3 100644 --- a/tex/context/base/publ-imp-definitions.mkvi +++ b/tex/context/base/publ-imp-definitions.mkvi @@ -75,7 +75,7 @@ \ifx\p_monthconversion\empty % month month:mnem \currentbtxfieldmonth \else - \doifnumberelse \currentbtxfieldmonth { + \doifelsenumber \currentbtxfieldmonth { \convertnumber\p_monthconversion\currentbtxfieldmonth } { \currentbtxfieldmonth @@ -111,7 +111,7 @@ \stoptexdefinition \starttexdefinition btx:style #style #content - \doifdefinedelse {btx:style:#style} { + \doifelsedefined {btx:style:#style} { \texdefinition{btx:style:#style} { #content } diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 392742c37..3ddb49eff 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -961,9 +961,11 @@ implement { } } -function commands.convertbtxdatasettoxml(name,nice) - publications.converttoxml(name,nice) -end +implement { + name = "convertbtxdatasettoxml", + arguments = { "string", true }, + actions = publications.converttoxml +} -- enhancing @@ -1467,7 +1469,7 @@ do end function publications.loaddefinitionfile(name) -- a more specific name - commands.uselibrary { + resolvers.uselibrary { name = string.gsub(name,"^publ%-",""), patterns = patterns, action = action, @@ -1481,7 +1483,7 @@ do } function publications.loadreplacementfile(name) -- a more specific name - commands.uselibrary { + resolvers.uselibrary { name = string.gsub(name,"^publ%-",""), patterns = patterns, action = publications.loaders.registercleaner, diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index 6cad81dcf..79150c53e 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -280,7 +280,7 @@ {\publ_set_publication_indeed\v!default{#1}} \def\publ_set_publication_checked#1#2% - {\doifassignmentelse{#1} + {\doifelseassignment{#1} {\publ_set_publication_indeed\v!default{#1}} {\publ_set_publication_indeed{#1}{}}} @@ -674,9 +674,11 @@ \unexpanded\def\btxsetcurrentlistentry#1{\edef\currentbtxlistentry{#1}} \unexpanded\def\btxsetcurrentlistindex#1{\edef\currentbtxlistindex{#1}} -\unexpanded\def\btxdoifsameaspreviouselse#1% +\unexpanded\def\btxdoifelsesameasprevious#1% {\clf_btxdoifelsesameasprevious{\currentbtxdataset}\currentbtxlistentry{#1}} +\let\btxdoifsameaspreviouselse\btxdoifelsesameasprevious + \def\publ_place_list_indeed#1[#2][#3]% {\begingroup \ifsecondargument @@ -688,7 +690,7 @@ \let\currentbtxspecification\p_specification \fi \else\iffirstargument - \doifassignmentelse{#2} + \doifelseassignment{#2} {% [settings] \let\currentbtxrendering\currentbtxspecification \setupcurrentbtxrendering[#2]% @@ -934,6 +936,8 @@ \def\currentbtxuservariable #1{\clf_btxuservariable {\currentbtxdataset}{#1}} \def\btxdoifelseuservariable#1{\clf_btxdoifelseuservariable{\currentbtxdataset}{#1}} +\let\btxdoifuservariableelse\btxdoifelseuservariable + \let\btxcitereference\btx_cite_reference_inject \let\currentbtxnumbering\empty @@ -959,7 +963,7 @@ % \to \everysetupbtxlistplacement \unexpanded\def\btxflushauthor - {\doifnextoptionalcselse\btx_flush_author_yes\btx_flush_author_nop} + {\doifelsenextoptionalcs\btx_flush_author_yes\btx_flush_author_nop} \def\btx_flush_author_yes[#1]{\btx_flush_author{#1}} \def\btx_flush_author_nop {\btx_flush_author{\btxparameter\c!authorconversion}} @@ -1122,10 +1126,10 @@ \unexpanded\def\btxhybridcite % so one can alias the old {\dontleavehmode \begingroup - \strictdoifnextoptionalelse\publ_cite_tags_options\publ_cite_tags_indeed} + \strictdoifelsenextoptional\publ_cite_tags_options\publ_cite_tags_indeed} \unexpanded\def\publ_cite_tags_options[#1]% - {\strictdoifnextoptionalelse{\publ_cite_tags_options_indeed{#1}}{\publ_cite_tags_indeed{#1}}} + {\strictdoifelsenextoptional{\publ_cite_tags_options_indeed{#1}}{\publ_cite_tags_indeed{#1}}} \unexpanded\def\publ_cite_tags_indeed#1% {\letinteractionparameter\c!style\empty @@ -1138,7 +1142,7 @@ \endgroup} \unexpanded\def\publ_cite_tags_options_indeed#1% - {\doifassignmentelse{#1}\publ_cite_tags_settings_indeed\publ_cite_tags_variants_indeed{#1}} + {\doifelseassignment{#1}\publ_cite_tags_settings_indeed\publ_cite_tags_variants_indeed{#1}} \def\publ_cite_tags_settings_indeed#1[#2]% {\letinteractionparameter\c!style\empty @@ -1462,11 +1466,11 @@ {\ifthirdargument \publ_save_dataset_indeed[#1][#2][#3]% \else\ifsecondargument - \doifassignmentelse{#2}% + \doifelseassignment{#2}% {\publ_save_dataset_indeed[\s!default][#1][#2]}% {\publ_save_dataset_indeed[#1][#2][]}% \else\iffirstargument - \doifassignmentelse{#1}% + \doifelseassignment{#1}% {\publ_save_dataset_indeed[\s!default][\jobname-saved.bib][#1]}% {\publ_save_dataset_indeed[\s!default][#1][]}% % \else diff --git a/tex/context/base/publ-tra.mkiv b/tex/context/base/publ-tra.mkiv index fb64b4171..415505198 100644 --- a/tex/context/base/publ-tra.mkiv +++ b/tex/context/base/publ-tra.mkiv @@ -32,7 +32,7 @@ \setdummyparameter\c!dataset {\currentbtxdataset}% \letdummyparameter\c!field \empty \iffirstargument - \doifassignmentelse{#2} + \doifelseassignment{#2} {\getdummyparameters[#2]}% {\setdummyparameter\c!dataset{#2}}% \else @@ -54,7 +54,7 @@ \def\publ_show_fields[#1]% {\begingroup \setdummyparameter\c!rotation{90}% - \doifassignmentelse{#1}% + \doifelseassignment{#1}% {\letdummyparameter\c!specification\currentbtxspecification \getdummyparameters[#1]}% {\doifelsenothing{#1}% diff --git a/tex/context/base/publ-xml.mkiv b/tex/context/base/publ-xml.mkiv index c08d84a9b..96375b9cc 100644 --- a/tex/context/base/publ-xml.mkiv +++ b/tex/context/base/publ-xml.mkiv @@ -19,7 +19,7 @@ {\dosingleempty\publ_convert_to_xml} \def\publ_convert_to_xml[#1]% - {\ctxcommand{convertbtxdatasettoxml("\iffirstargument#1\else\v!default\fi",true)}} % or current when not empty + {\clf_convertbtxdatasettoxml{\iffirstargument#1\else\s!default\fi}} % or current when not empty % \startxmlsetups btx:initialize % \xmlregistereddocumentsetups{#1}{} diff --git a/tex/context/base/regi-ini.lua b/tex/context/base/regi-ini.lua index 179fd7448..e4a4e2399 100644 --- a/tex/context/base/regi-ini.lua +++ b/tex/context/base/regi-ini.lua @@ -27,12 +27,7 @@ local sequencers = utilities.sequencers local textlineactions = resolvers.openers.helpers.textlineactions local setmetatableindex = table.setmetatableindex -local scanners = tokens.scanners -local scanstring = scanners.string -local setters = tokens.setters -local setmacro = setters.macro - -local scanners = interfaces.scanners +local implement = interfaces.implement --[[ldx-- <p>We will hook regime handling code into the input methods.</p> @@ -267,36 +262,53 @@ end -- interface: -scanners.enableregime = function() - setmacro("currentregime",enable(scanstring())) -end +implement { + name = "enableregime", + arguments = "string", + actions = function(regime) setmacro("currentregime",enable(regime)) end +} -scanners.disableregime = function() - setmacro("currentregime",disable()) -end +implement { + name = "disableregime", + actions = function() setmacro("currentregime",disable()) end +} -scanners.pushregime = push -scanners.popregime = pop +implement { + name = "pushregime", + actions = push +} -local stack = { } +implement { + name = "popregime", + actions = pop +} -scanners.startregime = function(regime) - insert(stack,currentregime) - if trace_translating then - report_translating("start using %a",regime) - end - setmacro("currentregime",enable(regime)) -end +local stack = { } -scanners.stopregime = function() - if #stack > 0 then - local regime = remove(stack) +implement { + name = "startregime", + arguments = "string", + actions = function(regime) + insert(stack,currentregime) if trace_translating then - report_translating("stop using %a",regime) + report_translating("start using %a",regime) end setmacro("currentregime",enable(regime)) end -end +} + +implement { + name = "stopregime", + actions = function() + if #stack > 0 then + local regime = remove(stack) + if trace_translating then + report_translating("stop using %a",regime) + end + setmacro("currentregime",enable(regime)) + end + end +} -- Next we provide some hacks. Unfortunately we run into crappy encoded -- (read : mixed) encoded xml files that have these ë ä ö ü sequences diff --git a/tex/context/base/s-inf-03.mkiv b/tex/context/base/s-inf-03.mkiv index 7699c46d4..a253bed77 100644 --- a/tex/context/base/s-inf-03.mkiv +++ b/tex/context/base/s-inf-03.mkiv @@ -8,7 +8,7 @@ \setupbodyfont[dejavu] -\doifmodeelse {tablet} { +\doifelsemode {tablet} { \setuppapersize [S6,landscape] diff --git a/tex/context/base/s-map-10.mkiv b/tex/context/base/s-map-10.mkiv index b1218f6e2..c7541babc 100644 --- a/tex/context/base/s-map-10.mkiv +++ b/tex/context/base/s-map-10.mkiv @@ -172,7 +172,7 @@ \def\hfontii{\ssbf} \def\hfontiii{\rm\it} -\doifmodeelse{nosubsub}{% +\doifelsemode{nosubsub}{% \setuphead [section][% style=\hfontii, before={\blank[line]}, @@ -201,7 +201,7 @@ before={\blank[halfline]}% ]} -\doifmodeelse{nosubsub}{% +\doifelsemode{nosubsub}{% \setuphead [subject][% style=\hfontii, before={\blank[halfline]}, @@ -348,10 +348,10 @@ #1]% \doifnothing{\MapsPeriod}{% \ifnum \normalmonth<6 \gdef\MapsPeriod{VOORJAAR}\else \gdef\MapsPeriod{NAJAAR}\fi} - \doifinstringelse{oorjaar}{\MapsPeriod}{\gdef\MapsPeriod{VOORJAAR}}{}% - \doifinstringelse{pring}{\MapsPeriod}{\gdef\MapsPeriod{VOORJAAR}}{}% - \doifinstringelse{ajaar}{\MapsPeriod}{\gdef\MapsPeriod{NAJAAR}}{}% - \doifinstringelse{utumn}{\MapsPeriod}{\gdef\MapsPeriod{NAJAAR}}{}% + \doifelseinstring{oorjaar}{\MapsPeriod}{\gdef\MapsPeriod{VOORJAAR}}{}% + \doifelseinstring{pring}{\MapsPeriod}{\gdef\MapsPeriod{VOORJAAR}}{}% + \doifelseinstring{ajaar}{\MapsPeriod}{\gdef\MapsPeriod{NAJAAR}}{}% + \doifelseinstring{utumn}{\MapsPeriod}{\gdef\MapsPeriod{NAJAAR}}{}% \doifnothing{\MapsYear}{\gdef\MapsYear{\the\year}}% \doifnothing{\MapsNumber}{% \ifnum \normalmonth<6 @@ -441,9 +441,9 @@ %%%%%%%%%%% -\doifmodeelse{onecolumn}{% +\doifelsemode{onecolumn}{% \setuplayout[width=340pt] - \doifmodeelse{asym}{% one col, asymmetric + \doifelsemode{asym}{% one col, asymmetric \setuplayout[backspace=187.3pt]% \setuptyping [widetyping][oddmargin=-117pt] \setuppagenumbering [alternative={singlesided,doublesided}] diff --git a/tex/context/base/s-math-repertoire.mkiv b/tex/context/base/s-math-repertoire.mkiv index 08c58aea3..53a173f16 100644 --- a/tex/context/base/s-math-repertoire.mkiv +++ b/tex/context/base/s-math-repertoire.mkiv @@ -230,7 +230,7 @@ \showmathcharactersmth{10}{#1}% \endgroup \vfilll - \doifmodeelse{crosslink} + \doifelsemode{crosslink} {\goto{\strut\textcolor\showmathcharacterstxt{#2}}[#2::#1]}% {\strut\textcolor\showmathcharacterstxt{#2}}}% \hskip1ex} diff --git a/tex/context/base/s-pre-17.mkiv b/tex/context/base/s-pre-17.mkiv index 9505faa6b..9c46b4ed7 100644 --- a/tex/context/base/s-pre-17.mkiv +++ b/tex/context/base/s-pre-17.mkiv @@ -194,7 +194,7 @@ \egroup \setbox\scratchbox\vbox\bgroup \vskip100pt - \doifmodeelse {SpreadPage} { + \doifelsemode {SpreadPage} { \hbox spread 200pt } { \hbox to \wd\scratchbox diff --git a/tex/context/base/scrn-bar.mkvi b/tex/context/base/scrn-bar.mkvi index 1dadc26f3..8a2f9441c 100644 --- a/tex/context/base/scrn-bar.mkvi +++ b/tex/context/base/scrn-bar.mkvi @@ -67,7 +67,7 @@ \def\scrn_bar_direct[#tag][#settings]% somewhat messy {\iflocation \begingroup - \doifassignmentelse{#tag} + \doifelseassignment{#tag} {\let\currentinteractionbar\empty \setupcurrentinteractionbar[#tag]% \edef\currentinteractionbar{\interactionbarparameter\c!alternative}}% diff --git a/tex/context/base/scrn-but.mkvi b/tex/context/base/scrn-but.mkvi index f8b236c52..b2ee1827f 100644 --- a/tex/context/base/scrn-but.mkvi +++ b/tex/context/base/scrn-but.mkvi @@ -159,7 +159,7 @@ \attribute\referenceattribute\attributeunsetvalue \global\setfalse\c_scrn_button_skipped \chardef\locationboxpagestate\csname\??buttonlocation#currentparameter\c!samepage\endcsname % ?? bt: todo - \doifreferencefoundelse{#action}\scrn_button_make_yes\scrn_button_make_nop + \doifelsereferencefound{#action}\scrn_button_make_yes\scrn_button_make_nop #currentparameter% #inheritedframed% #letparameter% @@ -343,12 +343,12 @@ \def\scrn_menu_define[#tag][#category][#settings]% category reflects location, settings can be parent {\ifthirdargument - \doifassignmentelse{#settings}% + \doifelseassignment{#settings}% {\scrn_menu_define_original[#tag][#category][\c!category=#category,#settings]}% child definition {\scrn_menu_define_original[#tag][#settings][\c!category=#category]}% % child definition \scrn_menu_register{#tag}{#category}% \else\ifsecondargument - \doifassignmentelse{#category}% + \doifelseassignment{#category}% {\scrn_menu_define_original[#tag][#category]}% % root definition {\scrn_menu_define_original[#tag][#category][\c!category=#category]% % child definition \scrn_menu_register{#tag}{#category}}% @@ -691,7 +691,7 @@ \def\scrn_button_make_position#currentparameter#inheritedframed#letparameter#setparameter#text#action% {\global\advance\c_scrn_menu_position\plusone - \doifreferencefoundelse{#action}% 0=not found, 1=same page, >1=elsewhere + \doifelsereferencefound{#action}% 0=not found, 1=same page, >1=elsewhere {\c_scrn_menu_page_mode\ifnum\currentreferencerealpage=\realpageno\plusone\else\plustwo\fi}% {\c_scrn_menu_page_mode\plustwo}% \doglobal\appendetoks @@ -967,7 +967,7 @@ \scrn_menu_menu_button_a {#menutag}{#settings}{#text}{#action}% \else - \doifassignmentelse{#menutag}\scrn_menu_menu_button_b\scrn_menu_menu_button_c + \doifelseassignment{#menutag}\scrn_menu_menu_button_b\scrn_menu_menu_button_c {#menutag}{#text}{#action}% \fi} diff --git a/tex/context/base/scrn-fld.mkvi b/tex/context/base/scrn-fld.mkvi index bf1923e11..d72592195 100644 --- a/tex/context/base/scrn-fld.mkvi +++ b/tex/context/base/scrn-fld.mkvi @@ -127,7 +127,7 @@ {\processcommalist[#set]\scrn_symbols_preset_indeed}% \def\scrn_symbols_preset_indeed#tag% - {\doifobjectfoundelse{SYM}{#tag} + {\doifelseobjectfound{SYM}{#tag} {} {\settightobject{SYM}{#tag}\hbox{\symbol[#tag]}% % todo: set this as immediate xform \page_otr_add_special_content{\hskip-\maxdimen\getobject{SYM}{#tag}}}} % and then force it into the file @@ -276,10 +276,14 @@ %D A few testing macros: -\def\doiffieldbodyelse #tag{\ctxcommand{doiffieldelse("#tag")}} -\def\doiffieldcategoryelse#tag{\ctxcommand{doiffieldcategoryelse("#tag")}} +\def\doifelsefieldbody #tag{\ctxcommand{doiffieldelse("#tag")}} +\def\doifelsefieldcategory#tag{\ctxcommand{doiffieldcategoryelse("#tag")}} -\let\doiffieldelse\doiffieldbodyelse % compatibility +\let\doiffieldbodyelse \doifelsefieldbody +\let\doiffieldcategoryelse\doifelsefieldcategory + +\let\doiffieldelse \doifelsefieldbody % compatibility / will be dropped +\let\doifelsefield \doifelsefieldbody % compatibility / will be dropped %D We still support the traditional method of defining fields: %D @@ -679,7 +683,7 @@ \edef\currenttooltipname{tooltip:\number\c_scrn_tooltip_n}% \setbox\b_scrn_tooltip_anchor\hbox {\strut#anchortext}% - \doifassignmentelse{#settings} + \doifelseassignment{#settings} {\setupcurrenttooltip[#settings]}% {\setupcurrenttooltip[\c!location=#settings]}% \setbox\b_scrn_tooltip_text\hbox @@ -870,7 +874,7 @@ \setvalue{pushbutton:#tag}{\scrn_pushbutton_handle{#tag}{#settings}}} \def\scrn_pushbutton_define_variant#tag#variant#content% - {\doifsymboldefinedelse{pushsymbol:#tag:#variant} + {\doifelsesymboldefined{pushsymbol:#tag:#variant} \donothing {\definesymbol[pushsymbol:#tag:#variant][{#content}]}} @@ -977,7 +981,7 @@ \setupcurrentinteractionmenu[#settings]% \let\scrn_rollbutton_symbol\scrn_rollbutton_symbol_m \else - \doifassignmentelse{#tag} + \doifelseassignment{#tag} {\let\currentbutton\empty \setupcurrentbutton[#tag]% \let\scrn_rollbutton_symbol\scrn_rollbutton_symbol_b}% diff --git a/tex/context/base/scrn-hlp.mkvi b/tex/context/base/scrn-hlp.mkvi index f5a78fb08..8a8f5f094 100644 --- a/tex/context/base/scrn-hlp.mkvi +++ b/tex/context/base/scrn-hlp.mkvi @@ -139,6 +139,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doifhelpelse\doifelsehelp + \def\placehelp % was \helpdata {\ifinpagebody\ifcase\c_scrn_help_n\else \ctxcommand{collecthelp(255)}% rather hard coded ... bad diff --git a/tex/context/base/scrn-ini.mkvi b/tex/context/base/scrn-ini.mkvi index f6e4486a0..2ed822c6e 100644 --- a/tex/context/base/scrn-ini.mkvi +++ b/tex/context/base/scrn-ini.mkvi @@ -51,6 +51,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doiflocationelse\doifelselocation + \setupinteraction [\c!state=\v!stop] diff --git a/tex/context/base/scrn-wid.mkvi b/tex/context/base/scrn-wid.mkvi index 8dcc7a86a..931933bf1 100644 --- a/tex/context/base/scrn-wid.mkvi +++ b/tex/context/base/scrn-wid.mkvi @@ -136,7 +136,7 @@ {\bgroup \doifelsenothing{#registered} {\scrn_attachment_inject[\v!auto][]} - {\doifassignmentelse{#registered} + {\doifelseassignment{#registered} {\scrn_attachment_inject[\v!auto][#registered]} {\scrn_attachment_inject[#registered][#settings]}}% \egroup} @@ -162,7 +162,7 @@ {\bgroup \doifelsenothing{#registered} {\def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment]\egroup}}% - {\doifassignmentelse{#registered} + {\doifelseassignment{#registered} {\def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment,#registered]\egroup}}% {\def\scrn_attachment_stop{\scrn_attachment_inject[#registered][\c!buffer=\v!attachment,#settings]\egroup}}}% \grabbufferdatadirect\v!attachment{\e!start\currentattachment}{\e!stop\currentattachment}} @@ -398,7 +398,7 @@ \scrn_comment_argument_ignore} \def\scrn_comment_argument_indeed[#title][#settings]#text% - {\doifassignmentelse{#title} + {\doifelseassignment{#title} {\setupcurrentcomment[#title]} {\setupcurrentcomment[\c!title=#title,#settings]}% \ctxcommand{assignbuffer("\v!comment",\!!bs#text\!!es)}% todo: expansion control, but expanded by default (xml) @@ -421,7 +421,7 @@ \def\scrn_comment_start_indeed[#title][#settings]% {\bgroup - \doifassignmentelse{#title} + \doifelseassignment{#title} {\setupcurrentcomment[#title]} {\setupcurrentcomment[\c!title=#title,#settings]}% \unexpanded\def\scrn_comment_stop{\scrn_comment_inject\egroup}% diff --git a/tex/context/base/scrp-ini.lua b/tex/context/base/scrp-ini.lua index fa2bc771f..3c3517542 100644 --- a/tex/context/base/scrp-ini.lua +++ b/tex/context/base/scrp-ini.lua @@ -27,6 +27,8 @@ local texsetattribute = tex.setattribute local nodecodes = nodes.nodecodes local unsetvalue = attributes.unsetvalue +local implement = interfaces.implement + local glyph_code = nodecodes.glyph local glue_code = nodecodes.glue @@ -938,5 +940,22 @@ function autofontfeature.disable() disableaction("processors","scripts.autofontfeature.handler") end -commands.enableautofontscript = autofontfeature.enable -commands.disableautofontscript = autofontfeature.disable +implement { + name = "enableautofontscript", + actions = autofontfeature.enable +} + +implement { + name = "disableautofontscript", + actions = autofontfeature.disable } + +implement { + name = "setscript", + actions = scripts.set, + arguments = { "string", "string", "string" } +} + +implement { + name = "resetscript", + actions = scripts.reset +} diff --git a/tex/context/base/scrp-ini.mkiv b/tex/context/base/scrp-ini.mkiv index 4a27dd8e2..cd060c02b 100644 --- a/tex/context/base/scrp-ini.mkiv +++ b/tex/context/base/scrp-ini.mkiv @@ -41,14 +41,14 @@ \to \everydefinescript \unexpanded\def\scripts_basics_set - {\ctxlua{scripts.set("\currentscript","\scriptparameter\c!method","\scriptparameter\c!preset")}} + {\clf_setscript{\currentscript}{\scriptparameter\c!method}{\scriptparameter\c!preset}} \unexpanded\def\setscript[#1]% {\edef\currentscript{#1}% \scripts_basics_set} \unexpanded\def\resetscript - {\ctxlua{scripts.reset()}} + {\clf_resetscript} \unexpanded\def\startscript[#1]% {\begingroup @@ -86,8 +86,8 @@ \fi \to \everysetupscript -\unexpanded\def\enableautofontscript {\ctxcommand{enableautofontscript ()}} -\unexpanded\def\disableautofontscript{\ctxcommand{disableautofontscript()}} +\unexpanded\def\enableautofontscript {\clf_enableautofontscript } +\unexpanded\def\disableautofontscript{\clf_disableautofontscript} \definefontfeature[latn][script=latn] \definefontfeature[grek][script=grek] diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index 13a4ce192..90f980341 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -715,7 +715,7 @@ \forgetall \let\\=\endgraf \ifdoublesided\signalinnerrealign\fi - \doifrightpageelse\spac_align_set_horizontal_right\spac_align_set_horizontal_left + \doifelserightpage\spac_align_set_horizontal_right\spac_align_set_horizontal_left \let\next} \unexpanded\def\obox#1#2#3% @@ -723,7 +723,7 @@ \forgetall \let\\=\endgraf \ifdoublesided\signalouterrealign\fi - \doifrightpageelse\c_spac_align_state_horizontal_left\spac_align_set_horizontal_right + \doifelserightpage\c_spac_align_state_horizontal_left\spac_align_set_horizontal_right \let\next} \let\raggedbox\relax @@ -961,7 +961,7 @@ \hbox} \def\doxcheckline % used for floats so multipass anyway - {\signalrightpage\doifrightpageelse\donetrue\donefalse} + {\signalrightpage\doifelserightpage\donetrue\donefalse} \setvalue{\??alignline\v!inner }{\doxalignline\doxcheckline++\zeropoint \relax\hss } \setvalue{\??alignline\v!outer }{\doxalignline\doxcheckline++\zeropoint \hss \relax} diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv index 72828c1b8..54156c3b4 100644 --- a/tex/context/base/spac-hor.mkiv +++ b/tex/context/base/spac-hor.mkiv @@ -32,7 +32,7 @@ {\doifoutervmode{\ifconditional\c_spac_indentation_indent_first\else\spac_indentation_variant_no\fi}} \unexpanded\def\setupindenting - {\doifnextoptionalcselse\spac_indentation_setup_options\spac_indentation_setup_size} + {\doifelsenextoptionalcs\spac_indentation_setup_options\spac_indentation_setup_size} \unexpanded\def\spac_indentation_setup_size {\assigndimension\v_spac_indentation_current\d_spac_indentation_par{1\emwidth}{1.5\emwidth}{2\emwidth}} @@ -128,7 +128,7 @@ \fi\fi} \unexpanded\def\indenting % kind of obsolete - {\doifnextoptionalcselse\spac_indentation_setup_options\relax} + {\doifelsenextoptionalcs\spac_indentation_setup_options\relax} % use \noindentation to suppress next indentation @@ -264,7 +264,7 @@ \unexpanded\def\spac_indentation_check_next_indentation {\global\let\dorechecknextindentation\relax - \doifnextcharelse\par\donothing\spac_indentation_variant_no} % messy check as next is seldom \par + \doifelsenextchar\par\donothing\spac_indentation_variant_no} % messy check as next is seldom \par \def\spac_indentation_variant_auto {\global\let\dorechecknextindentation\spac_indentation_check_next_indentation} @@ -386,7 +386,7 @@ \installspacingmethod \v!broad {\nonfrenchspacing} % more depending on what punctuation \unexpanded\def\setupspacing - {\doifnextoptionalcselse\spac_spacecodes_setup_yes\spac_spacecodes_setup_nop} + {\doifelsenextoptionalcs\spac_spacecodes_setup_yes\spac_spacecodes_setup_nop} \def\spac_spacecodes_setup_yes[#1]% {\csname\??spacecodemethod#1\endcsname @@ -677,7 +677,7 @@ \fi} \def\spac_narrower_start_named_one[#1]% - {\doifassignmentelse{#1}\spac_narrower_start_named_one_yes\spac_narrower_start_named_one_nop[#1]} + {\doifelseassignment{#1}\spac_narrower_start_named_one_yes\spac_narrower_start_named_one_nop[#1]} \def\spac_narrower_start_named_one_yes[#1][#2]% [settings] [] {\setupcurrentnarrower[#1]% @@ -688,14 +688,14 @@ \spac_narrower_start_apply{\narrowerparameter\v!default}} \def\spac_narrower_start_named_two[#1]% - {\doifassignmentelse{#1}\spac_narrower_start_named_settings_how\spac_narrower_start_named_tag_unknown[#1]} + {\doifelseassignment{#1}\spac_narrower_start_named_settings_how\spac_narrower_start_named_tag_unknown[#1]} \def\spac_narrower_start_named_settings_how[#1][#2]% [settings] [how] {\setupcurrentnarrower[#1]% \spac_narrower_start_apply{#2}} \def\spac_narrower_start_named_tag_unknown[#1][#2]% [tag] [...] - {\doifassignmentelse{#2}\spac_narrower_start_named_tag_settings\spac_narrower_start_named_tag_how[#1][#2]} + {\doifelseassignment{#2}\spac_narrower_start_named_tag_settings\spac_narrower_start_named_tag_how[#1][#2]} \def\spac_narrower_start_named_tag_settings[#1][#2]% [tag] [settings] {\edef\currentnarrower{#1}% @@ -786,7 +786,7 @@ {\dosingleargument\spac_tolerances_setup} \def\spac_tolerances_setup[#1]% - {\doifinsetelse\v!vertical{#1}% + {\doifelseinset\v!vertical{#1}% {\processcommacommand[#1]\spac_tolerances_step_vertical } {\processcommacommand[#1]\spac_tolerances_step_horizontal}} @@ -1081,7 +1081,7 @@ %D A rather unknown one: \unexpanded\def\widened % moved from cont-new - {\doifnextoptionalcselse\spac_widened_yes\spac_widened_nop} + {\doifelsenextoptionalcs\spac_widened_yes\spac_widened_nop} \def\spac_widened_yes[#1]#2{\hbox \s!spread #1{\hss#2\hss}} \def\spac_widened_nop #1{\hbox \s!spread \emwidth{\hss#1\hss}} diff --git a/tex/context/base/spac-lin.mkiv b/tex/context/base/spac-lin.mkiv index f73809f2c..20fec5d45 100644 --- a/tex/context/base/spac-lin.mkiv +++ b/tex/context/base/spac-lin.mkiv @@ -128,7 +128,7 @@ \egroup} \def\spac_lines_between - {\doifmeaningelse\next\obeyedline % brrr + {\doifelsemeaning\next\obeyedline % brrr {\linesparameter\c!inbetween} {\spac_after_first_obeyed_line}} diff --git a/tex/context/base/spac-pag.mkiv b/tex/context/base/spac-pag.mkiv index da4c8e970..1ecc31d8c 100644 --- a/tex/context/base/spac-pag.mkiv +++ b/tex/context/base/spac-pag.mkiv @@ -51,7 +51,7 @@ \setpagestaterealpageno{#1}{\number#2}% \fi} -\unexpanded\def\doifrightpagestateelse#1#2% not expandable ! +\unexpanded\def\doifelserightpagestate#1#2% not expandable ! {\ifcase\frozenpagestate \pagestatemismatchfalse \realpagestateno\realfolio @@ -100,7 +100,7 @@ \expandafter\secondoftwoarguments \fi} -\unexpanded\def\doifforcedrightpagestateelse#1#2% +\unexpanded\def\doifelseforcedrightpagestate#1#2% {\ifcase\frozenpagestate \pagestatemismatchfalse \realpagestateno\realfolio @@ -135,6 +135,9 @@ \expandafter\secondoftwoarguments \fi} +\let\doifrightpagestateelse \doifelserightpagestate +\let\doifforcedrightpagestateelse\doifelseforcedrightpagestate + \unexpanded\def\freezepagestate {\frozenpagestate\plusone } \unexpanded\def\defrostpagestate{\frozenpagestate\zerocount} @@ -147,7 +150,9 @@ \definepagestate[\s!paragraph] \unexpanded\def\signalrightpage {\dotrackpagestate \s!paragraph\nofraggedparagraphs} % use \dontleavehmode if needed -\unexpanded\def\doifrightpageelse{\doifrightpagestateelse\s!paragraph\nofraggedparagraphs} +\unexpanded\def\doifelserightpage{\doifelserightpagestate\s!paragraph\nofraggedparagraphs} + +\let\doifrightpageelse\doifelserightpage \installcorenamespace{pagechanges} diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv index 5c6e994fa..e860aacde 100644 --- a/tex/context/base/spac-ver.mkiv +++ b/tex/context/base/spac-ver.mkiv @@ -122,7 +122,7 @@ \setvalue{\??interlinespacerelative\v!auto }{\let\setrelativeinterlinespace\spac_linespacing_set_relative_interlinespace} \def\spac_linespacing_set_specified_relative_interlinespace#1% fragile? - {\doifdimenstringelse{#1} + {\doifelsedimenstring{#1} {\setupspecifiedinterlinespace[\c!line=#1]} {\assignvalue{#1}\currentrelativeinterlinespace{1.00}{1.25}{1.50}% \spacing\currentrelativeinterlinespace}} @@ -190,7 +190,7 @@ \fi\fi} \def\spac_linespacing_setup_specified_or_relative[#1]% - {\doifassignmentelse{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]% + {\doifelseassignment{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]% \the\iflocalinterlinespace\everysetuplocalinterlinespace\else\everysetupglobalinterlinespace\fi} \def\spac_linespacing_synchronize_local % adapts to the font @@ -217,7 +217,7 @@ \fi \popmacro\currentinterlinespace \else - \normalexpanded{\noexpand\doifassignmentelse{\p_spac_checked_interlinespace}% + \normalexpanded{\noexpand\doifelseassignment{\p_spac_checked_interlinespace}% \setupspecifiedinterlinespace\setuprelativeinterlinespace[\p_spac_checked_interlinespace]}% \iflocalinterlinespace \the\everysetuplocalinterlinespace @@ -350,7 +350,7 @@ \let\v_spac_whitespace_current\v!none \unexpanded\def\setupwhitespace - {\doifnextoptionalcselse\spac_whitespace_setup_yes\spac_whitespace_setup_nop} + {\doifelsenextoptionalcs\spac_whitespace_setup_yes\spac_whitespace_setup_nop} \def\spac_whitespace_setup_nop {\ifx\v_spac_whitespace_current\v!none\else @@ -1820,7 +1820,7 @@ % The main spacer: \unexpanded\def\vspacing - {\doifnextoptionalcselse\spac_vspacing_yes\spac_vspacing_nop} + {\doifelsenextoptionalcs\spac_vspacing_yes\spac_vspacing_nop} \def\spac_vspacing_yes {\ifinpagebody % somewhat weird @@ -1876,7 +1876,7 @@ % these depend on bigskipamount cum suis so we'd better sync them \unexpanded\def\setupvspacing - {\doifnextoptionalcselse\setupvspacing_yes\setupvspacing_nop} + {\doifelsenextoptionalcs\setupvspacing_yes\setupvspacing_nop} \let\currentvspacing\s!default % hm, default, standard ... @@ -2077,7 +2077,7 @@ \let\m_spac_hanging_location\empty \def\spac_hanging_start[#1]% - {\doifassignmentelse{#1} + {\doifelseassignment{#1} {\let\m_spac_hanging_location\empty \setupcurrenthanging[#1]}% {\edef\m_spac_hanging_location{#1}}% diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex b81d43b32..b4e94c21c 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 751b19917..d01a9e85c 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-bkm.mkiv b/tex/context/base/strc-bkm.mkiv index f61017cf3..9688a1f93 100644 --- a/tex/context/base/strc-bkm.mkiv +++ b/tex/context/base/strc-bkm.mkiv @@ -110,7 +110,7 @@ \ifthirdargument \setupcurrentbookmark[#3]% no every so not all possible \else\ifsecondargument - \doifassignmentelse{#2}{\let\m_bookmarks_opened\empty\setupcurrentbookmark[#2]}\donothing + \doifelseassignment{#2}{\let\m_bookmarks_opened\empty\setupcurrentbookmark[#2]}\donothing \fi\fi \clf_registerbookmark names {\m_bookmarks_names}% diff --git a/tex/context/base/strc-blk.mkiv b/tex/context/base/strc-blk.mkiv index a2e66da17..fe259d223 100644 --- a/tex/context/base/strc-blk.mkiv +++ b/tex/context/base/strc-blk.mkiv @@ -76,7 +76,7 @@ \def\strc_blocks_select[#1][#2][#3][#4]% state name tag setups {\bgroup - \doifassignmentelse{#3} + \doifelseassignment{#3} {\getparameters[\??blocktemp][\c!criterium=\v!text,#3]% \def\strc_blocks_setup{\setupcurrentblock[#3]}% \clf_selectstructureblock{#1}{#2}{}{\csname\??blocktemp\c!criterium\endcsname}} diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi index 31311279e..f4c20dbc9 100644 --- a/tex/context/base/strc-con.mkvi +++ b/tex/context/base/strc-con.mkvi @@ -539,7 +539,7 @@ \startsetups[\??constructionrenderings:\v!left] \edef\p_strc_constructions_hang{\constructionparameter\c!hang}% - \doifsetupselse{\??constructionrenderings:\v!left:\p_strc_constructions_hang} { + \doifelsesetups{\??constructionrenderings:\v!left:\p_strc_constructions_hang} { \directsetup{\??constructionrenderings:\v!left:\p_strc_constructions_hang} } { \directsetup{\??constructionrenderings:\v!left:\v!hanging} @@ -548,7 +548,7 @@ \startsetups[\??constructionrenderings:\v!right] \edef\p_strc_constructions_hang{\constructionparameter\c!hang} - \doifsetupselse{\??constructionrenderings:\v!right:\p_strc_constructions_hang} { + \doifelsesetups{\??constructionrenderings:\v!right:\p_strc_constructions_hang} { \directsetup{\??constructionrenderings:\v!right:\p_strc_constructions_hang} } { \directsetup{\??constructionrenderings:\v!right:\v!hanging} @@ -745,7 +745,7 @@ \startsetups[\??constructionrenderings:\v!serried] \edef\p_strc_constructions_width{\constructionparameter\c!width}% CHECK ! ! ! wrong parameter namespace - \doifsetupselse{\??constructionrenderings:\v!serried:\p_strc_constructions_width} { + \doifelsesetups{\??constructionrenderings:\v!serried:\p_strc_constructions_width} { \directsetup{\??constructionrenderings:\v!serried:\p_strc_constructions_width} } { \directsetup{\??constructionrenderings:\v!serried:\v!wide} @@ -861,7 +861,7 @@ \let\currentconstructionlistentry\!!zerocount \def\strc_constructions_register - {\clf_doiflisthasentry\numexpr\currentconstructionlistentry\relax + {\clf_doifelselisthasentry\numexpr\currentconstructionlistentry\relax \strc_constructions_register_nop \strc_constructions_register_yes} diff --git a/tex/context/base/strc-des.mkvi b/tex/context/base/strc-des.mkvi index 81cd6ee52..3557000f9 100644 --- a/tex/context/base/strc-des.mkvi +++ b/tex/context/base/strc-des.mkvi @@ -103,10 +103,10 @@ \unexpanded\def\strc_descriptions_start#1% {\begingroup \strc_constructions_initialize{#1}% - \doifnextoptionalcselse\strc_descriptions_start_yes\strc_descriptions_start_nop} + \doifelsenextoptionalcs\strc_descriptions_start_yes\strc_descriptions_start_nop} \unexpanded\def\strc_descriptions_start_yes[#1]% - {\doifassignmentelse{#1}\strc_descriptions_start_yes_assignment\strc_descriptions_start_yes_reference[#1]} + {\doifelseassignment{#1}\strc_descriptions_start_yes_assignment\strc_descriptions_start_yes_reference[#1]} \unexpanded\def\strc_descriptions_start_yes_assignment[#1]% todo userdata {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=,#1][]% @@ -120,7 +120,7 @@ \fi} \unexpanded\def\strc_descriptions_start_yes_titled[#1]% - {\doifnextbgroupelse + {\doifelsenextbgroup {\strc_descriptions_start_yes_titled_indeed[#1]}% {\setfalse\c_strc_constructions_title_state \strc_descriptions_start_yes_normal[#1]}} @@ -141,7 +141,7 @@ \fi} \unexpanded\def\strc_descriptions_start_nop_titled - {\doifnextbgroupelse + {\doifelsenextbgroup {\strc_descriptions_start_nop_titled_indeed}% {\setfalse\c_strc_constructions_title_state \strc_descriptions_start_nop_normal}}% @@ -163,7 +163,7 @@ \unexpanded\def\strc_descriptions_command#1% {\begingroup \strc_constructions_initialize{#1}% - \doifnextoptionalcselse\strc_descriptions_yes\strc_descriptions_nop} + \doifelsenextoptionalcs\strc_descriptions_yes\strc_descriptions_nop} \unexpanded\def\strc_descriptions_yes {\ifconditional\c_strc_constructions_title_state @@ -177,7 +177,7 @@ \csname\??constructioncommandhandler\currentconstructionhandler\endcsname} \unexpanded\def\strc_descriptions_yes_titled[#1]% - {\doifnextbgroupelse + {\doifelsenextbgroup {\strc_descriptions_yes_titled_indeed[#1]}% {\setfalse\c_strc_constructions_title_state \strc_descriptions_yes_normal[#1]}} @@ -198,7 +198,7 @@ \fi} \unexpanded\def\strc_descriptions_nop_titled - {\doifnextbgroupelse + {\doifelsenextbgroup {\strc_descriptions_nop_titled_indeed}% {\setfalse\c_strc_constructions_title_state \strc_descriptions_nop_normal}} diff --git a/tex/context/base/strc-enu.mkvi b/tex/context/base/strc-enu.mkvi index 0da71ecdf..b76bc0067 100644 --- a/tex/context/base/strc-enu.mkvi +++ b/tex/context/base/strc-enu.mkvi @@ -172,7 +172,7 @@ \ifx\p_counter\empty % \let\p_counter\currentenumeration \fi - \doifcounterelse\p_counter\donothing{\strc_enumerations_define_counter\p_counter}% + \doifelsecounter\p_counter\donothing{\strc_enumerations_define_counter\p_counter}% \letenumerationparameter\s!counter\p_counter %\strc_enumerations_setup_counter\currentenumeration \to \everydefineenumeration @@ -284,7 +284,7 @@ \unexpanded\def\strc_enumerations_inject_extra_text {\ifconditional\c_strc_constructions_title_state - \clf_doiflisthastitleelse{\currentconstructionmain}\numexpr\currentconstructionlistentry\relax + \clf_doifelselisthastitle{\currentconstructionmain}\numexpr\currentconstructionlistentry\relax \donothing \strc_enumerations_inject_extra_text_indeed \fi} diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi index 41dc98109..d293a9a6c 100644 --- a/tex/context/base/strc-flt.mkvi +++ b/tex/context/base/strc-flt.mkvi @@ -509,7 +509,7 @@ \fi \strc_floats_analyze_location \setupcurrentfloatcaption[\c!reference={#reference},\c!title={#caption},\c!marking=,\c!list=,\c!bookmark=]% - \doifinsetelse\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal} + \doifelseinset\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal} \unexpanded\def\placefloat {\flushnotes @@ -554,7 +554,7 @@ \setupcurrentfloatuserdata[#userdata]% \fi \strc_floats_analyze_location - \doifinsetelse\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal + \doifelseinset\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal \bgroup \ignorespaces} @@ -655,9 +655,9 @@ \unexpanded\def\strc_floats_place_next_box_normal {\ifconditional\c_page_floats_some_waiting % this was \checkwaitingfloats spread all over - \doifinsetelse\v!always\floatlocation + \doifelseinset\v!always\floatlocation {\showmessage\m!floatblocks5\empty} - {\doifcommonelse\floatlocation\flushfloatslist\page_otr_command_flush_floats\donothing}% + {\doifelsecommon\floatlocation\flushfloatslist\page_otr_command_flush_floats\donothing}% % but which should be done before using box \floatbox \fi \page_margin_strc_floats_before % todo: each float handler gets a before @@ -700,7 +700,7 @@ {\ifinsidecolumns \global\setfalse\c_strc_floats_par_float \else - \doifcommonelse\floatlocation\flushfloatslist + \doifelsecommon\floatlocation\flushfloatslist {\global\settrue \c_strc_floats_par_float} {\global\setfalse\c_strc_floats_par_float}% \fi @@ -739,12 +739,12 @@ 180=>\global\c_strc_floats_rotation\commalistelement\relax,% 270=>\global\c_strc_floats_rotation\commalistelement\relax]% \fi - \doifinsetelse\v!nonumber\floatlocation + \doifelseinset\v!nonumber\floatlocation {\global\nofloatnumbertrue} {\doifelse{\floatcaptionparameter\c!number}\v!yes {\global\nofloatnumberfalse} {\global\nofloatnumbertrue}}% - \doifinsetelse\v!none\floatlocation + \doifelseinset\v!none\floatlocation {\global\nofloatcaptiontrue} {\global\nofloatcaptionfalse}% \doif{\floatcaptionparameter\c!number}\v!none % new @@ -760,7 +760,7 @@ \ifconditional\c_page_floats_center_box_global \settrue\c_page_floats_center_box_local \else - \doifinsetelse\v!local\floatlocation\settrue\setfalse\c_page_floats_center_box_local + \doifelseinset\v!local\floatlocation\settrue\setfalse\c_page_floats_center_box_local \fi \doifnotcommon{\v!always,\v!here,\v!force}\floatlocation % ! ! ! ! ! ! {\setfalse\c_page_floats_center_box_global @@ -786,6 +786,8 @@ \expandafter\firstoftwoarguments \fi} +\let\doifmainfloatbodyelse\doifelsemainfloatbody + % todo: optional user pars \let\currentfloatattribute\empty % to be checked @@ -915,26 +917,29 @@ \strc_float_load_data \to \everyinsidefloat -\def\doifrightpagefloatelse +\def\doifelserightpagefloat {\ifdoublesided \ifsinglesided \doubleexpandafter\firstoftwoarguments \else - \doubleexpandafter\doifoddfloatpageelse + \doubleexpandafter\doifelseoddfloatpage \fi \else \expandafter\firstoftwoarguments \fi} -\def\doifoddfloatpageelse +\def\doifelseoddfloatpage {\ifodd\purenumber\strc_float_realpage\space \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doifrightpagefloatelse\doifelserightpagefloat +\let\doifoddpagefloatelse \doifelseoddpagefloat + \appendtoks - \let\rightorleftpageaction\doifrightpagefloatelse + \let\rightorleftpageaction\doifelserightpagefloat \to \everyinsidefloat % \let\movesidefloat\gobbleoneargument @@ -945,7 +950,7 @@ \unexpanded\def\movesidefloat[#settings]% (-)n*line|x=,y= {\global\d_page_sides_downshift \zeropoint \global\d_page_sides_extrashift\zeropoint - \doifassignmentelse{#settings}% + \doifelseassignment{#settings}% {\begingroup \setupcurrentfloat[\c!x=\zeropoint,\c!y=\zeropoint,#settings]% \ifgridsnapping @@ -1057,10 +1062,10 @@ \fi \fi % we can also support edges .. in that case no common but a fast loop - \doifinsetelse\v!hanging\floatlocation - {\doifcommonelse{\v!inleft,\v!leftmargin}\floatlocation + \doifelseinset\v!hanging\floatlocation + {\doifelsecommon{\v!inleft,\v!leftmargin}\floatlocation {\let\p_maxwidth\leftmarginwidth}% - {\doifcommonelse{\v!inright,\v!rightmargin}\floatlocation + {\doifelsecommon{\v!inright,\v!rightmargin}\floatlocation {\let\p_maxwidth\rightmarginwidth}% {\edef\p_maxwidth{\floatparameter\c!maxwidth}}}}% {\edef\p_maxwidth{\floatparameter\c!maxwidth}}% @@ -1069,9 +1074,9 @@ \else \scratchwidth\p_maxwidth\relax \ifdim\wd\floatbox>\scratchwidth - \doifcommonelse{\v!inright,\v!rightmargin,\v!rightedge,\v!inleft,\v!leftmargin,\v!leftedge}\floatlocation + \doifelsecommon{\v!inright,\v!rightmargin,\v!rightedge,\v!inleft,\v!leftmargin,\v!leftedge}\floatlocation {\global\d_page_sides_maximum\scratchwidth} - {\doifcommonelse{\v!right,\v!left}\floatlocation + {\doifelsecommon{\v!right,\v!left}\floatlocation \strc_floats_realign_floatbox_horizontal_one \strc_floats_realign_floatbox_horizontal_two}% \fi @@ -1156,7 +1161,7 @@ \global\floatheight \ht\floatbox % forget about the depth \global\floattextwidth\dimexpr\hsize-\floatwidth-\rootfloatparameter\c!margin\relax \edef\floatlocation{\floatlocationmethod}% to be sure .. why - \doifinsetelse\v!tall\floatlocationmethod + \doifelseinset\v!tall\floatlocationmethod {\floattextheight\dimexpr\pagegoal-\pagetotal-\bigskipamount\relax % ugly, this bigskip \ifdim\floattextheight>\textheight \floattextheight\textheight @@ -1181,27 +1186,27 @@ {\floattextheight\ifdim\ht\floattext<\floatheight\floatheight\else\ht\floattext\fi}% \setbox\floatbox\vbox to \floattextheight {\hsize\floatwidth - \doifinsetelse\v!both\floatlocation - {\doifinsetelse\v!low\floatlocation + \doifelseinset\v!both\floatlocation + {\doifelseinset\v!low\floatlocation {\vfill\box\floatbox} - {\doifinsetelse\v!middle\floatlocation + {\doifelseinset\v!middle\floatlocation {\vfill\box\floatbox\vfill} {\box\floatbox\vfill}}} {\box\floatbox\vfill}}% \setbox\floattext\vbox to \floattextheight {\hsize\floattextwidth - \doifinsetelse\v!low\floatlocation + \doifelseinset\v!low\floatlocation {\vfill \box\floattext \doifinset\c!offset\floatlocation{\whitespace\blank}} - {\doifinsetelse\v!middle\floatlocation + {\doifelseinset\v!middle\floatlocation {\vfill \box\floattext \vfill} {\doifinset\v!offset\floatlocation{\whitespace\blank}% \box\floattext \vfill}}}% - \doifinsetelse\v!right\floatlocation + \doifelseinset\v!right\floatlocation {\setbox\floatbox\hbox to \hsize {\box\floattext \hfill @@ -1551,10 +1556,10 @@ \box\b_strc_floats_content}} \def\strc_floats_build_box_next_outer - {\doifrightpagefloatelse\strc_floats_build_box_next_right\strc_floats_build_box_next_left} + {\doifelserightpagefloat\strc_floats_build_box_next_right\strc_floats_build_box_next_left} \def\strc_floats_build_box_next_inner - {\doifrightpagefloatelse\strc_floats_build_box_next_left\strc_floats_build_box_next_right} + {\doifelserightpagefloat\strc_floats_build_box_next_left\strc_floats_build_box_next_right} \def\strc_floats_build_box_next_right_hang#1% {\ifconditional\c_strc_floats_par_float \hbox \else \expandafter \strc_floats_align_content \fi @@ -1605,12 +1610,12 @@ {\strc_floats_build_box_next_left_margin_indeed \leftmargindistance } \def\strc_floats_build_box_next_outer_margin - {\doifrightpagefloatelse + {\doifelserightpagefloat {\strc_floats_build_box_next_right_margin_indeed\rightmargindistance} {\strc_floats_build_box_next_left_margin_indeed \rightmargindistance}} \def\strc_floats_build_box_next_inner_margin - {\doifrightpagefloatelse + {\doifelserightpagefloat {\strc_floats_build_box_next_left_margin_indeed \leftmargindistance} {\strc_floats_build_box_next_right_margin_indeed\leftmargindistance}} @@ -1647,29 +1652,16 @@ \def\strc_floats_flush_left_caption_hang {\hsmash{\llap{\box\b_strc_floats_caption\dotfskip{\floatcaptionparameter\c!distance}}}} -% \def\strc_floats_flush_caption_hang % expanded can go -% {\expanded{\doifinsetelse{\v!righthanging}{\floatcaptionparameter\c!location}} -% {\strc_floats_flush_right_caption_hang} -% {\expanded{\doifinsetelse{\v!lefthanging}{\floatcaptionparameter\c!location}} -% {\strc_floats_flush_left_caption_hang} -% {\expanded{\doifinsetelse{\v!hang}{\floatcaptionparameter\c!location}} -% {\expanded{\doifinsetelse{\v!outer}{\floatcaptionparameter\c!location}} -% {\doifrightpagefloatelse{\strc_floats_flush_right_caption_hang}{\strc_floats_flush_left_caption_hang}} -% {\expanded{\doifinsetelse{\v!right}{\floatcaptiondirectives}} -% {\strc_floats_flush_right_caption_hang} -% {\strc_floats_flush_left_caption_hang}}} -% {\box\b_strc_floats_caption}}}} - \def\strc_floats_flush_caption_hang % expanded can go {\edef\p_strc_floats_caption_location{\floatcaptionparameter\c!location}% - \doifinsetelse\v!righthanging\p_strc_floats_caption_location + \doifelseinset\v!righthanging\p_strc_floats_caption_location {\strc_floats_flush_right_caption_hang} - {\doifinsetelse\v!lefthanging\p_strc_floats_caption_location + {\doifelseinset\v!lefthanging\p_strc_floats_caption_location {\strc_floats_flush_left_caption_hang} - {\doifinsetelse\v!hang\p_strc_floats_caption_location - {\doifinsetelse\v!outer\p_strc_floats_caption_location - {\doifrightpagefloatelse{\strc_floats_flush_right_caption_hang}{\strc_floats_flush_left_caption_hang}} - {\doifinsetelse\v!right\floatcaptiondirectives + {\doifelseinset\v!hang\p_strc_floats_caption_location + {\doifelseinset\v!outer\p_strc_floats_caption_location + {\doifelserightpagefloat{\strc_floats_flush_right_caption_hang}{\strc_floats_flush_left_caption_hang}} + {\doifelseinset\v!right\floatcaptiondirectives {\strc_floats_flush_right_caption_hang} {\strc_floats_flush_left_caption_hang}}} {\box\b_strc_floats_caption}}}} @@ -1732,7 +1724,7 @@ \fi} \def\strc_floats_build_box_top_stack_normal - {\doifinsetelse\v!overlay{\floatcaptionparameter\c!location} + {\doifelseinset\v!overlay{\floatcaptionparameter\c!location} \strc_floats_build_box_top_stack_normal_overlay \strc_floats_build_box_top_stack_normal_content} @@ -1848,8 +1840,8 @@ \processallactionsinset[\floatcaptionparameter\c!location] [ \v!left=>\let\next\strc_floats_relocate_caption_left, \v!right=>\let\next\strc_floats_relocate_caption_right, - \v!inner=>\doifrightpagefloatelse{\let\next\strc_floats_relocate_caption_left }{\let\next\strc_floats_relocate_caption_right}, - \v!outer=>\doifrightpagefloatelse{\let\next\strc_floats_relocate_caption_right}{\let\next\strc_floats_relocate_caption_left }]% + \v!inner=>\doifelserightpagefloat{\let\next\strc_floats_relocate_caption_left }{\let\next\strc_floats_relocate_caption_right}, + \v!outer=>\doifelserightpagefloat{\let\next\strc_floats_relocate_caption_right}{\let\next\strc_floats_relocate_caption_left }]% \next} \installfloatboxbuilder \v!none \strc_floats_build_box_default diff --git a/tex/context/base/strc-itm.mkvi b/tex/context/base/strc-itm.mkvi index dc95f569b..b69d5bac0 100644 --- a/tex/context/base/strc-itm.mkvi +++ b/tex/context/base/strc-itm.mkvi @@ -581,7 +581,7 @@ % can be made a bit faster \def\strc_itemgroups_setup_each#category#whatever% - {\doifassignmentelse{#whatever} + {\doifelseassignment{#whatever} {\strc_itemgroups_normal_setup[#category][#whatever]} {\strc_itemgroups_normal_setup[#category][\c!option={#whatever}]}} @@ -592,7 +592,7 @@ {\strc_itemgroups_normal_setup[#category:#level][\c!option={#whatever}]} \def\strc_itemgroups_setup_list#subcategories#category#whatever% - {\doifassignmentelse{#whatever} + {\doifelseassignment{#whatever} {\processcommalist[#subcategories]{\strc_itemgroups_setup_list_level_a{#category}{#whatever}}} {\processcommalist[#subcategories]{\strc_itemgroups_setup_list_level_b{#category}{#whatever}}}} @@ -644,9 +644,9 @@ \def\strc_itemgroups_set_symbol#symbol% {\edef\strc_itemgroups_tmp_symbol{#symbol}% \ifx\strc_itemgroups_tmp_symbol\empty \else - \doifsymboldefinedelse\strc_itemgroups_tmp_symbol + \doifelsesymboldefined\strc_itemgroups_tmp_symbol \strc_itemgroups_set_symbol_symbol - {\doifconversiondefinedelse\strc_itemgroups_tmp_symbol + {\doifelseconversiondefined\strc_itemgroups_tmp_symbol \strc_itemgroups_set_symbol_conversion \donothing}% \fi} @@ -711,7 +711,7 @@ \ifthirdargument \strc_itemgroups_start_indeed[#options][#settings]% \else\ifsecondargument - \doifassignmentelse{#options} + \doifelseassignment{#options} {\strc_itemgroups_start_indeed[][#options]} {\strc_itemgroups_start_indeed[#options][]}% \else @@ -1539,7 +1539,7 @@ {\strc_itemgroups_item_alone} \def\strc_itemgroups_item_alone[#category]#text\par - {\doifsomethingelse{#category}{\startitemgroup[#category]}{\startitemgroup[\v!itemize]}% + {\doifelsesomething{#category}{\startitemgroup[#category]}{\startitemgroup[\v!itemize]}% \startitem#text\stopitem \stopitemgroup} @@ -1547,7 +1547,7 @@ {\strc_itemgroups_head_alone} \def\strc_itemgroups_head_alone[#category]#head\par#body\par - {\doifsomethingelse{#category}{\startitemgroup[#category]}{\startitemgroup[\v!itemize]}% + {\doifelsesomething{#category}{\startitemgroup[#category]}{\startitemgroup[\v!itemize]}% \starthead{#head}#body\stophead \stopitemgroup} diff --git a/tex/context/base/strc-lab.mkiv b/tex/context/base/strc-lab.mkiv index 189c58272..ac49941aa 100644 --- a/tex/context/base/strc-lab.mkiv +++ b/tex/context/base/strc-lab.mkiv @@ -101,7 +101,7 @@ \ifx\p_counter\empty % \let\p_counter\currentlabel \fi - \doifcounterelse\p_counter\donothing{\strc_labels_define_counter\p_counter}% + \doifelsecounter\p_counter\donothing{\strc_labels_define_counter\p_counter}% \letlabelparameter\s!counter\p_counter \to \everydefinelabel diff --git a/tex/context/base/strc-lev.mkvi b/tex/context/base/strc-lev.mkvi index 1384f5f2f..dae3f28e3 100644 --- a/tex/context/base/strc-lev.mkvi +++ b/tex/context/base/strc-lev.mkvi @@ -34,7 +34,7 @@ \unexpanded\def\nostophead {\dosingleargument\strc_levels_stop_nop } % used at the lua end \unexpanded\def\strc_levels_start[#category]% - {\doifassignmentelse{#category} + {\doifelseassignment{#category} {\clf_startsectionlevel{\v!default}[#category]} {\clf_startsectionlevel{#category}}} diff --git a/tex/context/base/strc-lnt.mkvi b/tex/context/base/strc-lnt.mkvi index f84521002..ee7d5dd88 100644 --- a/tex/context/base/strc-lnt.mkvi +++ b/tex/context/base/strc-lnt.mkvi @@ -92,10 +92,10 @@ \def\page_lines_in_to {\in[lr:e:\currentlinenotereference]} \unexpanded\def\strc_linenotes_range_normal#1% order - {\doifreferencefoundelse{lr:b:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_from + {\doifelsereferencefound{lr:b:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_from \ifconditional\c_page_lines_current_from \xdef\m_page_lines_current_from{\currentreferencelinenumber}% - \doifreferencefoundelse{lr:e:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_to + \doifelsereferencefound{lr:e:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_to \ifconditional\c_page_lines_current_to \xdef\m_page_lines_current_to{\currentreferencelinenumber}% \page_lines_in_from @@ -111,10 +111,10 @@ \fi} \unexpanded\def\strc_linenotes_range_sparse#1% order - {\doifreferencefoundelse{lr:b:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_from + {\doifelsereferencefound{lr:b:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_from \ifconditional\c_page_lines_current_from \xdef\m_page_lines_current_from{\currentreferencelinenumber}% - \doifreferencefoundelse{lr:e:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_to + \doifelsereferencefound{lr:e:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_to \ifconditional\c_page_lines_current_to \xdef\m_page_lines_current_to{\currentreferencelinenumber}% \ifx\m_page_lines_previous_from\m_page_lines_current_from diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua index 7c4e423c4..e63f70f9f 100644 --- a/tex/context/base/strc-lst.lua +++ b/tex/context/base/strc-lst.lua @@ -1128,10 +1128,10 @@ implement { -- we could also set variables .. names will change (when this module is done) -- maybe strc_lists_savedtitle etc -implement { name = "doiflisthastitleelse", actions = { lists.hastitledata, commands.doifelse }, arguments = { "string", "integer" } } -implement { name = "doiflisthaspageelse", actions = { lists.haspagedata, commands.doifelse }, arguments = { "string", "integer" } } -implement { name = "doiflisthasnumberelse", actions = { lists.hasnumberdata, commands.doifelse }, arguments = { "string", "integer" } } -implement { name = "doiflisthasentry", actions = { lists.iscached, commands.doifelse }, arguments = { "integer" } } +implement { name = "doifelselisthastitle", actions = { lists.hastitledata, commands.doifelse }, arguments = { "string", "integer" } } +implement { name = "doifelselisthaspage", actions = { lists.haspagedata, commands.doifelse }, arguments = { "string", "integer" } } +implement { name = "doifelselisthasnumber", actions = { lists.hasnumberdata, commands.doifelse }, arguments = { "string", "integer" } } +implement { name = "doifelselisthasentry", actions = { lists.iscached, commands.doifelse }, arguments = { "integer" } } local function savedlisttitle(name,n,tag) local data = cached[tonumber(n)] diff --git a/tex/context/base/strc-lst.mkvi b/tex/context/base/strc-lst.mkvi index 3595f74cc..b6d79e54f 100644 --- a/tex/context/base/strc-lst.mkvi +++ b/tex/context/base/strc-lst.mkvi @@ -94,6 +94,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doiflistelse\doifelselist + %D Regular list entries are bound to a specific location in order to %D get the right pagenumber etc.\ associated. When pushing something %D inbetween (in mkiv) it ends up directtly in the list. This is the @@ -375,11 +377,14 @@ \def\rawstructurelistfirst {\rawstructurelistuservariable\s!first } % s! % was \unexpanded \def\rawstructurelistsecond{\rawstructurelistuservariable\s!second} % s! % was \unexpanded -\unexpanded\def\doifstructurelisthaspageelse - {\clf_doiflisthaspageelse{\currentlist}\numexpr\currentlistindex\relax} +\unexpanded\def\doifelsestructurelisthaspage + {\clf_doifelselisthaspage{\currentlist}\numexpr\currentlistindex\relax} + +\unexpanded\def\doifelsestructurelisthasnumber + {\clf_doifelselisthasnumber{\currentlist}\numexpr\currentlistindex\relax} -\unexpanded\def\doifstructurelisthasnumberelse - {\clf_doiflisthasnumberelse{\currentlist}\numexpr\currentlistindex\relax} +\let\doifstructurelisthaspageelse \doifelsestructurelisthaspage +\let\doifstructurelisthasnumberelse\doifelsestructurelisthasnumber \unexpanded\def\structurelistgenerictitle {\dostarttagged\t!listcontent\empty @@ -431,8 +436,8 @@ reference {#reference} \relax} -\def\firststructureelementinlist#list% - {\ctxcommand{firstinset("#list")}} +\def\firststructureelementinlist#list% expandable + {\clf_firstinset{#list}} \def\structurelistsize {\clf_listsize} @@ -538,7 +543,7 @@ \def\strc_lists_assign_dimen#dimension#key#default% {\edef\m_strc_list_dimen{\listparameter#key}% - \doifinsetelse\m_strc_list_dimen{\v!fit,\v!broad}{#dimension#default}{#dimension\m_strc_list_dimen}\relax} + \doifelseinset\m_strc_list_dimen{\v!fit,\v!broad}{#dimension#default}{#dimension\m_strc_list_dimen}\relax} \definesymbol[\v!list][\v!none ][\strc_lists_symbol_none] \definesymbol[\v!list][\v!one ][\strc_lists_symbol_one] @@ -549,7 +554,7 @@ \unexpanded\def\currentlistsymbol {\edef\p_symbol{\listparameter\c!symbol}% - \doifinsymbolsetelse\v!list\p_symbol + \doifelseinsymbolset\v!list\p_symbol {\directsymbol\v!list\p_symbol} {\directsymbol\v!list\s!default}} @@ -718,7 +723,7 @@ \let\p_method\v!command \fi \normalexpanded{\definelistalternative[#tag][\p_method]}[\c!command=\strc_lists_placement_command]% - \doifnextbgroupelse + \doifelsenextbgroup {\strc_lists_define_placement_yes{#tag}} {\strc_lists_define_placement_nop{#tag}}} @@ -782,7 +787,7 @@ \settrue\c_lists_has_page \settrue\c_lists_show_page \else - \doifstructurelisthaspageelse\settrue\setfalse\c_lists_has_page + \doifelsestructurelisthaspage\settrue\setfalse\c_lists_has_page \ifx\p_pagenumber\v!yes \settrue\c_lists_show_page \else @@ -795,7 +800,7 @@ \settrue\c_lists_has_number \settrue\c_lists_show_number \else - \doifstructurelisthasnumberelse\settrue\setfalse\c_lists_has_number + \doifelsestructurelisthasnumber\settrue\setfalse\c_lists_has_number \ifx\p_headnumber\v!yes \settrue\c_lists_show_number \else diff --git a/tex/context/base/strc-mar.mkiv b/tex/context/base/strc-mar.mkiv index 6ffd3ad31..8bd8c094e 100644 --- a/tex/context/base/strc-mar.mkiv +++ b/tex/context/base/strc-mar.mkiv @@ -77,15 +77,11 @@ \def\strc_markings_synchronize[#1][#2][#3]% #1=class #2=boxnumber (some day also name) #3=options, maybe second argument table {\ifvoid#2\else\clf_synchronizemarking{#1}#2{#3}\fi} -% \def\doifelsemarking#1% why no \unexpanded -% {\clf_doifelsemarking{#1}} - -% \def\doifelsemarking#1% -% {\normalexpanded{\noexpand\clf_doifelsemarking{\noexpand\detokenize{#1}}}} - \def\doifelsemarking#1% no \noexpanded {\clf_doifelsemarking{#1}} +\let\doifmarkingelse \doifelsemarking + % \appendtoks % \strc_markings_synchronize[\v!page][\normalpagebox][\v!keep]% keep if no marks % \to \everybeforepagebody diff --git a/tex/context/base/strc-mat.mkiv b/tex/context/base/strc-mat.mkiv index 742cf00aa..22fa54889 100644 --- a/tex/context/base/strc-mat.mkiv +++ b/tex/context/base/strc-mat.mkiv @@ -360,7 +360,7 @@ \def\strc_formulas_handle_sub_numbering_indeed {\let\strc_formulas_handle_sub_numbering\relax % else error: see math/numbering-001.tex - \doiftextelse\currentsubformulasuffix + \doifelsetext\currentsubformulasuffix {\strc_counters_setown_sub\v!formula\plustwo\currentsubformulasuffix} {\strc_counters_increment_sub\v!formula\plustwo}% \placecurrentformulanumber} @@ -835,14 +835,14 @@ \def\strc_formulas_place[#1]% {\def\currentplaceformulareference{#1}% \let\currentplaceformulasuffix\empty - \doifnextbgroupelse\strc_formulas_place_yes\strc_formulas_place_nop\strc_formulas_place_nop} % [ref]{} + \doifelsenextbgroup\strc_formulas_place_yes\strc_formulas_place_nop\strc_formulas_place_nop} % [ref]{} \def\strc_formulas_place_yes#1% {\def\currentplaceformulasuffix{#1}% \strc_formulas_place_nop} \def\strc_formulas_place_nop - {\doifnextcharelse$\strc_formulas_place_pickup\strc_formulas_place_indeed} % [ref]$$ [ref]\start + {\doifelsenextchar$\strc_formulas_place_pickup\strc_formulas_place_indeed} % [ref]$$ [ref]\start \def\strc_formulas_place_indeed {\strc_formulas_place_numbering} diff --git a/tex/context/base/strc-not.mkvi b/tex/context/base/strc-not.mkvi index bfa029e2b..1113cfa76 100644 --- a/tex/context/base/strc-not.mkvi +++ b/tex/context/base/strc-not.mkvi @@ -170,7 +170,7 @@ \ifx\p_counter\empty % \let\p_counter\currentnotation \fi - \doifcounterelse\p_counter\donothing{\strc_notes_define_counter\p_counter}% + \doifelsecounter\p_counter\donothing{\strc_notes_define_counter\p_counter}% \letnotationparameter\s!counter\p_counter %\strc_notes_setup_counter\currentnotation \to \everydefinenotation @@ -232,7 +232,7 @@ \ifnotesenabled \strc_counters_increment_sub\currentconstructionnumber\currentconstructionlevel \fi - \doifnextoptionalcselse\strc_notations_command_yes\strc_notations_command_nop} + \doifelsenextoptionalcs\strc_notations_command_yes\strc_notations_command_nop} \unexpanded\def\strc_notations_command_nop#title% {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title={#title},\c!bookmark=,\c!list=][]% @@ -241,7 +241,7 @@ \normalexpanded{\endgroup\noteparameter\c!next}} \unexpanded\def\strc_notations_command_yes[#optional]% - {\doifassignmentelse{#optional}\strc_notations_command_assignment\strc_notations_command_argument[#optional]} + {\doifelseassignment{#optional}\strc_notations_command_assignment\strc_notations_command_argument[#optional]} \unexpanded\def\strc_notations_command_assignment[#settings]% {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=,#settings][]% @@ -279,7 +279,7 @@ \normalexpanded % not that efficient but also not that frequently used (\normaldef for parser) {\def\noexpand\strc_pickup_yes[#one]#two\csname\e!stop#stoptag\endcsname{\strc_notations_command_yes[#one]{#two}}% \def\noexpand\strc_pickup_nop #one\csname\e!stop#stoptag\endcsname{\strc_notations_command_nop {#one}}}% - \doifnextoptionalcselse\strc_pickup_yes\strc_pickup_nop} + \doifelsenextoptionalcs\strc_pickup_yes\strc_pickup_nop} \unexpanded\def\strc_notations_start_yes[#reference]#title% {\strc_constructions_register[\c!label={\descriptionparameter\c!text},\c!reference={#reference},\c!title={#title},\c!bookmark=,\c!list=][]% @@ -383,7 +383,7 @@ \appendtoks \ifx\currentnoteparent\empty - \doifinsertionelse\currentnote + \doifelseinsertion\currentnote \donothing {\defineinsertion[\currentnote]% could be an option \normalexpanded{\t_strc_notes{\the\t_strc_notes\noexpand\strc_notes_process_list{\currentnote}}}}% @@ -639,7 +639,7 @@ \unexpanded\def\strc_notes_inject_symbol_indeed#synchronize% {\removeunwantedspaces - \doifitalicelse\/\donothing % Charles IV \footnote{the fourth} + \doifelseitalic\/\donothing % Charles IV \footnote{the fourth} \ifdim\lastkern=\notesignal % \kern\noteparameter\c!distance % yes or no note font? or main text \strc_notes_inject_separator @@ -666,7 +666,7 @@ \unexpanded\def\strc_notes_inject_dummy % temp hack {\removeunwantedspaces - \doifitalicelse\/\donothing % Charles IV \footnote{the fourth} + \doifelseitalic\/\donothing % Charles IV \footnote{the fourth} \ifdim\lastkern=\notesignal % \kern\noteparameter\c!distance % yes or no note font? or main text \strc_notes_inject_separator @@ -1602,7 +1602,7 @@ \setupcurrentnote[\c!location=]% \inheritednoteframed {\edef\currentnotewidth{\noteparameter\c!width}% - \doifdimensionelse\currentnotewidth\donothing + \doifelsedimension\currentnotewidth\donothing {\edef\currentnotewidth{\the\hsize}}% \startsimplecolumns[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\currentnotewidth]% \flushlocalnotes\currentnote @@ -1769,7 +1769,9 @@ %D } %D \stoptyping -\def\doifnoteonsamepageelse[#tag]{\clf_doifnoteonsamepageasprevious{#tag}} +\def\doifelsenoteonsamepage[#tag]{\clf_doifnoteonsamepageasprevious{#tag}} + +\let\doifnoteonsamepageelse\doifelsenoteonsamepage %D New trickery: diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv index 42634fb9a..9e69ed248 100644 --- a/tex/context/base/strc-num.mkiv +++ b/tex/context/base/strc-num.mkiv @@ -98,10 +98,12 @@ {\counterparameter\c!state}% \fi} -\unexpanded\def\doifcounterelse #1{\clf_doifelsecounter{\namedcounterparameter{#1}\s!name}} +\unexpanded\def\doifelsecounter #1{\clf_doifelsecounter{\namedcounterparameter{#1}\s!name}} \unexpanded\def\doifcounter #1{\clf_doifcounter {\namedcounterparameter{#1}\s!name}} \unexpanded\def\doifnotcounter #1{\clf_doifnotcounter {\namedcounterparameter{#1}\s!name}} +\let\doifcounterelse\doifelsecounter + \unexpanded\def\setcounter {\dotripleempty \strc_counters_set_interfaced} \unexpanded\def\setcounterown {\dotripleempty \strc_counters_setown_interfaced} \unexpanded\def\restartcounter {\dotripleempty \strc_counters_restart_interfaced} @@ -433,7 +435,9 @@ \unexpanded\def\doifdefinedcounter {\doifcommandhandler \??counter} \unexpanded\def\doifundefinedcounter {\doifnotcommandhandler \??counter} -\unexpanded\def\doifdefinedcounterelse{\doifelsecommandhandler\??counter} +\unexpanded\def\doifelsedefinedcounter{\doifelsecommandhandler\??counter} + +\let\doifdefinedcounterelse\doifelsedefinedcounter %D What follows is a compatibility layer. @@ -454,7 +458,8 @@ \let \doifdefinednumber \doifdefinedcounter % {number}{true} \let \doifundefinednumber \doifnotdefinedcounter % {number}{true} -\let \doifdefinednumberelse \doifdefinedcounterelse % {number}{true}{false} +\let \doifelsedefinednumber \doifelsedefinedcounter % {number}{true}{false} +\let \doifdefinednumberelse \doifelsedefinedcounter % {number}{true}{false} \let \setupnumbering \setupcounter diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index f684a6170..91417fe69 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -539,7 +539,7 @@ local function geturl(name) end implement { - name = "doifurldefinedelse", + name = "doifelseurldefined", actions = { urls.found, commands.doifelse }, arguments = "string" } @@ -590,7 +590,7 @@ local function getfile(name) end implement { - name = "doiffiledefinedelse", + name = "doifelsefiledefined", actions = { files.found, commands.doifelse }, arguments = "string" } diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi index 2deb32f65..fe4e5c765 100644 --- a/tex/context/base/strc-ref.mkvi +++ b/tex/context/base/strc-ref.mkvi @@ -672,12 +672,14 @@ \def\expandreferenceoperation#tag#content{\clf_setreferenceoperation#tag{#content}} \def\expandreferencearguments#tag#content{\clf_setreferencearguments#tag{#content}} -\def\doifreferencefoundelse#label#yes#nop% +\def\doifelsereferencefound#label#yes#nop% {\clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}% {\expandtexincurrentreference #yes}% {#nop}} +\let\doifreferencefoundelse \doifelsereferencefound + %D The tester only splits the reference in components but does %D not look into them. The following macro does a preroll and %D determines for instance the current real reference pagenumber. @@ -985,7 +987,7 @@ \def\strc_references_get_reference[#key][#label]% #key = number page title text default realpage ... {\ifsecondargument - \doifreferencefoundelse{#label}{\clf_filterreference{#key}}\dummyreference + \doifelsereferencefound{#label}{\clf_filterreference{#key}}\dummyreference \else \dummyreference \fi} @@ -1001,7 +1003,7 @@ \let\\\space \postponenotes % might go \referencingparameter\c!left - \doifreferencefoundelse{#label} + \doifelsereferencefound{#label} {\goto{\limitatetext\currentreferencetitle{\referencingparameter\c!width}\unknown}[#label]}% not so efficient (dup lookup) {}% todo \flushnotes % might go @@ -1093,7 +1095,7 @@ \endgroup} \unexpanded\def\doifcheckedpagestate#label% #preceding#backward#current#foreward#following#otherwise% - {\doifreferencefoundelse{#label}\strc_references_handle_page_state_yes\strc_references_handle_page_state_nop} + {\doifelsereferencefound{#label}\strc_references_handle_page_state_yes\strc_references_handle_page_state_nop} \let\strc_references_handle_page_state_nop\sixthofsixarguments @@ -1187,11 +1189,11 @@ \setvalue{\??referencinginteraction\v!all}% {\the\leftreferencetoks - \doifsometokselse\leftreferencetoks \leftofreferencecontent \donothing + \doifelsesometoks\leftreferencetoks \leftofreferencecontent \donothing \leftofreference \currentreferencecontent \rightofreference - \doifsometokselse\rightreferencetoks\rightofreferencecontent\donothing + \doifelsesometoks\rightreferencetoks\rightofreferencecontent\donothing \the\rightreferencetoks} \setvalue{\??referencinginteraction\v!label}% @@ -1251,7 +1253,7 @@ \let\rightofreferencecontent\empty \fi % inefficient: double resolve - \doifreferencefoundelse{#label} % we need to resolve the text + \doifelsereferencefound{#label} % we need to resolve the text {\goto{\referencesequence}[#label]} {\let\currentreferencecontent\dummyreference \goto{\referencesequence}[#label]}% @@ -1511,7 +1513,7 @@ \iflocation \clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}% {\expandtexincurrentreference - \clf_injectcurrentreference_dimensions + \clf_injectcurrentreferencehtdp \ht\strutbox \dp\strutbox \relax @@ -1548,7 +1550,7 @@ \unexpanded\def\startgoto_yes {\expandtexincurrentreference - \clf_injectcurrentreference_dimensions + \clf_injectcurrentreferencehtdp \ht\strutbox \dp\strutbox \relax @@ -1571,7 +1573,7 @@ \iflocation \clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}% {\expandtexincurrentreference - \clf_injectcurrentreference_dimensions + \clf_injectcurrentreferencehtdp \dimexpr\interactionparameter\c!height\relax \dimexpr\interactionparameter\c!depth \relax \relax @@ -1745,8 +1747,11 @@ \def\strc_references_use_file[#label][#file][#description]% {\clf_usefile{#label}{\detokenize{#file}}{\detokenize{#description}}} -\def\doifurldefinedelse #label{\clf_doifurldefinedelse {#label}} -\def\doiffiledefinedelse#label{\clf_doiffiledefinedelse{#label}} +\def\doifelseurldefined #label{\clf_doifelseurldefined {#label}} +\def\doifelsefiledefined#label{\clf_doifelsefiledefined{#label}} + +\let\doifurldefinedelse \doifelseurldefined +\let\doiffiledefinedelse\doifelsefiledefined %D \macros %D {url,setupurl} diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv index fc269a651..34903dfa0 100644 --- a/tex/context/base/strc-ren.mkiv +++ b/tex/context/base/strc-ren.mkiv @@ -135,7 +135,7 @@ \unexpanded\def\strc_rendering_place_head_number_and_text {\strc_rendering_start_placement \setheadmarking - \doiftextelse\getheadnumber + \doifelsetext\getheadnumber \dosettructureheadnumbercontent \doresettructureheadnumbercontent \ifconditional\c_strc_sectioning_empty @@ -422,7 +422,7 @@ {\dodoubleargument\strc_rendering_define_placement} \def\strc_rendering_define_placement[#1][#2]% - {\doifnextbgroupelse + {\doifelsenextbgroup {\strc_rendering_define_placement_yes[#1][#2]}% {\strc_rendering_define_placement_nop[#1][#2]}} @@ -635,7 +635,7 @@ \hbox { \hfill \headnumbercontent - \doifrightpageelse{ + \doifelserightpage{ \scratchdistance\leftmargindistance } { \scratchdistance\rightmargindistance diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index b9560162f..ae5a271c9 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -616,7 +616,7 @@ \unexpanded\def\strc_sectioning_handle_nop_indeed[#1][#2]% for taco: [key=value] variant {\setfalse\currentstructureown \triggerautostructurelevel - \doifassignmentelse{#2}\strc_sectioning_handle_nop_indeed_yes\strc_sectioning_handle_nop_indeed_nop{#1}{#2}} + \doifelseassignment{#2}\strc_sectioning_handle_nop_indeed_yes\strc_sectioning_handle_nop_indeed_nop{#1}{#2}} \unexpanded\def\strc_sectioning_handle_nop_indeed_yes#1#2% {\strc_sectioning_handle{#1}{#2}{}} diff --git a/tex/context/base/strc-tag.lua b/tex/context/base/strc-tag.lua index aa7311947..8c77965ae 100644 --- a/tex/context/base/strc-tag.lua +++ b/tex/context/base/strc-tag.lua @@ -485,7 +485,7 @@ implement { } implement { - name = "doifinelementelse", + name = "doifelseinelement", actions = { structures.atlocation, commands.testcase }, arguments = "string", } diff --git a/tex/context/base/strc-tag.mkiv b/tex/context/base/strc-tag.mkiv index 804eadc61..a401492b9 100644 --- a/tex/context/base/strc-tag.mkiv +++ b/tex/context/base/strc-tag.mkiv @@ -383,7 +383,7 @@ \paragraph_start_indeed} \def\paragraph_start_one[#1][#2]% - {\doifassignmentelse{#1} + {\doifelseassignment{#1} {\let\currentparagraph\empty \setupcurrentparagraph[#1]} {\edef\currentparagraph{#1}}% @@ -432,12 +432,14 @@ \strc_tags_disable \to \everybeforepagebody -% \doifinelementelse{structure:section} {yes} {no} -% \doifinelementelse{structure:chapter} {yes} {no} -% \doifinelementelse{division:*-structure:chapter} {yes} {no} +% \doifelseinelement{structure:section} {yes} {no} +% \doifelseinelement{structure:chapter} {yes} {no} +% \doifelseinelement{division:*-structure:chapter} {yes} {no} -\unexpanded\def\doifinelementelse#1% - {\clf_doifinelementelse{#1}} +\unexpanded\def\doifelseinelement#1% + {\clf_doifelseinelement{#1}} + +\let\doifinelementelse\doifelseinelement \unexpanded\def\taggedlabeltexts#1#2#3% experimental: label, numberdetail, numbercontent {\begingroup diff --git a/tex/context/base/supp-box.lua b/tex/context/base/supp-box.lua index 13fca4548..7cc71a891 100644 --- a/tex/context/base/supp-box.lua +++ b/tex/context/base/supp-box.lua @@ -8,13 +8,16 @@ if not modules then modules = { } end modules ['supp-box'] = { -- this is preliminary code, use insert_before etc +local lpegmatch = lpeg.match + local report_hyphenation = logs.reporter("languages","hyphenation") local tex = tex local context = context -local commands = commands local nodes = nodes +local implement = interfaces.implement + local splitstring = string.split local nodecodes = nodes.nodecodes @@ -120,12 +123,16 @@ local function hyphenatedlist(head,usecolor) end end -function commands.hyphenatedlist(n,color) - local b = texgetbox(n) - if b then - hyphenatedlist(b.list,color) +implement { + name = "hyphenatedlist", + arguments = { "integer", "boolean" }, + actions = function(n,color) + local b = texgetbox(n) + if b then + hyphenatedlist(b.list,color) + end end -end +} -- local function hyphenatedhack(head,pre) -- pre = tonut(pre) @@ -140,10 +147,6 @@ end -- -- commands.hyphenatedhack = hyphenatedhack -function commands.showhyphenatedinlist(list) - report_hyphenation("show: %s",listtoutf(tonut(list),false,true)) -end - local function checkedlist(list) if type(list) == "number" then return getlist(getbox(tonut(list))) @@ -152,6 +155,14 @@ local function checkedlist(list) end end +implement { + name = "showhyphenatedinlist", + arguments = "integer", + actions = function(box) + report_hyphenation("show: %s",listtoutf(checkedlist(n),false,true)) + end +} + local function applytochars(current,doaction,noaction,nested) while current do local id = getid(current) @@ -192,17 +203,43 @@ local function applytowords(current,doaction,noaction,nested) end end -commands.applytochars = function(list,what,nested) applytochars(checkedlist(list),context[what or "ruledhbox"],context,nested) end -commands.applytowords = function(list,what,nested) applytowords(checkedlist(list),context[what or "ruledhbox"],context,nested) end +local methods = { + char = applytochars, + characters = applytochars, + word = applytowords, + words = applytowords, +} + +implement { + name = "applytobox", + arguments = { + { + { "box", "integer" }, + { "command" }, + { "method" }, + { "nested", "boolean" }, + } + }, + actions = function(specification) + local list = checkedlist(specification.box) + local action = methods[specification.method or "char"] + if list and action then + action(list,context[specification.command or "ruledhbox"],context,specification.nested) + end + end +} local split_char = lpeg.Ct(lpeg.C(1)^0) local split_word = lpeg.tsplitat(lpeg.patterns.space) local split_line = lpeg.tsplitat(lpeg.patterns.eol) -function commands.processsplit(str,command,how,spaced) - how = how or "word" - if how == "char" then - local words = lpeg.match(split_char,str) +local function processsplit(specification) + local str = specification.data or "" + local command = specification.command or "ruledhbox" + local method = specification.method or "word" + local spaced = specification.spaced + if method == "char" or method == "character" then + local words = lpegmatch(split_char,str) for i=1,#words do local word = words[i] if word == " " then @@ -215,8 +252,8 @@ function commands.processsplit(str,command,how,spaced) context(word) end end - elseif how == "word" then - local words = lpeg.match(split_word,str) + elseif method == "word" then + local words = lpegmatch(split_word,str) for i=1,#words do local word = words[i] if spaced and i > 1 then @@ -228,8 +265,8 @@ function commands.processsplit(str,command,how,spaced) context(word) end end - elseif how == "line" then - local words = lpeg.match(split_line,str) + elseif method == "line" then + local words = lpegmatch(split_line,str) for i=1,#words do local word = words[i] if spaced and i > 1 then @@ -246,63 +283,88 @@ function commands.processsplit(str,command,how,spaced) end end +implement { + name = "processsplit", + actions = processsplit, + arguments = { + { + { "data" }, + { "command" }, + { "method" }, + { "spaced", "boolean" }, + } + } +} + local a_vboxtohboxseparator = attributes.private("vboxtohboxseparator") -function commands.vboxlisttohbox(original,target,inbetween) - local current = getlist(getbox(original)) - local head = nil - local tail = nil - while current do - local id = getid(current) - local next = getnext(current) - if id == hlist_code then - local list = getlist(current) - if head then - if inbetween > 0 then - local n = new_glue(0,0,inbetween) - setfield(tail,"next",n) - setfield(n,"prev",tail) - tail = n - end - setfield(tail,"next",list) - setfield(list,"prev",tail) - else - head = list - end - tail = find_tail(list) - -- remove last separator - if getid(tail) == hlist_code and getattribute(tail,a_vboxtohboxseparator) == 1 then - local temp = tail - local prev = getprev(tail) - if next then - local list = getlist(tail) - setfield(prev,"next",list) - setfield(list,"prev",prev) - setfield(tail,"list",nil) - tail = find_tail(list) +implement { + name = "vboxlisttohbox", + arguments = { "integer", "integer", "dimen" }, + actions = function(original,target,inbetween) + local current = getlist(getbox(original)) + local head = nil + local tail = nil + while current do + local id = getid(current) + local next = getnext(current) + if id == hlist_code then + local list = getlist(current) + if head then + if inbetween > 0 then + local n = new_glue(0,0,inbetween) + setfield(tail,"next",n) + setfield(n,"prev",tail) + tail = n + end + setfield(tail,"next",list) + setfield(list,"prev",tail) else - tail = prev + head = list end - free_node(temp) + tail = find_tail(list) + -- remove last separator + if getid(tail) == hlist_code and getattribute(tail,a_vboxtohboxseparator) == 1 then + local temp = tail + local prev = getprev(tail) + if next then + local list = getlist(tail) + setfield(prev,"next",list) + setfield(list,"prev",prev) + setfield(tail,"list",nil) + tail = find_tail(list) + else + tail = prev + end + free_node(temp) + end + -- done + setfield(tail,"next",nil) + setfield(current,"list",nil) end - -- done - setfield(tail,"next",nil) - setfield(current,"list",nil) + current = next end - current = next + local result = new_hlist() + setfield(result,"list",head) + setbox(target,result) end - local result = new_hlist() - setfield(result,"list",head) - setbox(target,result) -end +} -function commands.hboxtovbox(original) - local b = getbox(original) - local factor = texget("baselineskip").width / texget("hsize") - setfield(b,"depth",0) - setfield(b,"height",getfield(b,"width") * factor) -end +implement { + name = "hboxtovbox", + arguments = "integer", + actions = function(n) + local b = getbox(n) + local factor = texget("baselineskip").width / texget("hsize") + setfield(b,"depth",0) + setfield(b,"height",getfield(b,"width") * factor) + end +} -function commands.boxtostring(n) - context.puretext(nodes.toutf(texgetbox(n).list)) -- helper is defined later -end +implement { + name = "boxtostring", + arguments = "integer", + actions = function(n) + context.puretext(nodes.toutf(texgetbox(n).list)) -- helper is defined later + end +} diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv index 5cfedac7c..54b0e2860 100644 --- a/tex/context/base/supp-box.mkiv +++ b/tex/context/base/supp-box.mkiv @@ -570,7 +570,7 @@ %D \doiftext {data} {then branch} %D \stoptyping -\unexpanded\def\doiftextelse#1% +\unexpanded\def\doifelsetext#1% {\begingroup \setbox\scratchbox\hbox {\settrialtypesetting @@ -581,6 +581,8 @@ \endgroup\expandafter\firstoftwoarguments \fi} +\let\doiftextelse\doifelsetext + \unexpanded\def\doiftext#1% {\begingroup \setbox\scratchbox\hbox @@ -1064,9 +1066,10 @@ %D \stoptyping \unexpanded\def\doshowhyphenatednextbox - {\ctxcommand{showhyphenatedinlist(tex.box[\number\nextbox].list)}} + {\clf_showhyphenatedinlist\nextbox} -\unexpanded\def\showhyphens{\dowithnextboxcs\doshowhyphenatednextbox\hbox} +\unexpanded\def\showhyphens + {\dowithnextboxcs\doshowhyphenatednextbox\hbox} %D The following macros are seldom used but handy for tracing. %D @@ -1077,7 +1080,7 @@ %D \stoptyping \unexpanded\def\dohyphenatednextbox - {\ctxcommand{hyphenatedlist(\number\nextbox)}% + {\clf_hyphenatedlist\nextbox false\relax \unhbox\nextbox} \unexpanded\def\hyphenatedword {\dowithnextboxcs\dohyphenatednextbox\hbox} @@ -1085,25 +1088,11 @@ \unexpanded\def\hyphenatedfile#1{\dowithnextboxcs\dohyphenatednextbox\hbox{\readfile{#1}\donothing\donothing}} \unexpanded\def\dohyphenatednextboxcolor - {\ctxcommand{hyphenatedlist(\number\nextbox,true)}% + {\clf_hyphenatedlist\nextbox true\relax \unhbox\nextbox} \unexpanded\def\hyphenatedcoloredword{\dowithnextboxcs\dohyphenatednextboxcolor\hbox} -% D \starttyping -% D \hyphenatedhack{\kern-.25em_}{alongword} -% D \stoptyping -% -% \unexpanded\def\dohyphenatedhackbox -% {\ctxcommand{hyphenatedhack(tex.box[\number\nextbox].list,tex.box[\number\scratchbox].list)}% -% \unhbox\nextbox -% \endgroup} -% -% \unexpanded\def\hyphenatedhack#1% the result of a test, not that useful -% {\begingroup -% \setbox\scratchbox\hbox{#1}% only chars and kerns ! -% \dowithnextboxcs\dohyphenatedhackbox\hbox} - %D \macros %D {processtokens} %D @@ -1383,7 +1372,12 @@ \begingroup \setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}% \setbox\scratchbox\hbox{\restorecurrentattributes{pic}#1}% - \ctxcommand{applytochars(\number\scratchbox,"\strippedcsname#2",true)}% + \clf_applytobox + method {char}% + box \scratchbox + command {\checkedstrippedcsname#2}% + nested true% + \relax \endgroup} \unexpanded\def\processisolatedwords#1#2% @@ -1391,34 +1385,88 @@ \begingroup \setbox\scratchbox\hbox{\settrialtypesetting#2{\savecurrentattributes{pic}}}% \setbox\scratchbox\hbox{\restorecurrentattributes{pic}#1}% - \ctxcommand{applytowords(\number\scratchbox,"\strippedcsname#2",true)}% + \clf_applytobox + method {word}% + box \scratchbox + command {\checkedstrippedcsname#2}% + nested true% + \relax \endgroup} -\unexpanded\def\processwords#1% - {\processisolatedwords{#1}\processword} - -\let\processword\relax - -\unexpanded\def\applytosplitstringchar#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","char")}} -\unexpanded\def\applytosplitstringword#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","word")}} -\unexpanded\def\applytosplitstringline#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","line")}} - -\unexpanded\def\applytosplitstringcharspaced#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","char",true)}} -\unexpanded\def\applytosplitstringwordspaced#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","word",true)}} -\unexpanded\def\applytosplitstringlinespaced#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","line",true)}} - %D A variant: \unexpanded\def\applytocharacters#1% {\dontleavehmode - \dowithnextbox{\ctxcommand{applytochars(\number\nextbox,"\strippedcsname#1",true)}}% + \dowithnextbox{\clf_applytobox + method {char}% + box \nextbox + command {\checkedstrippedcsname#1}% + nested true% + \relax}% \hbox} \unexpanded\def\applytowords#1% {\dontleavehmode - \dowithnextbox{\ctxcommand{applytowords(\number\nextbox,"\strippedcsname#1",true)}}% + \dowithnextbox{\clf_applytobox + method {word}% + box \nextbox + command {\checkedstrippedcsname#1}% + nested true% + \relax}% \hbox} +%D The old call: + +\unexpanded\def\processwords#1% + {\processisolatedwords{#1}\processword} + +\let\processword\relax + +\unexpanded\def\applytosplitstringchar#1#2% + {\dontleavehmode\clf_processsplit + data {#2}% + command {\checkedstrippedcsname#1}% + method {char}% + \relax} + +\unexpanded\def\applytosplitstringword#1#2% + {\dontleavehmode\clf_processsplit + data {#2}% + command {\checkedstrippedcsname#1}% + method {word}% + \relax} + +\unexpanded\def\applytosplitstringline#1#2% + {\dontleavehmode\clf_processsplit + data {#2}% + command {\checkedstrippedcsname#1}% + method {line}% + \relax} + +\unexpanded\def\applytosplitstringcharspaced#1#2% + {\dontleavehmode\clf_processsplit + data {#2}% + command {\checkedstrippedcsname#1}% + method {char}% + spaced true% + \relax} + +\unexpanded\def\applytosplitstringwordspaced#1#2% + {\dontleavehmode\clf_processsplit + data {#2}% + command {\checkedstrippedcsname#1}% + method {word}% + spaced true% + \relax} + +\unexpanded\def\applytosplitstringlinespaced#1#2% + {\dontleavehmode\clf_processsplit + data {#2}% + command {\checkedstrippedcsname#1}% + method {line}% + spaced true% + \relax} + %D \macros %D {sbox} %D @@ -1815,7 +1863,7 @@ \box\d_syst_boxes_separator \fi \egroup - \ctxcommand{hboxtovbox(\number\scratchbox)}% + \clf_hboxtovbox\scratchbox \box\scratchbox \endgroup} @@ -1869,7 +1917,7 @@ \unexpanded\def\stophboxestohbox {\egroup - \ctxcommand{vboxlisttohbox(\number\scratchbox,\number\nextbox,\number\dimexpr\hboxestohboxslack)}% + \clf_vboxlisttohbox\scratchbox\nextbox\dimexpr\hboxestohboxslack\relax \dontleavehmode \unhbox\nextbox \removeunwantedspaces @@ -2044,7 +2092,7 @@ {\bgroup \def\syst_boxes_process_indeed{#1}% #1 can be redefined halfway \setbox\processbox\emptybox - \doifnextbgroupelse\syst_boxes_process_yes\syst_boxes_process_nop} + \doifelsenextbgroup\syst_boxes_process_yes\syst_boxes_process_nop} \def\syst_boxes_process_yes {\dowithnextboxcs\syst_boxes_process_content\hbox} @@ -2052,7 +2100,7 @@ \def\syst_boxes_process_content {\removeunwantedspaces \syst_boxes_process_indeed % takes \nextbox makes \processbox - \doifnextbgroupelse\syst_boxes_process_yes\syst_boxes_process_nop} + \doifelsenextbgroup\syst_boxes_process_yes\syst_boxes_process_nop} \unexpanded\def\syst_boxes_process_nop {\removeunwantedspaces @@ -2509,13 +2557,15 @@ \copy\csname\??stackbox#1:#2\endcsname \fi}} -\unexpanded\def\doifboxelse#1#2#3#4% +\unexpanded\def\doifelsebox#1#2#3#4% {\ifcsname\??stackbox#1:#2\endcsname \ifvoid\csname\??stackbox#1:#2\endcsname#4\else#3\fi \else #4% \fi} +\let\doifboxelse\doifelsebox + %D This one is cheaper (the above is no longer used that much): \installcorenamespace {boxstack} @@ -2545,9 +2595,6 @@ \unexpanded\def\globalpushbox{\syst_boxes_push\global} \unexpanded\def\globalpopbox {\syst_boxes_pop \global} -% \unexpanded\def\pushbox#1{\ctxcommand{pushbox(\number#1)}} -% \unexpanded\def\popbox #1{\ctxcommand{popbox(\number#1)}} - %D \macros %D {removedepth, obeydepth} %D @@ -2796,12 +2843,12 @@ % {\dowithnextbox{\edef#1{\syst_boxes_nodestostring}}\hbox} % % \def\syst_boxes_nodestostring -% {\ctxcommand{boxtostring(\number\nextbox)}} +% {\clf_boxtostring\nextbox} \unexpanded\def\nodestostring#1#2% more tolerant for #2=\cs {\begingroup \setbox\nextbox\hbox{#2}% - \normalexpanded{\endgroup\edef\noexpand#1{\ctxcommand{boxtostring(\number\nextbox)}}}} + \normalexpanded{\endgroup\edef\noexpand#1{\clf_boxtostring\nextbox}}} %D Even more dirty: diff --git a/tex/context/base/symb-imp-cc.mkiv b/tex/context/base/symb-imp-cc.mkiv index 71e837c3f..e753d695f 100644 --- a/tex/context/base/symb-imp-cc.mkiv +++ b/tex/context/base/symb-imp-cc.mkiv @@ -14,7 +14,7 @@ %D LS/HH: This font has changed over time so there might be diffences %D in rendering. The otf, ttf and type1 version can differ too. -\doiffontpresentelse{ccicons.otf} { % redone ctan version +\doifelsefontpresent{ccicons.otf} { % redone ctan version \definefontfeature [creativecommons] [mode=base, diff --git a/tex/context/base/symb-ini.lua b/tex/context/base/symb-ini.lua index 9586338be..6a4a18825 100644 --- a/tex/context/base/symb-ini.lua +++ b/tex/context/base/symb-ini.lua @@ -6,20 +6,27 @@ if not modules then modules = { } end modules ['symb-ini'] = { license = "see context related readme files" } -local context, commands = context, commands +local context = context +local variables = interfaces.variables -local variables = interfaces.variables +fonts = fonts or { } -- brrrr -fonts = fonts or { } -- brrrr +local symbols = fonts.symbols or { } +fonts.symbols = symbols -local symbols = fonts.symbols or { } -fonts.symbols = symbols +local listitem = utilities.parsers.listitem +local uselibrary = resolvers.uselibrary local report_symbols = logs.reporter ("fonts","symbols") local status_symbols = logs.messenger("fonts","symbols") -local patterns = { "symb-imp-%s.mkiv", "symb-imp-%s.tex", "symb-%s.mkiv", "symb-%s.tex" } -local listitem = utilities.parsers.listitem +local patterns = { + "symb-imp-%s.mkiv", + "symb-imp-%s.tex", + -- obsolete: + "symb-%s.mkiv", + "symb-%s.tex" +} local function action(name,foundname) -- context.startnointerference() @@ -37,7 +44,7 @@ end function symbols.uselibrary(name) if name ~= variables.reset then for name in listitem(name) do - commands.uselibrary { + uselibrary { name = name, patterns = patterns, action = action, @@ -48,4 +55,8 @@ function symbols.uselibrary(name) end end -commands.usesymbols = symbols.uselibrary +interfaces.implement { + name = "usesymbols", + actions = symbols.uselibrary, + arguments = "string", +} diff --git a/tex/context/base/symb-ini.mkiv b/tex/context/base/symb-ini.mkiv index e957e68c1..40a0af6d6 100644 --- a/tex/context/base/symb-ini.mkiv +++ b/tex/context/base/symb-ini.mkiv @@ -74,9 +74,12 @@ \letvalue{\??symbolset}\empty -\unexpanded\def\doifinsymbolsetelse#1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} +\unexpanded\def\doifelseinsymbolset#1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} \unexpanded\def\doifinsymbolset #1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi} -\unexpanded\def\doifsymbolsetelse #1{\ifcsname\??symbolset#1\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} +\unexpanded\def\doifelsesymbolset #1{\ifcsname\??symbolset#1\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} + +\let\doifinsymbolsetelse\doifelseinsymbolset +\let\doifsymbolsetelse \doifelsesymbolset \def\symbolset#1{\csname\??symbolset\ifcsname\??symbolset#1\endcsname#1\fi\endcsname} % no [#1], to be used in commalists etc @@ -216,7 +219,7 @@ \def\symb_fetch_second#1% {\doifinsymbolset\empty\currentsymbol{\settrue\c_symb_found}} -\def\doifsymboldefinedelse#1% +\unexpanded\def\doifelsesymboldefined#1% {\begingroup \edef\currentsymbol{#1}% \let\symb_fetch\symb_fetch_first @@ -233,6 +236,8 @@ \fi \fi} +\let\doifsymboldefinedelse\doifelsesymboldefined + %D \macros %D {setupsymbolset,startsymbolset} %D @@ -300,7 +305,7 @@ %D %D \showsetup{usesymbols} -\unexpanded\def\usesymbols[#1]{\ctxcommand{usesymbols("#1")}} +\unexpanded\def\usesymbols[#1]{\clf_usesymbols{#1}} %D As longs as symbols are linked to levels or numbers, we can %D also use the conversion mechanism, but in for instance the diff --git a/tex/context/base/syst-aux.lua b/tex/context/base/syst-aux.lua index 7eec63e4f..71c56169f 100644 --- a/tex/context/base/syst-aux.lua +++ b/tex/context/base/syst-aux.lua @@ -57,7 +57,7 @@ local pattern = C(utf8character^-1) local ctx_doifelse = commands.doifelse implement { - name = "doiffirstcharelse", + name = "doifelsefirstchar", arguments = { "string", "string" }, actions = function(str) ctx_doifelse(lpegmatch(pattern,str) == chr) diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 77ee8bee8..1a05ba3df 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -287,12 +287,14 @@ %D {\localnext} because we don't want clashes with \type %D {\next}. -\unexpanded\def\doifnextcharelse#1#2#3% #1 should not be {} ! +\unexpanded\def\doifelsenextchar#1#2#3% #1 should not be {} ! {\let\charactertoken=#1% = needed here \def\m_syst_action_yes{#2}% \def\m_syst_action_nop{#3}% \futurelet\nexttoken\syst_helpers_inspect_next_character} +\let\doifnextcharelse\doifelsenextchar + \def\syst_helpers_inspect_next_character {\ifx\nexttoken\blankspace \expandafter\syst_helpers_reinspect_next_character @@ -327,18 +329,21 @@ \let\syst_helpers_next_optional_character_token=[ -\unexpanded\def\doifnextoptionalelse#1#2% +\unexpanded\def\doifelsenextoptional#1#2% {\def\m_syst_action_yes{#1}% \def\m_syst_action_nop{#2}% \let\if_next_blank_space_token\iffalse \futurelet\nexttoken\syst_helpers_inspect_next_optional_character} -\unexpanded\def\doifnextoptionalcselse#1#2% \cs \cs (upto 10% faster) +\unexpanded\def\doifelsenextoptionalcs#1#2% \cs \cs (upto 10% faster) {\let\m_syst_action_yes#1% \let\m_syst_action_nop#2% \let\if_next_blank_space_token\iffalse \futurelet\nexttoken\syst_helpers_inspect_next_optional_character} +\let\doifnextoptionalelse \doifelsenextoptional +\let\doifnextoptionalcselse\doifelsenextoptionalcs + \def\syst_helpers_inspect_next_optional_character {\ifx\nexttoken\blankspace \expandafter\syst_helpers_reinspect_next_optional_character @@ -355,18 +360,21 @@ \let\syst_helpers_next_bgroup_character_token\bgroup -\unexpanded\def\doifnextbgroupelse#1#2% +\unexpanded\def\doifelsenextbgroup#1#2% {\def\m_syst_action_yes{#1}% \def\m_syst_action_nop{#2}% \let\if_next_blank_space_token\iffalse \futurelet\nexttoken\syst_helpers_inspect_next_bgroup_character} -\unexpanded\def\doifnextbgroupcselse#1#2% +\unexpanded\def\doifelsenextbgroupcs#1#2% {\let\m_syst_action_yes#1% \let\m_syst_action_nop#2% \let\if_next_blank_space_token\iffalse \futurelet\nexttoken\syst_helpers_inspect_next_bgroup_character} +\let\doifnextbgroupelse \doifelsenextbgroup +\let\doifnextbgroupcselse\doifelsenextbgroupcs + \def\syst_helpers_inspect_next_bgroup_character {\ifx\nexttoken\blankspace \expandafter\syst_helpers_reinspect_next_bgroup_character @@ -383,12 +391,14 @@ \let\syst_helpers_next_parenthesis_character_token( -\unexpanded\def\doifnextparenthesiselse#1#2% +\unexpanded\def\doifelsenextparenthesis#1#2% {\def\m_syst_action_yes{#1}% \def\m_syst_action_nop{#2}% \let\if_next_blank_space_token\iffalse \futurelet\nexttoken\syst_helpers_inspect_next_parenthesis_character} +\let\doifnextparenthesiselse\doifelsenextparenthesis + \def\syst_helpers_inspect_next_parenthesis_character {\ifx\nexttoken\blankspace \expandafter\syst_helpers_reinspect_next_parenthesis_character @@ -405,16 +415,19 @@ %D The next one is handy in predictable situations: -\unexpanded\def\doiffastoptionalcheckelse#1#2% +\unexpanded\def\doifelsefastoptionalcheck#1#2% {\def\m_syst_action_yes{#1}% \def\m_syst_action_nop{#2}% \futurelet\nexttoken\syst_helpers_do_if_fast_optional_check_else} -\unexpanded\def\doiffastoptionalcheckcselse#1#2% \cs \cs +\unexpanded\def\doifelsefastoptionalcheckcs#1#2% \cs \cs {\let\m_syst_action_yes#1% \let\m_syst_action_nop#2% \futurelet\nexttoken\syst_helpers_do_if_fast_optional_check_else} +\let\doiffastoptionalcheckelse \doifelsefastoptionalcheck +\let\doiffastoptionalcheckcselse\doifelsefastoptionalcheckcs + \def\syst_helpers_do_if_fast_optional_check_else {\ifx\nexttoken\syst_helpers_next_optional_character_token \expandafter\m_syst_action_yes @@ -583,12 +596,12 @@ \suppressifcsnameerror\plusone -\def\doifundefinedelse#1% +\def\doifelseundefined#1% {\ifcsname#1\endcsname \expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments \fi} -\def\doifdefinedelse#1% +\def\doifelsedefined#1% {\ifcsname#1\endcsname \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments \fi} @@ -603,6 +616,9 @@ \expandafter\firstofoneargument\else\expandafter\gobbleoneargument \fi} +\let\doifundefinedelse\doifelseundefined +\let\doifdefinedelse \doifelsedefined + %D \macros %D {letbeundefined} %D @@ -626,7 +642,7 @@ %D behavior in text and math mode, which was due to this grouping subtilities. We %D therefore decided to use \type{\begingroup} instead of \type{\bgroup}. -\unexpanded\def\doifalldefinedelse#1% +\unexpanded\def\doifelsealldefined#1% {\begingroup \donetrue % we could use a reserved one and avoid the group \processcommalist[#1]\syst_helpers_do_if_all_defined_else @@ -636,6 +652,8 @@ \endgroup\expandafter\secondoftwoarguments \fi} +\let\doifalldefinedelse\doifelsealldefined + \def\syst_helpers_do_if_all_defined_else#1% {\ifcsname#1\endcsname\else \donefalse @@ -699,7 +717,7 @@ %D %D This time, the string is not expanded. -\unexpanded\def\doifemptyelse#1% +\unexpanded\def\doifelseempty#1% {\def\m_syst_string_one{#1}% \ifx\m_syst_string_one\empty \expandafter\firstoftwoarguments @@ -707,6 +725,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doifemptyelse\doifelseempty + \unexpanded\def\doifempty#1% {\def\m_syst_string_one{#1}% \ifx\m_syst_string_one\empty @@ -772,7 +792,7 @@ \def\syst_helpers_re_do_if_in_set {\expandafter\syst_helpers_do_check_if_item_in_set \m_syst_string_two,],\relax} \def\syst_helpers_re_do_if_not_in_set {\expandafter\syst_helpers_do_check_if_item_not_in_set \m_syst_string_two,],\relax} -\unexpanded\def\doifinsetelse#1% make this two step too +\unexpanded\def\doifelseinset#1% make this two step too {\edef\m_syst_string_one{#1}% \ifx\m_syst_string_one\empty \expandafter\thirdofthreearguments @@ -780,6 +800,8 @@ \expandafter\syst_helpers_do_if_in_set_else \fi} +\let\doifinsetelse\doifelseinset + \def\syst_helpers_do_if_in_set_else#1% {\edef\m_syst_string_two{#1}% \ifx\m_syst_string_two\empty @@ -970,10 +992,12 @@ \fi\fi #1#2} -\unexpanded\def\doifcommonelse{\syst_helpers_do_do_if_common_else\firstoftwoarguments\secondoftwoarguments} +\unexpanded\def\doifelsecommon{\syst_helpers_do_do_if_common_else\firstoftwoarguments\secondoftwoarguments} \unexpanded\def\doifcommon {\syst_helpers_do_do_if_common_else\firstofoneargument \gobbleoneargument } \unexpanded\def\doifnotcommon {\syst_helpers_do_do_if_common_else\gobbleoneargument \firstofoneargument } +\let\doifcommonelse\doifelsecommon + %D \macros %D {processcommalist,processcommacommand,quitcommalist, %D processcommalistwithparameters} @@ -1316,10 +1340,12 @@ \let\remainingcharacters\empty \unexpanded\def\getfirstcharacter #1{\clf_getfirstcharacter{#1}} -\unexpanded\def\doiffirstcharelse #1#2{\clf_doiffirstcharelse{#1}{#2}} % chr str +\unexpanded\def\doifelsefirstchar #1#2{\clf_doifelsefirstchar{#1}{#2}} \unexpanded\def\thefirstcharacter #1{\clf_thefirstcharacter{#1}} \unexpanded\def\theremainingcharacters#1{\clf_theremainingcharacters{#1}} +\let\doiffirstcharelse\doifelsefirstchar + %D \macros %D {doifinstringelse, doifincsnameelse} %D @@ -1332,7 +1358,7 @@ \let\m_syst_sub_string\empty -\unexpanded\def\doifinstringelse#1% +\unexpanded\def\doifelseinstring#1% {\edef\m_syst_sub_string{#1}% expand #1 here \ifx\m_syst_sub_string\empty \expandafter\thirdofthreearguments @@ -1340,6 +1366,8 @@ \expandafter\syst_helpers_do_if_in_string_else_indeed \fi} +\let\doifinstringelse\doifelseinstring + \unexpanded\def\syst_helpers_do_if_in_string_else_indeed#1% {\syst_helpers_do_if_in_string_else\m_syst_sub_string{#1}% \expandafter\firstoftwoarguments @@ -1402,13 +1430,15 @@ {\unless\if##2@}% \expandafter\syst_helpers_do_do_if_in_csname_else#2#1@@\_e_o_s_} -\unexpanded\def\doifincsnameelse#1#2% +\unexpanded\def\doifelseincsname#1#2% {\normalexpanded{\syst_helpers_do_if_in_csname_else{#1}}{#2}% \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doifincsnameelse\doifelseincsname + %D \macros %D {doifnumberelse,doifnumber,doifnotnumber} %D @@ -1424,13 +1454,15 @@ %D The macro accepts \type {123}, \type {abc}, \type {{}}, \type {\getal} and %D \type {\the\count...}. This macro is a rather dirty one. -\def\doifnumberelse#1% does not accept counters (fully expandable) +\def\doifelsenumber#1% does not accept counters (fully expandable) {\ifcase0\ifcase1#1\or\or\or\or\or\or\or\or\or\else1\fi\space \expandafter\secondoftwoarguments \else \expandafter\firstoftwoarguments \fi} +\let\doifnumberelse\doifelsenumber + \def\doifnumber#1% {\ifcase0\ifcase1#1\or\or\or\or\or\or\or\or\or\else1\fi\space \expandafter\firstofoneargument @@ -1478,7 +1510,7 @@ %D %D \starttyping %D \makerawcommalist[string,string,...]\stringlist -%D \rawdoifinsetelse{string}{string,...}{...}{...} +%D \rawdoifelseinset{string}{string,...}{...}{...} %D \rawprocesscommalist[string,string,...]\commando %D \rawprocessaction[x][a=>\a,b=>\b,c=>\c] %D \stoptyping @@ -1513,12 +1545,12 @@ \unexpanded\def\rawprocesscommacommand[#1]% not really needed {\normalexpanded{\rawprocesscommalist[#1]}} -% \def\rawdoifinsetelse#1#2{\doifinstringelse{,#1,}{,#2,}} +% \def\rawdoifelseinset#1#2{\doifinstringelse{,#1,}{,#2,}} % \def\rawdoifinset #1#2{\doifinstring {,#1,}{,#2,}} \def\m_syst_two_commas{,,} -\unexpanded\def\rawdoifinsetelse#1% +\unexpanded\def\rawdoifelseinset#1% {\edef\m_syst_sub_string{,#1,}% expand #1 here \ifx\m_syst_sub_string\m_syst_two_commas \expandafter\thirdofthreearguments @@ -1526,6 +1558,8 @@ \expandafter\syst_helpers_raw_do_if_in_set_else \fi} +\let\rawdoifinsetelse\rawdoifinsetelse + \unexpanded\def\syst_helpers_raw_do_if_in_set_else#1% {\syst_helpers_do_if_in_string_else\m_syst_sub_string{,#1,}% \expandafter\firstoftwoarguments @@ -2191,7 +2225,7 @@ \unexpanded\def\dosingleempty#1% {\syst_helpers_argument_reset - \doifnextoptionalelse + \doifelsenextoptional {\firstargumenttrue#1}% {\syst_helpers_single_empty_one_nop#1}} @@ -2203,13 +2237,13 @@ \unexpanded\def\dodoubleempty#1% {\syst_helpers_argument_reset - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_double_empty_one_yes#1}% {\syst_helpers_double_empty_one_nop#1}} \def\syst_helpers_double_empty_one_yes#1[#2]% {\firstargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\secondargumenttrue#1[{#2}]}% {\syst_helpers_double_empty_two_nop#1{#2}}} @@ -2233,19 +2267,19 @@ \unexpanded\def\dotripleempty#1% {\syst_helpers_argument_reset - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_triple_empty_one_yes#1}% {\syst_helpers_triple_empty_one_nop#1}} \def\syst_helpers_triple_empty_one_yes#1[#2]% {\firstargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_triple_empty_two_yes#1{#2}}% {\syst_helpers_triple_empty_two_nop#1{#2}}} \def\syst_helpers_triple_empty_two_yes#1#2[#3]% {\secondargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\thirdargumenttrue#1[{#2}][{#3}]}% {\syst_helpers_triple_empty_three_nop#1{#2}{#3}}} @@ -2281,25 +2315,25 @@ \unexpanded\def\doquadrupleempty#1% {\syst_helpers_argument_reset - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_quadruple_empty_one_yes#1}% {\syst_helpers_quadruple_empty_one_nop#1}} \def\syst_helpers_quadruple_empty_one_yes#1[#2]% {\firstargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_quadruple_empty_two_yes#1{#2}}% {\syst_helpers_quadruple_empty_two_nop#1{#2}}} \def\syst_helpers_quadruple_empty_two_yes#1#2[#3]% {\secondargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_quadruple_empty_three_yes#1{#2}{#3}}% {\syst_helpers_quadruple_empty_three_nop#1{#2}{#3}}} \def\syst_helpers_quadruple_empty_three_yes#1#2#3[#4]% {\thirdargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\fourthargumenttrue#1[{#2}][{#3}][{#4}]}% {\syst_helpers_quadruple_empty_four_nop#1{#2}{#3}{#4}}} @@ -2348,31 +2382,31 @@ \unexpanded\def\doquintupleempty#1% {\syst_helpers_argument_reset - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_quintuple_empty_one_yes#1}% {\syst_helpers_quintuple_empty_one_nop#1}} \def\syst_helpers_quintuple_empty_one_yes#1[#2]% {\firstargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_quintuple_empty_two_yes#1{#2}}% {\syst_helpers_quintuple_empty_two_nop#1{#2}}} \def\syst_helpers_quintuple_empty_two_yes#1#2[#3]% {\secondargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_quintuple_empty_three_yes#1{#2}{#3}}% {\syst_helpers_quintuple_empty_three_nop#1{#2}{#3}}} \def\syst_helpers_quintuple_empty_three_yes#1#2#3[#4]% {\thirdargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_quintuple_empty_four_yes#1{#2}{#3}{#4}}% {\syst_helpers_quintuple_empty_four_nop#1{#2}{#3}{#4}}} \def\syst_helpers_quintuple_empty_four_yes#1#2#3#4[#5]% {\fourthargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\fifthargumenttrue#1[{#2}][{#3}][{#4}][{#5}]}% {\syst_helpers_quintuple_empty_five_nop#1{#2}{#3}{#4}{#5}}} @@ -2435,37 +2469,37 @@ \unexpanded\def\dosixtupleempty#1% {\syst_helpers_argument_reset - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_sixtuple_empty_one_yes#1} {\syst_helpers_sixtuple_empty_one_nop#1}} \def\syst_helpers_sixtuple_empty_one_yes#1[#2]% {\firstargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_sixtuple_empty_two_yes#1{#2}}% {\syst_helpers_sixtuple_empty_two_nop#1{#2}}} \def\syst_helpers_sixtuple_empty_two_yes#1#2[#3]% {\secondargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_sixtuple_empty_three_yes#1{#2}{#3}}% {\syst_helpers_sixtuple_empty_three_nop#1{#2}{#3}}} \def\syst_helpers_sixtuple_empty_three_yes#1#2#3[#4]% {\thirdargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_sixtuple_empty_four_yes#1{#2}{#3}{#4}}% {\syst_helpers_sixtuple_empty_four_nop#1{#2}{#3}{#4}}} \def\syst_helpers_sixtuple_empty_four_yes#1#2#3#4[#5]% {\fourthargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_sixtuple_empty_five_yes#1{#2}{#3}{#4}{#5}}% {\syst_helpers_sixtuple_empty_five_nop#1{#2}{#3}{#4}{#5}}} \def\syst_helpers_sixtuple_empty_five_yes#1#2#3#4#5[#6]% {\fifthargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\sixthargumenttrue#1[{#2}][{#3}][{#4}][{#5}][{#6}]}% {\syst_helpers_sixtuple_empty_six_nop#1{#2}{#3}{#4}{#5}{#6}}} @@ -2543,43 +2577,43 @@ \unexpanded\def\doseventupleempty#1% {\syst_helpers_argument_reset - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_seventuple_empty_one_yes#1}% {\syst_helpers_seventuple_empty_one_nop#1}} \def\syst_helpers_seventuple_empty_one_yes#1[#2]% {\firstargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_seventuple_empty_two_yes#1{#2}}% {\syst_helpers_seventuple_empty_two_nop#1{#2}}} \def\syst_helpers_seventuple_empty_two_yes#1#2[#3]% {\secondargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_seventuple_empty_three_yes#1{#2}{#3}}% {\syst_helpers_seventuple_empty_three_nop#1{#2}{#3}}} \def\syst_helpers_seventuple_empty_three_yes#1#2#3[#4]% {\thirdargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_seventuple_empty_four_yes#1{#2}{#3}{#4}}% {\syst_helpers_seventuple_empty_four_nop#1{#2}{#3}{#4}}} \def\syst_helpers_seventuple_empty_four_yes#1#2#3#4[#5]% {\fourthargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_seventuple_empty_five_yes#1{#2}{#3}{#4}{#5}}% {\syst_helpers_seventuple_empty_five_nop#1{#2}{#3}{#4}{#5}}} \def\syst_helpers_seventuple_empty_five_yes#1#2#3#4#5[#6]% {\fifthargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\syst_helpers_seventuple_empty_six_yes#1{#2}{#3}{#4}{#5}{#6}}% {\syst_helpers_seventuple_empty_six_nop#1{#2}{#3}{#4}{#5}{#6}}} \def\syst_helpers_seventuple_empty_six_yes#1#2#3#4#5#6[#7]% {\sixthargumenttrue - \doifnextoptionalelse + \doifelsenextoptional {\seventhargumenttrue#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}]}% {\syst_helpers_seventuple_empty_seven_nop#1{#2}{#3}{#4}{#5}{#6}{#7}}} @@ -2735,13 +2769,13 @@ \unexpanded\def\complexorsimple#1% {% \relax % prevents lookahead, brrr - \doifnextoptionalelse + \doifelsenextoptional {\firstargumenttrue \csname\s!complex\strippedcsname#1\endcsname} {\firstargumentfalse\csname\s!simple \strippedcsname#1\endcsname}} \unexpanded\def\complexorsimpleempty#1% {% \relax % prevents lookahead, brrr - \doifnextoptionalelse + \doifelsenextoptional {\firstargumenttrue \csname\s!complex\strippedcsname#1\endcsname} {\firstargumentfalse\csname\s!complex\strippedcsname#1\endcsname[]}} @@ -2753,10 +2787,10 @@ %D in protection. \unexpanded\def\syst_helpers_complex_or_simple#1#2% - {\doifnextoptionalelse{\firstargumenttrue#1}{\firstargumentfalse#2}} + {\doifelsenextoptional{\firstargumenttrue#1}{\firstargumentfalse#2}} \unexpanded\def\syst_helpers_complex_or_simple_empty#1% - {\doifnextoptionalelse{\firstargumenttrue#1}{\firstargumentfalse#1[]}} + {\doifelsenextoptional{\firstargumenttrue#1}{\firstargumentfalse#1[]}} \unexpanded\def\definecomplexorsimple#1% {\unexpanded\edef#1{\syst_helpers_complex_or_simple @@ -3380,14 +3414,14 @@ \def\syst_helpers_do_do_do_increment#1,#2){\dodoglobal\edef#1{\the\numexpr\ifdefined#1\ifx#1\relax\else#1\fi\fi+#2\relax}} \def\syst_helpers_do_do_do_decrement#1,#2){\dodoglobal\edef#1{\the\numexpr\ifdefined#1\ifx#1\relax\else#1\fi\fi-#2\relax}} -\def\syst_helpers_do_do_increment(#1{\doifnextcharelse,{\syst_helpers_do_do_do_increment#1}{\syst_helpers_do_do_do_increment#1,\plusone}} -\def\syst_helpers_do_do_decrement(#1{\doifnextcharelse,{\syst_helpers_do_do_do_decrement#1}{\syst_helpers_do_do_do_decrement#1,\plusone}} +\def\syst_helpers_do_do_increment(#1{\doifelsenextchar,{\syst_helpers_do_do_do_increment#1}{\syst_helpers_do_do_do_increment#1,\plusone}} +\def\syst_helpers_do_do_decrement(#1{\doifelsenextchar,{\syst_helpers_do_do_do_decrement#1}{\syst_helpers_do_do_do_decrement#1,\plusone}} \unexpanded\def\fastincrement#1{\dodoglobal\edef#1{\the\numexpr#1+\plusone \relax}} \unexpanded\def\fastdecrement#1{\dodoglobal\edef#1{\the\numexpr#1+\minusone\relax}} -\unexpanded\def\increment{\doifnextcharelse(\syst_helpers_do_do_increment\syst_helpers_do_increment} -\unexpanded\def\decrement{\doifnextcharelse(\syst_helpers_do_do_decrement\syst_helpers_do_decrement} +\unexpanded\def\increment{\doifelsenextchar(\syst_helpers_do_do_increment\syst_helpers_do_increment} +\unexpanded\def\decrement{\doifelsenextchar(\syst_helpers_do_do_decrement\syst_helpers_do_decrement} \unexpanded\def\incrementvalue#1{\expandafter\increment\csname#1\endcsname} \unexpanded\def\decrementvalue#1{\expandafter\decrement\csname#1\endcsname} @@ -4064,13 +4098,15 @@ \def\syst_helpers_check_if_assignment_else#1=#2#3\_e_o_p_{\if#2@}% -\unexpanded\def\doifassignmentelse#1% expandable +\unexpanded\def\doifelseassignment#1% expandable {\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=@@\_e_o_p_ \expandafter\secondoftwoarguments \else \expandafter\firstoftwoarguments \fi} +\let\doifassignmentelse\doifelseassignment + \newif\ifassignment \unexpanded\def\docheckassignment#1% @@ -4143,7 +4179,7 @@ %D %D Watch the one level expansion of the second argument. -\unexpanded\def\doifmeaningelse#1#2% +\unexpanded\def\doifelsemeaning#1#2% {\edef\m_syst_string_one{\meaning#1}% \def \m_syst_string_two{#2}% \edef\m_syst_string_two{\meaning\m_syst_string_two}% @@ -4153,6 +4189,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doifmeaningelse\doifelsemeaning + %D \macros %D {doifsamestringselse,doifsamestring,doifnotsamestring} %D @@ -4170,10 +4208,12 @@ \edef\m_syst_string_two{\detokenize\expandafter{\normalexpanded{#4}}}% \ifx\m_syst_string_one\m_syst_string_two\expandafter#1\else\expandafter#2\fi} -\unexpanded\def\doifsamestringelse{\syst_helpers_if_samestring_else\firstoftwoarguments\secondoftwoarguments} +\unexpanded\def\doifelsesamestring{\syst_helpers_if_samestring_else\firstoftwoarguments\secondoftwoarguments} \unexpanded\def\doifsamestring {\syst_helpers_if_samestring_else\firstofoneargument \gobbleoneargument } \unexpanded\def\doifnotsamestring {\syst_helpers_if_samestring_else\gobbleoneargument \firstofoneargument } +\let\doifsamestringelse\doifelsesamestring + %D \macros %D {ConvertToConstant,ConvertConstantAfter} %D @@ -4235,7 +4275,7 @@ \unexpanded\def\CheckConstantAfter#1#2% {\expandafter\convertargument\v!prefix!\to\ascii \convertargument#1\to#2\relax - \doifinstringelse\ascii{#2} + \doifelseinstring\ascii{#2} {\expandafter\convertargument#1\to#2} {}} @@ -4506,10 +4546,10 @@ %D implementation became: \unexpanded\def\groupedcommand#1#2% - {\doifnextbgroupelse{\syst_helpers_handle_group_normal{#1}{#2}}{\syst_helpers_handle_group_nop{#1}{#2}}} + {\doifelsenextbgroup{\syst_helpers_handle_group_normal{#1}{#2}}{\syst_helpers_handle_group_nop{#1}{#2}}} \unexpanded\def\simplegroupedcommand#1#2% - {\doifnextbgroupelse{\syst_helpers_handle_group_simple{#1}{#2}}{\syst_helpers_handle_group_nop{#1}{#2}}} + {\doifelsenextbgroup{\syst_helpers_handle_group_simple{#1}{#2}}{\syst_helpers_handle_group_nop{#1}{#2}}} %D Users should be aware of the fact that grouping can %D interfere with ones paragraph settings that are executed @@ -4603,14 +4643,14 @@ \newtoks\AfterPar \def\redowithpar\par - {\doifnextcharelse\par\redowithpar\dodowithpar}% + {\doifelsenextchar\par\redowithpar\dodowithpar}% \def\dowithpar#1#2% {\def\dodowithpar##1\par{#1##1#2}% \redowithpar\par} \def\redogotopar\par - {\doifnextcharelse\par\redogotopar\dodogotopar}% + {\doifelsenextchar\par\redogotopar\dodogotopar}% \def\dogotopar#1% {\def\dodogotopar{#1}% @@ -4674,7 +4714,7 @@ \unexpanded\def\dowithpargument#1% {\def\syst_helpers_next_par##1 \par{#1{##1}}% \def\syst_helpers_next_arg##1{#1{##1}}% - \doifnextbgroupelse\syst_helpers_next_arg{\doifnextcharelse\par{#1{}}\syst_helpers_next_par}} + \doifelsenextbgroup\syst_helpers_next_arg{\doifelsenextchar\par{#1{}}\syst_helpers_next_par}} %D The \type{p} in the previous command stands for paragraph. %D When we want to act upon words we can use the \type{w} @@ -4704,7 +4744,7 @@ \unexpanded\def\dowithwargument#1% {\def\syst_helpers_next_war##1 {#1{##1}}% \def\syst_helpers_next_arg##1{#1{##1}}% - \doifnextbgroupelse\syst_helpers_next_arg\syst_helpers_next_war} + \doifelsenextbgroup\syst_helpers_next_arg\syst_helpers_next_war} %D \macros %D {dorepeat,dorepeatwithcommand} @@ -4799,11 +4839,13 @@ \expandafter\firstoftwoarguments \fi} -\def\doifstringinstringelse#1#2% +\def\doifelsestringinstring#1#2% {\expandafter\def\expandafter\syst_helpers_if_instring_else\expandafter##\expandafter1#1##2##3\_e_o_s_ {\syst_helpers_if_instring_else_indeed##2}% \expandafter\expandafter\expandafter\syst_helpers_if_instring_else\expandafter#2#1@@\_e_o_s_} +\let\doifstringinstringelse\doifelsestringinstring + %D \macros %D {appendtoks,prependtoks,appendtoksonce,prependtoksonce, %D doifintokselse,flushtoks,dotoks} @@ -4849,19 +4891,21 @@ \def\syst_helpers_append_toks_once#1\to#2% {\let\m_syst_helpers_scratch#2% \t_syst_helpers_scratch\expandafter{\gobbleoneargument#1}% - \doifintokselse\t_syst_helpers_scratch\m_syst_helpers_scratch\donothing\syst_helpers_append_toks_indeed} + \doifelseintoks\t_syst_helpers_scratch\m_syst_helpers_scratch\donothing\syst_helpers_append_toks_indeed} \def\syst_helpers_prepend_toks_once#1\to#2% {\let\m_syst_helpers_scratch#2% \t_syst_helpers_scratch\expandafter{\gobbleoneargument#1}% - \doifintokselse\t_syst_helpers_scratch\m_syst_helpers_scratch\donothing\syst_helpers_prepend_toks_indeed} + \doifelseintoks\t_syst_helpers_scratch\m_syst_helpers_scratch\donothing\syst_helpers_prepend_toks_indeed} %D The test macro: -\unexpanded\def\doifintokselse#1#2% #1 en #2 zijn toks +\unexpanded\def\doifelseintoks#1#2% #1 en #2 zijn toks {\edef\asciia{\detokenize\expandafter{\the#1}}% \edef\asciib{\detokenize\expandafter{\the#2}}% - \doifstringinstringelse\asciia\asciib} + \doifelsestringinstring\asciia\asciib} + +\let\doifintokselse\doifelseintoks %D A nice one too: @@ -5055,24 +5099,26 @@ {\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}} \unexpanded\def\addtocommalist#1#2% {item} \cs - {\rawdoifinsetelse{#1}#2\resetglobal + {\rawdoifelseinset{#1}#2\resetglobal {\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}} \unexpanded\def\pretocommalist#1#2% {item} \cs - {\rawdoifinsetelse{#1}#2\resetglobal + {\rawdoifelseinset{#1}#2\resetglobal {\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}} -\unexpanded\def\robustdoifinsetelse#1#2% +\unexpanded\def\robustdoifelseinset#1#2% {\edef\m_syst_string_one{\detokenize\expandafter{\normalexpanded{#1}}}% \edef\m_syst_string_two{\detokenize\expandafter{\normalexpanded{#2}}}% - \rawdoifinsetelse\m_syst_string_one\m_syst_string_two} + \rawdoifelseinset\m_syst_string_one\m_syst_string_two} + +\let\robustdoifinsetelse\robustdoifelseinset \unexpanded\def\robustaddtocommalist#1#2% {item} \cs - {\robustdoifinsetelse{#1}#2\resetglobal + {\robustdoifelseinset{#1}#2\resetglobal {\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}} \unexpanded\def\robustpretocommalist#1#2% {item} \cs - {\robustdoifinsetelse{#1}#2\resetglobal + {\robustdoifelseinset{#1}#2\resetglobal {\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}} \unexpanded\def\xsplitstring#1#2% \cs {str} @@ -5086,7 +5132,7 @@ \def\acleanedupcommalist#1,,#2\relax{#1} \unexpanded\def\removefromcommalist#1#2% to be sped up - {\rawdoifinsetelse{#1}#2% + {\rawdoifelseinset{#1}#2% {\normalexpanded{\xsplitstring\noexpand#2{#1}}% \dodoglobal\edef#2% {\ifx\m_syst_string_one\empty @@ -5343,7 +5389,7 @@ \newdimen\localhsize \unexpanded\def\setlocalhsize % don't change ! - {\doifnextoptionalelse + {\doifelsenextoptional \syst_helpers_set_local_hsize_yes \syst_helpers_set_local_hsize_nop} @@ -5430,7 +5476,7 @@ \expandafter\secondoftwoarguments \fi} -\unexpanded\def\doifsomethingelse#1% +\unexpanded\def\doifelsesomething#1% {\edef\m_syst_string_one{#1}% \ifx\m_syst_string_one\empty \expandafter\secondoftwoarguments @@ -5462,18 +5508,25 @@ \expandafter\secondoftwoarguments \fi} +\let\doifvalueelse \doifelsevalue +\let\doifnothingelse \doifelsenothing +\let\doifsomethingelse \doifelsesomething +\let\doifvaluenothingelse\doifelsevaluenothing + %D \macros %D {doifemptyelsevalue, doifemptyvalue, doifnotemptyvalue} %D %D Also handy: -\def\doifemptyelsevalue#1% +\def\doifelseemptyvalue#1% {\expandafter\ifx\csname#1\endcsname\empty \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} +\let\doifemptyvalueelse\doifelseemptyvalue + \def\doifemptyvalue#1% {\expandafter\ifx\csname#1\endcsname\empty \expandafter\firstofoneargument @@ -5503,10 +5556,12 @@ \processcommalist[#3]\syst_helpers_do_common_check_all \ifdone\expandafter#1\else\expandafter#2\fi} -\unexpanded\def\doifallcommonelse{\syst_helpers_do_if_all_common_else\firstoftwoarguments\secondoftwoarguments} +\unexpanded\def\doifelseallcommon{\syst_helpers_do_if_all_common_else\firstoftwoarguments\secondoftwoarguments} \unexpanded\def\doifallcommon {\syst_helpers_do_if_all_common_else\firstofonearguments\gobbleoneargument } \unexpanded\def\doifnotallcommon {\syst_helpers_do_if_all_common_else\gobbleoneargument \firstofonearguments } +\let\doifallcommonelse\doifelseallcommon + %D \macros %D {DOIF,DOIFELSE,DOIFNOT} %D @@ -5710,13 +5765,15 @@ \def\syst_helpers_if_some_space_else#1 #2#3\_e_o_s_{\if\noexpand#2@} -\def\doifsomespaceelse#1% % #2#3% +\def\doifelsesomespace#1% % #2#3% {\syst_helpers_if_some_space_else#1 @ @\_e_o_s_ % #3\else#2\fi} \expandafter\secondoftwoarguments \else \expandafter\firstoftwoarguments \fi} +\let\doifsomespaceelse\doifelsesomespace + %D \macros %D {processseparatedlist} %D @@ -6245,7 +6302,7 @@ %D Not that fast I guess, but here's a way to test for token %D registers being empty. -\unexpanded\def\doifsometokselse#1% +\unexpanded\def\doifelsesometoks#1% {\edef\m_syst_string_one{\the#1}% one level expansion so quite ok \ifx\m_syst_string_one\empty \expandafter\secondoftwoarguments @@ -6253,6 +6310,8 @@ \expandafter\firstoftwoarguments \fi} +\let\doifsometokselse\doifelsesometoks + \unexpanded\def\doifsometoks#1% {\edef\m_syst_string_one{\the#1}% one level expansion so quite ok \ifx\m_syst_string_one\empty @@ -6291,9 +6350,11 @@ \unexpanded\def\stopstrictinspectnextcharacter {\let\syst_helpers_inspect_next_character\syst_helpers_normal_inspect_next_character} -\def\strictdoifnextoptionalelse#1#2% +\unexpanded\def\strictdoifelsenextoptional#1#2% {\startstrictinspectnextcharacter - \doifnextcharelse[{\stopstrictinspectnextcharacter#1}{\stopstrictinspectnextcharacter#2}} + \doifelsenextchar[{\stopstrictinspectnextcharacter#1}{\stopstrictinspectnextcharacter#2}} + +\let\strictdoifnextoptionalelse\strictdoifelsenextoptional %D \macros %D {gobblespacetokens} @@ -6486,9 +6547,11 @@ %D %D This is a dirty one: we simply append a unit and discard it when needed. -\def\doifdimensionelse#1% +\def\doifelsedimension#1% {\afterassignment\syst_helpers_if_dimension_else\scratchdimen#1pt\relax} +\let\doifdimensionelse\doifelsedimension + \def\syst_helpers_if_dimension_else#1% {\ifx#1\relax \expandafter\secondoftwoarguments @@ -6517,7 +6580,9 @@ \installsystemnamespace{dimencheckb} \installsystemnamespace{dimencheckc} -\def\doifdimenstringelse#1{\normalexpanded{\noexpand\dodimenteststageone#1}\empty\empty]} +\def\doifelsedimenstring#1{\normalexpanded{\noexpand\dodimenteststageone#1}\empty\empty]} + +\let\doifdimenstringelse\doifelsedimenstring \def\dodimenteststageone #1#2{\csname \??dimenchecka\ifcsname \??dimenchecka#2\endcsname#2\else x\fi\endcsname#2} \def\dodimenteststagetwo #1#2{\csname \??dimencheckb\ifcsname \??dimencheckb#2\endcsname#2\else x\fi\endcsname#2} @@ -6640,10 +6705,12 @@ % sometimes handy: -\unexpanded\def\doifhasspaceelse#1% +\unexpanded\def\doifelsehasspace#1% {\edef\m_syst_string_one{#1}% \normalexpanded{\syst_helpers_if_has_space_else#1\space}\empty\relax} +\let\doifhasspaceelse\doifelsehasspace + \unexpanded\def\syst_helpers_if_has_space_else#1 #2#3\relax % \space\empty\relax {\ifx\m_syst_string_one\space \expandafter\firstoftwoarguments @@ -6652,7 +6719,7 @@ \else \doubleexpandafter\firstoftwoarguments \fi\fi} - + % this will replace loadfile once and alike !!! todo \installsystemnamespace{flag} @@ -6671,6 +6738,8 @@ \doubleexpandafter\secondoftwoarguments \fi\fi} +\let\doifflaggedelse\doifelseflagged + \def\doifnotflagged#1% {\expandafter\ifx\csname\??flag#1\endcsname\relax \expandafter\firstofoneargument @@ -6679,10 +6748,10 @@ \else \doubleexpandafter\firstofoneargument \fi\fi} - + \unexpanded\def\inheritparameter[#1]#2[#3]#4[#5]% tag tokey fromkey {\expandafter\def\csname#1#3\expandafter\endcsname\expandafter{\csname#1#5\endcsname}} - + \def\syst_helpers_if_non_zero_positive_else#1#2\end % #3#4% {\ifx#1\relax \ifcase\scratchcounter @@ -6697,9 +6766,11 @@ \expandafter\secondoftwoarguments \fi} -\def\doifnonzeropositiveelse#1% +\def\doifelsenonzeropositive#1% {\begingroup\afterassignment\syst_helpers_if_non_zero_positive_else\scratchcounter=0#1\relax\empty\end} - + +\let\doifnonzeropositiveelse\doifelsenonzeropositive + % here ? \unexpanded\def\dosetrawvalue #1#2#3{\expandafter \def\csname#1#2\endcsname{#3}} @@ -6858,7 +6929,7 @@ %D \typebuffer \getbuffer \unexpanded\def\ignoreimplicitspaces - {\doifnextcharelse\relax\relax\relax} + {\doifelsenextchar\relax\relax\relax} %D \macros %D {processwords} diff --git a/tex/context/base/syst-lua.lua b/tex/context/base/syst-lua.lua index aa258d542..a6665f410 100644 --- a/tex/context/base/syst-lua.lua +++ b/tex/context/base/syst-lua.lua @@ -8,7 +8,8 @@ if not modules then modules = { } end modules ['syst-lua'] = { local find, match = string.find, string.match local tonumber = tonumber -local S, lpegmatch, lpegtsplitat = lpeg.S, lpeg.match, lpeg.tsplitat +local S, C, P, lpegmatch, lpegtsplitat = lpeg.S, lpeg.C, lpeg.P, lpeg.match, lpeg.tsplitat + commands = commands or { } local commands = commands @@ -115,7 +116,7 @@ end local s = lpegtsplitat(",") local h = { } -local function doifcommonelse(a,b) -- often the same test +local function doifelsecommon(a,b) -- often the same test local ha = h[a] local hb = h[b] if not ha then @@ -139,7 +140,7 @@ local function doifcommonelse(a,b) -- often the same test ctx_secondoftwoarguments() end -local function doifinsetelse(a,b) +local function doifelseinset(a,b) local hb = h[b] if not hb then hb = lpegmatch(s,b) h[b] = hb end for i=1,#hb do @@ -152,20 +153,20 @@ local function doifinsetelse(a,b) end implement { - name = "doifcommonelse", + name = "doifelsecommon", arguments = two_strings, - actions = doifcommonelse + actions = doifelsecommon } implement { - name = "doifinsetelse", + name = "doifelseinset", arguments = two_strings, - actions = doifinsetelse + actions = doifelseinset } local pattern = lpeg.patterns.validdimen -function commands.doifdimenstringelse(str) +function commands.doifelsedimenstring(str) if lpegmatch(pattern,str) then ctx_firstoftwoarguments() else @@ -173,15 +174,18 @@ function commands.doifdimenstringelse(str) end end -function commands.firstinset(str) - local first = match(str,"^([^,]+),") - context(first or str) -end +local p_first = C((1-P(",")-P(-1))^0) + +implement { + name = "firstinset", + arguments = "string", + actions = function(str) context(lpegmatch(p_first,str or "")) end +} implement { name = "ntimes", - actions = { string.rep, context }, - arguments = { "string", "integer" } + arguments = { "string", "integer" }, + actions = { string.rep, context } } implement { @@ -203,7 +207,7 @@ implement { -- end implement { - name = "doifsameelse", + name = "doifelsesame", arguments = two_strings, actions = function(a,b) if a == b then diff --git a/tex/context/base/syst-lua.mkiv b/tex/context/base/syst-lua.mkiv index 145cb3ebe..5e82a9ea9 100644 --- a/tex/context/base/syst-lua.mkiv +++ b/tex/context/base/syst-lua.mkiv @@ -15,15 +15,18 @@ \unprotect -\def\expdoifelse#1#2{\clf_doifsameelse{#1}{#2}} +\def\expdoifelse#1#2{\clf_doifelsesame{#1}{#2}} \def\expdoif #1#2{\clf_doifsame {#1}{#2}} \def\expdoifnot #1#2{\clf_doifnotsame {#1}{#2}} % \testfeatureonce{100000}{\doifelse{hello world}{here i am}{}} % 0.3 % \testfeatureonce{100000}{\expandabledoifelse{hello world}{here i am}{}} % 1.5 -\def\expdoifcommonelse#1#2{\clf_doifcommonelse{#1}{#2}} -\def\expdoifinsetelse #1#2{\clf_doifinset {#1}{#2}} +\def\expdoifelsecommon#1#2{\clf_doifelsecommon{#1}{#2}} +\def\expdoifelseinset #1#2{\clf_doifelseinset {#1}{#2}} + +\def\expdoifcommonelse\expdoifelsecommon +\def\expdoifinsetelse \expdoifelseinset % we define these here, just in case ... diff --git a/tex/context/base/tabl-ltb.mkiv b/tex/context/base/tabl-ltb.mkiv index f7fbc0390..4c892138e 100644 --- a/tex/context/base/tabl-ltb.mkiv +++ b/tex/context/base/tabl-ltb.mkiv @@ -138,6 +138,8 @@ \expandafter\secondoftwoarguments \fi} +\let\doiflinetablecparameterelse\doifelselinetablecparameter + \def\linetablecparameter#1% {\csname \ifcsname\??lec\number\linetablecolumn#1\endcsname @@ -614,7 +616,7 @@ {\global\linetablepage\zerocount \ifcase\linetablerepeat \else \ifcase\linetablepage \doif{\linetableparameter\c!repeat}\v!no - {\global\linetablepage\doifoddpageelse\plusone\plustwo}% + {\global\linetablepage\doifelseoddpage\plusone\plustwo}% \fi \fi} \def\flushlinetablehead diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv index 51564f825..9454ce1d9 100644 --- a/tex/context/base/tabl-ntb.mkiv +++ b/tex/context/base/tabl-ntb.mkiv @@ -964,10 +964,10 @@ \unexpanded\def\eTABLE % beware, we need to get rid of spurious spaces when in hmode {% tricky and dirty order -) - \doifsometokselse\t_tabl_ntb_head % slow, better a flag + \doifelsesometoks\t_tabl_ntb_head % slow, better a flag {\the\t_tabl_ntb_head \c_tabl_ntb_n_of_head_lines\c_tabl_ntb_maximum_row\relax - \doifsometokselse\t_tabl_ntb_next + \doifelsesometoks\t_tabl_ntb_next {\the\t_tabl_ntb_next \c_tabl_ntb_n_of_next_lines\numexpr\c_tabl_ntb_maximum_row-\c_tabl_ntb_n_of_head_lines\relax}% {\c_tabl_ntb_n_of_next_lines\zerocount}% was 1 diff --git a/tex/context/base/tabl-tab.mkiv b/tex/context/base/tabl-tab.mkiv index f9ac27e70..9813b995e 100644 --- a/tex/context/base/tabl-tab.mkiv +++ b/tex/context/base/tabl-tab.mkiv @@ -1503,9 +1503,9 @@ \global\setfalse\tableactionstatepermitted \global\setfalse\hassometablehead \global\setfalse\hassometabletail - \expanded{\doifinstringelse{|}{#1}} + \expanded{\doifelseinstring{|}{#1}} {\xdef\restarttable{\noexpand\dorestarttable{\noexpand\thirdstagestarttable{#1}}}} - {\doifdefinedelse{\??tabletemplate#1} + {\doifelsedefined{\??tabletemplate#1} {\gdef\restarttable{\getvalue{\??tabletemplate#1}}} {\gdef\restarttable{\dorestarttable{\getvalue{#1}}}}}% \egroup @@ -1921,7 +1921,7 @@ {\global\currenttablecolumn\zerocount} \def\dotablevrulecommand#1% global assignments - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\global\tablevrulethicknessfactor#1\relax \global\multiply\tablevrulethicknessfactor\m_tabl_table_VLwidth\relax} {\xdef\tablecurrentvrulecolor{#1}}} @@ -1955,7 +1955,7 @@ \unexpanded\def\dotableVN#1{\global\noftablevrules#1\relax\VL} \def\dotablehrulecommand#1% global assignments - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\global\tablehrulethicknessfactor#1\relax \global\multiply\tablehrulethicknessfactor\m_tabl_table_HLheight\relax} {\xdef\tablecurrenthrulecolor{#1}}} @@ -2075,7 +2075,7 @@ \fi} \def\dotabledrulecommand#1% global assignments - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\ifcase\tabledrulespan \global\tabledrulespan#1\relax \else diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index c1dcef46f..675361b43 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -599,17 +599,17 @@ \tabl_tabulate_set_preamble} \def\tabl_tabulate_set_preskip#1% - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\s_tabl_tabulate_pre#1\d_tabl_tabulate_unit\tabl_tabulate_set_preamble } {\s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\tabl_tabulate_set_preamble#1}} \def\tabl_tabulate_set_posskip#1% - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\s_tabl_tabulate_post#1\d_tabl_tabulate_unit\tabl_tabulate_set_preamble } {\s_tabl_tabulate_post.5\d_tabl_tabulate_unit\tabl_tabulate_set_preamble#1}} \def\tabl_tabulate_set_preposskip#1% - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\s_tabl_tabulate_pre#1\d_tabl_tabulate_unit\s_tabl_tabulate_post\s_tabl_tabulate_pre\tabl_tabulate_set_preamble } {\s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\s_tabl_tabulate_post\s_tabl_tabulate_pre\tabl_tabulate_set_preamble#1}} @@ -651,7 +651,7 @@ \tabl_tabulate_set_preamble} \def\tabl_tabulate_pickup_width - {\doifnextparenthesiselse\tabl_tabulate_set_width_indeed\tabl_tabulate_set_preamble} + {\doifelsenextparenthesis\tabl_tabulate_set_width_indeed\tabl_tabulate_set_preamble} \def\tabl_tabulate_set_width {\setfalse\c_tabl_tabulate_pwidth_set @@ -664,7 +664,7 @@ \tabl_tabulate_set_preamble} \def\tabl_tabulate_set_paragraph - {\doifnextparenthesiselse + {\doifelsenextparenthesis {\c_tabl_tabulate_modus\plusone \settrue\c_tabl_tabulate_pwidth_set \tabl_tabulate_pickup_width} @@ -749,7 +749,7 @@ \tabl_tabulate_set_preamble} \def\tabl_tabulate_set_vrule_command#1% - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\global\d_tabl_tabulate_vrulethickness#1\d_tabl_tabulate_vrulethickness_default} {\xdef\m_tabl_tabulate_vrule_color{#1}}} @@ -1087,8 +1087,8 @@ \tabulatenoalign{\kern-\lineheight}% \fi} -\setuvalue{\e!start\v!tabulatehead}{\doifnextoptionalcselse\tabl_tabulate_start_head_yes\tabl_tabulate_start_head_nop} -\setuvalue{\e!start\v!tabulatetail}{\doifnextoptionalcselse\tabl_tabulate_start_foot_yes\tabl_tabulate_start_foot_nop} +\setuvalue{\e!start\v!tabulatehead}{\doifelsenextoptionalcs\tabl_tabulate_start_head_yes\tabl_tabulate_start_head_nop} +\setuvalue{\e!start\v!tabulatetail}{\doifelsenextoptionalcs\tabl_tabulate_start_foot_yes\tabl_tabulate_start_foot_nop} \let\m_tabl_tabulate_data\empty @@ -1135,7 +1135,7 @@ \fi} \def\tabl_start_defined_one[#1][#2]% - {\doifassignmentelse{#1} + {\doifelseassignment{#1} {\setuptabulation[\currenttabulation][#1]}% {\edef\currenttabulation{\currenttabulation:#1}}% \tabl_tabulate_start_building} @@ -1164,7 +1164,7 @@ \fi} \def\tabl_start_regular_one[#1][#2]% - {\doifassignmentelse{#1} + {\doifelseassignment{#1} {\setupcurrenttabulation[\c!format={|l|p|},#1]} {\def\p_format{#1}% \ifx\p_format\empty @@ -1314,7 +1314,7 @@ \def\tabl_tabulate_set_color_column#1% overloaded {\unskip - \doiffastoptionalcheckelse{\tabl_tabulate_set_color_column_yes#1}{\tabl_tabulate_set_color_column_nop#1}} + \doifelsefastoptionalcheck{\tabl_tabulate_set_color_column_yes#1}{\tabl_tabulate_set_color_column_nop#1}} \def\tabl_tabulate_set_color_column_nop {\tabl_tabulate_column_normal} @@ -1353,13 +1353,13 @@ % \fi\fi \global\let\m_tabl_tabulate_vrule_color_local\m_tabl_tabulate_vrule_color_default \global\d_tabl_tabulate_vrulethickness_local\d_tabl_tabulate_vrulethickness_default - \doiffastoptionalcheckelse{\tabl_tabulate_column_vruled_yes#1}{\tabl_tabulate_column_vruled_nop#1}} + \doifelsefastoptionalcheck{\tabl_tabulate_column_vruled_yes#1}{\tabl_tabulate_column_vruled_nop#1}} \def\tabl_tabulate_column_vruled_nop {\tabl_tabulate_column_normal} \def\tabl_tabulate_column_vruled_step#1% - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\global\d_tabl_tabulate_vrulethickness_local#1\d_tabl_tabulate_vrulethickness_default} {\xdef\m_tabl_tabulate_vrule_color_local{#1}}} @@ -1447,15 +1447,15 @@ \def\tabl_tabulate_hrule_spec_ignore#1% {%\global\let\currenttabulationlocalhrulecolor\empty %\global\d_tabl_tabulate_hrulethickness_local\d_tabl_tabulate_hrulethickness_default - \doiffastoptionalcheckelse#1#1} + \doifelsefastoptionalcheck#1#1} \def\tabl_tabulate_hrule_spec_pickup#1% {\global\let\currenttabulationlocalhrulecolor\m_tabl_tabulate_hrule_color_default \global\d_tabl_tabulate_hrulethickness_local\d_tabl_tabulate_hrulethickness_default - \doiffastoptionalcheckelse{\tabl_tabulate_hrule_preset#1}#1} + \doifelsefastoptionalcheck{\tabl_tabulate_hrule_preset#1}#1} \def\tabl_tabulate_hrule_preset_step#1% - {\doifnumberelse{#1} + {\doifelsenumber{#1} {\global\d_tabl_tabulate_hrulethickness_local#1\d_tabl_tabulate_hrulethickness_default} {\xdef\currenttabulationlocalhrulecolor{#1}}} @@ -1524,7 +1524,7 @@ \unexpanded\def\tabl_tabulate_color_set#1% we could store the attributes at the cost of a lua call {\begingroup - \node_backgrounds_align_initialize % name might change + \clf_enablebackgroundalign % was \node_backgrounds_align_initialize \global\let\tabl_tabulate_color_repeat\tabl_tabulate_color_repeat_second \global\settrue\c_tabl_tabulate_has_colors \ifnum\c_tabl_tabulate_column>\c_tabl_tabulate_max_colorcolumn diff --git a/tex/context/base/tabl-tsp.mkiv b/tex/context/base/tabl-tsp.mkiv index 0138697af..64ab94a67 100644 --- a/tex/context/base/tabl-tsp.mkiv +++ b/tex/context/base/tabl-tsp.mkiv @@ -195,7 +195,7 @@ \normalexpanded{\egroup\noexpand\edef\noexpand\extrasplitfloatlines{\the\noflines}}% \global\settrue\usesamefloatnumber \else - \doifnumberelse\extrasplitfloatlines\donothing{\def\extrasplitfloatlines{1}}% + \doifelsenumber\extrasplitfloatlines\donothing{\def\extrasplitfloatlines{1}}% \fi} \unexpanded\def\doifnotinsidesplitfloat diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index 343b00620..8742818d5 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -422,7 +422,7 @@ \unexpanded\def\startxrow {\begingroup - \doifnextoptionalcselse\tabl_x_start_row_yes\tabl_x_start_row_nop} + \doifelsenextoptionalcs\tabl_x_start_row_yes\tabl_x_start_row_nop} \unexpanded\def\tabl_x_start_row_reflow_width_yes[#settings]% {\setupcurrentxtable[#settings]% @@ -456,7 +456,7 @@ \endgroup} \unexpanded\def\startxcell - {\doifnextoptionalcselse\tabl_x_start_cell_yes\tabl_x_start_cell_nop} + {\doifelsenextoptionalcs\tabl_x_start_cell_yes\tabl_x_start_cell_nop} \unexpanded\def\stopxcell {\tabl_x_stop_cell} @@ -706,7 +706,7 @@ \unexpanded\def\startxgroup {\begingroup - \doifnextoptionalcselse\tabl_x_start_group_delayed_one\relax} + \doifelsenextoptionalcs\tabl_x_start_group_delayed_one\relax} \unexpanded\def\stopxgroup {\endgroup} @@ -724,7 +724,7 @@ \chaintocurrentxtable{#tag}% \fi \edef\currentxtable{#tag}% - \doifnextoptionalcselse\setupcurrentxtable\relax} + \doifelsenextoptionalcs\setupcurrentxtable\relax} \let\startxrowgroup \startxgroup \let\stopxrowgroup \stopxgroup @@ -735,7 +735,7 @@ \unexpanded\def\startxcell {\begingroup - \doifnextoptionalcselse\tabl_x_start_cell_delayed_one\tabl_x_start_cell_nop} + \doifelsenextoptionalcs\tabl_x_start_cell_delayed_one\tabl_x_start_cell_nop} \unexpanded\def\tabl_x_start_cell_delayed_one[#tag]% % {\ifcsname\namedxtablehash{#tag}\s!parent\endcsname @@ -750,7 +750,7 @@ \chaintocurrentxtable{#tag}% \fi \edef\currentxtable{#tag}% - \doifnextoptionalcselse\tabl_x_start_cell_yes\tabl_x_start_cell_nop} + \doifelsenextoptionalcs\tabl_x_start_cell_yes\tabl_x_start_cell_nop} \unexpanded\def\stopxcell {\tabl_x_stop_cell @@ -760,7 +760,7 @@ \unexpanded\def\startxrow {\begingroup - \doifnextoptionalcselse\tabl_x_start_row_delayed_one\tabl_x_start_row_nop} + \doifelsenextoptionalcs\tabl_x_start_row_delayed_one\tabl_x_start_row_nop} \unexpanded\def\tabl_x_start_row_delayed_one[#tag]% % {\ifcsname\namedxtablehash{#tag}\s!parent\endcsname @@ -775,7 +775,7 @@ \chaintocurrentxtable{#tag}% \fi \edef\currentxtable{#tag}% - \doifnextoptionalcselse\tabl_x_start_row_yes\tabl_x_start_row_nop} + \doifelsenextoptionalcs\tabl_x_start_row_yes\tabl_x_start_row_nop} \unexpanded\def\stopxrow {\tabl_x_stop_row diff --git a/tex/context/base/type-ini.mkvi b/tex/context/base/type-ini.mkvi index 01b2e9524..f56c5573d 100644 --- a/tex/context/base/type-ini.mkvi +++ b/tex/context/base/type-ini.mkvi @@ -294,12 +294,12 @@ %{\appendtoks\starttypescript#definitions\stoptypescript\to\c_font_typescripts_document} {\c_font_typescripts_document\expandafter{\the\c_font_typescripts_document\starttypescript#definitions\stoptypescript}} -\def\font_typescripts_start_process % could be a faster \doifnextoptionalelse if needed +\def\font_typescripts_start_process % could be a faster \doifelsenextoptionalif needed {\let\typescriptone \m_font_typescripts_one \let\typescripttwo \m_font_typescripts_two \let\typescriptthree\m_font_typescripts_three \let\m_font_typescripts_match\empty - \doifnextoptionalcselse\font_typescripts_start_process_one\font_typescripts_start_process_all} + \doifelsenextoptionalcs\font_typescripts_start_process_one\font_typescripts_start_process_all} \def\font_typescripts_start_process_all % could be a \let {\ifconditional\c_font_typescripts_first_pass @@ -333,10 +333,10 @@ {\font_typescripts_check\m_font_typescripts_three\typescriptthree\font_typescripts_start_process_again_three} \def\font_typescripts_start_process_again_one - {\doifnextoptionalcselse\font_typescripts_start_process_two\font_typescripts_start_process_yes} + {\doifelsenextoptionalcs\font_typescripts_start_process_two\font_typescripts_start_process_yes} \def\font_typescripts_start_process_again_two - {\doifnextoptionalcselse\font_typescripts_start_process_three\font_typescripts_start_process_yes} + {\doifelsenextoptionalcs\font_typescripts_start_process_three\font_typescripts_start_process_yes} \let\font_typescripts_start_process_again_three\font_typescripts_start_process_yes @@ -359,7 +359,7 @@ \donetrue \let#target\m_font_typescripts_check \else - \doifcommonelse\m_font_typescripts_check#asked\donetrue\donefalse + \doifelsecommon\m_font_typescripts_check#asked\donetrue\donefalse \ifdone \let#target\commalistelement \fi diff --git a/tex/context/base/type-run.mkiv b/tex/context/base/type-run.mkiv index a61321375..0455d8966 100644 --- a/tex/context/base/type-run.mkiv +++ b/tex/context/base/type-run.mkiv @@ -21,7 +21,7 @@ \def\dochecktypescript##1##2% script use {\doifelsenothing{##1##2} {\donetrue} - {\doifcommonelse{##1}{##2}\donetrue\donefalse}} + {\doifelsecommon{##1}{##2}\donetrue\donefalse}} \edef\typescriptone {\truetypescript{#1}}% \edef\typescripttwo {\truetypescript{#2}}% \edef\typescriptthree{\truetypescript{#3}}% diff --git a/tex/context/base/typo-bld.lua b/tex/context/base/typo-bld.lua index ad37c36f4..4d0f28d9a 100644 --- a/tex/context/base/typo-bld.lua +++ b/tex/context/base/typo-bld.lua @@ -165,13 +165,8 @@ local function processor(head,followed_by_display) end end -function constructors.enable() - enabled = true -end - -function constructors.disable() - enabled = false -end +function constructors.enable () enabled = true end +function constructors.disable() enabled = false end callbacks.register('linebreak_filter', processor, "breaking paragraps into lines") @@ -179,15 +174,6 @@ statistics.register("linebreak processing time", function() return statistics.elapsedseconds(parbuilders) end) --- interface - -commands.defineparbuilder = constructors.define -commands.startparbuilder = constructors.start -commands.stopparbuilder = constructors.stop -commands.setparbuilder = constructors.set -commands.enableparbuilder = constructors.enable -commands.disableparbuilder = constructors.disable - -- todo: move from nodes.builders to builders nodes.builders = nodes.builder or { } @@ -267,3 +253,12 @@ callbacks.register('buildpage_filter', builders.buildpage_filter, "vertical spac statistics.register("v-node processing time", function() return statistics.elapsedseconds(builders) end) + +local implement = interfaces.implement + +implement { name = "defineparbuilder", actions = constructors.define, arguments = "string" } +implement { name = "setparbuilder", actions = constructors.set, arguments = "string" } +implement { name = "startparbuilder", actions = constructors.start, arguments = "string" } +implement { name = "stopparbuilder", actions = constructors.stop } +implement { name = "enableparbuilder", actions = constructors.enable } +implement { name = "disableparbuilder", actions = constructors.disable } diff --git a/tex/context/base/typo-bld.mkiv b/tex/context/base/typo-bld.mkiv index 459dfb132..69047c98b 100644 --- a/tex/context/base/typo-bld.mkiv +++ b/tex/context/base/typo-bld.mkiv @@ -38,18 +38,18 @@ \installcorenamespace {parbuilder} \unexpanded\def\defineparbuilder[#1]% - {\ctxcommand{defineparbuilder("#1")}} + {\clf_defineparbuilder{#1}} \unexpanded\def\startparbuilder[#1]% {\ifhmode\par\fi - \ctxcommand{startparbuilder("#1")}} + \clf_startparbuilder{#1}} \unexpanded\def\stopparbuilder {\ifhmode\par\fi - \ctxcommand{stopparbuilder()}} + \clf_stopparbuilder} \unexpanded\def\setmainparbuilder[#1]% - {\ctxcommand{setparbuilder("#1")}} + {\clf_setparbuilder{#1}} % no high level interface, after all implementing a linebreaker is not something that % the average user will do @@ -58,7 +58,7 @@ \defineparbuilder[oneline] % just for testing \defineparbuilder[basic] % just for testing -\def\enableparbuilders {\ctxcommand{enableparbuilder()}} % hooks in otr so we need to pickup -\def\disableparbuilders{\ctxcommand{disableparbuilder()}} % hooks in otr so we need to pickup +\unexpanded\def\enableparbuilders {\clf_enableparbuilder } % hooks in otr so we need to pickup +\unexpanded\def\disableparbuilders{\clf_disableparbuilder} % hooks in otr so we need to pickup \protect \endinput diff --git a/tex/context/base/typo-brk.lua b/tex/context/base/typo-brk.lua index 2a9c94c86..a9d775856 100644 --- a/tex/context/base/typo-brk.lua +++ b/tex/context/base/typo-brk.lua @@ -53,6 +53,8 @@ local tasks = nodes.tasks local v_reset = interfaces.variables.reset +local implement = interfaces.implement + local new_penalty = nodepool.penalty local new_glue = nodepool.glue local new_disc = nodepool.disc @@ -319,6 +321,32 @@ end -- interface -commands.definebreakpoints = breakpoints.define -commands.definebreakpoint = breakpoints.setreplacement -commands.setbreakpoints = breakpoints.set +implement { + name = "definebreakpoints", + actions = breakpoints.define, + arguments = "string" +} + +implement { + name = "definebreakpoint", + actions = breakpoints.setreplacement, + arguments = { + "string", + "string", + "string", + { + { "type", "integer" }, + { "nleft" }, + { "nright" }, + { "right" }, + { "left" }, + { "middle" }, + } + } +} + +implement { + name = "setbreakpoints", + actions = breakpoints.set, + arguments = "string" +} diff --git a/tex/context/base/typo-brk.mkiv b/tex/context/base/typo-brk.mkiv index a42bed1b7..3b463c06f 100644 --- a/tex/context/base/typo-brk.mkiv +++ b/tex/context/base/typo-brk.mkiv @@ -31,7 +31,7 @@ {\dosingleargument\typo_breakpoints_define} \def\typo_breakpoints_define[#1]% - {\ctxcommand{definebreakpoints("#1")}} + {\clf_definebreakpoints{#1}} \def\definebreakpoint {\dotripleempty\typo_breakpoints_define_character} @@ -39,19 +39,24 @@ \def\typo_breakpoints_define_character[#1][#2][#3]% name char settings {\begingroup \getdummyparameters[\c!type=1,\c!nleft=3,\c!nright=3,\s!language=,\c!left=,\c!right=,\c!middle=,#3]% - \ctxcommand{definebreakpoint("#1", "#2", "\reallanguagetag{\directdummyparameter\s!language}", { % maybe deal with #3 at the lua end - type = \directdummyparameter\c!type, - nleft = "\directdummyparameter\c!nleft", - nright = "\directdummyparameter\c!nright", - right = "\directdummyparameter\c!right", - left = "\directdummyparameter\c!left", - middle = "\directdummyparameter\c!middle" - } )}% + \clf_definebreakpoint + {#1}% + {#2}% + {\reallanguagetag{\directdummyparameter\s!language}}% + {% maybe deal with #3 at the lua end + type \directdummyparameter\c!type + nleft {\directdummyparameter\c!nleft}% + nright {\directdummyparameter\c!nright}% + right {\directdummyparameter\c!right}% + left {\directdummyparameter\c!left}% + middle {\directdummyparameter\c!middle}% + }% + \relax \endgroup} \unexpanded\def\setbreakpoints[#1]% {\exhyphenchar\minusone % we use a different order tha n base tex, so we really need this - \ctxcommand{setbreakpoints("#1")}} + \clf_setbreakpoints{#1}} \unexpanded\def\resetbreakpoints {\attribute\breakpointattribute\attributeunsetvalue} diff --git a/tex/context/base/typo-chr.mkiv b/tex/context/base/typo-chr.mkiv index 23efecb22..c6f17ceca 100644 --- a/tex/context/base/typo-chr.mkiv +++ b/tex/context/base/typo-chr.mkiv @@ -21,7 +21,6 @@ \registerctxluafile{typo-chr}{1.001} -%unexpanded\def\removepunctuation{\ctxcommand{signal("removepunctuation")}} \unexpanded\def\removepunctuation{\clf_removepunctuation} \protect diff --git a/tex/context/base/typo-dir.lua b/tex/context/base/typo-dir.lua index e7d3c686c..482b7114d 100644 --- a/tex/context/base/typo-dir.lua +++ b/tex/context/base/typo-dir.lua @@ -50,6 +50,8 @@ local tracers = nodes.tracers local setcolor = tracers.colors.set local resetcolor = tracers.colors.reset +local implement = interfaces.implement + local directions = typesetters.directions or { } typesetters.directions = directions @@ -137,9 +139,17 @@ function directions.setcolor(current,direction,reversed,mirror) end end -function commands.getbidimode(specification) - context(tomode(specification)) -- hash at tex end -end +implement { + name = "getbidimode", + actions = { tomode, context }, + arguments = { + { + { "scope" }, + { "method" }, + { "fences" }, + } + } +} local enabled = false @@ -190,4 +200,8 @@ function directions.set(n) -- todo: names and numbers texsetattribute(a_directions,n) end -commands.setdirection = directions.set +implement { + name = "setdirection", + arguments = "integer", + actions = directions.set +} diff --git a/tex/context/base/typo-dir.mkiv b/tex/context/base/typo-dir.mkiv index 69adb14a9..f9b4ecb97 100644 --- a/tex/context/base/typo-dir.mkiv +++ b/tex/context/base/typo-dir.mkiv @@ -36,10 +36,14 @@ \edef\righttoleftmark{\normalUchar"200F} \let\rlm\righttoleftmark \unexpanded\def\setdirection[#1]% todo: symbolic names - {\ctxcommand{setdirection(\number#1)}} + {\clf_setdirection#1\relax} + +% \unexpanded\def\resetdirection +% {\clf_setdirection\zerocount} +% +% is in fact: \unexpanded\def\resetdirection - %{\ctxcommand{setdirection(0)}} {\attribute\directionsattribute\attributeunsetvalue} \newconstant\directionsbidimode % this one might become pivate @@ -49,12 +53,14 @@ % \setupdirections[bidi=global,method=two] % \setupdirections[bidi=global,method=two,fences=no] +% maybee use chardefs + \def\typo_dir_get_mode - {\def\currentbidimode{\ctxcommand{getbidimode { - scope = "\directionsparameter\c!bidi ", - method = "\directionsparameter\c!method", - fences = "\directionsparameter\c!fences", - }}}% + {\def\currentbidimode{\clf_getbidimode + scope {\directionsparameter\c!bidi}% + method {\directionsparameter\c!method}% + fences {\directionsparameter\c!fences}% + }% \expandafter\glet\csname\??directionsbidimode\currentbidistamp\endcsname\currentbidimode} \appendtoks diff --git a/tex/context/base/typo-inj.lua b/tex/context/base/typo-inj.lua index 4c870d83d..b5d9e1c51 100644 --- a/tex/context/base/typo-inj.lua +++ b/tex/context/base/typo-inj.lua @@ -7,7 +7,9 @@ if not modules then modules = { } end modules ['typo-inj'] = { -- was node-par } local tonumber = tonumber -local context, commands = context, commands + +local context = context +local implement = interfaces.implement local injectors = { } typesetters.injectors = injectors @@ -68,7 +70,7 @@ function injectors.mark(name,show) end end -function injectors.check(name,n) +function injectors.check(name,n) -- we could also accent n = number : +/- 2 local injector = list[name] if n == false then n = injector.counter @@ -83,8 +85,10 @@ function injectors.check(name,n) end end -commands.resetinjector = injectors.reset -commands.showinjector = injectors.show -commands.setinjector = injectors.set -commands.markinjector = injectors.mark -commands.checkinjector = injectors.check +implement { name = "resetinjector", actions = injectors.reset, arguments = "string" } +implement { name = "showinjector", actions = injectors.show, arguments = "string" } +implement { name = "setinjector", actions = injectors.set, arguments = { "string", "string", "string" } } +implement { name = "markinjector", actions = injectors.mark, arguments = "string" } +implement { name = "checkinjector", actions = injectors.check, arguments = "string" } +implement { name = "checkpreviousinjector", actions = injectors.check, arguments = { "string", true } } +implement { name = "checknextinjector", actions = injectors.check } diff --git a/tex/context/base/typo-inj.mkiv b/tex/context/base/typo-inj.mkiv index 0293f12fa..46cd9fe45 100644 --- a/tex/context/base/typo-inj.mkiv +++ b/tex/context/base/typo-inj.mkiv @@ -44,13 +44,13 @@ %D \startsection[title=Delta] fourth \index{fourth} \stopsection %D \stoptext -\unexpanded\def\resetinjector [#1]{\ctxcommand{resetinjector("#1")}} -\unexpanded\def\markinjector [#1]{\dontleavehmode\ctxcommand{markinjector("#1")}} -\unexpanded\def\checkinjector [#1]{\ctxcommand{checkinjector("#1")}} -\unexpanded\def\checknextinjector {\ctxcommand{checkinjector()}} -\unexpanded\def\checkpreviousinjector {\ctxcommand{checkinjector(true)}} -\unexpanded\def\dosetinjector [#1][#2][#3]{\ctxcommand{setinjector("#1","#2",\!!bs#3\!!es)}} -\unexpanded\def\doshowinjector [#1]{\ctxcommand{showinjector("#1")}} +\unexpanded\def\resetinjector [#1]{\clf_resetinjector{#1}} +\unexpanded\def\markinjector [#1]{\dontleavehmode\clf_markinjector{#1}} +\unexpanded\def\checkinjector [#1]{\clf_checkinjector{#1}} +\unexpanded\def\checknextinjector {\clf_checknextinjector} +\unexpanded\def\checkpreviousinjector {\clf_checkpreviousinjector} +\unexpanded\def\dosetinjector [#1][#2][#3]{\clf_setinjector{#1}{#2}{#3}} +\unexpanded\def\doshowinjector [#1]{\clf_showinjector{#1}} \unexpanded\def\setinjector {\dotripleargument\dosetinjector} \unexpanded\def\showinjector{\dosingleempty\doshowinjector} @@ -66,8 +66,8 @@ \letvalue{typo_injectors_check_#1}\donothing} \unexpanded\def\doactivateinjector#1% used at lua end - {\setuxvalue{typo_injectors_mark_#1}{\dontleavehmode\noexpand\ctxcommand{markinjector("#1")}}% - \setuxvalue{typo_injectors_check_#1}{\noexpand\ctxcommand{checkinjector("#1")}}} + {\setuxvalue{typo_injectors_mark_#1}{\dontleavehmode\noexpand\clf_markinjector{#1}}% + \setuxvalue{typo_injectors_check_#1}{\noexpand\clf_checkinjector{#1}}} \unexpanded\def\dotestinjector#1% only for testing outside unprotect {\csname typo_injectors_check_#1\endcsname diff --git a/tex/context/base/typo-itm.mkiv b/tex/context/base/typo-itm.mkiv index eb47e4076..0bb8170c7 100644 --- a/tex/context/base/typo-itm.mkiv +++ b/tex/context/base/typo-itm.mkiv @@ -109,9 +109,9 @@ \let\p_typo_items_symbol\empty \let\m_typo_items_symbol\firstofoneargument \else - \doifconversiondefinedelse\p_typo_items_symbol + \doifelseconversiondefined\p_typo_items_symbol {\def\m_typo_items_symbol{\convertnumber\p_typo_items_symbol}} - {\doifsymboldefinedelse\p_typo_items_symbol + {\doifelsesymboldefined\p_typo_items_symbol {\def\m_typo_items_symbol{\symbol[\p_typo_items_symbol]\gobbleoneargument}} {\let\m_typo_items_symbol\firstofoneargument}}% \fi\fi diff --git a/tex/context/base/typo-krn.mkiv b/tex/context/base/typo-krn.mkiv index e638ab85f..6d6126542 100644 --- a/tex/context/base/typo-krn.mkiv +++ b/tex/context/base/typo-krn.mkiv @@ -86,7 +86,7 @@ \appendtoks \setuevalue{\currentcharacterkerning}% - {\doifnextoptionalelse + {\doifelsenextoptional {\typo_kerning_apply_yes{\currentcharacterkerning}}% {\typo_kerning_apply_nop{\currentcharacterkerning}}}% \to \everydefinecharacterkerning diff --git a/tex/context/base/typo-mar.mkiv b/tex/context/base/typo-mar.mkiv index a59a498d2..d5869b459 100644 --- a/tex/context/base/typo-mar.mkiv +++ b/tex/context/base/typo-mar.mkiv @@ -165,7 +165,7 @@ \unexpanded\def\typo_margins_data_synchronize {\doforcedtrackpagestate\s!margintext\nofmargintexts % includes increment \docheckpagestate\s!margintext\nofmargintexts - %\doifrightpagestateelse\s!margintext\nofmargintexts\relax\relax + %\doifelserightpagestate\s!margintext\nofmargintexts\relax\relax \realpageno\realpagestateno \swapmargins} diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua index a3ae01be0..ea34c2c27 100644 --- a/tex/context/base/util-prs.lua +++ b/tex/context/base/util-prs.lua @@ -341,6 +341,12 @@ function utilities.parsers.options_to_hash(str,target) return str and lpegmatch(splitter,str,1,target or { }) or { } end +local splitter = lpeg.tsplitat(" ") + +function utilities.parsers.options_to_array(str) + return str and lpegmatch(splitter,str) or { } +end + -- for chem (currently one level) local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace) diff --git a/tex/context/base/util-sql-loggers.lua b/tex/context/base/util-sql-loggers.lua index 7fceb8032..ceb1ff75c 100644 --- a/tex/context/base/util-sql-loggers.lua +++ b/tex/context/base/util-sql-loggers.lua @@ -52,7 +52,7 @@ table.setmetatableindex(fromtype,function() return "info" end) loggers.totype = totype loggers.fromtype = fromtype -local template =[[ +local template = [[ CREATE TABLE IF NOT EXISTS %basename% ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` int(11) NOT NULL, diff --git a/tex/context/base/x-asciimath.lua b/tex/context/base/x-asciimath.lua index 1fc9ae5a4..c9c787d84 100644 --- a/tex/context/base/x-asciimath.lua +++ b/tex/context/base/x-asciimath.lua @@ -791,14 +791,19 @@ local digitized_2 = Cs ( p_beforecomma * ((p_aftercomma + d_one^1)^0) ) +local p_fourbefore = d_four * d_split +local p_fourafter = d_four local d_spaced = (Carg(1) * (d_three + d_two + d_one))^1 -local p_aftercomma = p_fourafter +local p_aftercomma = p_fourafter * P(-1) + d_three * d_spaced * P(1)^0 + + d_one^1 -local digitized_3 = Cs ( - p_fourbefore * (p_aftercomma^0) + - p_beforecomma * ((p_aftercomma + d_one^1)^0) - ) +-- local digitized_3 = Cs ( +-- p_fourbefore * p_aftercomma^0 + +-- p_beforecomma * p_aftercomma^0 +-- ) + +local digitized_3 = Cs((p_fourbefore + p_beforecomma) * p_aftercomma^0) local splitmethods = { digitized_1, @@ -844,6 +849,7 @@ end -- "1,1", -- "12,12", -- "123,123", +-- "1234,123", -- "1234,1234", -- "12345,1234", -- "1234,12345", diff --git a/tex/context/base/x-mathml.mkiv b/tex/context/base/x-mathml.mkiv index 4c1146a7a..654d4f914 100644 --- a/tex/context/base/x-mathml.mkiv +++ b/tex/context/base/x-mathml.mkiv @@ -214,7 +214,9 @@ %D We start with the parent elements and the option handler. -\def\xmlmathmldirective#1{\dosetvalue{MML#1}} +\unexpanded\def\xmlmathmldirective#1{\dosetvalue{MML#1}} + +\xmlinstalldirective{mathml}{xmlmathmldirective} %def\xmlmathmldirective#1#2#3{[#1][#2][#3]\dosetvalue{MML#1}{#2}{#3}} @@ -383,7 +385,7 @@ % \MMLdoR % } { \edef\mmlapplyaction{\xmlfilter{#1}{/*/name()}} - \doifsetupselse {mml:apply:mml:\mmlapplyaction} { + \doifelsesetups {mml:apply:mml:\mmlapplyaction} { \xmlsetup{#1}{mml:apply:mml:\mmlapplyaction} } { % \MMLdoL @@ -404,7 +406,7 @@ \startxmlsetups mml:apply:mml:fn \xmldoifelse {#1} {/mml:fn/mml:ci} { \edef\mmlfnci{\xmlstripped{#1}{/mml:fn/mml:ci}}% was xmlcontent - \doifsetupselse{mmc:fn:\mmlfnci} { % was mmc:fn:... + \doifelsesetups{mmc:fn:\mmlfnci} { % was mmc:fn:... \xmlsetup{#1}{mmc:fn:\mmlfnci} % \MMLdoL/MMLdoR to be handled in plugin } { \MMLcreset @@ -471,7 +473,7 @@ \fi \xmldoifelse {#1} {/mml:ci} { % first \edef\mmlfnci{\xmltext{#1}{/mml:ci}}% was xmlcontent - \doifsetupselse{mmc:fn:\mmlfnci} { % was mmc:fn:... + \doifelsesetups{mmc:fn:\mmlfnci} { % was mmc:fn:... \xmlsetup{#1}{mmc:fn:\mmlfnci} % \MMLdoL/MMLdoR to be handled in plugin } { \MMLcreset @@ -502,7 +504,7 @@ \startxmlsetups mmc:fn:apply % where used? \xmldoifelse {#1} {/mml:ci} { % first \edef\mmlfnci{\xmltext{#1}{/mml:ci}}% was xmlcontent - \doifsetupselse{mmc:fn:\mmlfnci} { % was mmc:fn:... + \doifelsesetups{mmc:fn:\mmlfnci} { % was mmc:fn:... \xmlsetup{#1}{mmc:fn:\mmlfnci} % \MMLdoL/MMLdoR to be handled in plugin } { \MMLcreset @@ -532,12 +534,12 @@ % {\mr #4} \text{#4} } { - \doifsetupselse {mml:csymbol:#1} { + \doifelsesetups {mml:csymbol:#1} { % full url \fastsetup{mml:csymbol:#1} } { % somename (fallback) - \doifsetupselse {mml:csymbol:#2} { + \doifelsesetups {mml:csymbol:#2} { \fastsetup{mml:csymbol:#2} } { \xmlval{mmc:cs}{#3}{}% todo @@ -1056,7 +1058,7 @@ \let\MMLtimes@@symbol\MMLtimessymbol } { \xmldoifelse {#1} {/mml:cn[name(1) == 'mml:cn']} {% name(1) is next one - \doifinsetelse\MMLtimessymbol{\v!yes,\v!no} { + \doifelseinset\MMLtimessymbol{\v!yes,\v!no} { \let\MMLtimes@@symbol\v!yes } { \let\MMLtimes@@symbol\MMLtimessymbol @@ -2026,13 +2028,13 @@ \framed [frame=off,strut=no,background={\mmlmenclosenotation}] % offset is kind of undefined {\startimath - \expanded{\doifinsetelse {mml:enclose:longdiv} {\mmlmenclosenotation}} { + \expanded{\doifelseinset {mml:enclose:longdiv} {\mmlmenclosenotation}} { \overline{\left)\strut\xmlflush{#1}\right.} } { - \expanded{\doifinsetelse {mml:enclose:actuarial} {\mmlmenclosenotation}} { + \expanded{\doifelseinset {mml:enclose:actuarial} {\mmlmenclosenotation}} { \overline{\left.\strut\xmlflush{#1}\right|} } { - \expanded{\doifinsetelse {mml:enclose:radical} {\mmlmenclosenotation}} { + \expanded{\doifelseinset {mml:enclose:radical} {\mmlmenclosenotation}} { \sqrt{\xmlflush{#1}} } { \xmlflush{#1} diff --git a/tex/context/base/x-res-01.mkiv b/tex/context/base/x-res-01.mkiv index e234e9867..36070c615 100644 --- a/tex/context/base/x-res-01.mkiv +++ b/tex/context/base/x-res-01.mkiv @@ -256,7 +256,7 @@ \vfill } \advance\hsize by -30pt - \doifmodeelse {clipgrid-distance,clipgrid-steps} { + \doifelsemode {clipgrid-distance,clipgrid-steps} { \xmlsetup{#1}{xml:resource:a} } { \xmlsetup{#1}{xml:resource:b} diff --git a/tex/context/base/x-set-11.mkiv b/tex/context/base/x-set-11.mkiv index 53e172102..73e68e073 100644 --- a/tex/context/base/x-set-11.mkiv +++ b/tex/context/base/x-set-11.mkiv @@ -577,7 +577,7 @@ \startxmlsetups xml:setups:word \showSETUPcomponent{#1}{word} {word} \stopxmlsetups \def\showSETUPcomponent#1#2#3% - {\doifmodeelse{setups-pass-one} + {\doifelsemode{setups-pass-one} {\getvalue{showSETUP#2}{#1}} {\simpleSETUPargument{#3}}} @@ -612,7 +612,7 @@ \stopxmlsetups \startxmlsetups xml:setups:assignments - \doifmodeelse{setups-pass-one} { + \doifelsemode{setups-pass-one} { \showSETUPassignment{#1} } { \xdef\currentSETUPwidth{0pt}% @@ -634,7 +634,7 @@ \stopxmlsetups \startxmlsetups xml:setups:keywords - \doifmodeelse{setups-pass-one} { + \doifelsemode{setups-pass-one} { \showSETUPkeyword{#1} } { \startfirstSETUPcolumn{\showSETUPnumber}% @@ -670,7 +670,7 @@ \stopxmlsetups \startxmlsetups xml:setups:constant - \doifmodeelse {setups-pass-one} { + \doifelsemode {setups-pass-one} { } { \doif {\xmlatt{#1}{default}} {yes} { \underbar % next needs to be {braced} @@ -682,7 +682,7 @@ \stopxmlsetups \startxmlsetups xml:setups:variable - \doifmodeelse {setups-pass-one} { + \doifelsemode {setups-pass-one} { \expanded{\setupintfont{\xmlatt{#1}{value}}}\ignorespaces } { \c!setup!reserved!{\xmlatt{#1}{value}} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index e8f62413e..516fa7778 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 04/01/15 12:00:07 +-- merge date : 04/03/15 20:01:39 do -- begin closure to overcome local limits and interference |