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

Fix some functions that used to use args.string.

This commit is contained in:
Kris Maglione
2010-09-29 13:21:01 -04:00
parent 47f5b5e9d9
commit f7b99e9272
9 changed files with 25 additions and 25 deletions

View File

@@ -230,8 +230,8 @@ const Abbreviations = Module("abbreviations", {
commands.add([ch ? ch + "a[bbrev]" : "ab[breviate]"], commands.add([ch ? ch + "a[bbrev]" : "ab[breviate]"],
"Abbreviate a key sequence" + modeDescription, "Abbreviate a key sequence" + modeDescription,
function (args) { function (args) {
let [,, lhs,, rhs] = splitAbbrev(args[0]); let [,, lhs,, rhs] = splitAbbrev(args[0] || "");
dactyl.assert(lhs, "E474: Invalid argument"); dactyl.assert(lhs != null, "E474: Invalid argument");
if (rhs) { if (rhs) {
if (args["-javascript"]) { if (args["-javascript"]) {

View File

@@ -1185,7 +1185,7 @@ const Buffer = Module("buffer", {
commands.add(["pagest[yle]", "pas"], commands.add(["pagest[yle]", "pas"],
"Select the author style sheet to apply", "Select the author style sheet to apply",
function (args) { function (args) {
let arg = args.literalArg; let arg = args[0] || "";
let titles = buffer.alternateStyleSheets.map(function (stylesheet) stylesheet.title); let titles = buffer.alternateStyleSheets.map(function (stylesheet) stylesheet.title);

View File

@@ -1562,7 +1562,7 @@ const CommandLine = Module("commandline", {
commands.add([command.name], commands.add([command.name],
command.description, command.description,
function (args) { function (args) {
let str = CommandLine.echoArgumentToString(args[0], true); let str = CommandLine.echoArgumentToString(args[0] || "", true);
if (str != null) if (str != null)
command.action(str); command.action(str);
}, { }, {
@@ -1597,7 +1597,7 @@ const CommandLine = Module("commandline", {
commands.add(["sil[ent]"], commands.add(["sil[ent]"],
"Run a command silently", "Run a command silently",
function (args) { function (args) {
commandline.runSilently(function () dactyl.execute(args[0], null, true)); commandline.runSilently(function () dactyl.execute(args[0] || "", null, true));
}, { }, {
completer: function (context) completion.ex(context), completer: function (context) completion.ex(context),
literal: 0, literal: 0,

View File

@@ -1344,7 +1344,7 @@ const Dactyl = Module("dactyl", {
commands.add(["em[enu]"], commands.add(["em[enu]"],
"Execute the specified menu item from the command line", "Execute the specified menu item from the command line",
function (args) { function (args) {
let arg = args.literalArg; let arg = args[0] || "";
let items = Dactyl.getMenuItems(); let items = Dactyl.getMenuItems();
dactyl.assert(items.some(function (i) i.fullMenuPath == arg), dactyl.assert(items.some(function (i) i.fullMenuPath == arg),
@@ -1364,7 +1364,7 @@ const Dactyl = Module("dactyl", {
"Execute the argument as an Ex command", "Execute the argument as an Ex command",
function (args) { function (args) {
try { try {
let cmd = dactyl.userEval(args[0]); let cmd = dactyl.userEval(args[0] || "");
dactyl.execute(cmd, null, true); dactyl.execute(cmd, null, true);
} }
catch (e) { catch (e) {
@@ -1689,7 +1689,7 @@ const Dactyl = Module("dactyl", {
commands.add(["norm[al]"], commands.add(["norm[al]"],
"Execute Normal mode commands", "Execute Normal mode commands",
function (args) { events.feedkeys(args[0], args.bang); }, function (args) { events.feedkeys(args[0] || "", args.bang); },
{ {
argCount: "+", argCount: "+",
bang: true, bang: true,
@@ -1730,7 +1730,7 @@ const Dactyl = Module("dactyl", {
let tbcmd = function (names, desc, action, filter) { let tbcmd = function (names, desc, action, filter) {
commands.add(names, desc, commands.add(names, desc,
function (args) { function (args) {
let toolbar = findToolbar(args[0]); let toolbar = findToolbar(args[0] || "");
dactyl.assert(toolbar, "E474: Invalid argument"); dactyl.assert(toolbar, "E474: Invalid argument");
action(toolbar); action(toolbar);
}, { }, {
@@ -1759,7 +1759,7 @@ const Dactyl = Module("dactyl", {
function (args) { function (args) {
let count = args.count; let count = args.count;
let special = args.bang; let special = args.bang;
args = args[0]; args = args[0] || "";
if (args[0] == ":") if (args[0] == ":")
var method = function () dactyl.execute(args, null, true); var method = function () dactyl.execute(args, null, true);
@@ -1848,7 +1848,7 @@ const Dactyl = Module("dactyl", {
try { try {
vbs.set(args.count || 1); vbs.set(args.count || 1);
vbs.setFrom = null; vbs.setFrom = null;
dactyl.execute(args[0], null, true); dactyl.execute(args[0] || "", null, true);
} }
finally { finally {
vbs.set(value); vbs.set(value);

View File

@@ -117,7 +117,7 @@ const History = Module("history", {
commands.add(["ba[ck]"], commands.add(["ba[ck]"],
"Go back in the browser history", "Go back in the browser history",
function (args) { function (args) {
let url = args.literalArg; let url = args[0];
if (args.bang) if (args.bang)
history.goToStart(); history.goToStart();

View File

@@ -503,7 +503,7 @@ lookup:
commands.add(["cd", "chd[ir]"], commands.add(["cd", "chd[ir]"],
"Change the current directory", "Change the current directory",
function (args) { function (args) {
let arg = args.literalArg; let arg = args[0];
if (!arg) if (!arg)
arg = "~"; arg = "~";
@@ -618,7 +618,7 @@ lookup:
commands.add(["!", "run"], commands.add(["!", "run"],
"Run a command", "Run a command",
function (args) { function (args) {
let arg = args.literalArg; let arg = args[0] || "";
// :!! needs to be treated specially as the command parser sets the // :!! needs to be treated specially as the command parser sets the
// bang flag but removes the ! from arg // bang flag but removes the ! from arg

View File

@@ -225,7 +225,7 @@ const Marks = Module("marks", {
"Delete the specified marks", "Delete the specified marks",
function (args) { function (args) {
let special = args.bang; let special = args.bang;
args = args[0]; args = args[0] || "";
// assert(special ^ args) // assert(special ^ args)
dactyl.assert( special || args, "E471: Argument required"); dactyl.assert( special || args, "E471: Argument required");
@@ -256,7 +256,7 @@ const Marks = Module("marks", {
commands.add(["ma[rk]"], commands.add(["ma[rk]"],
"Mark current location within the web page", "Mark current location within the web page",
function (args) { function (args) {
let mark = args[0]; let mark = args[0] || "";
dactyl.assert(mark.length <= 1, "E488: Trailing characters"); dactyl.assert(mark.length <= 1, "E488: Trailing characters");
dactyl.assert(/[a-zA-Z]/.test(mark), dactyl.assert(/[a-zA-Z]/.test(mark),
"E191: Argument must be a letter or forward/backward quote"); "E191: Argument must be a letter or forward/backward quote");
@@ -268,7 +268,7 @@ const Marks = Module("marks", {
commands.add(["marks"], commands.add(["marks"],
"Show all location marks of current web page", "Show all location marks of current web page",
function (args) { function (args) {
args = args[0]; args = args[0] || "";
// ignore invalid mark characters unless there are no valid mark chars // ignore invalid mark characters unless there are no valid mark chars
dactyl.assert(!args || /[a-zA-Z]/.test(args), dactyl.assert(!args || /[a-zA-Z]/.test(args),

View File

@@ -1240,7 +1240,7 @@ const Options = Module("options", {
commands.add(["let"], commands.add(["let"],
"Set or list a variable", "Set or list a variable",
function (args) { function (args) {
args = args.literalArg.trim(); args = (args[0] || "").trim();
function fmt(value) (typeof value == "number" ? "#" : function fmt(value) (typeof value == "number" ? "#" :
typeof value == "function" ? "*" : typeof value == "function" ? "*" :
" ") + value; " ") + value;

View File

@@ -511,7 +511,7 @@ const Tabs = Module("tabs", {
function (args) { function (args) {
let special = args.bang; let special = args.bang;
let count = args.count; let count = args.count;
let arg = args.literalArg; let arg = args[0] || "";
if (arg) { if (arg) {
let removed = 0; let removed = 0;
@@ -568,7 +568,7 @@ const Tabs = Module("tabs", {
let alternate = tabs.alternate; let alternate = tabs.alternate;
try { try {
dactyl.execute(args[0], null, true); dactyl.execute(args[0] || "", null, true);
} }
finally { finally {
tabs.updateSelectionHistory([tabs.getTab(), alternate]); tabs.updateSelectionHistory([tabs.getTab(), alternate]);
@@ -587,7 +587,7 @@ const Tabs = Module("tabs", {
try { try {
var force = dactyl.forceNewTab; var force = dactyl.forceNewTab;
dactyl.forceNewTab = true; dactyl.forceNewTab = true;
dactyl.execute(args[0], null, true); dactyl.execute(args[0] || "", null, true);
} }
finally { finally {
dactyl.forceNewTab = force; dactyl.forceNewTab = force;
@@ -604,7 +604,7 @@ const Tabs = Module("tabs", {
function (args) { function (args) {
for (let i = 0; i < tabs.count; i++) { for (let i = 0; i < tabs.count; i++) {
tabs.select(i); tabs.select(i);
dactyl.execute(args[0], null, true); dactyl.execute(args[0] || "", null, true);
} }
}, { }, {
argCount: "1", argCount: "1",
@@ -683,7 +683,7 @@ const Tabs = Module("tabs", {
function (args) { function (args) {
let special = args.bang; let special = args.bang;
let count = args.count; let count = args.count;
let arg = args.literalArg; let arg = args[0];
// if a numeric arg is specified any count is ignored; if a // if a numeric arg is specified any count is ignored; if a
// count and non-numeric arg are both specified then E488 // count and non-numeric arg are both specified then E488
@@ -706,7 +706,7 @@ const Tabs = Module("tabs", {
commands.add(["buffers", "files", "ls", "tabs"], commands.add(["buffers", "files", "ls", "tabs"],
"Show a list of all buffers", "Show a list of all buffers",
function (args) { tabs.list(args.literalArg); }, { function (args) { tabs.list(args[0] || ""); }, {
argCount: "?", argCount: "?",
literal: 0 literal: 0
}); });