From 4d9822eafe9e74e63e1f970e3cdf29d0f3b2cdd5 Mon Sep 17 00:00:00 2001
From: Marius <mariausol@gmail.com>
Date: Mon, 31 Jan 2011 00:33:48 +0200
Subject: beta 2011.01.26 09:01

---
 scripts/context/ruby/base/tex.rb            | 138 +-------
 scripts/context/ruby/ctxtools.rb            |   6 -
 scripts/context/ruby/mtxtools.rb            | 475 ----------------------------
 scripts/context/ruby/texexec.rb             |   6 +-
 scripts/context/ruby/texmfstart.rb          |   8 +-
 tex/context/base/anch-pos.mkiv              |  47 +--
 tex/context/base/cont-cs.mkii               |  15 +-
 tex/context/base/cont-cs.mkiv               |  11 +-
 tex/context/base/cont-de.mkii               |  15 +-
 tex/context/base/cont-de.mkiv               |  11 +-
 tex/context/base/cont-en.mkii               |  17 +-
 tex/context/base/cont-en.mkiv               |  11 +-
 tex/context/base/cont-fr.mkii               |  17 +-
 tex/context/base/cont-fr.mkiv               |  11 +-
 tex/context/base/cont-gb.mkii               |  17 +-
 tex/context/base/cont-gb.mkiv               |  11 +-
 tex/context/base/cont-it.mkii               |  17 +-
 tex/context/base/cont-it.mkiv               |  11 +-
 tex/context/base/cont-new.mkii              |   2 +-
 tex/context/base/cont-new.mkiv              |   2 +-
 tex/context/base/cont-nl.mkii               |  17 +-
 tex/context/base/cont-nl.mkiv               |  11 +-
 tex/context/base/cont-pe.mkiv               |  12 +-
 tex/context/base/cont-ro.mkii               |  16 +-
 tex/context/base/cont-ro.mkiv               |  11 +-
 tex/context/base/context.mkii               |  21 +-
 tex/context/base/context.mkiv               |  14 +-
 tex/context/base/context.rme                | 102 +++---
 tex/context/base/core-env.lua               |  20 ++
 tex/context/base/core-env.mkiv              |  23 +-
 tex/context/base/font-ctx.lua               |   4 +-
 tex/context/base/font-ini.mkiv              |  50 +--
 tex/context/base/lpdf-wid.lua               |  17 +
 tex/context/base/pack-obj.mkiv              |  90 +++---
 tex/context/base/s-inf-01.mkiv              | 224 -------------
 tex/context/base/s-inf-01.mkvi              | 244 ++++++++++++++
 tex/context/base/status-files.pdf           | Bin 0 -> 23909 bytes
 tex/context/base/type-ini.mkiv              |   2 +-
 tex/generic/context/luatex-fonts-merged.lua |   2 +-
 39 files changed, 578 insertions(+), 1150 deletions(-)
 delete mode 100644 scripts/context/ruby/mtxtools.rb
 delete mode 100644 tex/context/base/s-inf-01.mkiv
 create mode 100644 tex/context/base/s-inf-01.mkvi
 create mode 100644 tex/context/base/status-files.pdf

diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 72cf7dad0..2184447ce 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -87,8 +87,6 @@ class TEX
     @@texmethods      = Hash.new
     @@mpsmethods      = Hash.new
     @@pdftex          = 'pdftex' # new default, pdfetex is gone
-    @@luafiles        = "luafiles.tmp"
-    @@luatarget       = "lua/context"
 
     @@platformslash = if System.unix? then "\\\\" else "\\" end
 
@@ -96,7 +94,6 @@ class TEX
     ['aleph','omega']                              .each do |e| @@texengines[e] = 'aleph'     end
     ['xetex']                                      .each do |e| @@texengines[e] = 'xetex'     end
     ['petex']                                      .each do |e| @@texengines[e] = 'petex'     end
-    ['luatex']                                     .each do |e| @@texengines[e] = 'luatex'    end
 
     ['metapost','mpost', 'standard']               .each do |e| @@mpsengines[e] = 'mpost'     end
 
@@ -135,7 +132,7 @@ class TEX
     ['metafun','context','standard']               .each do |f| @@mpsformats[f] = 'metafun'   end
 
     ['pdftex','pdfetex','aleph','omega','petex',
-     'xetex','luatex']                             .each do |p| @@prognames[p]  = 'context'   end
+     'xetex']                                      .each do |p| @@prognames[p]  = 'context'   end
     ['mpost']                                      .each do |p| @@prognames[p]  = 'metafun'   end
     ['latex','pdflatex']                           .each do |p| @@prognames[p]  = 'latex'     end
 
@@ -161,7 +158,6 @@ class TEX
      'cont-pe','cont-xp']                         .each do |f| @@texprocstr[f] = @@platformslash + "emergencyend"  end
 
     @@runoptions['aleph']      = ['--8bit']
-    @@runoptions['luatex']     = ['--file-line-error']
     @@runoptions['mpost']      = ['--8bit']
     @@runoptions['pdfetex']    = ['--8bit']           # obsolete
     @@runoptions['pdftex']     = ['--8bit']           # pdftex is now pdfetex
@@ -169,11 +165,9 @@ class TEX
     @@runoptions['xetex']      = ['--8bit','-output-driver="xdvipdfmx -E -d 4 -V 5"']
     @@draftoptions['pdftex']   = ['--draftmode']
     @@synctexcoptions['pdftex'] = ['--synctex=1']
-    @@synctexcoptions['luatex'] = ['--synctex=1']
     @@synctexcoptions['xetex']  = ['--synctex=1']
 
     @@tcxflag['aleph']   = true
-    @@tcxflag['luatex']  = false
     @@tcxflag['mpost']   = false
     @@tcxflag['pdfetex'] = true
     @@tcxflag['pdftex']  = true
@@ -187,7 +181,7 @@ class TEX
         'nomapfiles', 'local',
         'arrange', 'noarrange',
         'forcexml', 'foxet',
-        'alpha', 'beta', 'luatex',
+        'alpha', 'beta',
         'mpyforce', 'forcempy',
         'forcetexutil', 'texutil',
         'globalfile', 'autopath',
@@ -429,7 +423,7 @@ class TEX
     def prefixed(format,engine)
         # format
         case engine
-           when /etex|pdftex|pdfetex|aleph|xetex|luatex/io then
+           when /etex|pdftex|pdfetex|aleph|xetex/io then
                "*#{format}"
            else
                format
@@ -577,39 +571,6 @@ class TEX
         return version
     end
 
-    def cleanupluafiles
-        File.delete(@@luafiles) rescue false
-    end
-
-    def compileluafiles
-        begin
-            Dir.glob("lua/context/*.luc").each do |luc|
-                File.delete(luc) rescue false
-            end
-        rescue
-        end
-        if data = (IO.readlines(@@luafiles) rescue nil) then
-            report("compiling lua files (using #{File.expand_path(@@luafiles)})")
-            begin
-                FileUtils.makedirs(@@luatarget) rescue false
-                data.each do |line|
-                    luafile = line.chomp
-                    lucfile = File.basename(luafile).gsub(/\..*?$/,'') + ".luc"
-                    if runcommand(["luac","-s","-o",quoted(File.join(Dir.getwd,@@luatarget,lucfile)),quoted(luafile)]) then
-                        report("#{File.basename(luafile)} converted to #{File.basename(lucfile)}")
-                    else
-                        report("#{File.basename(luafile)} not converted to #{File.basename(lucfile)}")
-                    end
-                end
-            rescue
-                report("fatal error in compilation")
-            end
-        else
-            report("no lua compilations needed")
-        end
-        File.delete(@@luafiles) rescue false
-    end
-
     # we need engine methods
 
     def makeformats
@@ -622,14 +583,6 @@ class TEX
         else
             report('updating file database')
             Kpse.update # obsolete here
-            if getvariable('luatex') then
-                begin
-                    runcommand(["luatools","--generate","--verbose"])
-                rescue
-                    report("run 'luatools --generate' manualy")
-                    exit
-                end
-            end
         end
         # goody
         if getvariable('texformats') == 'standard' then
@@ -662,22 +615,10 @@ class TEX
             #       makeuserfile
             #       makeresponsefile
             #   end
-                if texengine == 'luatex' then
-                    cleanupluafiles
-                    texformats.each do |texformat|
-                        report("generating tex format #{texformat}")
-                        flags = ['--ini','--compile']
-                        flags << '--verbose' if getvariable('verbose')
-                        flags << '--mkii'    if getvariable('mkii')
-                        run_luatools("#{flags.join(" ")} #{texformat}")
-                    end
-                    compileluafiles
-                else
-                    texformats.each do |texformat|
-                        report("generating tex format #{texformat}")
-                        progname = validprogname([getvariable('progname'),texformat,texengine])
-                        runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag(texengine),prefixed(texformat,texengine),texmakeextras(texformat)])
-                    end
+                texformats.each do |texformat|
+                    report("generating tex format #{texformat}")
+                    progname = validprogname([getvariable('progname'),texformat,texengine])
+                    runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag(texengine),prefixed(texformat,texengine),texmakeextras(texformat)])
                 end
             else
                 report("unable to make format due to lack of permissions")
@@ -732,15 +673,6 @@ class TEX
                 end
             end
         end
-        begin
-            lucdir = File.join(texformatpath,@@luatarget)
-            Dir.chdir(lucdir)
-        rescue
-        else
-            Dir.glob("*.luc").each do |file|
-                report("luc: #{filestate(file)} > #{File.expand_path(file)} (#{File.size(file)})")
-            end
-        end
         # to be sure, go back to current path
         begin
             Dir.chdir(savedpath)
@@ -785,7 +717,7 @@ class TEX
                     f.close
                     if FileTest.file?(tempfilename('tex')) then
                         format = File.basename(name)
-                        engine = if name =~ /(pdftex|pdfetex|aleph|xetex|luatex)[\/\\]#{format}/ then $1 else '' end
+                        engine = if name =~ /(pdftex|pdfetex|aleph|xetex)[\/\\]#{format}/ then $1 else '' end
                         if engine.empty? then
                             engineflag = ""
                         else
@@ -835,7 +767,7 @@ class TEX
 
     private
 
-    def makeuserfile # not used in luatex (yet)
+    def makeuserfile
         language = getvariable('language')
         mainlanguage = getvariable('mainlanguage')
         bodyfont = getvariable('bodyfont')
@@ -1183,24 +1115,6 @@ class TEX
 
     public
 
-    # def run_luatools(args)
-        # dirty trick: we know that the lua path is relative to the ruby path; of course this
-        # will not work well when stubs are used
-        # [(ENV["_CTX_K_S_texexec_"] or ENV["_CTX_K_S_THREAD_"] or ENV["TEXMFSTART.THREAD"]), File.dirname($0)].each do |path|
-            # if path then
-                # script = "#{path}/../lua/luatools.lua"
-                # if FileTest.file?(script) then
-                    # return runcommand("luatex --luaonly #{script} #{args}")
-                # end
-            # end
-        # end
-        # return runcommand("texmfstart luatools #{args}")
-    # end
-
-    def run_luatools(args)
-        return runcommand("luatools #{args}")
-    end
-
     def processmpgraphic
         getarrayvariable('files').each do |filename|
             setvariable('filename',filename)
