diff options
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/bibl-bib.mkiv | 3 | ||||
-rw-r--r-- | tex/context/base/bibl-tra.mkiv | 5 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/strc-lst.lua | 53 | ||||
-rw-r--r-- | tex/context/base/strc-lst.mkiv | 34 | ||||
-rw-r--r-- | tex/generic/context/luatex-fonts-merged.lua | 2 |
7 files changed, 80 insertions, 21 deletions
diff --git a/tex/context/base/bibl-bib.mkiv b/tex/context/base/bibl-bib.mkiv index a2d194eee..9f8e8c55b 100644 --- a/tex/context/base/bibl-bib.mkiv +++ b/tex/context/base/bibl-bib.mkiv @@ -616,11 +616,12 @@ \doifelse{\bibtexpublicationsparameter\c!method}\v!local {\ctxlua{bibtex.hacks.reset(1)}}% function can take method {\ctxlua{bibtex.hacks.reset(2)}}% - \placestructurelist + \doplacestructurelist {\currentbibtexsession} {\currentbibtexcriterium} {\namedlistparameter\currentbibtexsession\c!number}% {\namedlistparameter\currentbibtexsession\c!extras}% + {\namedlistparameter\currentbibtexsession\c!order}% \ctxlua{bibtex.hacks.flush("\bibtexpublicationsparameter\c!sorttype")}% \doendoflist} diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv index fba750d82..a6a594d7f 100644 --- a/tex/context/base/bibl-tra.mkiv +++ b/tex/context/base/bibl-tra.mkiv @@ -825,11 +825,12 @@ {\ctxlua{bibtex.hacks.filterall()}} {\doif{\listparameter\c!criterium}\v!cite {\setuplist[pubs][\c!criterium=\v!here]}% - \placestructurelist + \doplacestructurelist {pubs}% {\listparameter\c!criterium}% {\listparameter\c!number}% - {\listparameter\c!extras}}% + {\listparameter\c!extras}% + {\listparameter\c!order}}% \ctxlua{bibtex.hacks.flush("\@@pbsorttype")}% \doendoflist} diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 2d46457a9..d767b1f03 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2010.12.13 20:58} +\newcontextversion{2010.12.13 22:59} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 9065429f9..dfecbb321 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2010.12.13 20:58} +\edef\contextversion{2010.12.13 22:59} %D For those who want to use this: diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua index 5e154b1d6..8278a66d9 100644 --- a/tex/context/base/strc-lst.lua +++ b/tex/context/base/strc-lst.lua @@ -196,7 +196,22 @@ local splitter = lpeg.splitat(":") -- this will become filtercollected(specification) and then we'll also have sectionblock as key -local function filtercollected(names, criterium, number, collected, forced, nested) -- names is hash or string +local sorters = { + [variables.command] = function(a,b) + if a.metadata.kind == "command" or b.metadata.kind == "command" then + return a.references.internal < b.references.internal + else + return a.references.order < b.references.order + end + end, + [variables.all] = function(a,b) + return a.references.internal < b.references.internal + end, +} + +-- some day soon we will pass a table + +local function filtercollected(names, criterium, number, collected, forced, nested, sortorder) -- names is hash or string local numbers, depth = documents.data.numbers, documents.data.depth local result, nofresult, detail = { }, 0, nil local block = false -- all @@ -252,7 +267,7 @@ local function filtercollected(names, criterium, number, collected, forced, nest end elseif criterium == variables.current then if depth == 0 then - return filtercollected(names,variables.intro,number,collected,forced) + return filtercollected(names,variables.intro,number,collected,forced,false,sortorder) else for i=1,#collected do local v = collected[i] @@ -285,7 +300,7 @@ local function filtercollected(names, criterium, number, collected, forced, nest elseif criterium == variables.here then -- this is quite dirty ... as cnumbers is not sparse we can misuse #cnumbers if depth == 0 then - return filtercollected(names,variables.intro,number,collected,forced) + return filtercollected(names,variables.intro,number,collected,forced,false,sortorder) else for i=1,#collected do local v = collected[i] @@ -318,7 +333,7 @@ local function filtercollected(names, criterium, number, collected, forced, nest end elseif criterium == variables.previous then if depth == 0 then - return filtercollected(names,variables.intro,number,collected,forced) + return filtercollected(names,variables.intro,number,collected,forced,false,sortorder) else for i=1,#collected do local v = collected[i] @@ -351,11 +366,11 @@ local function filtercollected(names, criterium, number, collected, forced, nest elseif criterium == variables["local"] then -- not yet ok local nested = nesting[#nesting] if nested then - return filtercollected(names,nested.name,nested.number,collected,forced,nested) + return filtercollected(names,nested.name,nested.number,collected,forced,nested,sortorder) elseif sections.autodepth(documents.data.numbers) == 0 then - return filtercollected(names,variables.all,number,collected,forced) + return filtercollected(names,variables.all,number,collected,forced,false,sortorder) else - return filtercollected(names,variables.current,number,collected,forced) + return filtercollected(names,variables.current,number,collected,forced,false,sortorder) end else -- sectionname, number -- not the same as register @@ -393,13 +408,35 @@ local function filtercollected(names, criterium, number, collected, forced, nest report_lists("criterium: %s, block: %s, found: %s",criterium,block or "*",#result) end end + + if sortorder then -- experiment + local sorter = sorters[sortorder] + if sorter then + if trace_lists then + report_lists("sorting list using method %s",sortorder) + end + for i=1,#result do + result[i].references.order = i + end + table.sort(result,sorter) + end + end + return result end lists.filtercollected = filtercollected function lists.filter(specification) - return filtercollected(specification.names, specification.criterium, specification.number, lists.collected, specification.forced) + return filtercollected( + specification.names, + specification.criterium, + specification.number, + lists.collected, + specification.forced, + false, + specification.order + ) end lists.result = { } diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv index f037ea6ae..7e20d25ec 100644 --- a/tex/context/base/strc-lst.mkiv +++ b/tex/context/base/strc-lst.mkiv @@ -88,6 +88,7 @@ internal = \nextinternalreference, block = "\currentstructureblock", % handy for lists, like bibl section = structures.sections.currentid(), + % location = "\currentlistlocation", }, metadata = { kind = "\currentlisttype", @@ -157,17 +158,18 @@ % \appendtoks % \to \everystructurelist -\unexpanded\def\placestructurelist#1#2#3#4% +\unexpanded\def\doplacestructurelist#1#2#3#4#5% beware, not a user command {\dostarttagged\t!list\empty \ctxlua{structures.lists.process { names = "#1", criterium = "#2", number = "#3", - extras = "#4" + extras = "#4", + order = "#5" }}% \dostoptagged} -\unexpanded\def\analyzestructurelist#1#2#3% +\unexpanded\def\doanalyzestructurelist#1#2#3% {\ctxlua{structures.lists.analyze { names = "#1", criterium = "#2", @@ -389,6 +391,23 @@ \let\dowritetolist \gobblefourarguments \let\dodowritetolist\gobblefourarguments + +%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 +%D default because otherwise users will wonder why spacing might get +%D messed up (due to an unseen but present node). It is possible to +%D force a location by explicitly setting \type {location} to \type +%D {here}. +%D +%D Another way to force a certain order is to set the \type {order} +%D variable when placing a list. The \type {command} option only +%D pushes commands into the right order, and \type {all} orders all +%D entries (which might be too much). In this case no specific +%D location is needed with the inbetween method. Maybe additional +%D mechanisms show up some day. See \type {inbetween-001.tex} for an +%D example. + % command : location=none % userdata : location=none % simple : location=here @@ -405,7 +424,6 @@ \dostructurelistinject[#1][\c!type=command][command={#3}]% \fi}} - \def\dowritedatatolist[#1][#2][#3]% we can overload location {\doif{\namedlistparameter{#1}\c!state}\v!start {\ifthirdargument @@ -440,11 +458,12 @@ \edef\currentlist{\firststructureelementinlist{#1}}% \the\everystructurelist \doif{\listparameter\c!coupling}\v!on{\startlistreferences{#1}}% - \placestructurelist + \doplacestructurelist {#1}% {\listparameter\c!criterium}% {\number\listparameter\c!number}% {\listparameter\c!extras}% + {\listparameter\c!order}% \stoplistreferences \endgroup \dosetlistmode} @@ -913,7 +932,7 @@ \dosetuplist[#1][#2]% \edef\currentlist{\firststructureelementinlist{#1}}% \the\everystructurelist - \analyzestructurelist{#1}{\listparameter\c!criterium}{\number\listparameter\c!number}% + \doanalyzestructurelist{#1}{\listparameter\c!criterium}{\number\listparameter\c!number}% \xdef\utilitylistlength{\structurelistsize}% \endgroup \dosetlistmode} @@ -955,11 +974,12 @@ \doif{\combinedlistparameter\c!coupling}\v!on{\startlistreferences{#1}}% \dobeginoflist \normalexpanded{\noexpand\dosetuplist[\combinedlist][#2]}% - \placestructurelist + \doplacestructurelist {\combinedlist}% {\combinedlistparameter\c!criterium}% {\combinedlistparameter\c!number}% {\combinedlistparameter\c!extras}% + {\combinedlistparameter\c!order}% \doendoflist \stoplistreferences \endgroup diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 6af528034..e2abae9eb 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 12/13/10 20:58:02 +-- merge date : 12/13/10 22:59:02 do -- begin closure to overcome local limits and interference |