1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 09:27:58 +01:00

Change multiline error message guard clauses to single line formatting.

Also apply similar formattng fixes to conditional blocks as per
standard.
This commit is contained in:
Doug Kearns
2009-05-22 02:36:35 +10:00
parent 4c4295029e
commit 26dabbfd0d
20 changed files with 70 additions and 400 deletions

View File

@@ -59,10 +59,7 @@ function Buffer() //{{{
function setZoom(value, fullZoom)
{
if (value < ZOOM_MIN || value > ZOOM_MAX)
{
liberator.echoerr("Zoom value out of range (" + ZOOM_MIN + " - " + ZOOM_MAX + "%)");
return;
}
return void liberator.echoerr("Zoom value out of range (" + ZOOM_MIN + " - " + ZOOM_MAX + "%)");
ZoomManager.useFullZoom = fullZoom;
ZoomManager.zoom = value / 100;
@@ -533,7 +530,7 @@ function Buffer() //{{{
// FIXME: arg handling is a bit of a mess, check for filename
if (arg && (liberator.has("Win32") || arg[0] != ">"))
return liberator.echoerr("E488: Trailing characters");
return void liberator.echoerr("E488: Trailing characters");
options.withContext(function () {
if (arg)
@@ -543,9 +540,7 @@ function Buffer() //{{{
liberator.echomsg("Printing to file: " + arg.substr(1));
}
else
{
liberator.echomsg("Sending to printer...");
}
options.setPref("print.always_print_silent", args.bang);
options.setPref("print.show_print_progress", !args.bang);
@@ -585,10 +580,7 @@ function Buffer() //{{{
let titles = buffer.alternateStyleSheets.map(function (stylesheet) stylesheet.title);
if (arg && titles.indexOf(arg) == -1)
{
liberator.echoerr("E475: Invalid argument: " + arg);
return;
}
return void liberator.echoerr("E475: Invalid argument: " + arg);
if (options["usermode"])
options["usermode"] = false;
@@ -673,13 +665,9 @@ function Buffer() //{{{
let level;
if (!arg)
{
level = 100;
}
else if (/^\d+$/.test(arg))
{
level = parseInt(arg, 10);
}
else if (/^[+-]\d+$/.test(arg))
{
if (args.bang)
@@ -694,10 +682,7 @@ function Buffer() //{{{
level = ZOOM_MAX;
}
else
{
liberator.echoerr("E488: Trailing characters");
return;
}
return void liberator.echoerr("E488: Trailing characters");
if (args.bang)
buffer.fullZoom = level;
@@ -1735,15 +1720,9 @@ function Marks() //{{{
args = args.string;
if (!special && !args)
{
liberator.echoerr("E471: Argument required");
return;
}
return void liberator.echoerr("E471: Argument required");
if (special && args)
{
liberator.echoerr("E474: Invalid argument");
return;
}
return void liberator.echoerr("E474: Invalid argument");
let matches;
if (matches = args.match(/(?:(?:^|[^a-zA-Z0-9])-|-(?:$|[^a-zA-Z0-9])|[^a-zA-Z0-9 -]).*/))
{
@@ -1784,15 +1763,9 @@ function Marks() //{{{
{
let mark = args[0];
if (mark.length > 1)
{
liberator.echoerr("E488: Trailing characters");
return;
}
return void liberator.echoerr("E488: Trailing characters");
if (!/[a-zA-Z]/.test(mark))
{
liberator.echoerr("E191: Argument must be a letter or forward/backward quote");
return;
}
return void liberator.echoerr("E191: Argument must be a letter or forward/backward quote");
marks.add(mark);
},
@@ -1806,10 +1779,7 @@ function Marks() //{{{
// ignore invalid mark characters unless there are no valid mark chars
if (args && !/[a-zA-Z]/.test(args))
{
liberator.echoerr("E283: No marks matching " + args.quote());
return;
}
return void liberator.echoerr("E283: No marks matching " + args.quote());
let filter = args.replace(/[^a-zA-Z]/g, "");
marks.list(filter);
@@ -1973,19 +1943,13 @@ function Marks() //{{{
let marks = getSortedMarks();
if (marks.length == 0)
{
liberator.echoerr("No marks set");
return;
}
return void liberator.echoerr("No marks set");
if (filter.length > 0)
{
marks = marks.filter(function (mark) filter.indexOf(mark[0]) >= 0);
if (marks.length == 0)
{
liberator.echoerr("E283: No marks matching " + filter.quote());
return;
}
return void liberator.echoerr("E283: No marks matching " + filter.quote());
}
let list = template.tabular(["mark", "line", "col", "file"],

View File

@@ -375,9 +375,7 @@ function Commands() //{{{
if (exCommands.some(function (c) c.hasName(command.name)))
{
if (isUserCommand && replace)
{
commands.removeUserCommand(command.name);
}
else
{
liberator.log("Warning: :" + command.name + " already exists, NOT replacing existing command.", 1);
@@ -716,7 +714,7 @@ function Commands() //{{{
{
[count, arg, quote, error] = getNextArg(sub.substr(optname.length + 1));
if (error)
return liberator.echoerr(error);
return void liberator.echoerr(error);
// if we add the argument to an option after a space, it MUST not be empty
if (sep != "=" && !quote && arg.length == 0)
@@ -725,9 +723,7 @@ function Commands() //{{{
count++; // to compensate the "=" character
}
else if (!/\s/.test(sep) && sep != undefined) // this isn't really an option as it has trailing characters, parse it as an argument
{
invalid = true;
}
let context = null;
if (!complete && quote)
@@ -807,7 +803,7 @@ function Commands() //{{{
// if not an option, treat this token as an argument
let [count, arg, quote, error] = getNextArg(sub);
if (error)
return liberator.echoerr(error);
return void liberator.echoerr(error);
if (complete)
{
@@ -997,10 +993,7 @@ function Commands() //{{{
let cmd = args[0];
if (cmd != null && /\W/.test(cmd))
{
liberator.echoerr("E182: Invalid command name");
return;
}
return void liberator.echoerr("E182: Invalid command name");
if (args.literalArg)
{
@@ -1036,10 +1029,8 @@ function Commands() //{{{
}
}
else
{
completeFunc = completion[completeOptionMap[completeOpt]];
}
}
let added = commands.addUserCommand([cmd],
"User defined command",
@@ -1083,10 +1074,8 @@ function Commands() //{{{
commandline.echo(str, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
}
else
{
liberator.echomsg("No user-defined commands found");
}
}
},
{
bang: true,

View File

@@ -537,13 +537,9 @@ function Editor() //{{{
function (count)
{
if (modes.main == modes.VISUAL)
{
count = getEditor().selectionEnd - getEditor().selectionStart;
}
if (typeof count != "number" || count < 1)
{
count = 1;
}
while (count-- > 0)
{
@@ -867,10 +863,7 @@ function Editor() //{{{
let args = commands.parseArgs(options["editor"], [], "*", true);
if (args.length < 1)
{
liberator.echoerr("No editor specified");
return;
}
return void liberator.echoerr("No editor specified");
args.push(path);
liberator.callFunctionInThread(null, io.run, io.expandPath(args.shift()), args, true);
@@ -1038,12 +1031,10 @@ function Editor() //{{{
return;
}
else
{
return;
}
}
}
}
if (abbreviations[lhs][0][0] == "!")
{
@@ -1125,9 +1116,7 @@ function Editor() //{{{
let list = this.getAbbreviations(filter, lhs);
if (!list.length)
{
liberator.echomsg("No abbreviations found");
}
else if (list.length == 1)
{
let [mode, lhs, rhs] = list[0];

View File

@@ -80,10 +80,7 @@ function AutoCommands() //{{{
events = event.split(",");
if (!events.every(function (event) validEvents.indexOf(event) >= 0))
{
liberator.echoerr("E216: No such group or event: " + event);
return;
}
return void liberator.echoerr("E216: No such group or event: " + event);
}
if (cmd) // add new command, possibly removing all others with the same event/pattern
@@ -104,10 +101,8 @@ function AutoCommands() //{{{
autocommands.remove(event, regex); // remove all
}
else
{
autocommands.list(event, regex); // list all
}
}
},
{
bang: true,
@@ -146,13 +141,9 @@ function AutoCommands() //{{{
let validEvents = config.autocommands.map(function (e) e[0]);
if (event == "*")
{
liberator.echoerr("E217: Can't execute autocommands for ALL events");
}
else if (validEvents.indexOf(event) == -1)
{
liberator.echoerr("E216: No such group or event: " + args);
}
else
{
// TODO: perhaps trigger could return the number of autocmds triggered
@@ -314,12 +305,10 @@ function AutoCommands() //{{{
}
}
else
{
liberator.execute(commands.replaceTokens(autoCmd.command, args), null, true);
}
}
}
}
};
//}}}
}; //}}}
@@ -603,9 +592,7 @@ function Events() //{{{
}
}
else // background tab
{
liberator.echomsg("Background tab loaded: " + title || url, 3);
}
triggerLoadAutocmd("PageLoad", doc);
}
@@ -663,10 +650,8 @@ function Events() //{{{
}
}
else
{
liberator.log("No user macros directory found", 3);
}
}
catch (e)
{
// thrown if directory does not exist
@@ -733,10 +718,7 @@ function Events() //{{{
function (args)
{
if (args.bang && args.string)
{
liberator.echoerr("E474: Invalid argument");
return;
}
return void liberator.echoerr("E474: Invalid argument");
if (args.bang)
events.deleteMacros();
@@ -811,11 +793,8 @@ function Events() //{{{
startRecording: function (macro)
{
if (!/[a-zA-Z0-9]/.test(macro))
{
// TODO: ignore this like Vim?
liberator.echoerr("E354: Invalid register name: '" + macro + "'");
return;
}
return void liberator.echoerr("E354: Invalid register name: '" + macro + "'");
modes.isRecording = true;
@@ -981,21 +960,13 @@ function Events() //{{{
charCode = keyname.charCodeAt(0);
}
else if (keyname.toLowerCase() == "space")
{
charCode = 32;
}
else if (keyname.toLowerCase() == "nop")
{
string = "<Nop>";
}
else if (keyCode = getKeyCode(keyname))
{
charCode = 0;
}
else // an invalid key like <A-xxx> was found, stop propagation here (like Vim)
{
break;
}
i += match.length - 1;
}
@@ -1020,9 +991,7 @@ function Events() //{{{
events.onKeyPress(evt);
}
else
{
elem.dispatchEvent(evt);
}
if (!this.feedingKeys)
break;
// stop feeding keys if page loading failed
@@ -1120,10 +1089,8 @@ function Events() //{{{
modifier = modifier.replace("C-", "");
}
else // [Ctrl-Bug 2,3,4,5/5] the <C-\\>, <C-]>, <C-^>, <C-_> bugs
{
key = String.fromCharCode(event.charCode + 64);
}
}
// special handling of the Space key
else if (event.charCode == 32)
{
@@ -1310,11 +1277,9 @@ function Events() //{{{
}, 0);
}
else
{
modes.reset();
}
}
}
finally
{
lastFocus = elem;
@@ -1422,10 +1387,8 @@ function Events() //{{{
return true;
}
else if (!mappings.hasMap(liberator.mode, input.buffer + key))
{
macros.set(currentMacro, macros.get(currentMacro) + key);
}
}
if (key == "<C-c>")
liberator.interrupted = true;
@@ -1606,9 +1569,7 @@ function Events() //{{{
else if (input.pendingMotionMap)
{
if (key != "<Esc>" && key != "<C-[>")
{
input.pendingMotionMap.execute(candidateCommand, input.count, null);
}
input.pendingMotionMap = null;
input.buffer = "";
inputBufferLength = 0;
@@ -1671,11 +1632,9 @@ function Events() //{{{
commandline.onEvent(event); // reroute event in command line mode
}
else if (liberator.mode != modes.INSERT && liberator.mode != modes.TEXTAREA)
{
liberator.beep();
}
}
}
if (stop)
{

View File

@@ -409,9 +409,7 @@ function Finder() //{{{
let result = getBrowser().fastFind.findAgain(up, linksOnly);
if (result == Ci.nsITypeAheadFind.FIND_NOTFOUND)
{
liberator.echoerr("E486: Pattern not found: " + lastSearchPattern, commandline.FORCE_SINGLELINE);
}
else if (result == Ci.nsITypeAheadFind.FIND_WRAPPED)
{
// hack needed, because wrapping causes a "scroll" event which clears

View File

@@ -260,11 +260,9 @@ function Hints() //{{{
// If we found a satisfactory offset, let's use it.
if (curdist < Infinity)
{
return [leftpos + curleft, toppos + curtop]
}
}
}
catch (e) {} //badly formed document, or shape == "default" in which case we don't move the hint
return [leftpos, toppos]
}
@@ -323,9 +321,7 @@ function Hints() //{{{
let toppos = Math.max((rect.top + scrollY), scrollY);
if (tagname == "area")
{
[leftpos, toppos] = getAreaOffset(elem, leftpos, toppos);
}
span.style.left = leftpos + "px";
span.style.top = toppos + "px";
@@ -532,10 +528,8 @@ function Hints() //{{{
return false;
}
else if (validHints.length > 1)
{
return false;
}
}
let timeout = followFirst || events.feedingKeys ? 0 : 500;
let activeIndex = (hintNumber ? hintNumber - 1 : 0);