@@ -1588,17 +1502,8 @@ end
         report("tex format: #{texformat}")
         if texengine && texformat then
             fixbackendvars(@@mappaths[texengine])
-            if texengine == "luatex" then
-                # currently we use luatools to start luatex but some day we should
-                # find a clever way to directly call luatex (problem is that we need
-                # to feed the explicit location of the format and lua initialization
-                # file)
-                run_luatools("--fmt=#{texformat} #{filename}")
-            else
-                progname = validprogname([getvariable('progname'),texformat,texengine])
-                runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag(texengine),runoptions(texengine),filename,texprocextras(texformat)])
-            end
-            # true
+            progname = validprogname([getvariable('progname'),texformat,texengine])
+            runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag(texengine),runoptions(texengine),filename,texprocextras(texformat)])
         else
             false
         end
@@ -1677,24 +1582,6 @@ end
         end
     end
 
-    def runluacheck(jobname)
-        if false then
-            # test-pos.tex / 6 meg tua file: 18.6 runtime
-            old, new = File.suffixed(jobname,'tua'), File.suffixed(jobname,'tuc')
-            if FileTest.file?(old) then
-                report("converting #{old} into #{new}")
-                system("luac -s -o #{new} #{old}")
-            end
-        else
-            # test-pos.tex / 6 meg tua file: 17.5 runtime
-            old, new = File.suffixed(jobname,'tua'), File.suffixed(jobname,'tuc')
-            if FileTest.file?(old) then
-                report("renaming #{old} into #{new}")
-                File.rename(old,new) rescue false
-            end
-        end
-    end
-
     # 1=tex 2=mptex 3=mpxtex 4=mpgraphic 5=mpstatic
 
     def runtexexec(filename=[], options=[], mode=nil)
@@ -1932,7 +1819,6 @@ end
                         ok = runtex(if dummyfile || forcexml then rawbase else rawname end)
                         if ok then
                             ok = runtexutil(rawbase) if getvariable('texutil') || getvariable('forcetexutil')
-                            runluacheck(rawbase)
                             runbackend(rawbase)
                             popresult(rawbase,result)
                         end
@@ -1983,7 +1869,6 @@ end
                                     mprundone = runtexmpjob(rawbase, "mprun")
                                 end
                                 ok = runtexutil(rawbase)
-                                runluacheck(rawbase)
                                 state.update
                                 stoprunning = state.stable?
                             end
@@ -1993,7 +1878,6 @@ end
                         end
                         if (nofruns == 1) && getvariable('texutil') then
                             ok = runtexutil(rawbase)
-                            runluacheck(rawbase)
                         end
                         if ok && finalrun && (nofruns > 1) then
                             makeoptionfile(rawbase,jobname,orisuffix,true,finalrun,4,texruns) unless getvariable('nooptionfile')
diff --git a/scripts/context/ruby/ctxtools.rb b/scripts/context/ruby/ctxtools.rb
index 9407be79c..339f3d490 100644
--- a/scripts/context/ruby/ctxtools.rb
+++ b/scripts/context/ruby/ctxtools.rb
@@ -1853,8 +1853,6 @@ class Commands
                             ok = data.add_shebang(filename,'perl')
                         when /\.py$/ then
                             ok = data.add_shebang(filename,'python')
-                        when /\.lua$/ then
-                            ok = data.add_shebang(filename,'lua')
                         when /\.tex$/ then
                             ok = data.add_directive(filename,'tex')
                         when /\.mp$/ then
@@ -2697,11 +2695,7 @@ class Commands
 
         def remakeformats
             system("mktexlsr")
-            system("luatools --selfupdate")
-            system("mtxrun --selfupdate")
-            system("luatools --generate")
             system("texmfstart texexec --make --all  --fast --pdftex")
-            system("texmfstart texexec --make --all  --fast --luatex")
             system("texmfstart texexec --make --all  --fast --xetex")
             return true
         end
