1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 22:02:26 +01:00

improve error messages given when sourcing files

This commit is contained in:
Doug Kearns
2008-09-30 12:27:16 +00:00
parent fce599268e
commit f1b40dd6ec
3 changed files with 53 additions and 30 deletions

View File

@@ -777,7 +777,7 @@ lookup:
liberator.echomsg("sourcing \"" + filename + "\"", 2); liberator.echomsg("sourcing \"" + filename + "\"", 2);
var str = ioManager.readFile(file); let str = ioManager.readFile(file);
// handle pure javascript files specially // handle pure javascript files specially
if (/\.js$/.test(filename)) if (/\.js$/.test(filename))
@@ -786,14 +786,12 @@ lookup:
} }
else else
{ {
var heredoc = ""; let heredoc = "";
var heredocEnd = null; // the string which ends the heredoc let heredocEnd = null; // the string which ends the heredoc
var lines = str.split("\n"); let lines = str.split("\n");
for (let i = 0; i < lines.length; i++) for (let [i, line] in Iterator(lines))
{ {
let line = lines[i];
if (heredocEnd) // we already are in a heredoc if (heredocEnd) // we already are in a heredoc
{ {
if (heredocEnd.test(line)) if (heredocEnd.test(line))
@@ -809,17 +807,36 @@ lookup:
} }
else else
{ {
var [count, cmd, special, args] = liberator.commands.parseCommand(line); // skip line comments and blank lines
var command = liberator.commands.get(cmd); if (/^\s*(".*)?$/.test(line))
continue;
if (command && command.name == "finish") let [count, cmd, special, args] = liberator.commands.parseCommand(line);
let command = liberator.commands.get(cmd);
if (!command)
{
let lineNumber = i + 1;
// FIXME: messages need to be able to specify
// whether they can be cleared/overwritten or
// should be appended to and the MOW opened
liberator.echoerr("Error detected while processing " + file.path,
liberator.commandline.FORCE_MULTILINE);
liberator.commandline.echo("line " + lineNumber + ":", liberator.commandline.HL_LINENR,
liberator.commandline.APPEND_TO_MESSAGES);
liberator.echoerr("E492: Not an editor command: " + line);
}
else
{
if (command.name == "finish")
{ {
break; break;
} }
else if (command && command.name == "javascript") else if (command.name == "javascript")
{ {
// check for a heredoc // check for a heredoc
var matches = args.match(/(.*)<<\s*([^\s]+)$/); let matches = args.match(/(.*)<<\s*([^\s]+)$/);
if (matches) if (matches)
{ {
@@ -839,6 +856,7 @@ lookup:
} }
} }
} }
}
// if no heredoc-end delimiter is found before EOF then // if no heredoc-end delimiter is found before EOF then
// process the heredoc anyway - Vim compatible ;-) // process the heredoc anyway - Vim compatible ;-)
@@ -854,7 +872,7 @@ lookup:
} }
catch (e) catch (e)
{ {
var message = "Sourcing file: " + file.path + ": " + e; let message = "Sourcing file: " + file.path + ": " + e;
Components.utils.reportError(message); Components.utils.reportError(message);
if (!silent) if (!silent)
liberator.echoerr(message); liberator.echoerr(message);

View File

@@ -529,6 +529,7 @@ liberator.CommandLine = function () //{{{
HL_QUESTION : "hl-Question", HL_QUESTION : "hl-Question",
HL_INFOMSG : "hl-InfoMsg", HL_INFOMSG : "hl-InfoMsg",
HL_WARNINGMSG : "hl-WarningMsg", HL_WARNINGMSG : "hl-WarningMsg",
HL_LINENR : "hl-LineNr",
// not yet used // not yet used
FORCE_MULTILINE : 1 << 0, FORCE_MULTILINE : 1 << 0,

View File

@@ -127,6 +127,10 @@ the terms of any one of the MPL, the GPL or the LGPL.
background-color: white; background-color: white;
color: black; color: black;
} }
.hl-LineNr {
background-color: white;
color: orange;
}
.hl-MoreMsg { .hl-MoreMsg {
background-color: white; background-color: white;
color: green; color: green;