From 9273ab2ccc41973a34fbde3c7667beec8021f2eb Mon Sep 17 00:00:00 2001
From: Marius <mariausol@gmail.com>
Date: Wed, 9 Feb 2011 18:00:12 +0200
Subject: beta 2011.02.09 16:42

---
 scripts/context/lua/mtx-context.lua         |  11 +++++++----
 scripts/context/lua/mtxrun.lua              |  29 +++++++++++++++++++---------
 scripts/context/stubs/mswin/mtxrun.lua      |  29 +++++++++++++++++++---------
 scripts/context/stubs/unix/mtxrun           |  29 +++++++++++++++++++---------
 tex/context/base/cont-new.mkii              |   2 +-
 tex/context/base/cont-new.mkiv              |   2 +-
 tex/context/base/context.mkii               |   2 +-
 tex/context/base/context.mkiv               |   2 +-
 tex/context/base/grph-fig.mkiv              |   6 ++++--
 tex/context/base/l-dir.lua                  |  27 ++++++++++++++++++--------
 tex/context/base/pack-rul.mkiv              |   4 ++--
 tex/context/base/status-files.pdf           | Bin 23232 -> 23251 bytes
 tex/generic/context/luatex-fonts-merged.lua |   2 +-
 13 files changed, 97 insertions(+), 48 deletions(-)

diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index 2ffab155a..da629323e 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -1313,17 +1313,20 @@ end
 -- modules
 
 local labels = { "title", "comment", "status" }
+local cards  = { "*.mkvi", "*.mkiv", "*.tex" }
 
 function scripts.context.modules(pattern)
     local list = { }
     local found = resolvers.findfile("context.mkiv")
     if not pattern or pattern == "" then
         -- official files in the tree
-        resolvers.findwildcardfiles("*.tex",list)
-        resolvers.findwildcardfiles("*.mkiv",list)
+        for _, card in ipairs(cards) do
+            resolvers.findwildcardfiles(card,list)
+        end
         -- my dev path
-        dir.glob(file.join(file.dirname(found),"*.tex"),list)
-        dir.glob(file.join(file.dirname(found),"*.mkiv"),list)
+        for _, card in ipairs(cards) do
+            dir.glob(file.join(file.dirname(found),card),list)
+        end
     else
         resolvers.findwildcardfiles(pattern,list)
         dir.glob(file.join(file.dirname(found,pattern)),list)
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index fed0e13f4..187b26e06 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -2927,21 +2927,32 @@ end
 -- optimizing for no find (*) does not save time
 
 
+local lfsisdir = isdir
+
+local function isdir(path)
+    path = gsub(path,"[/\\]+$","")
+    return lfsisdir(path)
+end
+
+lfs.isdir = isdir
+
 local function globpattern(path,patt,recurse,action)
     if path == "/" then
         path = path .. "."
     elseif not find(path,"/$") then
         path = path .. '/'
     end
-    for name in walkdir(path) do
-        local full = path .. name
-        local mode = attributes(full,'mode')
-        if mode == 'file' then
-            if find(full,patt) then
-                action(full)
-            end
-        elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
-            globpattern(full,patt,recurse,action)
+    if isdir(path) then -- lfs.isdir does not like trailing /
+        for name in walkdir(path) do -- lfs.dir accepts trailing /
+            local full = path .. name
+            local mode = attributes(full,'mode')
+            if mode == 'file' then
+                if find(full,patt) then
+                    action(full)
+                end
+            elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
+                globpattern(full,patt,recurse,action)
+            end
         end
     end
 end
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index fed0e13f4..187b26e06 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -2927,21 +2927,32 @@ end
 -- optimizing for no find (*) does not save time
 
 
+local lfsisdir = isdir
+
+local function isdir(path)
+    path = gsub(path,"[/\\]+$","")
+    return lfsisdir(path)
+end
+
+lfs.isdir = isdir
+
 local function globpattern(path,patt,recurse,action)
     if path == "/" then
         path = path .. "."
     elseif not find(path,"/$") then
         path = path .. '/'
     end
-    for name in walkdir(path) do
-        local full = path .. name
-        local mode = attributes(full,'mode')
-        if mode == 'file' then
-            if find(full,patt) then
-                action(full)
-            end
-        elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
-            globpattern(full,patt,recurse,action)
+    if isdir(path) then -- lfs.isdir does not like trailing /
+        for name in walkdir(path) do -- lfs.dir accepts trailing /
+            local full = path .. name
+            local mode = attributes(full,'mode')
+            if mode == 'file' then
+                if find(full,patt) then
+                    action(full)
+                end
+            elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
+                globpattern(full,patt,recurse,action)
+            end
         end
     end
 end
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index fed0e13f4..187b26e06 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -2927,21 +2927,32 @@ end
 -- optimizing for no find (*) does not save time
 
 