diff --git a/scripts/context/ruby/mtxtools.rb b/scripts/context/ruby/mtxtools.rb
deleted file mode 100644
index 41d0f7085..000000000
--- a/scripts/context/ruby/mtxtools.rb
+++ /dev/null
@@ -1,475 +0,0 @@
-#!/usr/bin/env ruby
-
-# program   : mtxtools
-# copyright : PRAGMA Advanced Document Engineering
-# version   : 2004-2005
-# author    : Hans Hagen
-#
-# info      : j.hagen@xs4all.nl
-# www       : www.pragma-ade.com
-
-# This script hosts MetaTeX related features.
-
-banner = ['MtxTools', 'version 1.0.0', '2006', 'PRAGMA ADE/POD']
-
-$: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq!
-
-require 'base/switch'
-require 'base/logger'
-require 'base/system'
-require 'base/kpse'
-
-class Reporter
-    def report(str)
-        puts(str)
-    end
-end
-
-module ConTeXt
-
-    def ConTeXt::banner(filename,companionname,compact=false)
-        "-- filename : #{File.basename(filename)}\n" +
-        "-- comment  : companion to #{File.basename(companionname)} (in ConTeXt)\n" +
-        "-- author   : Hans Hagen, PRAGMA-ADE, Hasselt NL\n" +
-        "-- copyright: PRAGMA ADE / ConTeXt Development Team\n" +
-        "-- license  : see context related readme files\n" +
-        if compact then "\n-- remark   : compact version\n" else "" end
-    end
-
-end
-
-class UnicodeTables
-
-    @@version = "1.001"
-
-    @@shape_a = /^((GREEK|LATIN|HEBREW)\s*(SMALL|CAPITAL|)\s*LETTER\s*[A-Z]+)$/
-    @@shape_b = /^((GREEK|LATIN|HEBREW)\s*(SMALL|CAPITAL|)\s*LETTER\s*[A-Z]+)\s*(.+)$/
-
-    @@shape_a = /^(.*\s*LETTER\s*[A-Z]+)$/
-    @@shape_b = /^(.*\s*LETTER\s*[A-Z]+)\s+WITH\s+(.+)$/
-
-    attr_accessor :context, :comment
-
-    def initialize(logger=Reporter.new)
-        @data    = Array.new
-        @logger  = logger
-        @error   = false
-        @context = true
-        @comment = true
-        @shapes  = Hash.new
-    end
-
-    def load_unicode_data(filename='unicodedata.txt')
-        # beware, the unicodedata table is bugged, sometimes ending
-        @logger.report("reading base data from #{filename}") if @logger
-        begin
-            IO.readlines(filename).each do |line|
-                if line =~ /^[0-9A-F]{4,4}/ then
-                    d = line.chomp.sub(/\;$/, '').split(';')
-                    if d then
-                        while d.size < 15 do d << '' end
-                        n = d[0].hex
-                        @data[n] = d
-                        if d[1] =~ @@shape_a then
-                            @shapes[$1] = d[0]
-                        end
-                    end
-                end
-            end
-        rescue
-            @error = true
-            @logger.report("error while reading base data from #{filename}") if @logger
-        end
-    end
-
-    def load_context_data(filename='contextnames.txt')
-        @logger.report("reading data from #{filename}") if @logger
-        begin
-            IO.readlines(filename).each do |line|
-                if line =~ /^[0-9A-F]{4,4}/ then
-                    d = line.chomp.split(';')
-                    if d then
-                        n = d[0].hex
-                        if @data[n] then
-                            @data[d[0].hex] << d[1] # adobename   == 15
-                            @data[d[0].hex] << d[2] # contextname == 16
-                        else
-                            @logger.report("missing information about #{d} in #{filename}") if @logger
-                        end
-                    end
-                end
-            end
-        rescue
-            @error = true
-            @logger.report("error while reading context data from #{filename}") if @logger
-        end
-    end
-
-    def save_metatex_data(filename='char-def.lua',compact=false)
-        if not @error then
-            begin
-                File.open(filename,'w') do |f|
-                    @logger.report("saving data in #{filename}") if @logger
-                    f << ConTeXt::banner(filename,'char-def.tex',compact)
-                    f << "\n"
-                    f << "\nif not versions then versions = { } end versions['#{filename.gsub(/\..*?$/,'')}'] = #{@@version}\n"
-                    f << "\n"
-                    f << "if not characters      then characters      = { } end\n"
-                    f << "if not characters.data then characters.data = { } end\n"
-                    f << "\n"
-                    f << "characters.data = {\n" if compact
-                    @data.each do |d|
-                        if d then
-                            r = metatex_data(d)
-                            if compact then
-                                f << "\t" << "[0x#{d[0]}]".rjust(8,' ') << " = { #{r.join(", ").gsub(/\t/,'')} }, \n"
-                            else
-                                f << "characters.define { -- #{d[0].hex}" << "\n"
-                                f << r.join(",\n") << "\n"
-                                f << "}" << "\n"
-                            end
-                        end
-                    end
-                    f << "}\n" if compact
-                end
-            rescue
-                @logger.report("error while saving data in #{filename}") if @logger
-            else
-                @logger.report("#{@data.size} (#{sprintf('%X',@data.size)}) entries saved in #{filename}") if @logger
-            end
-        else
-            @logger.report("not saving data in #{filename} due to previous error") if @logger
-        end
-    end
-
-    def metatex_data(d)
-        r = Array.new
-        r << "\tunicodeslot=0x#{d[0]}"
-        if d[2] && ! d[2].empty? then
-            r << "\tcategory='#{d[2].downcase}'"
-        end
-        if @context then
-            if d[15] && ! d[15].empty? then
-                r << "\tadobename='#{d[15]}'"
-            end
-            if d[16] && ! d[16].empty? then
-                r << "\tcontextname='#{d[16]}'"
-            end
-        end
-        if @comment then
-            if d[1] == "<control>" then
-                r << "\tdescription='#{d[10]}'" unless d[10].empty?
-            else
-                r << "\tdescription='#{d[1]}'" unless d[1].empty?
-            end
-        end
-        if d[1] =~ @@shape_b then
-            r << "\tshcode=0x#{@shapes[$1]}" if @shapes[$1]
-        end
-        if d[12] && ! d[12].empty? then
-            r << "\tuccode=0x#{d[12]}"
-        elsif d[14] && ! d[14].empty? then
-            r << "\tuccode=0x#{d[14]}"
-        end
-        if d[13] && ! d[13].empty? then
-            r << "\tlccode=0x#{d[13]}"
-        end
-        if d[5] && ! d[5].empty? then
-            special, specials = '', Array.new
-            c = d[5].split(/\s+/).collect do |cc|
-                if cc =~ /^\<(.*)\>$/io then
-                    special = $1.downcase
-                else
-                    specials << "0x#{cc}"
-                end
-            end
-            if specials.size > 0 then
-                special = 'char' if special.empty?
-                r << "\tspecials={'#{special}',#{specials.join(',')}}"
-            end
-        end
-        return r
-    end
-
-    def save_xetex_data(filename='enco-utf.tex')
-        if not @error then
-            begin
-                minnumber, maxnumber, n = 0x001F, 0xFFFF, 0
-                File.open(filename,'w') do |f|
-                    @logger.report("saving data in #{filename}") if @logger
-                    f << "% filename : #{filename}\n"
-                    f << "% comment  : poor man's alternative for a proper enco file\n"
-                    f << "%            this file is generated by mtxtools and can be\n"
-                    f << "%            used in xetex and luatex mkii mode\n"
-                    f << "% author   : Hans Hagen, PRAGMA-ADE, Hasselt NL\n"
-                    f << "% copyright: PRAGMA ADE / ConTeXt Development Team\n"
-                    f << "% license  : see context related readme files\n"
-                    f << "\n"
-                    f << "\\ifx\\setcclcucx\\undefined\n"
-                    f << "\n"
-                    f << "  \\def\\setcclcucx #1 #2 #3 %\n"
-                    f << "    {\\global\\catcode\"#1=11 \n"
-                    f << "     \\global\\lccode \"#1=\"#2 \n"
-                    f << "     \\global\\uccode \"#1=\"#3 }\n"
-                    f << "\n"
-                    f << "\\fi\n"
-                    f << "\n"
-                    @data.each do |d|
-                        if d then
-                            number, type = d[0], d[2].downcase
-                            if number.hex >= minnumber && number.hex <= maxnumber && type =~ /^l(l|u|t)$/o then
-                                if d[13] && ! d[13].empty? then
-                                    lc = d[13]
-                                else
-                                    lc = number
-                                end
-                                if d[12] && ! d[12].empty? then
-                                    uc = d[12]
-                                elsif d[14] && ! d[14].empty? then
-                                    uc = d[14]
-                                else
-                                    uc = number
-                                end
-                                if @comment then
-                                    f << "\\setcclcuc #{number} #{lc} #{uc} % #{d[1]}\n"
-                                else
-                                    f << "\\setcclcuc #{number} #{lc} #{uc} \n"
-                                end
-                                n += 1
-                            end
-                        end
-                    end
-                    f << "\n"
-                    f << "\\endinput\n"
-                end
-            rescue
-                @logger.report("error while saving data in #{filename}") if @logger
-            else
-                @logger.report("#{n} entries saved in #{filename}") if @logger
-            end
-        else
-            @logger.report("not saving data in #{filename} due to previous error") if @logger
-        end
-    end
-
-end
-
-class RegimeTables
-
-    @@version = "1.001"
-
-    def initialize(logger=Reporter.new)
-        @logger = logger
-        reset
-    end
-
-    def reset
-        @code, @regime, @filename, @loaded = Array.new(256), '', '', false
-        (32..127).each do |i|
-            @code[i] = [sprintf('%04X',i), i.chr]
-        end
-    end
-
-    def load(filename)
-        begin
-            reset
-            if filename =~ /regi\-(ini|run|uni|utf|syn)/ then
-                report("skipping #{filename}")
-            else
-                report("loading file #{filename}")
-                @regime, unicodeset = File.basename(filename).sub(/\..*?$/,''), false
-                IO.readlines(filename).each do |line|
-                    case line
-                        when /^\#/ then
-                            # skip
-                        when /^(0x[0-9A-F]+)\s+(0x[0-9A-F]+)\s+\#\s+(.*)$/ then
-                            @code[$1.hex], unicodeset = [$2, $3], true
-                        when /^(0x[0-9A-F]+)\s+(0x[0-9A-F]+)\s+/ then
-                            @code[$1.hex], unicodeset = [$2, ''], true
-                    end
-                end
-                reset if not unicodeset
-            end
-        rescue
-            report("problem in loading file #{filename}")
-            reset
-        else
-            if ! @regime.empty? then
-                @loaded = true
-            else
-                reset
-            end
-        end
-    end
-
-    def save(filename,compact=false)
-        begin
-            if @loaded && ! @regime.empty? then
-                if File.expand_path(filename) == File.expand_path(@filename) then
-                    report("saving in #{filename} is blocked")
-                else
-                    report("saving file #{filename}")
-                    File.open(filename,'w') do |f|
-                        f << ConTeXt::banner(filename,'regi-ini.tex',compact)
-                        f << "\n"
-                        f << "\nif not versions then versions = { } end versions['#{filename.gsub(/\..*?$/,'')}'] = #{@@version}\n"
-                        f << "\n"
-                        f << "if not regimes      then regimes      = { } end\n"
-                        f << "if not regimes.data then regimes.data = { } end\n"
-                        f << "\n"
-                        if compact then
-                            f << "regimes.data[\"#{@regime}\"] = { [0] = \n\t"
-                            i = 17
-                            @code.each_index do |c|
-                                if (i-=1) == 0 then
-                                    i = 16
-                                    f << "\n\t"
-                                end
-                                if @code[c] then
-                                    f << @code[c][0].rjust(6,' ')
-                                else
-                                    f << "0x0000".rjust(6,' ')
-                                end
-                                f << ', ' if c<@code.length-1
-                            end
-                            f << "\n}\n"
-                        else
-                            @code.each_index do |c|
-                                if @code[c] then
-                                    f << someregimeslot(@regime,c,@code[c][0],@code[c][1])
-                                else
-                                    f << someregimeslot(@regime,c,'','')
-                                end
-                            end
-                        end
-                    end
-                end
-            end
-        rescue
-            report("problem in saving file #{filename} #{$!}")
-        end
-    end
-
-    def report(str)
-        @logger.report(str)
-    end
-
-    private
-
-    def someregimeslot(regime,slot,unicodeslot,comment)
-        "regimes.define { #{if comment.empty? then '' else '-- ' end} #{comment}\n" +
-            "\tregime='#{regime}',\n" +
-            "\tslot='#{sprintf('0x%02X',slot)}',\n" +
-            "\tunicodeslot='#{if unicodeslot.empty? then '0x0000' else unicodeslot end}'\n" +
-        "}\n"
-    end
-
-    public
-
-    def RegimeTables::convert(filenames,compact=false)
-        filenames.each do |filename|
-            txtfile = File.expand_path(filename)
-            luafile = File.join(File.dirname(txtfile),'regi-'+File.basename(txtfile.sub(/\..*?$/, '.lua')))
-            unless txtfile == luafile then
-                regime = RegimeTables.new
-                regime.load(txtfile)
-                regime.save(luafile,compact)
-            end
-        end
-    end
-
-end
-
-class Commands
-
-    include CommandBase
-
-    def unicodetable
-        unicode = UnicodeTables.new(logger)
-        unicode.load_unicode_data
-        unicode.load_context_data
-        unicode.save_metatex_data('char-def.lua',@commandline.option('compact'))
-    end
-
-    def xetextable
-        unicode = UnicodeTables.new(logger)
-        unicode.load_unicode_data
-        unicode.load_context_data
-        # unicode.comment = false
-        unicode.save_xetex_data
-    end
-
-    def regimetable
-        if @commandline.arguments.length > 0 then
-            RegimeTables::convert(@commandline.arguments, @commandline.option('compact'))
-        else
-            RegimeTables::convert(Dir.glob("cp*.txt")   , @commandline.option('compact'))
-            RegimeTables::convert(Dir.glob("8859*.txt") , @commandline.option('compact'))
-        end
-    end
-
-    def pdftextable
-        # instead of directly saving the data, we use luatex (kind of test)
-        pdfrdef = 'pdfr-def.tex'
-        tmpfile = 'mtxtools.tmp'
-        File.delete(pdfrdef) rescue false
-        if f = File.open(tmpfile,'w') then
-            f << "\\starttext\n"
-            f << "\\ctxlua{characters.pdftex.make_pdf_to_unicodetable('#{pdfrdef}')}\n"
-            f << "\\stoptext\n"
-            f.close()
-            system("texmfstart texexec --luatex --once --purge mtxtools.tmp")
-            report("vecor saved in #{pdfrdef}")
-        end
-        File.delete(tmpfile) rescue false
-    end
-
-    def xmlmapfile
-        # instead of directly saving the data, we use luatex (kind of test)
-        tmpfile   = 'mtxtools.tmp'
-        xmlsuffix = 'frx'
-        @commandline.arguments.each do |mapname|
-            if f = File.open(tmpfile,'w') then
-                xmlname = mapname.gsub(/\.map$/,".#{xmlsuffix}")
-                File.delete(xmlname) rescue false
-                f << "\\starttext\n"
-                f << "\\ctxlua{\n"
-                f << "  mapname = input.find_file(texmf.instance,'#{mapname}') or ''\n"
-                f << "  xmlname = '#{xmlname}'\n"
-                f << "  if mapname and not mapname:is_empty() then\n"
-                f << "    ctx.fonts.map.convert_file(mapname,xmlname)\n"
-                f << "  end\n"
-                f << "}\n"
-                f << "\\stoptext\n"
-                f.close()
-                system("texmfstart texexec --luatex --once --purge mtxtools.tmp")
-                if FileTest.file?(xmlname) then
-                    report("map file #{mapname} converted to #{xmlname}")
-                else
-                    report("no valid map file #{mapname}")
-                end
-            end
-        end
-        File.delete(tmpfile) rescue false
-    end
-
-end
-
-logger      = Logger.new(banner.shift)
-commandline = CommandLine.new
-
-commandline.registeraction('unicodetable', 'create unicode table for metatex/luatex')
-commandline.registeraction('regimetable' , 'create regime table(s) for metatex/luatex [--compact]')
-commandline.registeraction('xetextable'  , 'create unicode table for xetex')
-commandline.registeraction('pdftextable' , 'create unicode table for xetex')
-commandline.registeraction('xmlmapfile'  , 'convert traditional mapfile to xml font resourse')
-
-# general
-
-commandline.registeraction('help')
-commandline.registeraction('version')
-commandline.registerflag('compact')
-
-commandline.expand
-
-Commands.new(commandline,logger,banner).send(commandline.action || 'help')
diff --git a/scripts/context/ruby/texexec.rb b/scripts/context/ruby/texexec.rb
index 4a08c3b61..32c9d0ca5 100644
--- a/scripts/context/ruby/texexec.rb
+++ b/scripts/context/ruby/texexec.rb
@@ -587,8 +587,6 @@ job.setvariable('given.backend',job.getvariable('backend'))
 
         if (str = @commandline.option('engine')) && ! str.standard? && ! str.empty? then
             job.setvariable('texengine',str)
-        elsif @commandline.oneof('luatex') then
-            job.setvariable('texengine','luatex')
         elsif @commandline.oneof('pdfetex','pdftex','pdf') then
             job.setvariable('texengine','pdftex')
         elsif @commandline.oneof('xetex','xtx') then
@@ -603,7 +601,7 @@ job.setvariable('given.backend',job.getvariable('backend'))
 
         if (str = @commandline.option('backend')) && ! str.standard? && ! str.empty? then
             job.setvariable('backend',str)
-        elsif @commandline.oneof('pdfetex','pdftex','pdf','luatex') then
+        elsif @commandline.oneof('pdfetex','pdftex','pdf') then
             job.setvariable('backend','pdftex')
         elsif @commandline.oneof('dvipdfmx','dvipdfm','dpx','dpm') then
             job.setvariable('backend','dvipdfmx')
@@ -621,7 +619,6 @@ job.setvariable('given.backend',job.getvariable('backend'))
             case job.getvariable('texengine')
                 when 'pdfetex'  then job.setvariable('backend','pdftex')
                 when 'pdftex'   then job.setvariable('backend','pdftex')
