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

Purge unnecessary uses of args.string.

This commit is contained in:
Kris Maglione
2010-09-25 02:45:19 -04:00
parent d1ecfe8041
commit e6c716d1e3
10 changed files with 39 additions and 34 deletions

View File

@@ -382,7 +382,7 @@ const Bookmarks = Module("bookmarks", {
}
});
else {
let url = args.string || buffer.URL;
let url = args[0] || buffer.URL;
let deletedCount = bookmarks.remove(url);
dactyl.echomsg({ domains: [util.getHost(url)], message: deletedCount + " bookmark(s) with url " + url.quote() + " deleted" },

View File

@@ -171,10 +171,8 @@ const Browser = Module("browser", {
commands.add(["o[pen]"],
"Open one or more URLs in the current tab",
function (args) {
args = args.string;
if (args)
dactyl.open(args);
if (args[0])
dactyl.open(args[0]);
else
dactyl.open("about:blank");
}, {

View File

@@ -1437,7 +1437,7 @@ const CommandLine = Module("commandline", {
commands.add([command.name],
command.description,
function (args) {
let str = CommandLine.echoArgumentToString(args.string, true);
let str = CommandLine.echoArgumentToString(args[0], true);
if (str != null)
command.action(str);
}, {

View File

@@ -1415,13 +1415,13 @@ const Dactyl = Module("dactyl", {
"Execute the argument as an Ex command",
function (args) {
try {
let cmd = dactyl.userEval(args.string);
let cmd = dactyl.userEval(args[0]);
dactyl.execute(cmd, null, true);
}
catch (e) {
dactyl.echoerr(e);
}
});
}, { literal: 0 });
///////////////////////////////////////////////////////////////////////////
@@ -1736,15 +1736,17 @@ const Dactyl = Module("dactyl", {
commands.add(["norm[al]"],
"Execute Normal mode commands",
function (args) { events.feedkeys(args.string, args.bang); },
function (args) { events.feedkeys(args[0], args.bang); },
{
argCount: "+",
bang: true
bang: true,
literal: 0
});
commands.add(["optionu[sage]"],
"List all options with a short description",
function (args) { Dactyl.showHelpIndex("option-index", options, args.bang); }, {
function (args) { Dactyl.showHelpIndex("option-index", options, args.bang); },
{
argCount: "0",
bang: true
});
@@ -1804,7 +1806,7 @@ const Dactyl = Module("dactyl", {
function (args) {
let count = args.count;
let special = args.bang;
args = args.string;
args = args[0];
if (args[0] == ":")
var method = function () dactyl.execute(args, null, true);

View File

@@ -1126,17 +1126,18 @@ const Events = Module("events", {
commands.add(["delmac[ros]"],
"Delete macros",
function (args) {
dactyl.assert(!args.bang || !args.string, "E474: Invalid argument");
dactyl.assert(!args.bang || !args[0], "E474: Invalid argument");
if (args.bang)
events.deleteMacros();
else if (args.string)
events.deleteMacros(args.string);
else if (args[0])
events.deleteMacros(args[0]);
else
dactyl.echoerr("E471: Argument required");
}, {
bang: true,
completer: function (context) completion.macro(context)
completer: function (context) completion.macro(context),
literal: 0
});
commands.add(["macros"],

View File

@@ -225,7 +225,7 @@ const Marks = Module("marks", {
"Delete the specified marks",
function (args) {
let special = args.bang;
args = args.string;
args = args[0];
// assert(special ^ args)
dactyl.assert( special || args, "E471: Argument required");
@@ -249,7 +249,8 @@ const Marks = Module("marks", {
},
{
bang: true,
completer: function (context) completion.mark(context)
completer: function (context) completion.mark(context),
literal: 0
});
commands.add(["ma[rk]"],
@@ -267,7 +268,7 @@ const Marks = Module("marks", {
commands.add(["marks"],
"Show all location marks of current web page",
function (args) {
args = args.string;
args = args[0];
// ignore invalid mark characters unless there are no valid mark chars
dactyl.assert(!args || /[a-zA-Z]/.test(args),
@@ -275,6 +276,8 @@ const Marks = Module("marks", {
let filter = args.replace(/[^a-zA-Z]/g, "");
marks.list(filter);
}, {
literal: 0
});
},

View File

@@ -1195,7 +1195,7 @@ const Options = Module("options", {
commands.add(["let"],
"Set or list a variable",
function (args) {
args = args.string;
args = args[0];
if (!args) {
let str =

View File

@@ -117,21 +117,22 @@ const QuickMarks = Module("quickmarks", {
"Delete the specified QuickMarks",
function (args) {
// TODO: finish arg parsing - we really need a proper way to do this. :)
// assert(args.bang ^ args.string)
dactyl.assert( args.bang || args.string, "E471: Argument required");
dactyl.assert(!args.bang || !args.string, "E474: Invalid argument");
// assert(args.bang ^ args[0])
dactyl.assert( args.bang || args[0], "E471: Argument required");
dactyl.assert(!args.bang || !args[0], "E474: Invalid argument");
if (args.bang)
quickmarks.removeAll();
else
quickmarks.remove(args.string);
quickmarks.remove(args[0]);
},
{
bang: true,
completer: function (context) {
context.title = ["QuickMark", "URL"];
context.completions = this._qmarks;
}
},
literal: 0
});
commands.add(["qma[rk]"],
@@ -156,13 +157,15 @@ const QuickMarks = Module("quickmarks", {
commands.add(["qmarks"],
"Show all QuickMarks",
function (args) {
args = args.string;
args = args[0];
// ignore invalid qmark characters unless there are no valid qmark chars
dactyl.assert(!args || /[a-zA-Z0-9]/.test(args), "E283: No QuickMarks matching " + args.quote());
let filter = args.replace(/[^a-zA-Z0-9]/g, "");
quickmarks.list(filter);
}, {
literal: 0
});
},
mappings: function () {

View File

@@ -591,7 +591,7 @@ const Tabs = Module("tabs", {
"Execute a command and tell it to output in a new tab",
function (args) {
dactyl.forceNewTab = true;
dactyl.execute(args.string, null, true);
dactyl.execute(args[0], null, true);
dactyl.forceNewTab = false;
}, {
argCount: "+",
@@ -605,7 +605,7 @@ const Tabs = Module("tabs", {
function (args) {
for (let i = 0; i < tabs.count; i++) {
tabs.select(i);
dactyl.execute(args.string, null, true);
dactyl.execute(args[0], null, true);
}
}, {
argCount: "1",
@@ -756,7 +756,7 @@ const Tabs = Module("tabs", {
commands.add(["tabopen", "t[open]", "tabnew"],
"Open one or more URLs in a new tab",
function (args) {
dactyl.open(args.string || "about:blank", { from: "tabopen", where: dactyl.NEW_TAB, background: args.bang });
dactyl.open(args[0] || "about:blank", { from: "tabopen", where: dactyl.NEW_TAB, background: args.bang });
}, {
bang: true,
completer: function (context) completion.url(context),

View File

@@ -203,7 +203,7 @@ const Config = Module("config", ConfigBase, {
"Execute a command and tell it to output in a new window",
function (args) {
dactyl.forceNewWindow = true;
dactyl.execute(args.string, null, true);
dactyl.execute(args[0], null, true);
dactyl.forceNewWindow = false;
},
{
@@ -221,10 +221,8 @@ const Config = Module("config", ConfigBase, {
commands.add(["wino[pen]", "wo[pen]"],
"Open one or more URLs in a new window",
function (args) {
args = args.string;
if (args)
dactyl.open(args, dactyl.NEW_WINDOW);
if (args[0])
dactyl.open(args[0], dactyl.NEW_WINDOW);
else
dactyl.open("about:blank", dactyl.NEW_WINDOW);
},