diff options
| author | Philipp Gesang <phg42.2a@gmail.com> | 2013-04-21 00:55:45 +0200 | 
|---|---|---|
| committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-04-21 00:55:45 +0200 | 
| commit | 1e04ecc2c4918448e8ff30a2e6363025267cac79 (patch) | |
| tree | b31b5a94146a0a300b3fd09cb50d5736a002f086 /lualibs.lua | |
| parent | 465d4cbb1ba7162d6c60ebd55449c71981f1b75c (diff) | |
| download | lualibs-1e04ecc2c4918448e8ff30a2e6363025267cac79.tar.gz | |
add rudimentary verbosity switch
Diffstat (limited to 'lualibs.lua')
| -rw-r--r-- | lualibs.lua | 37 | 
1 files changed, 24 insertions, 13 deletions
| 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 | 