-                when 'luatex'   then job.setvariable('backend','pdftex')
                 when 'xetex'    then job.setvariable('backend','xetex')
                 when 'petex'    then job.setvariable('backend','dvipdfmx')
                 when 'aleph'    then job.setvariable('backend','dvipdfmx')
@@ -761,7 +758,6 @@ end
 commandline.registerflag('pdf')
 commandline.registerflag('pdftex')
 commandline.registerflag('pdfetex')
-commandline.registerflag('luatex')
 
 commandline.registerflag('dvipdfmx')
 commandline.registerflag('dvipdfm')
diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb
index 97087c3ae..be892c83c 100644
--- a/scripts/context/ruby/texmfstart.rb
+++ b/scripts/context/ruby/texmfstart.rb
@@ -158,7 +158,6 @@ $runners      = Hash.new
 $suffixinputs['pl']  = 'PERLINPUTS'
 $suffixinputs['rb']  = 'RUBYINPUTS'
 $suffixinputs['py']  = 'PYTHONINPUTS'
-$suffixinputs['lua'] = 'LUAINPUTS'
 $suffixinputs['jar'] = 'JAVAINPUTS'
 $suffixinputs['pdf'] = 'PDFINPUTS'
 
@@ -183,7 +182,6 @@ $predefined['pdftools'] = 'pdftools.rb'
 $predefined['mpstools'] = 'mpstools.rb'
 # $predefined['exatools'] = 'exatools.rb'
 $predefined['xmltools'] = 'xmltools.rb'
-# $predefined['luatools'] = 'luatools.lua'
 # $predefined['mtxtools'] = 'mtxtools.rb'
 
 $predefined['newpstopdf']   = 'pstopdf.rb'
@@ -213,12 +211,11 @@ $makelist = [
     'texfind',
     'texshow'
     #
-    # no 'luatools',
     # no 'mtxtools',
     # no, 'texmfstart'
 ]
 
-$scriptlist   = 'rb|pl|py|lua|jar'
+$scriptlist   = 'rb|pl|py|jar'
 $documentlist = 'pdf|ps|eps|htm|html'
 
 $editor       = ENV['TEXMFSTART_EDITOR'] || ENV['EDITOR'] || ENV['editor'] || 'scite'
@@ -230,7 +227,6 @@ def set_applications(page=1)
 
     $applications['unknown']  = ''
     $applications['ruby']     = $applications['rb']  = 'ruby'
-    $applications['lua']      = $applications['lua'] = 'lua'
     $applications['perl']     = $applications['pl']  = 'perl'
     $applications['python']   = $applications['py']  = 'python'
     $applications['java']     = $applications['jar'] = 'java'
@@ -248,8 +244,6 @@ def set_applications(page=1)
     $applications['htm']      = $applications['html']
     $applications['eps']      = $applications['ps']
 
-    $runners['lua']           = "texlua"
-
 end
 
 set_applications()
diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv
index 69d3525c6..888cb60eb 100644
--- a/tex/context/base/anch-pos.mkiv
+++ b/tex/context/base/anch-pos.mkiv
@@ -154,12 +154,6 @@
 
 \setnewconstant\positionanchormode\plusone
 
-%D The core set macros.
-
-\let\pospxy    \gobblefourarguments
-\let\pospxywhd \gobblesevenarguments
-\let\pospxyplus\gobbleeightarguments
-
 %D Sometimes we want to trick the position handler a bit:
 
 \def\replacepospxywhd#1#2#3#4#5#6#7{\ctxlua{commands.replacepospxywhd('#1',\number#2,"\the\dimexpr#3\relax","\the\dimexpr#4\relax","\the\dimexpr#5\relax","\the\dimexpr#6\relax","\the\dimexpr#7\relax")}}
@@ -178,34 +172,26 @@
 %D not applicable when the content floats indeed. In such
 %D situations one can treat positions and graphics local.
 
-\newif\iflocalpositioning
+\newif\iflocalpositioning % todo: conditional
 
 %D Watch out: sometimes a pagebreak occurs inside a float
 %D placement, so there we need to disable local mode.
 
 \appendtoks
-  \localpositioningtrue
+    \localpositioningtrue
 \to \everyinsidefloat
 
 \appendtoks
-  \localpositioningfalse
+    \localpositioningfalse
 \to \everypagebody
 
-%D Since the positional values are to be fully expandable, we
-%D need to preload them as soon as possible, which is why we
-%D load the data when we start a text.
-
-% \appendtoks \checkpositions \to \everystarttext
-
 %D \macros
 %D   {MPp, MPx, MPy, MPw, MPh, MPd,
 %D    MPxy, MPll, MPlr, MPur, MPul, MPpos}
 %D
 %D Access to the positional information is provided by macros
-%D with short names that are clearly meant for \METAPOST.
-
-% \the\dimexpr\noexpand\lastsavedpositionx\ifnum\positionanchormode=\plusone-\MPx\pageanchor\fi\relax
-% \the\dimexpr\noexpand\lastsavedpositiony\ifnum\positionanchormode=\plusone-\MPx\pageanchor\fi\relax
+%D with short names that are clearly meant for \METAPOST\ but
+%D nowadays also used for other purposes.
 
 \def\MPp  #1{\ctxlua{commands.MPp("#1")}}
 \def\MPx  #1{\ctxlua{commands.MPx("#1")}}
@@ -250,14 +236,6 @@
 
 \def\MPanchor{\MPpos}
 
-%D \macros
-%D   {POSp, POSx, POSy, POSh, POSd, POSw}
-%D
-%D and:
-
-\def\POSp{\MPp} \def\POSx{\MPx} \def\POSy{\MPy}
-\def\POSh{\MPh} \def\POSd{\MPd} \def\POSw{\MPw}
-
 %D There are two low level positioning macros. Both store the
 %D position as well as execute an action associated with that
 %D position.
@@ -758,7 +736,7 @@
 %D    doifpositionsonthispageelse}
 %D
 %D Instead of letting the user handle fuzzy expansion, we
-%D provide a simple test on positione being on the same page.
+%D provide a simple test on positions being on the same page.
 %D
 %D \starttyping
 %D \doifpositionsonsamepageelse{point a}{point b}
@@ -769,9 +747,11 @@
 %D   {action when not on this page}
 %D \stoptyping
 