+local lfsisdir = isdir
+
+local function isdir(path)
+    path = gsub(path,"[/\\]+$","")
+    return lfsisdir(path)
+end
+
+lfs.isdir = isdir
+
 local function globpattern(path,patt,recurse,action)
     if path == "/" then
         path = path .. "."
     elseif not find(path,"/$") then
         path = path .. '/'
     end
-    for name in walkdir(path) do
-        local full = path .. name
-        local mode = attributes(full,'mode')
-        if mode == 'file' then
-            if find(full,patt) then
-                action(full)
-            end
-        elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
-            globpattern(full,patt,recurse,action)
+    if isdir(path) then -- lfs.isdir does not like trailing /
+        for name in walkdir(path) do -- lfs.dir accepts trailing /
+            local full = path .. name
+            local mode = attributes(full,'mode')
+            if mode == 'file' then
+                if find(full,patt) then
+                    action(full)
+                end
+            elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
+                globpattern(full,patt,recurse,action)
+            end
         end
     end
 end
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index ab59c6f3e..93dd9df32 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.02.09 15:29}
+\newcontextversion{2011.02.09 16:42}
 
 %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 750518344..3b213f4a2 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.02.09 15:29}
+\newcontextversion{2011.02.09 16:42}
 
 %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.mkii b/tex/context/base/context.mkii
index b15d31767..af88a5482 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.02.09 15:29}
+\edef\contextversion{2011.02.09 16:42}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index bcd1de14a..fe949ae28 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.02.09 15:29}
+\edef\contextversion{2011.02.09 16:42}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv
index 26b93435b..fad1c864a 100644
--- a/tex/context/base/grph-fig.mkiv
+++ b/tex/context/base/grph-fig.mkiv
@@ -11,6 +11,8 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
+% ex => ef with proper parent
+
 \writestatus{loading}{ConTeXt Graphic Macros / Figure Handling}
 
 \unprotect
@@ -51,13 +53,13 @@
 \def\externalfigurereplacement#1#2#3%
   {\setupcolors
      [\c!state=\v!local]%
-   \localframed
+   \normalexpanded{\localframed
      [\??ef]
      [\c!width=\figurewidth,
       \c!height=\figureheight,
       \c!background=\v!color,
       \c!backgroundcolor=missingfigurecolor,
-      \c!frame=\@@efframe]
+      \c!frame=\@@efframe]}% we need to expand this in order to prevent a loop
      {\tt\tfxx \nohyphens
         name:  \expanded{\verbatimstring{#1}}\\%
         file:  \expanded{\verbatimstring{#2}}\\%
diff --git a/tex/context/base/l-dir.lua b/tex/context/base/l-dir.lua
index 2c4ff999b..40b94782b 100644
--- a/tex/context/base/l-dir.lua
+++ b/tex/context/base/l-dir.lua
@@ -58,21 +58,32 @@ end
 --~     end
 --~ end
 
+local lfsisdir = isdir
+
+local function isdir(path)
+    path = gsub(path,"[/\\]+$","")
+    return lfsisdir(path)
+end
+
+lfs.isdir = isdir
+
 local function globpattern(path,patt,recurse,action)
     if path == "/" then
         path = path .. "."
     elseif not find(path,"/$") then
         path = path .. '/'
     end
-    for name in walkdir(path) do
-        local full = path .. name
-        local mode = attributes(full,'mode')
-        if mode == 'file' then
-            if find(full,patt) then
-                action(full)
+    if isdir(path) then -- lfs.isdir does not like trailing /
+        for name in walkdir(path) do -- lfs.dir accepts trailing /
+            local full = path .. name
+            local mode = attributes(full,'mode')
+            if mode == 'file' then
+                if find(full,patt) then
+                    action(full)
+                end
+            elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
+                globpattern(full,patt,recurse,action)
             end
-        elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
-            globpattern(full,patt,recurse,action)
         end
     end
 end
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index b3e73c488..ccd3ebb83 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -680,14 +680,14 @@
 
 \newif\ifinframed
 
-\def\localframed
+\unexpanded\def\localframed
   {\bgroup
    \dodoubleempty\startlocalframed}
 
 %D The next one is faster on multiple backgrounds per page. No
 %D dimensions can be set, only frames and backgrounds.
 
-\def\fastlocalframed[#1]#2[#3]#4% 3-4
+\unexpanded\def\fastlocalframed[#1]#2[#3]#4% 3-4
   {\bgroup
    \inframedtrue
    \edef\@@framed{#1}%
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index b52bef4c8..48c45b084 100644
Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 9894895d6..edbdd402b 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  : 02/09/11 15:29:45
+-- merge date  : 02/09/11 16:42:54
 
 do -- begin closure to overcome local limits and interference
 
-- 
cgit v1.2.3