summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-05-23 20:45:51 +0200
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-11-11 15:49:17 +0100
commit36f5a75442848e55685b08b6a83366561aa86b88 (patch)
treef6279548b0974a0a9cf9887dd500af1878fec87c
parentccf067d02062a1d45cefbbab158d6e4df1443dcc (diff)
downloadluatexbase-36f5a75442848e55685b08b6a83366561aa86b88.tar.gz
Format of multi-line messages.
-rw-r--r--Changes2
-rw-r--r--TODO1
-rw-r--r--luatexbase-modutils.dtx33
3 files changed, 23 insertions, 13 deletions
diff --git a/Changes b/Changes
index ac5798f..af2201c 100644
--- a/Changes
+++ b/Changes
@@ -9,6 +9,8 @@
\RequireLuaModule with a unified syntax.
- luatexbase.use_module removed (use luatexbase.require_module with
a single argument instead).
+ - change formatting of messages.
+ - rm module_log & module_term functions.
2010/10/04
various documentation updates/fixes uploaded to CTAN
diff --git a/TODO b/TODO
index 64a1c18..9eaace7 100644
--- a/TODO
+++ b/TODO
@@ -2,7 +2,6 @@ modutils
--------
- create private functions for infwarrerr?
-- use LaTeX style linebreaks in messages?
- review logic: should this module be mandatory?
if not, what should happen with mixed require(), require_module(),
diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx
index 95e4611..16765c3 100644
--- a/luatexbase-modutils.dtx
+++ b/luatexbase-modutils.dtx
@@ -187,12 +187,12 @@ See source file '\inFileName' for details.
% Functions for reporting are provided; similarly to \latex's |\PackageError|
% etc. they take the module name as their first argument and include it in the
% printed message in an appropriate way. The remaining arguments are passed to
-% |string.format()| before being printed.
+% |string.format()|, and the package name is prepended to each line of the
+% resulting string before it is output.
%
% The functions provided (all found in the |luatexbase| table) are
% |module_error|, |module_warning|, |module_info| (writes to terminal and
-% log), |module_log| (writes only to the log file) and |module_term| (writes
-% only to the terminal).
+% log).
%
% \section{Implementation}
%
@@ -431,23 +431,32 @@ end
% consistent.
%
% \begin{macrocode}
+local function msg_format(msg_type, mod_name, ...)
+ local cont = '('..mod_name..')' .. ('Module: '..msg_type):gsub('.', ' ')
+ return 'Module '..mod_name..' '..msg_type..': '
+ .. string.format(...):gsub('\n', '\n'..cont)
+end
local function module_error_int(mod, ...)
- error('Module '..mod..' error: '..string.format(...), 3)
+ error(msg_format('error', mod, ...), 3)
end
function module_error(mod, ...)
module_error_int(mod, ...)
end
+% \end{macrocode}
+%
+% Split the lines explicitely in order not to depend on the value of
+% |\newlinechar|.
+%
+% \begin{macrocode}
function module_warning(mod, ...)
- texio.write_nl("Module "..mod.." warning: "..string.format(...))
+ for _, line in ipairs(msg_format('warning', mod, ...):explode('\n')) do
+ texio.write_nl(line)
+ end
end
function module_info(mod, ...)
- texio.write_nl(mod..": "..string.format(...))
-end
-function module_log(mod, ...)
- texio.write_nl('log', mod..": "..string.format(...))
-end
-function module_term(mod, ...)
- texio.write_nl('term', mod..": "..string.format(...))
+ for _, line in ipairs(msg_format('info', mod, ...):explode('\n')) do
+ texio.write_nl(line)
+ end
end
% \end{macrocode}
%