+% todo: move to lua when we really use it
+
 \def\dododoifpositionsonsamepageelse#1%
   {\ifcase\scratchcounter
-     \scratchcounter\MPp{##}\donetrue
+     \scratchcounter\MPp{#1}\donetrue
    \else
      \ifnum\scratchcounter=\MPp{#1}\relax\else\donefalse\fi
    \fi}%
@@ -786,8 +766,8 @@
      \endgroup\expandafter\secondoftwoarguments
    \fi}
 
-\def\doifpositionsonsamepageelse{\dodoifpositionsonsamepageelse\!!zerocount}
-\def\doifpositionsonthispageelse{\dodoifpositionsonsamepageelse\realfolio  }
+\def\doifpositionsonsamepageelse{\dodoifpositionsonsamepageelse\zerocount }
+\def\doifpositionsonthispageelse{\dodoifpositionsonsamepageelse\realpageno}
 
 %D Plugins:
 
@@ -796,6 +776,11 @@
 
 \let\MPanchor\MPpos
 
+%D \macros
+%D   {POSp, POSx, POSy, POSh, POSd, POSw}
+%D
+%D This is obsolete in \MKIV:
+
 \let\POSp\MPp \let\POSx\MPx \let\POSy\MPy
 \let\POSh\MPh \let\POSd\MPd \let\POSw\MPw
 
diff --git a/tex/context/base/cont-cs.mkii b/tex/context/base/cont-cs.mkii
index 82980acc2..714bf9568 100644
--- a/tex/context/base/cont-cs.mkii
+++ b/tex/context/base/cont-cs.mkii
@@ -11,16 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{czech}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkii
-
-\unprotect
+\def\defaultinterface  {czech}
+\def\defaultlanguagetag{cs}
 
-\setupcurrentlanguage[\s!cs]
-
-\ifnum\texengine=\luatexengine \else
-    \setupencoding[default=ec] \usetypescript[fallback][\defaultencoding] \setupbodyfont[rm,12pt]
-\fi
+\input context.mkii
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-cs.mkiv b/tex/context/base/cont-cs.mkiv
index 552bc5f51..e1805b1c9 100644
--- a/tex/context/base/cont-cs.mkiv
+++ b/tex/context/base/cont-cs.mkiv
@@ -11,12 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{czech}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkiv
-
-\unprotect
+\def\defaultinterface  {czech}
+\def\defaultlanguagetag{cs}
 
-\setupcurrentlanguage[\s!cs]
+\input context.mkiv
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-de.mkii b/tex/context/base/cont-de.mkii
index 3aec10a93..a110f67d2 100644
--- a/tex/context/base/cont-de.mkii
+++ b/tex/context/base/cont-de.mkii
@@ -11,16 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{german}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkii
-
-\unprotect
+\def\defaultinterface  {german}
+\def\defaultlanguagetag{de}
 
-\setupcurrentlanguage[\s!de]
-
-\ifnum\texengine=\luatexengine \else
-    \setupencoding[default=ec] \usetypescript[fallback][\defaultencoding] \setupbodyfont[rm,12pt]
-\fi
+\input context.mkii
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-de.mkiv b/tex/context/base/cont-de.mkiv
index 43251a206..1f4179781 100644
--- a/tex/context/base/cont-de.mkiv
+++ b/tex/context/base/cont-de.mkiv
@@ -11,12 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{german}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkiv
-
-\unprotect
+\def\defaultinterface  {german}
+\def\defaultlanguagetag{de}
 
-\setupcurrentlanguage[\s!de]
+\input context.mkiv
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-en.mkii b/tex/context/base/cont-en.mkii
index 5e91365bd..c3d510f98 100644
--- a/tex/context/base/cont-en.mkii
+++ b/tex/context/base/cont-en.mkii
@@ -11,18 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{english}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkii
-
-\unprotect
-
-\setupcurrentlanguage[\s!en]
+\def\defaultinterface  {english}
+\def\defaultlanguagetag{en}
 
-\setupencoding[default=ec]
-
-\usetypescript[fallback][\defaultencoding]
-
-\setupbodyfont[rm,12pt]
+\input context.mkii
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-en.mkiv b/tex/context/base/cont-en.mkiv
index 88724ca8f..1bf182cd8 100644
--- a/tex/context/base/cont-en.mkiv
+++ b/tex/context/base/cont-en.mkiv
@@ -11,12 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{english}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkiv
-
-\unprotect
+\def\defaultinterface  {english}
+\def\defaultlanguagetag{en}
 
-\setupcurrentlanguage[\s!en]
+\input context.mkiv
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-fr.mkii b/tex/context/base/cont-fr.mkii
index aea4cb625..6f1e806ad 100644
--- a/tex/context/base/cont-fr.mkii
+++ b/tex/context/base/cont-fr.mkii
@@ -11,18 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{french}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkii
-
-\unprotect
-
-\setupcurrentlanguage[\s!fr]
+\def\defaultinterface  {french}
+\def\defaultlanguagetag{fr}
 
-\setupencoding[default=ec]
-
-\usetypescript[fallback][\defaultencoding]
-
-\setupbodyfont[rm,12pt]
+\input context.mkii
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-fr.mkiv b/tex/context/base/cont-fr.mkiv
index 5de684314..5b0946625 100644
--- a/tex/context/base/cont-fr.mkiv
+++ b/tex/context/base/cont-fr.mkiv
@@ -11,12 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{french}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkiv
-
-\unprotect
+\def\defaultinterface  {french}
+\def\defaultlanguagetag{fr}
 
-\setupcurrentlanguage[\s!fr]
+\input context.mkiv
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-gb.mkii b/tex/context/base/cont-gb.mkii
index 24f52416d..35b7c85a4 100644
--- a/tex/context/base/cont-gb.mkii
+++ b/tex/context/base/cont-gb.mkii
@@ -11,18 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{english}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkii
-
-\unprotect
-
-\setupcurrentlanguage[\s!gb]
+\def\defaultinterface  {english}
+\def\defaultlanguagetag{gb}
 
-\setupencoding[default=ec]
-
-\usetypescript[fallback][\defaultencoding]
-
-\setupbodyfont[rm,12pt]
+\input context.mkii
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-gb.mkiv b/tex/context/base/cont-gb.mkiv
index ed4f65b66..3a4ed609b 100644
--- a/tex/context/base/cont-gb.mkiv
+++ b/tex/context/base/cont-gb.mkiv
@@ -11,12 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{english}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkiv
-
-\unprotect
+\def\defaultinterface  {english}
+\def\defaultlanguagetag{gb}
 
-\setupcurrentlanguage[\s!gb]
+\input context.mkiv
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-it.mkii b/tex/context/base/cont-it.mkii
index 5c8163a4e..c594a0659 100644
--- a/tex/context/base/cont-it.mkii
+++ b/tex/context/base/cont-it.mkii
@@ -11,18 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{italian}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkii
-
-\unprotect
-
-\setupcurrentlanguage[\s!it]
+\def\defaultinterface  {italian}
+\def\defaultlanguagetag{it}
 
-\setupencoding[default=ec]
-
-\usetypescript[fallback][\defaultencoding]
-
-\setupbodyfont[rm,12pt]
+\input context.mkii
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-it.mkiv b/tex/context/base/cont-it.mkiv
index 02e831891..af7a1149e 100644
--- a/tex/context/base/cont-it.mkiv
+++ b/tex/context/base/cont-it.mkiv
@@ -11,12 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{italian}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkiv
-
-\unprotect
+\def\defaultinterface  {italian}
+\def\defaultlanguagetag{it}
 
-\setupcurrentlanguage[\s!it]
+\input context.mkiv
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 8b2b65fa2..fb3fe8419 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2011.01.25 13:17}
+\newcontextversion{2011.01.26 09:01}
 
 %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 7da6d1e78..e68e2b158 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{2011.01.25 13:17}
+\newcontextversion{2011.01.26 09:01}
 
 %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/cont-nl.mkii b/tex/context/base/cont-nl.mkii
index f013c0d79..925ec8999 100644
--- a/tex/context/base/cont-nl.mkii
+++ b/tex/context/base/cont-nl.mkii
@@ -11,18 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{dutch}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkii
-
-\unprotect
-
-\setupcurrentlanguage[\s!nl]
+\def\defaultinterface  {dutch}
+\def\defaultlanguagetag{nl}
 
-\setupencoding[default=ec]
-
-\usetypescript[fallback][\defaultencoding]
-
-\setupbodyfont[rm,12pt]
+\input context.mkii
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-nl.mkiv b/tex/context/base/cont-nl.mkiv
index 4b64b6aeb..f6d2671e3 100644
--- a/tex/context/base/cont-nl.mkiv
+++ b/tex/context/base/cont-nl.mkiv
@@ -11,12 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{dutch}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkiv
-
-\unprotect
+\def\defaultinterface  {dutch}
+\def\defaultlanguagetag{nl}
 
-\setupcurrentlanguage[\s!nl]
+\input context.mkiv
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-pe.mkiv b/tex/context/base/cont-pe.mkiv
index a6f259ea4..e65ad1328 100644
--- a/tex/context/base/cont-pe.mkiv
+++ b/tex/context/base/cont-pe.mkiv
@@ -11,12 +11,12 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{persian} \def\messageinterface{english}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkiv
-
-\unprotect
+\def\defaultinterface  {persian}
+\def\messageinterface  {english}
+\def\defaultlanguagetag{pe}
 
-\setupcurrentlanguage[\s!pe]
+\input context.mkiv
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/cont-ro.mkii b/tex/context/base/cont-ro.mkii
index 84c31167b..595613194 100644
--- a/tex/context/base/cont-ro.mkii
+++ b/tex/context/base/cont-ro.mkii
@@ -11,18 +11,12 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{romanian}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkii
-
-\unprotect
-
-\setupcurrentlanguage[\s!ro]
+\def\defaultinterface  {romanian}
+\def\defaultlanguagetag{ro}
 
-\setupencoding[default=ec]
-
-\usetypescript[fallback][\defaultencoding]
+\input context.mkii
 
-\setupbodyfont[rm,12pt]
+\endinput
 
-\protect \errorstopmode \dump \endinput
diff --git a/tex/context/base/cont-ro.mkiv b/tex/context/base/cont-ro.mkiv
index d52bd1e3a..90bbc27dc 100644
--- a/tex/context/base/cont-ro.mkiv
+++ b/tex/context/base/cont-ro.mkiv
@@ -11,12 +11,11 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\catcode`\{=1 \catcode`\}=2 \def\defaultinterface{romanian}
+\catcode`\{=1 \catcode`\}=2
 
-\input context.mkiv
-
-\unprotect
+\def\defaultinterface  {romanian}
+\def\defaultlanguagetag{ro}
 
-\setupcurrentlanguage[\s!ro]
+\input context.mkiv
 
-\protect \errorstopmode \dump \endinput
+\endinput
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 346b2dc78..31f00884a 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
 %D your styles an modules.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2011.01.25 13:17}
+\edef\contextversion{2011.01.26 09:01}
 
 %D For those who want to use this:
 
@@ -44,6 +44,15 @@
 %D minimal as possible.
 
 \loadmarkfile{syst-ini}
+
+%D Some checking (more primitives are now defined):
+
+\ifdefined\defaultinterface   \else \def\defaultinterface  {english}         \fi
+%ifdefined\messageinterface   \else \let\messageinterface  \defaultinterface \fi
+\ifdefined\defaultlanguagetag \else \def\defaultlanguagetag{en}              \fi
+
+%D More core code.
+
 \loadmarkfile{syst-pln}
 
 \loadmarkfile{norm-tex}
@@ -416,3 +425,13 @@
 %D \item \type{cont-new}: new macro implementations (for testing)
 %D \item \type{cont-fil}: filename and module synonyms
 %D \stopitemize
+
+\setupcurrentlanguage[\defaultlanguagetag]
+
+\setupencoding[default=ec]
+
+\usetypescript[fallback][\defaultencoding]
+
+\setupbodyfont[rm,12pt]
+
+\errorstopmode \dump \endinput
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 76ef63028..dfd67c6a2 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
 %D your styles an modules.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2011.01.25 13:17}
+\edef\contextversion{2011.01.26 09:01}
 
 %D For those who want to use this:
 
@@ -45,6 +45,12 @@
 
 \loadmarkfile{syst-ini}
 
+%D Some checking (more primitives are now defined):
+
+\ifdefined\defaultinterface   \else \def\defaultinterface  {english}         \fi
+%ifdefined\messageinterface   \else \let\messageinterface  \defaultinterface \fi
+\ifdefined\defaultlanguagetag \else \def\defaultlanguagetag{en}              \fi
+
 %D We just quit if new functionality is expected.
 
 \ifnum\luatexversion<60 % also change message
@@ -394,9 +400,7 @@
 
 \loadmarkfile{back-exp}
 
-\unprotect
-
-\setupcurrentlanguage[\s!en]
+\setupcurrentlanguage[\defaultlanguagetag]
 
 \prependtoks
     \ctxlua{statistics.starttiming(statistics)}%
@@ -410,4 +414,4 @@
     \ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkiv")}% can become automatic
 \to \everydump
 
-\protect \errorstopmode \dump \endinput
+\errorstopmode \dump \endinput
diff --git a/tex/context/base/context.rme b/tex/context/base/context.rme
index 1b1e48902..1ce6b25c0 100644
--- a/tex/context/base/context.rme
+++ b/tex/context/base/context.rme
@@ -1,85 +1,79 @@
 Some Basic information
 ----------------------
 
-There are currently three interfaces available:
+The first public versions of ConTeXt date from around 1996. There
+are currently two versions of ConTeXt:
 
-  cont-en   the english version
-  cont-de   the german version
-  cont-nl   the dutch version
-  cont-cz   the czech version
-  cont-ro   the romanian version
-  cont-it   the italian version
+    MkII: to be used with pdfTeX and XeTeX
+    MkIV: to be used with LuaTeX
 
-One should compile one of these (or all) into a fmt file.
-When one uses the main file,
+In 2008 at the second ConTeXt conference the decision was made to
+freeze MkII. This means that only bugs are fixed and apart from an
+occasional addition no active development takes place. This is no
+real problem as the engines don't change much either.
 
-  context   the undefined version
+Early 2011 the code base between MkII and MkIV got split completely
+and there is no shared code any longer, apart from some styles and
+modules.
 
-TeX ask for an interface language as well as a message
-language. Here one has to specify the full name (english,
-german, dutch, etc.) or use the default (enter). The \
-savest way to update the TeX and MetaPost format files
-is to use TeXExec:
+The main files context.mkii and context.mkiv are normally not used
+directly but instead we use the interface specific formats:
 
-texexec --make --alone en nl metafun
+    cont-cs   czech
+    cont-de   german
+    cont-en   english us
+    cont-fr   french
+    cont-gb   english uk
+    cont-it   italian
+    cont-nl   dutch
+    cont-pe   persian
+    cont-ro   romanian
 
-In the TeXExec manual you can read how to generate a format
-with specific fonts and patterns.
+A MkII format is made with:
 
-By default only the english hyphenation patterns are loaded,
-unless more are enabled in:
+    texexec --make en nl metafun
 
-  cont-usr  the typesetting language specifications
+A MkIV format is made with:
 
-Furthermore, users can preset commands etc in the file
+    context --make en nl
 
-  cont-sys  a system file loaded at runtime
+As MetaPost is part of LuaTeX there is no need for a special MetaFun
+format. Also, when you update ConTeXt, a new format will be generated
+automatically.
 
-For questions and remarks on ConTeXt, one can subscribe to
-the list:
+You can preset commands etc in the file:
 
-  ntg-context@ntg.nl
+    cont-sys.mkii  a system file loaded at runtime
+    cont-sys.mkiv  a system file loaded at runtime
 
-by sending the message
-
-  subscribe ntg-context
+In the case of MkII, there is a fallback on cont-sys.tex (backward
+compatibility). If no file is found the file cont-sys.rme is loaded
+(only for MkII). For MkIV this file is normally not needed.
 
