summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-04-21 00:55:45 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-04-21 00:55:45 +0200
commit1e04ecc2c4918448e8ff30a2e6363025267cac79 (patch)
treeb31b5a94146a0a300b3fd09cb50d5736a002f086
parent465d4cbb1ba7162d6c60ebd55449c71981f1b75c (diff)
downloadlualibs-1e04ecc2c4918448e8ff30a2e6363025267cac79.tar.gz
add rudimentary verbosity switch
-rw-r--r--lualibs-basic.lua9
-rw-r--r--lualibs-extended.lua9
-rw-r--r--lualibs.lua37
3 files changed, 30 insertions, 25 deletions
diff --git a/lualibs-basic.lua b/lualibs-basic.lua
index cf8d6ea..8bdaf70 100644
--- a/lualibs-basic.lua
+++ b/lualibs-basic.lua
@@ -11,18 +11,15 @@ local lualibs_basic_module = {
license = "See ConTeXt's mreadme.pdf for the license",
}
-local find_file, error, warn, info
-if luatexbase and luatexbase.provides_module then
- error, warn, info = luatexbase.provides_module(lualibs_basic_module)
-else
- error, warn, info = texio.write_nl, texio.write_nl, texio.write_nl -- stub
-end
+local lualibs = _G.config.lualibs
+local error, warn, info = lualibs.error, lualibs.warn, lualibs.info
local loadmodule = lualibs.loadmodule
local stringformat = string.format
local loaded = false
if lualibs.prefer_merged then
+ info"Loading merged package for collection “basic”."
loaded = loadmodule('lualibs-basic-merged.lua')
else
info"Ignoring merged packages."
diff --git a/lualibs-extended.lua b/lualibs-extended.lua
index 438910b..b0aea31 100644
--- a/lualibs-extended.lua
+++ b/lualibs-extended.lua
@@ -11,12 +11,8 @@ local lualibs_extended_module = {
license = "See ConTeXt's mreadme.pdf for the license",
}
-local find_file, error, warn, info
-if luatexbase and luatexbase.provides_module then
- error, warn, info = luatexbase.provides_module(lualibs_extended_module)
-else
- error, warn, info = texio.write_nl, texio.write_nl, texio.write_nl -- stub
-end
+local lualibs = _G.config.lualibs
+local error, warn, info = lualibs.error, lualibs.warn, lualibs.info
local stringformat = string.format
local loadmodule = lualibs.loadmodule
@@ -122,6 +118,7 @@ fake_context()
local loaded = false
if lualibs.prefer_merged then
+ info"Loading merged package for collection “extended”."
loaded = loadmodule('lualibs-extended-merged.lua')
else
info"Ignoring merged packages."
diff --git a/lualibs.lua b/lualibs.lua
index 4f354b5..f126fb7 100644
--- a/lualibs.lua
+++ b/lualibs.lua
@@ -11,16 +11,13 @@ local lualibs_module = {
license = "See ConTeXt's mreadme.pdf for the license",
}
---- TODO should be set in some global config
-prefer_merged = true ---false
-local load_extended = true ---false
+_G.config = _G.config or { }
+_G.config.lualibs = _G.config.lualibs or { }
+local lualibs = _G.config.lualibs
-if config and config.lualibs then
- local cl_prefer_merged = config.lualibs.prefer_merged
- local cl_load_extended = config.lualibs.load_extended
- if cl_prefer_merged ~= nil then prefer_merged = cl_prefer_merged end
- if cl_load_extended ~= nil then load_extended = cl_load_extended end
-end
+if lualibs.prefer_merged == nil then lualibs.prefer_merged = true end
+if lualibs.load_extended == nil then lualibs.load_extended = true end
+lualibs.verbose = lualibs.verbose == true or false
local lpeg, kpse = lpeg, kpse
@@ -29,11 +26,24 @@ local lpegmatch = lpeg.match
local stringformat = string.format
local find_file, error, warn, info
-if luatexbase and luatexbase.provides_module then
- error, warn, info = luatexbase.provides_module(lualibs_module)
-else
- error, warn, info = texio.write_nl, texio.write_nl, texio.write_nl -- stub
+do
+ local _error, _warn, _info
+ if luatexbase and luatexbase.provides_module then
+ _error, _warn, _info = luatexbase.provides_module(lualibs_module)
+ else
+ _error, _warn, _info = texio.write_nl, texio.write_nl, texio.write_nl -- stub
+ end
+
+ -- if lualibs.verbose then
+ if lualibs.verbose then
+ error, warn, info = _error, _warn, _info
+ else
+ local dummylogger = function ( ) end
+ error, warn, info = _error, dummylogger, dummylogger
+ end
+ lualibs.error, lualibs.warn, lualibs.info = error, warn, info
end
+
if luatexbase and luatexbase.find_file then
find_file = luatexbase.find_file
else
@@ -51,6 +61,7 @@ loadmodule = _G.loadmodule or function (name, t)
dofile(filepath)
return true
end
+lualibs.loadmodule = loadmodule
--[[doc--
The separation of the “basic” from the “extended” sets coincides with