View File

@@ -206,20 +206,13 @@ function IO() //{{{
let arg = args.literalArg;
if (!arg)
{
arg = "~";
}
else if (arg == "-")
{
if (oldcwd)
{
arg = oldcwd.path;
}
else
{
liberator.echoerr("E186: No previous directory");
return;
}
return void liberator.echoerr("E186: No previous directory");
}
arg = io.expandPath(arg);
@@ -280,19 +273,13 @@ function IO() //{{{
function (args)
{
if (args.length > 1)
{
liberator.echoerr("E172: Only one file name allowed");
return;
}
return void liberator.echoerr("E172: Only one file name allowed");
let filename = args[0] || io.getRCFile(null, true).path;
let file = io.getFile(filename);
if (file.exists() && !args.bang)
{
liberator.echoerr("E189: \"" + filename + "\" exists (add ! to override)");
return;
}
return void liberator.echoerr("E189: \"" + filename + "\" exists (add ! to override)");
// TODO: Use a set/specifiable list here:
let lines = [cmd.serial().map(commands.commandToString) for (cmd in commands) if (cmd.serial)];
@@ -375,10 +362,7 @@ function IO() //{{{
// replaceable bang and no previous command?
if (/((^|[^\\])(\\\\)*)!/.test(arg) && !lastRunCommand)
{
liberator.echoerr("E34: No previous command");
return;
}
return void liberator.echoerr("E34: No previous command");
// NOTE: Vim doesn't replace ! preceded by 2 or more backslashes and documents it - desirable?
// pass through a raw bang when escaped or substitute the last command
@@ -527,9 +511,7 @@ function IO() //{{{
newDir = newDir || "~";
if (newDir == "-")
{
[cwd, oldcwd] = [oldcwd, this.getCurrentDirectory()];
}
else
{
let dir = self.getFile(newDir);
@@ -820,9 +802,7 @@ function IO() //{{{
let file;
if (isAbsolutePath(program))
{
file = self.getFile(program, true);
}
else
{
let dirs = services.get("environment").get("PATH").split(WINDOWS ? ";" : ":");
@@ -968,9 +948,7 @@ lookup:
}
}
else if (/\.css$/.test(filename))
{
storage.styles.registerSheet(uri.spec, true);
}
else
{
let heredoc = "";
@@ -988,10 +966,8 @@ lookup:
heredocEnd = null;
}
else
{
heredoc += line + "\n";
}
}
else
{
self.sourcing.line = i + 1;
@@ -1018,9 +994,7 @@ lookup:
else
{
if (command.name == "finish")
{
break;
}
else if (command.hereDoc)
{
// check for a heredoc
@@ -1034,10 +1008,8 @@ lookup:
heredoc = matches[1] + "\n";
}
else
{
command.execute(args, special, count);
}
}
else
{
// execute a normal liberator command

View File

@@ -299,10 +299,7 @@ const liberator = (function () //{{{
let items = getMenuItems();
if (!items.some(function (i) i.fullMenuPath == arg))
{
liberator.echoerr("E334: Menu not found: " + arg);
return;
}
return void liberator.echoerr("E334: Menu not found: " + arg);
for (let [,item] in Iterator(items))
{
@@ -333,7 +330,6 @@ const liberator = (function () //{{{
catch (e)
{
liberator.echoerr(e);
return;
}
});
@@ -350,10 +346,7 @@ const liberator = (function () //{{{
function (args)
{
if (args.bang)
{
liberator.echoerr("E478: Don't panic!");
return;
}
return void liberator.echoerr("E478: Don't panic!");
liberator.help(args.literalArg);
},
@@ -480,9 +473,7 @@ const liberator = (function () //{{{
totalUnits = "sec";
}
else
{
totalUnits = "msec";
}
let str = template.commandOutput(
<table>
@@ -811,10 +802,7 @@ const liberator = (function () //{{{
let opt = this.options.get(matches[1]);
if (!opt)
{
this.echoerr("E113: Unknown option: " + matches[1]);
return;
}
return void this.echoerr("E113: Unknown option: " + matches[1]);
let type = opt.type;
let value = opt.getter();
@@ -829,21 +817,14 @@ const liberator = (function () //{{{
else if (matches = string.match(/^(['"])([^\1]*?[^\\]?)\1/))
{
if (matches)
{
return matches[2].toString();
}
else
{
this.echoerr("E115: Missing quote: " + string);
return;
}
return void this.echoerr("E115: Missing quote: " + string);
}
// Number
else if (matches = string.match(/^(\d+)$/))
{
return parseInt(matches[1], 10);
}
let reference = this.variableReference(string);
@@ -874,20 +855,14 @@ const liberator = (function () //{{{
liberator.focusContent();
}
else if (command.action === null)
{
err = "E666: Internal error: command.action === null"; // TODO: need to perform this test? -- djk
}
else if (count != -1 && !command.count)
{
err = "E481: No range allowed";
}
else if (special && !command.bang)
{
err = "E477: No ! allowed";
}
if (err)
return liberator.echoerr(err);
return void liberator.echoerr(err);
if (!silent)
commandline.command = str.replace(/^\s*:\s*/, "");
command.execute(args, special, count, modifiers);
@@ -947,10 +922,8 @@ const liberator = (function () //{{{
if (item[0] == topic)
return format(item);
else if (!partialMatch && item[0].indexOf(topic) > -1)
{
partialMatch = item;
}
}
if (partialMatch)
return format(partialMatch);
@@ -975,7 +948,7 @@ const liberator = (function () //{{{
let page = this.findHelp(topic);
if (page == null)
return liberator.echoerr("E149: Sorry, no help for " + topic);
return void liberator.echoerr("E149: Sorry, no help for " + topic);
liberator.open("chrome://liberator/locale/" + page, where);
if (where == this.CURRENT_TAB)
@@ -991,10 +964,7 @@ const liberator = (function () //{{{
function sourceDirectory(dir)
{
if (!dir.isReadable())
{
liberator.echoerr("E484: Can't open file " + dir.path);
return;
}
return void liberator.echoerr("E484: Can't open file " + dir.path);
liberator.log("Sourcing plugin directory: " + dir.path + "...", 3);
io.readDirectory(dir.path, true).forEach(function (file) {
@@ -1011,9 +981,7 @@ const liberator = (function () //{{{
}
}
else if (file.isDirectory())
{
sourceDirectory(file);
}
});
}

View File

@@ -204,9 +204,7 @@ function Mappings() //{{{
let [lhs, rhs] = args;
if (!rhs) // list the mapping
{
mappings.list(mode, expandLeader(lhs));
}
else
{
for (let [,m] in Iterator(mode))

View File

@@ -214,9 +214,7 @@ Option.prototype = {
return null;
}
else
{
scope = this.scope;
}
let aValue;
@@ -602,25 +600,17 @@ function Options() //{{{
options.setPref(name, value);
}
else
{
options.listPrefs(onlyNonDefault, name);
}
return;
}
let opt = options.parseOpt(arg, modifiers);
if (!opt)
{
liberator.echoerr("Error parsing :set command: " + arg);
return;
}
return void liberator.echoerr("Error parsing :set command: " + arg);
let option = opt.option;
if (option == null && !opt.all)
{
liberator.echoerr("No such option: " + opt.name);
return;
}
return void liberator.echoerr("No such option: " + opt.name);
// reset a variable to its default value
if (opt.reset)
@@ -631,17 +621,13 @@ function Options() //{{{
option.reset();
}
else
{
option.reset();
}
}
// read access
else if (opt.get)
{
if (opt.all)
{
options.list(opt.onlyNonDefault, opt.scope);
}
else
{
if (option.type == "boolean")
@@ -658,10 +644,7 @@ function Options() //{{{
if (opt.option.type == "boolean")
{
if (opt.valueGiven)
{
liberator.echoerr("E474: Invalid argument: " + arg);
return;
}
return void liberator.echoerr("E474: Invalid argument: " + arg);
opt.values = !opt.unsetBoolean;
}
let res = opt.option.op(opt.operator || "=", opt.values, opt.scope, opt.invert);
@@ -803,17 +786,11 @@ function Options() //{{{
{
let reference = liberator.variableReference(matches[2]);
if (!reference[0] && matches[3])
{
liberator.echoerr("E121: Undefined variable: " + matches[2]);
return;
}
return void liberator.echoerr("E121: Undefined variable: " + matches[2]);
let expr = liberator.evalExpression(matches[4]);
if (expr === undefined)
{
liberator.echoerr("E15: Invalid expression: " + matches[4]);
return;
}
return void liberator.echoerr("E15: Invalid expression: " + matches[4]);
else
{
if (!reference[0])
@@ -843,10 +820,7 @@ function Options() //{{{
{
let reference = liberator.variableReference(matches[1]);
if (!reference[0])
{
liberator.echoerr("E121: Undefined variable: " + matches[1]);
return;
}
return void liberator.echoerr("E121: Undefined variable: " + matches[1]);
let value = reference[0][reference[1]];
let prefix = typeof value == "number" ? "#" :
@@ -1117,9 +1091,7 @@ function Options() //{{{
option.default = (option.default ? "" : "no") + opt.name;
}
else
{
option.value = <>={template.highlight(opt.value)}</>;
}
yield option;
}
};

View File

@@ -557,7 +557,7 @@ liberator.registerObserver("load_commands", function ()
if (scheme == "default")
highlight.clear();
else if (!io.sourceFromRuntimePath(["colors/" + scheme + ".vimp"]))
return liberator.echoerr("E185: Cannot find color scheme " + scheme);
return void liberator.echoerr("E185: Cannot find color scheme " + scheme);
autocommands.trigger("ColorScheme", { name: scheme });
},
{
@@ -605,9 +605,7 @@ liberator.registerObserver("load_commands", function ()
{
let compl = [];
if (args.completeArg == 0)
{
styles.completeSite(context, content);
}
else if (args.completeArg == 1)
{
let sheet = styles.get(false, args["-name"]);

View File

@@ -129,9 +129,7 @@ function Tabs() //{{{
return options["showtabline"]; // XXX
if (value == 0)
{
tabStrip.collapsed = true;
}
else
{
let pref = "browser.tabStrip.autoHide";
@@ -417,13 +415,9 @@ function Tabs() //{{{
liberator.echoerr("E488: Trailing characters");
}
else if (count > 0)
{
tabs.select("-" + count, true);
}
else
{
tabs.select("-1", true);
}
},
{
argCount: "?",
@@ -446,19 +440,12 @@ function Tabs() //{{{
if (arg)
{
if (/^\d+$/.test(arg))
{
index = arg - 1;
else
return void liberator.echoerr("E488: Trailing characters");
}
else
{
liberator.echoerr("E488: Trailing characters");
return;
}
}
else
{
index = count - 1;
}
if (index < tabs.count)
tabs.select(index, true);
@@ -466,9 +453,7 @@ function Tabs() //{{{
liberator.beep();
}
else
{
tabs.select("+1", true);
}
},
{
argCount: "?",
@@ -501,13 +486,9 @@ function Tabs() //{{{
liberator.echoerr("E488: Trailing characters");
}
else if (count > 0)
{
tabs.switchTo(count.toString(), special);
}
else
{
tabs.switchTo(arg, special);
}
},
{
argCount: "?",
@@ -555,10 +536,7 @@ function Tabs() //{{{
// FIXME: tabmove! N should probably produce an error
if (arg && !/^([+-]?\d+)$/.test(arg))
{
liberator.echoerr("E488: Trailing characters");
return;
}
return void liberator.echoerr("E488: Trailing characters");
// if not specified, move to after the last tab
tabs.move(getBrowser().mCurrentTab, arg || "$", args.bang);
@@ -647,10 +625,7 @@ function Tabs() //{{{
}
if (!count)
{
liberator.echoerr("Exxx: No matching closed tab");
return;
}
return void liberator.echoerr("Exxx: No matching closed tab");
}
window.undoCloseTab(count - 1);
@@ -1021,9 +996,7 @@ function Tabs() //{{{
getBrowser().getBrowserForTab(tab).reloadWithFlags(flags);
}
else
{
getBrowser().reloadTab(tab);
}
},
/**
@@ -1050,9 +1023,7 @@ function Tabs() //{{{
}
}
else
{
getBrowser().reloadAllTabs();
}
},
/**
@@ -1205,10 +1176,7 @@ function Tabs() //{{{
selectAlternateTab: function ()
{
if (tabs.alternate == null || tabs.getTab() == tabs.alternate)
{
liberator.echoerr("E23: No alternate page");
return;
}
return void liberator.echoerr("E23: No alternate page");
// NOTE: this currently relies on v.tabs.index() returning the
// currently selected tab index when passed null

View File

@@ -714,9 +714,7 @@ function CommandLine() //{{{
elements[elements.length - 1].scrollIntoView(true);
}
else
{
win.scrollTo(0, doc.height);
}
win.focus();
@@ -1413,9 +1411,7 @@ function CommandLine() //{{{
setTimeout(function () { multilineInputWidget.inputField.focus(); }, 0);
}
else if (event.type == "input")
{
autosizeMultilineInputWidget();
}
return true;
},
@@ -1462,9 +1458,7 @@ function CommandLine() //{{{
tabs.select(parseInt(event.originalTarget.parentNode.parentNode.firstChild.textContent, 10) - 1);
}
else
{
openLink(liberator.CURRENT_TAB);
}
break;
case "<MiddleMouse>":
case "<C-LeftMouse>":
@@ -1635,9 +1629,7 @@ function CommandLine() //{{{
events.onKeyPress(event);
}
else
{
commandline.updateMorePrompt(showMorePrompt, showMoreHelpPrompt);
}
},
getSpaceNeeded: function getSpaceNeeded()
@@ -2157,9 +2149,7 @@ function StatusLine() //{{{
progress = "";
if (typeof progress == "string")
{
progressWidget.value = progress;
}
else if (typeof progress == "number")
{
let progressStr = "";

View File

@@ -100,9 +100,7 @@ function Addressbook() //{{{
+ " -lastname=" + names[1].replace(/"/g, "");
}
else
{
displayName = "-name=\"" + displayName.replace(/"/g, "") + "\"";
}
commandline.open(":", "contact " + address + " " + displayName, modes.EX);
});

View File

@@ -707,10 +707,7 @@ function Mail() //{{{
// TODO: is there a better way to check for validity?
if (addresses.some(function (recipient) !(/\S@\S+\.\S/.test(recipient))))
{
liberator.echoerr("Exxx: Invalid e-mail address");
return;
}
return void liberator.echoerr("Exxx: Invalid e-mail address");
mail.composeNewMail(mailargs);
},
@@ -789,10 +786,7 @@ function Mail() //{{{
var url = args.attachments.pop();
var file = io.getFile(url);
if (!file.exists())
{
liberator.echoerr("Exxx: Could not attach file `" + url + "'", commandline.FORCE_SINGLELINE);
return;
}
return void liberator.echoerr("Exxx: Could not attach file `" + url + "'", commandline.FORCE_SINGLELINE);
attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"]
.createInstance(Components.interfaces.nsIMsgAttachment);

View File

@@ -467,9 +467,7 @@ function Bookmarks() //{{{
let count = this.remove(url);
if (count > 0)
{
commandline.echo("Removed bookmark: " + url, commandline.HL_NORMAL, commandline.FORCE_SINGLELINE);
}
else
{
let title = buffer.title || url;
@@ -692,9 +690,7 @@ function History() //{{{
let url = args.literalArg;
if (args.bang)
{
history.goToStart();
}
else
{
if (url)
@@ -711,10 +707,8 @@ function History() //{{{
liberator.echoerr("Exxx: URL not found in history");
}
else
{
history.stepTo(-Math.max(args.count, 1));
}
}
},
{
argCount: "?",
@@ -739,9 +733,7 @@ function History() //{{{
let url = args.literalArg;
if (args.bang)
{
history.goToEnd();
}
else
{
if (url)
@@ -758,10 +750,8 @@ function History() //{{{
liberator.echoerr("Exxx: URL not found in history");
}
else
{
history.stepTo(Math.max(args.count, 1));
}
}
},
{
argCount: "?",
@@ -944,16 +934,10 @@ function QuickMarks() //{{{
{
// TODO: finish arg parsing - we really need a proper way to do this. :)
if (!args.bang && !args.string)
{
liberator.echoerr("E471: Argument required");
return;
}
return void liberator.echoerr("E471: Argument required");
if (args.bang && args.string)
{
liberator.echoerr("E474: Invalid argument");
return;
}
return void liberator.echoerr("E474: Invalid argument");
if (args.bang)
quickmarks.removeAll();
@@ -991,10 +975,7 @@ function QuickMarks() //{{{
// ignore invalid qmark characters unless there are no valid qmark chars
if (args && !/[a-zA-Z0-9]/.test(args))
{
liberator.echoerr("E283: No QuickMarks matching \"" + args + "\"");
return;
}
return void liberator.echoerr("E283: No QuickMarks matching \"" + args + "\"");
let filter = args.replace(/[^a-zA-Z0-9]/g, "");
quickmarks.list(filter);
@@ -1048,19 +1029,13 @@ function QuickMarks() //{{{
marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);
if (marks.length == 0)
{
liberator.echoerr("No QuickMarks set");
return;
}
return void liberator.echoerr("No QuickMarks set");
if (filter.length > 0)
{
marks = marks.filter(function (qmark) filter.indexOf(qmark) >= 0);
if (marks.length == 0)
{
liberator.echoerr("E283: No QuickMarks matching \"" + filter + "\"");
return;
}
return void liberator.echoerr("E283: No QuickMarks matching \"" + filter + "\"");
}
let items = [[mark, qmarks.get(mark)] for ([k, mark] in Iterator(marks))];

View File

@@ -326,9 +326,7 @@ const config = { //{{{
function (args)
{
if (args.string)
{
liberator.open(args.string);
}
else if (args.bang)
BrowserReloadSkipCache();
else
@@ -351,9 +349,7 @@ const config = { //{{{
? liberator.NEW_TAB : liberator.CURRENT_TAB);
}
else
{
window.openPreferences();
}
},
{
argCount: "0",

View File

@@ -465,9 +465,7 @@ function Bookmarks() //{{{
let count = this.remove(url);
if (count > 0)
{
commandline.echo("Removed bookmark: " + url, commandline.HL_NORMAL, commandline.FORCE_SINGLELINE);
}
else
{
let title = buffer.title || url;
@@ -622,9 +620,7 @@ function Bookmarks() //{{{
param = aURL.substr(offset + 1);
}
if (!aPostDataRef)
{
aPostDataRef = {};
}
var engine = searchService.getEngineByAlias(keyword);
if (engine)
{
@@ -634,23 +630,17 @@ function Bookmarks() //{{{
}
[shortcutURL, aPostDataRef.value] = PlacesUtils.getURLAndPostDataForKeyword(keyword);
if (!shortcutURL)
{
return aURL;
}
var postData = "";
if (aPostDataRef.value)
{
postData = unescape(aPostDataRef.value);
}
if (/%s/i.test(shortcutURL) || /%s/i.test(postData))
{
var charset = "";
const re = /^(.*)\&mozcharset=([a-zA-Z][_\-a-zA-Z0-9]+)\s*$/;
var matches = shortcutURL.match(re);
if (matches)
{
[, shortcutURL, charset] = matches;
}
else
{
try
@@ -660,17 +650,15 @@ function Bookmarks() //{{{
}
var encodedParam = "";
if (charset)
{
encodedParam = escape(convertFromUnicode(charset, param));
} else {
else
encodedParam = encodeURIComponent(param);
}
shortcutURL = shortcutURL.replace(/%s/g, encodedParam).replace(/%S/g, param);
if (/%s/i.test(postData))
{
aPostDataRef.value = getPostDataStream(postData, param, encodedParam, "application/x-www-form-urlencoded");
}
} else if (param) {
else if (param)
{
aPostDataRef.value = null;
return aURL;
}
@@ -762,9 +750,7 @@ function History() //{{{
let url = args.literalArg;
if (args.bang)
{
history.goToStart();
}
else
{
if (url)
@@ -781,10 +767,8 @@ function History() //{{{
liberator.echoerr("Exxx: URL not found in history");
}
else
{
history.stepTo(-Math.max(args.count, 1));
}
}
},
{
argCount: "?",
@@ -808,9 +792,7 @@ function History() //{{{
let url = args.literalArg;
if (args.bang)
{
history.goToEnd();
}
else
{
if (url)
@@ -827,10 +809,8 @@ function History() //{{{
liberator.echoerr("Exxx: URL not found in history");
}
else
{
history.stepTo(Math.max(args.count, 1));
}
}
},
{
argCount: "?",
@@ -1006,16 +986,10 @@ function QuickMarks() //{{{
{
// TODO: finish arg parsing - we really need a proper way to do this. :)
if (!args.bang && !args.string)
{
liberator.echoerr("E471: Argument required");
return;
}
return void liberator.echoerr("E471: Argument required");
if (args.bang && args.string)
{
liberator.echoerr("E474: Invalid argument");
return;
}
return void liberator.echoerr("E474: Invalid argument");
if (args.bang)
quickmarks.removeAll();
@@ -1053,10 +1027,7 @@ function QuickMarks() //{{{
// ignore invalid qmark characters unless there are no valid qmark chars
if (args && !/[a-zA-Z0-9]/.test(args))
{
liberator.echoerr("E283: No QuickMarks matching \"" + args + "\"");
return;
}
return void liberator.echoerr("E283: No QuickMarks matching \"" + args + "\"");
let filter = args.replace(/[^a-zA-Z0-9]/g, "");
quickmarks.list(filter);
@@ -1110,19 +1081,13 @@ function QuickMarks() //{{{
marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);
if (marks.length == 0)
{
liberator.echoerr("No QuickMarks set");
return;
}
return void liberator.echoerr("No QuickMarks set");
if (filter.length > 0)
{
marks = marks.filter(function (qmark) filter.indexOf(qmark) >= 0);
if (marks.length == 0)
{
liberator.echoerr("E283: No QuickMarks matching \"" + filter + "\"");
return;
}
return void liberator.echoerr("E283: No QuickMarks matching \"" + filter + "\"");
}
let items = [[mark, qmarks.get(mark)] for ([k, mark] in Iterator(marks))];

View File

@@ -426,9 +426,7 @@ const config = { //{{{
function (args)
{
if (args.string)
{
liberator.open(args.string);
}
else if (args.bang)
BrowserReloadSkipCache();
else
@@ -451,9 +449,7 @@ const config = { //{{{
? liberator.NEW_TAB : liberator.CURRENT_TAB);
}
else
{
window.openPreferences();
}
},
{
argCount: "0",

View File

@@ -287,10 +287,7 @@ function Player() // {{{
// intentionally supports 999:99:99
if (!/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg))
{
liberator.echoerr("E475: Invalid argument: " + arg);
return;
}
return void liberator.echoerr("E475: Invalid argument: " + arg);
function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m])
@@ -322,10 +319,7 @@ function Player() // {{{
{
// FIXME: is this a SB restriction? --djk
if (!gBrowser.currentMediaPage)
{
liberator.echoerr("Exxx: Can only set the media view from the media tab"); // XXX
return;
}
return void liberator.echoerr("Exxx: Can only set the media view from the media tab"); // XXX
let arg = args[0];
@@ -401,10 +395,7 @@ function Player() // {{{
let arg = args[0];
if (!/^[+-]?\d+$/.test(arg))
{
liberator.echoerr("E488: Trailing characters");
return;
}
return void liberator.echoerr("E488: Trailing characters");
let level = parseInt(arg, 10) / 100;
@@ -602,9 +593,7 @@ function Player() // {{{
focusTrack(mySearchView.getItemByIndex(lastSearchIndex));
}
else
{
liberator.echoerr("E486 Pattern not found: " + searchString, commandline.FORCE_SINGLELINE);
}
},
searchViewAgain: function searchViewAgain(reverse)
@@ -683,9 +672,7 @@ function Player() // {{{
{
// FIXME: why are there null items and duplicates?
if (!playlists.some(function (list) list.name == item.name) && item.name != null)
{
playlists.push(item);
}
return Ci.sbIMediaListEnumerationListener.CONTINUE;
}
};
@@ -749,16 +736,16 @@ function Player() // {{{
{
case "#":
case "Title":
pa.appendProperty(SBProperties.trackName, 'a');
pa.appendProperty(SBProperties.trackName, "a");
break;
case "Rating":
pa.appendProperty(SBProperties.rating, 1);
break;
case "Album":
pa.appendProperty(SBProperties.albumName, 'a');
pa.appendProperty(SBProperties.albumName, "a");
break;
default:
pa.appendProperty(SBProperties.trackName, 'a');
pa.appendProperty(SBProperties.trackName, "a");
break;
}