-to the list server:
+For questions and remarks on ConTeXt, one can subscribe to the list:
 
-  majordomo@ntg.nl
+    ntg-context@ntg.nl
 
-One can find more info at:
-
-  www.pragma-ade.com
+by sending the message
 
-or at the mirror sites mentioned there.
+    subscribe ntg-context
 
-Don't hesitate to ask questions. ConTeXt can do a lot, and
-the manuals are always a bit behind and incomplete. Also take
-a look at the files
+to the list server:
 
-  mreadme.pdf
-  minstall.pdf
-  mtexexec.pdf
-  mtexutil.pdf
+    majordomo@ntg.nl
 
-The teTeX, fpTeX, and 4TeX distributions demonstrate how
-ConTeXt can be integrated in a TeX directory structure.
+A good place to get information is the ConTeXt wiki:
 
--------------------------
+    contextgarden.net
 
-functionality removed from mkiv:
+One can also find more info at:
 
-page-log : layers can do teh same and are more flexible
-core-dat : just use lua for database purposes
-core-swd : this was a temporary solution
+    www.pragma-ade.com
 
-functionality changed in mkii and mkiv:
+or at the mirror sites mentioned there.
 
-xtag-map : no longer preloaded
-xtag-stk : no longer preloaded
-xtag-prs : no longer preloaded
+Don't hesitate to ask questions. ConTeXt can do a lot, but the manuals
+always lag behind and can be incomplete.
 
 -------------------------
-
 Hans Hagen, pragma@wxs.nl
diff --git a/tex/context/base/core-env.lua b/tex/context/base/core-env.lua
index d0db40b81..5545b5d32 100644
--- a/tex/context/base/core-env.lua
+++ b/tex/context/base/core-env.lua
@@ -13,6 +13,8 @@ if not modules then modules = { } end modules ['core-env'] = {
 
 local csname_id, texcount, create = token.csname_id, tex.count, token.create
 
+local P, C, S, Cc, lpegmatch, patterns = lpeg.P, lpeg.C, lpeg.S, lpeg.Cc, lpeg.match, lpeg.patterns
+
 local undefined = csname_id("*undefined*crap*")
 local iftrue    = create("iftrue")[2] -- inefficient hack
 
@@ -83,3 +85,21 @@ setmetatable(tex.ifs, {
         return csname_id(k) ~= undefined and create(k)[2] == iftrue -- inefficient, this create, we need a helper
     end
 })
+
+----  arg = P("{") * C(patterns.nested) * P("}") + Cc("")
+
+local sep = S("), ")
+local str = C((1-sep)^1)
+local tag = P("(") * C((1-S(")" ))^1) * P(")")
+local arg = P("(") * C((1-S("){"))^1) * P("{") * C((1-P("}"))^0) * P("}") * P(")")
+
+local pattern = (
+     P("lua") * tag        / context.luasetup
+  +  P("xml") * arg        / context.setupwithargument -- or xmlw as xmlsetup has swapped arguments
+  + (P("tex") * tag + str) / context.texsetup
+  +             sep^1
+)^1
+
+function commands.autosetups(str)
+    lpegmatch(pattern,str)
+end
diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv
index 250356a35..1b70e983f 100644
--- a/tex/context/base/core-env.mkiv
+++ b/tex/context/base/core-env.mkiv
@@ -240,6 +240,15 @@
      \fi
    \endcsname\empty} % takes one argument
 
+% We can consider:
+%
+% \setvalue{\??su->\v!auto}#1{\ctxlua{commands.autosetup("#1")}}
+%
+% ":\letterpercent" => "->\v!auto" with "\endcsname{#1}"
+%
+% but it won't work out well with multiple setups (intercepted at the
+% lua end) that then get only one argument.
+
 % the next one is meant for \c!setups situations, hence the check for
 % a shortcut
 
@@ -249,13 +258,25 @@
      \dodoprocesslocalsetups
    \fi}
 
+% \def\dodoprocesslocalsetups
+%   {\@EA\processcommalist\@EA[\tobeprocessedsetups]\dosetups}
+
+% setups=S1
+% setups=lua(S2)
+% setups=S3
+% setups={S1,lua(S2),xml(test{123}),S3}
+
 \def\dodoprocesslocalsetups
-  {\@EA\processcommalist\@EA[\tobeprocessedsetups]\dosetups}
+  {\ctxlua{commands.autosetups("\tobeprocessedsetups")}}
+
+\def\autosetups#1%
+  {\ctxlua{commands.autosetups("#1")}}
 
 \edef\setupwithargument#1% saves a few expansions
   {\noexpand\csname\??su:\noexpand\ifcsname\??su:#1\endcsname#1\noexpand\else\letterpercent\noexpand\fi\endcsname}
 
 \let\directsetup\dosetups
+\let\texsetup   \dosetups % nicer than \directsetup and more en par with xmlsetup and luasetup
 
 \def\doifsetupselse#1% to be done: grid
   {\doifdefinedelse{\??su:#1}} % doto: ifcsname
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index c1231fb81..ac7334c10 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -957,14 +957,14 @@ function fonts.definetypeface(name,t)
     elseif t then
         if type(t) == "string" then
             -- "abc", "k=v,..."
-            t = utilities.parsers.settings_to_hash(name)
+            t = settings_to_hash(name)
         else
             -- "abc", {k=v,...}
         end
         t.name = t.name or name
     else
         -- "name=abc,k=v,..."
-        t = utilities.parsers.settings_to_hash(name)
+        t = settings_to_hash(name)
     end
     local p = t.preset and fonts.typefaces[t.preset] or { }
     local name         = t.name         or "unknowntypeface"
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index ffd099318..5435de545 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -2093,19 +2093,25 @@
    \ctxlua{fonts.definers.resetnullfont()}% in luatex 0.70 this will also do the previous
    \globallet\resetnullfont\relax}
 
-% \newconditional\fontsareloaded
-
 % \def\preloaddefaultfonts
 %   {\resetpreloadfonts
-%    \usetypescript[modern]%
-%    \setuptypeface[modern]%
-%   %\setupbodyfont[modern]%
+%    \setupbodyfont[modern,\fontstyle,\fontbody]%
 %    \showmessage\m!fonts6{\normalizedbodyfontsize\normalspace\fontstyle}}
 
 \def\preloaddefaultfonts
   {\resetpreloadfonts
    \setupbodyfont[modern,\fontstyle,\fontbody]%
-   \showmessage\m!fonts6{\normalizedbodyfontsize\normalspace\fontstyle}}
+   \showmessage\m!fonts6{fallback modern \fontstyle\normalspace\normalizedbodyfontsize}}
+
+\def\preloaddefaultfontsmm
+  {\writestatus\m!fonts{preloading latin modern fonts (math)}%
+   \definetypeface[\fontclass][\c!mm][\s!math][modern][\s!default]%
+   \showmessage\m!fonts6{fallback modern mm \normalizedbodyfontsize}}
+
+\def\preloaddefaultfontstt
+  {\writestatus\m!fonts{preloading latin modern fonts (mono)}%
+   \definetypeface[\fontclass][\c!tt][\s!mono][modern][\s!default]%
+   \showmessage\m!fonts6{fallback modern tt \normalizedbodyfontsize}}
 
 \def\resetpreloadfonts
   {\global\let\firststagepreloadfonts \relax
@@ -2125,12 +2131,29 @@
   {\writestatus\m!fonts{preloading latin modern fonts (second stage)}%
    \preloaddefaultfonts}
 
+% \def\thirdstagepreloadfonts
+%   {\ifx\fontclass\empty
+%      \writestatus\m!fonts{preloading latin modern fonts (third stage)}%
+%      \preloaddefaultfonts
+%    \else
+%      \resetpreloadfonts
+%    \fi}
+
 \def\thirdstagepreloadfonts
   {\ifx\fontclass\empty
      \writestatus\m!fonts{preloading latin modern fonts (third stage)}%
      \preloaddefaultfonts
    \else
      \resetpreloadfonts
+     \pushmacro\fontstyle
+     \ifcsname\fontclass\c!mm\s!features\endcsname \else
+       \preloaddefaultfontsmm
+     \fi
+     \ifcsname\fontclass\c!tt\s!features\endcsname \else
+       \preloaddefaultfontstt
+     \fi
+     \popmacro\fontstyle
+     \setupbodyfont[\fontstyle]%
    \fi}
 
 \def\fourthstagepreloadfonts
@@ -2150,21 +2173,6 @@
 %D handle changes in size as well as returning to the global
 %D bodyfont size.
 
-% \def\dosetfont#1#2%  #1 = set/switch state
-%   {\doifelse{#2}\v!global
-%      {\restoreglobalbodyfont}
-%      {\processcommacommand[#2]{\dodosetfont{#1}}% ##1 get also passed
-%       \ifproductionrun
-%         \thirdstagepreloadfonts
-%         \doswitchpoints[\normalizedbodyfontsize]%
-%         \doswitchstyle[\fontstyle]%
-%         \ifx\defaultfontclass\empty
-%           \let\defaultfontclass\fontclass
-%         \fi
-%       \fi}%
-%    \currentxfontsize\zerocount}
-
-
 \def\dosetfont#1#2%  #1 = set/switch state
   {\doifelse{#2}\v!global
      {\restoreglobalbodyfont}
diff --git a/tex/context/base/lpdf-wid.lua b/tex/context/base/lpdf-wid.lua
index 7b535d1b1..0d96d8086 100644
--- a/tex/context/base/lpdf-wid.lua
+++ b/tex/context/base/lpdf-wid.lua
@@ -163,6 +163,23 @@ local nofattachments, attachments, filestreams = 0, { }, { }
 
 -- todo: hash and embed once
 
+local function flushembeddedfiles()
+    if next(filestreams) then
+        local e = pdfarray()
+        for name, reference in next, filestreams do
+            if reference then
+                e[#e+1] = pdfstring(name)
+                e[#e+1] = reference -- already a reference
+            else
+                -- we can issue a message
+            end
+        end
+        lpdf.addtonames("EmbeddedFiles",pdfreference(pdfflushobject(pdfdictionary{ Names = e })))
+    end
+end
+
+lpdf.registerdocumentfinalizer(flushembeddedfiles,"embeddedfiles")
+
 function codeinjections.embedfile(filename)
     local r = filestreams[filename]
     if r == false then
diff --git a/tex/context/base/pack-obj.mkiv b/tex/context/base/pack-obj.mkiv
index 6af439021..3d87f52b5 100644
--- a/tex/context/base/pack-obj.mkiv
+++ b/tex/context/base/pack-obj.mkiv
@@ -265,49 +265,55 @@
      {\globalpopmacro\crossreferenceobject
       \dododosetobject{#1}{#2}{#3}\egroup}}
 
-% \def\dododosetobject#1#2#3%
-%   {\begingroup
-%    \dontshowcomposition % rather fuzzy in \setxvalue ... \hbox
-%    \scratchdimen\objectoffset
-%    \@EA\xdef\csname\r!object#2::#3\endcsname
-%      {\noexpand\dohandleobject{#2}{#3}%
-%         {\ifhbox\nextbox\hbox\else\vbox\fi}%
-%         {\number\nextboxwd}{\number\nextboxht}{\number\nextboxdp}%
-%         {\number\scratchdimen}}%
-%    \expanded % freeze the dimensions since \dostartobject may use \nextbox
-%      {\dostartobject{#2}{#3}{\the\nextboxwd}{\the\nextboxht}{\the\nextboxdp}}%
-%    \ifcase#1\relax\else \ifdim\objectoffset>\zeropoint
-%      \setbox\nextbox\vbox spread 2\scratchdimen
-%        {\forgetall \offinterlineskip
-%         \vss\hbox spread 2\scratchdimen{\hss\flushnextbox\hss}\vss}%
-%    \fi \fi
-%    \flushnextbox
-%    \dostopobject
-%    \endgroup}
+\ifnum\luatexversion<66
+
+    \def\dododosetobject#1#2#3% this is a hack: luatex adds 1bp around each side
+      {\begingroup
+       \dontshowcomposition % rather fuzzy in \setxvalue ... \hbox
+       \ifcase#1\relax
+          \scratchdimen-\onebasepoint % compensates auto 1 bp
+       \else\ifdim\objectoffset>\zeropoint
+          \scratchdimen \objectoffset
+       \else
+          \scratchdimen-\onebasepoint % compensates auto 1 bp
+       \fi\fi
+       \@EA\xdef\csname\r!object#2::#3\endcsname
+         {\noexpand\dohandleobject{#2}{#3}%
+            {\ifhbox\nextbox\hbox\else\vbox\fi}%
+            {\number\nextboxwd}{\number\nextboxht}{\number\nextboxdp}%
+            {\number\scratchdimen}}%
+       \expanded % freeze the dimensions since \dostartobject may use \nextbox
+         {\dostartobject{#2}{#3}{\the\nextboxwd}{\the\nextboxht}{\the\nextboxdp}}%
+       \setbox\nextbox\vbox spread 2\scratchdimen
+         {\forgetall \offinterlineskip
+          \vss\hbox spread 2\scratchdimen{\hss\flushnextbox\hss}\vss}%
+       \flushnextbox
+       \dostopobject
+       \endgroup}
+
+\else
+
+    \def\dododosetobject#1#2#3%
+      {\begingroup
+       \dontshowcomposition % rather fuzzy in \setxvalue ... \hbox
+       \scratchdimen\objectoffset
+       \@EA\xdef\csname\r!object#2::#3\endcsname
+         {\noexpand\dohandleobject{#2}{#3}%
+            {\ifhbox\nextbox\hbox\else\vbox\fi}%
+            {\number\nextboxwd}{\number\nextboxht}{\number\nextboxdp}%
+            {\number\scratchdimen}}%
+       \expanded % freeze the dimensions since \dostartobject may use \nextbox
+         {\dostartobject{#2}{#3}{\the\nextboxwd}{\the\nextboxht}{\the\nextboxdp}}%
+       \ifcase#1\relax\else \ifdim\objectoffset>\zeropoint
+         \setbox\nextbox\vbox spread 2\scratchdimen
+           {\forgetall \offinterlineskip
+            \vss\hbox spread 2\scratchdimen{\hss\flushnextbox\hss}\vss}%
+       \fi \fi
+       \flushnextbox
+       \dostopobject
+       \endgroup}
 
-\def\dododosetobject#1#2#3% this is a hack: luatex adds 1bp around each side
-  {\begingroup
-   \dontshowcomposition % rather fuzzy in \setxvalue ... \hbox
-   \ifcase#1\relax
-      \scratchdimen-\onebasepoint % compensates auto 1 bp
-   \else\ifdim\objectoffset>\zeropoint
-      \scratchdimen \objectoffset
-   \else
-      \scratchdimen-\onebasepoint % compensates auto 1 bp
-   \fi\fi
-   \@EA\xdef\csname\r!object#2::#3\endcsname
-     {\noexpand\dohandleobject{#2}{#3}%
-        {\ifhbox\nextbox\hbox\else\vbox\fi}%
-        {\number\nextboxwd}{\number\nextboxht}{\number\nextboxdp}%
-        {\number\scratchdimen}}%
-   \expanded % freeze the dimensions since \dostartobject may use \nextbox
-     {\dostartobject{#2}{#3}{\the\nextboxwd}{\the\nextboxht}{\the\nextboxdp}}%
-   \setbox\nextbox\vbox spread 2\scratchdimen
-     {\forgetall \offinterlineskip
-      \vss\hbox spread 2\scratchdimen{\hss\flushnextbox\hss}\vss}%
-   \flushnextbox
-   \dostopobject
-   \endgroup}
+\fi
 
 \def\getobject#1#2%
   {\begingroup
diff --git a/tex/context/base/s-inf-01.mkiv b/tex/context/base/s-inf-01.mkiv
deleted file mode 100644
index dc55735fe..000000000
--- a/tex/context/base/s-inf-01.mkiv
+++ /dev/null
@@ -1,224 +0,0 @@
-%D \module
-%D   [      file=s-inf-01,
-%D        version=2009.07.09,
-%D          title=\CONTEXT\ Style File,
-%D       subtitle=Information 1 (\MKII/\MKIV\ usage),
-%D         author=Hans Hagen,
-%D           date=\currentdate,
-%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D Some day I will generalize this table mechanism. This list is only
-%D right when run in the minimals as my machine might have more files.
-
-\startluacode
-    local format, gsub, find, match = string.format, string.gsub, string.find, string.match
-
-    local list, size, comp, used, nope = { }, { }, { }, { mkii = { }, mkiv = { }, mkvi = { } }, { 0, 0, 0, 0, 0 }
-
-    local omit = {
-        "char%-def%.lua",
-        "mult%-def%.lua", "mult%-..%.mkii", "mult%-m..%.mkii",
-    }
-    local skip = {
-        "prag%-.*%.tex", "docs%-.*.tex", "list%-.*%.tex", "test%-.*%.tex", "demo%-.*%.tex",
-        "opti%-.*%.tex", "chrt%-.*%.tex", ".*%-old", ".*%-obs", ".*%-tst", "supp%-.*%.tex",
-        "colo%-pan.tex", ".*test.*"
-    }
-    local types = {
-        "tex", "mkii", "mkiv", "mkvi", "lua"
-    }
-    local patterns = {
-        "^([a-z][a-z][a-z][a-z])%-[a-z0-9%-]+%.[a-z]+",
-        "^([xms])%-[a-z0-9%-]+%.[a-z]+",
-    }
-
-    local function collect(list,suffix,n)
-        local path = file.dirname(resolvers.find_file("context.mkiv"),".")
-        local pattern = path .. "/*." .. suffix
-        local texfiles = dir.glob(pattern)
-        for _, name in ipairs(texfiles) do
-            local base = file.basename(name)
-            for p=1,#patterns do
-                local category = match(base,patterns[p])
-                if category and lfs.isfile(name) then
-                    local okay = true
-                    for s=1,#skip do
-                        if find(base,skip[s]) then
-                            okay = false
-                            break
-                        end
-                    end
-                    if okay then
-                        local lm, sm, cm = list[category], size[category], comp[category]
-                        if not lm then
-                            lm, sm, cm = { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }
-                            list[category], size[category], comp[category] = lm, sm, cm
-                        end
-                        lm[n] = lm[n] + 1
-                        local done = true
-                        for o=1,#omit do
-                            if find(base,omit[o]) then
-                                done = false
-                                break
-                            end
-                        end
-                        local data = io.loaddata(name)
-                        if suffix == "lua" then
-                            data = gsub(data,"%-%-%[%[.-%]%]%-%-","")
-                            data = gsub(data,"%-%-.-[\n\r]","")
-                        else
-                            data = gsub(data,"%%.-[\n\r]","")
-                        end
-                        data = gsub(data,"%s","")
-                        sm[n+5] = sm[n+5] + #data
-                        if done then
-                            sm[n] = sm[n] + #data
-                        else
-                            cm[n] = cm[n] + 1
-                        end
-                    end
-                end
-            end
-        end
-    end
-
-    local function prepare(what)
-        if next(list) then
-            -- already loaded
-        else
-            for k, v in ipairs(types) do
-                collect(list,v,k)
-            end
-            for category, _ in pairs(list) do
-                pattern ="{"..category.."%-"
-                for suffix, t in pairs(used) do
-                    local data = io.loaddata(resolvers.find_file("context."..suffix))
-                    if data and find(data,pattern) then
-                        t[category] = true
-                    end
-                end
-            end
-        end
-        local max, what = 0, (what == "size" and size) or list
-        for k, v in table.sortedpairs(what) do
-            for i=1,5 do if v[i] > max then max = v[i] end end
-        end
-        return max, what, function(n) return n/max end
-    end
-
-    function document.context_state_1(what)
-        local max, what, norm = prepare(what)
-        context.starttabulate { "|Tl|T|T|T|T|T|" }
-        context.NC()
-        context(category)
-        context.NC()
-        for i, t in ipairs(types) do
-            local n, m = 0, 0
-            for k, v in pairs(list) do
-                local nn, mm = what[k][i], what[k][i+5]
-                n = n + nn
-                m = m + (mm or nn)
-            end
-            context.Top(t,norm(max),n,m)
-            context.NC()
-        end
-        context.NC()
-        context.NR()
-        context.HL()
-        for k, v in table.sortedpairs(what) do
-            local c = (what == size and comp[k]) or nope
-            context.NC()
-            context("%s~%s~~%s~~%s",
-                (used.mkii[k] and "ii") or "~~",
-                (used.mkiv[k] and "iv") or "~~",
-                (used.mkvi[k] and "vi") or "~~",
-                k
-            )
-            context.NC()
-            for i, t in ipairs(types) do
-                context.Bar(t,v[i],c[i],norm(v[i]))
-                context.NC()
-            end
-            context.NR()
-        end
-        context.stoptabulate()
-    end
-
-    function document.context_state_2(what)
-        local max, what, norm = prepare(what)
-        for k, v in table.sortedpairs(what) do
-            local c = (what == size and comp[k]) or nope
-            context.StartUp(k)
-            for i, t in ipairs(types) do
-                context.Up(t,norm(v[i]))
-            end
-            context.StopUp()
-        end
-    end
-
-\stopluacode
-
-\definecolor[bar:tex] [middlegreen]
-\definecolor[bar:mkii][middleblue]
-\definecolor[bar:mkiv][middlered]
-\definecolor[bar:mkvi][middleyellow]
-\definecolor[bar:lua] [middlegray]
-
-\def\Top#1#2#3#4%
-  {\hbox to 5em{\hss#3}%
-   \enspace
-%  \hbox to #2\dimexpr 20em\relax{#1\ifnum#3=#4\else~#4\rlap{~+}\fi\hss}}
-   \hbox {#1\ifnum#3=#4\else~#4\rlap{~+}\fi\hss}}
-
-\def\Bar#1#2#3#4%
-  {\ifcase#2\else
-     \hbox to 5em{\hss\ifcase#3\else\llap{-~}\fi#2}%
-     \enspace
-     \blackrule[color=bar:#1,width=#4\dimexpr 20em\relax,height=.8\strutht]%
-   \fi}
-
-\newcount\UpCounter
-
-\def\StartUp#1%
-  {\dontleavehmode\framed[frame=off,align={middle,low},height=18em]\bgroup
-   \def\StopUp
-     {\par\nointerlineskip\blackrule[height=1pt,width=4em,depth=0pt,color=darkgray]%
-      \par\tttf\strut#1\par
-      \egroup
-      \ifnum\UpCounter=17 \par \UpCounter\zerocount\else \kern1em \advance\UpCounter\plusone \fi}}
-
-\def\Up#1#2%
-  {\scratchdimen#2\dimexpr 16em\relax
-   \ifdim\scratchdimen=\zeropoint
-     \kern1em
-   \else
-     \ifdim\scratchdimen<\onepoint \scratchdimen\onepoint \fi
-     \blackrule[color=bar:#1,height=\scratchdimen,width=1em]%
-   \fi}
-
-\def\Show#1#2#3%
-  {\startTEXpage[offset=1em,width=fit]
-     \hbox{\tttf\strut\currentdate~-~#1}
-     \ctxlua{document.context_state_\number#2("#3")}
-   \stopTEXpage}
-
-% \doifnotmode{demo}{\endinput}
-
-\starttext
-    \Show
-        {The number of files used in ConTeXt (modules and styles are excluded).}
-        {1}{number}
-    \Show
-        {The size of (core) files used in ConTeXt (- indicates exclusion of large data files; + indicates inclusion of large data files; comment and spaces removed.)}
-        {1}{size}
-    \Show
-        {The relative number of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).}
-        {2}{number}
-    \Show
-        {The relative size of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).}
-        {2}{size}
-\stoptext
diff --git a/tex/context/base/s-inf-01.mkvi b/tex/context/base/s-inf-01.mkvi
new file mode 100644
index 000000000..d32356d69
--- /dev/null
+++ b/tex/context/base/s-inf-01.mkvi
@@ -0,0 +1,244 @@
+%D \module
+%D   [      file=s-inf-01,
+%D        version=2009.07.09,
+%D          title=\CONTEXT\ Style File,
+%D       subtitle=Information 1 (\MKII/\MKIV\ usage),
+%D         author=Hans Hagen,
+%D           date=\currentdate,
+%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Some day I will generalize this table mechanism. This list is only
+%D right when run in the minimals as my machine might have more files.
+%D
+%D Als, the remaining tex code can proably be lua also which is more
+%D consistent.
+%D
+%D \starttyping
+%D context auto:s-inf-01
+%D context auto:s-inf-01 --basepath=t:/texmf/tex/context/base
+%D \stoptyping
+
+\startluacode
+    local format, gsub, find, match = string.format, string.gsub, string.find, string.match
+
+    local list, size, comp, used, nope = { }, { }, { }, { mkii = { }, mkiv = { }, mkvi = { } }, { 0, 0, 0, 0, 0 }
+
+    local omit = {
+        "char%-def%.lua",
+        "mult%-def%.lua", "mult%-..%.mkii", "mult%-m..%.mkii",
+    }
+    local skip = {
+        "prag%-.*%.tex", "docs%-.*.tex", "list%-.*%.tex", "test%-.*%.tex", "demo%-.*%.tex",
+        "opti%-.*%.tex", "chrt%-.*%.tex", ".*%-old", ".*%-obs", ".*%-tst", "supp%-.*%.tex",
+        "colo%-pan.tex", ".*test.*"
+    }
+    local types = {
+        "tex", "mkii", "mkiv", "mkvi", "lua"
+    }
+    local patterns = {
+        "^([a-z][a-z][a-z][a-z])%-[a-z0-9%-]+%.[a-z]+",
+        "^([xms])%-[a-z0-9%-]+%.[a-z]+",
+    }
+
+    local function collect(list,suffix,n)
+        local path = document.arguments.basepath or file.dirname(resolvers.find_file("context.mkiv"),".")
+        local pattern = path .. "/*." .. suffix
+        local texfiles = dir.glob(pattern)
+        for _, name in ipairs(texfiles) do
+            local base = file.basename(name)
+            for p=1,#patterns do
+                local category = match(base,patterns[p])
+                if category and lfs.isfile(name) then
+                    local okay = true
+                    for s=1,#skip do
+                        if find(base,skip[s]) then
+                            okay = false
+                            break
+                        end
+                    end
+                    if okay then
+                        local lm, sm, cm = list[category], size[category], comp[category]
+                        if not lm then
+                            lm, sm, cm = { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }
+                            list[category], size[category], comp[category] = lm, sm, cm
+                        end
+                        lm[n] = lm[n] + 1
+                        local done = true
+                        for o=1,#omit do
+                            if find(base,omit[o]) then
+                                done = false
+                                break
+                            end
+                        end
+                        local data = io.loaddata(name)
+                        if suffix == "lua" then
+                            data = gsub(data,"%-%-%[%[.-%]%]%-%-","")
+                            data = gsub(data,"%-%-.-[\n\r]","")
+                        else
+                            data = gsub(data,"%%.-[\n\r]","")
+                        end
+                        data = gsub(data,"%s","")
+                        sm[n+5] = sm[n+5] + #data
+                        if done then
+                            sm[n] = sm[n] + #data
+                        else
+                            cm[n] = cm[n] + 1
+                        end
+                    end
+                end
+            end
+        end
+    end
+
+    local function prepare(what)
+        if next(list) then
+            -- already loaded
+        else
+            for k, v in ipairs(types) do
+                collect(list,v,k)
+            end
+            for category, _ in pairs(list) do
+                pattern ="{"..category.."%-"
+                for suffix, t in pairs(used) do
+                    local data = io.loaddata(resolvers.find_file("context."..suffix))
+                    if data and find(data,pattern) then
+                        t[category] = true
+                    end
+                end
+            end
+        end
+        local max, what = 0, (what == "size" and size) or list
+        for k, v in table.sortedpairs(what) do
+            for i=1,5 do if v[i] > max then max = v[i] end end
+        end
+        return max, what, function(n) return max == 0 and 0 or n/max end
+    end
+
+    function document.context_state_1(what)
+        local max, what, norm = prepare(what)
+        context.starttabulate { "|Tl|T|T|T|T|T|" }
+        context.NC()
+        context(category)
+        context.NC()
+        for i, t in ipairs(types) do
+            local n, m = 0, 0
+            for k, v in pairs(list) do
+                local nn, mm = what[k][i], what[k][i+5]
+                n = n + nn
+                m = m + (mm or nn)
+            end
+            context.Top(t,norm(max),n,m)
+            context.NC()
+        end
+        context.NC()
+        context.NR()
+        context.HL()
+        for k, v in table.sortedpairs(what) do
+            local c = (what == size and comp[k]) or nope
+            context.NC()
+            context("%s~%s~~%s~~%s",
+                (used.mkii[k] and "ii") or "~~",
+                (used.mkiv[k] and "iv") or "~~",
+                (used.mkvi[k] and "vi") or "~~",
+                k
+            )
+            context.NC()
+            for i, t in ipairs(types) do
+                context.Bar(t,v[i],c[i],norm(v[i]))
+                context.NC()
+            end
+            context.NR()
+        end
+        context.stoptabulate()
+    end
+
+    function document.context_state_2(what)
+        local max, what, norm = prepare(what)
+        for k, v in table.sortedpairs(what) do
+            local c = (what == size and comp[k]) or nope
+            context.StartUp(k)
+            for i, t in ipairs(types) do
+                context.Up(t,norm(v[i]))
+            end
+            context.StopUp()
+        end
+    end
+
+\stopluacode
+
+\definecolor[bar:tex] [middlegreen]
+\definecolor[bar:mkii][middleblue]
+\definecolor[bar:mkiv][middlered]
+\definecolor[bar:mkvi][middleyellow]
+\definecolor[bar:lua] [middlegray]
+
+\newcount\UpCounter
+
+\starttexdefinition Top #what#fraction#total#bigones
+    \hbox to 5em{\hss#total}%
+    \enspace
+    \hbox {#what\ifnum#total=#bigones\else~#bigones\rlap{~+}\fi\hss}%
+\stoptexdefinition
+
+\starttexdefinition Bar #color#size#nobigones#fraction
+    \ifcase#size\else
+        \hbox to 5em{\hss\ifcase#nobigones\else\llap{-~}\fi#size}%
+        \enspace
+        \blackrule[color=bar:#color,width=#fraction\dimexpr 20em\relax,height=.8\strutht]%
+    \fi
+\stoptexdefinition
+
+\starttexdefinition StartUp #name
+    \def\UpName{#name}%
+    \dontleavehmode\framed[frame=off,align={middle,low},height=18em]\bgroup
+\stoptexdefinition
+
+\starttexdefinition StopUp
+    \par\nointerlineskip\blackrule[height=1pt,width=4em,depth=0pt,color=darkgray]
+    \par\tttf\strut\UpName\par
+    \egroup
+    \ifnum\UpCounter=17
+        \par \UpCounter\zerocount
+    \else
+        \kern1em \advance\UpCounter\plusone
+    \fi
+\stoptexdefinition
+
+\starttexdefinition Up #color#width
+    \scratchdimen#width\dimexpr 16em\relax
+    \ifdim\scratchdimen=\zeropoint
+        \kern1em
+    \else
+        \ifdim\scratchdimen<\onepoint \scratchdimen\onepoint \fi
+        \blackrule[color=bar:#color,height=\scratchdimen,width=1em]%
+    \fi
+\stoptexdefinition
+
+\starttexdefinition Show #title#how#what
+    \startTEXpage[offset=1em,width=fit]
+        \hbox{\tttf\strut\currentdate~-~#title}
+        \par
+        \ctxlua{document.context_state_\number#how("#what")}
+    \stopTEXpage
+\stoptexdefinition
+
+% \doifnotmode{demo}{\endinput}
+
+\starttext
+    \Show
+        {The number of files used in ConTeXt (base modules and styles).}
+        {1}{number}
+    \Show
+        {The size of (core) files used in ConTeXt (- indicates exclusion of large data files; + indicates inclusion of large data files; comment and spaces removed.)}
+        {1}{size}
+    \Show
+        {The relative number of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).}
+        {2}{number}
+    \Show
+        {The relative size of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).}
+        {2}{size}
+\stoptext
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
new file mode 100644
index 000000000..a5b0a9e30
Binary files /dev/null and b/tex/context/base/status-files.pdf differ
diff --git a/tex/context/base/type-ini.mkiv b/tex/context/base/type-ini.mkiv
index 298618a4a..b6942376e 100644
--- a/tex/context/base/type-ini.mkiv
+++ b/tex/context/base/type-ini.mkiv
@@ -456,7 +456,7 @@
    \else\ifthirdargument
      \dododefinetypeface[#1][#2]%
      \getparameters[\??tf#1#2][#3]%
-   \else
+   \else % use definitions in lfg file
      \ctxlua{fonts.definetypeface(\!!bs#1\!!es,\!!bs#2\!!es)}%
    \fi\fi\fi}
 
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index c8f8a6f7a..5ad6a4edf 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  : 01/25/11 13:17:26
+-- merge date  : 01/26/11 09:01:20
 
 do -- begin closure to overcome local limits and interference
 
-- 
cgit v1.2.3