1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 08: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]"],
"Abbreviate a key sequence" + modeDescription,
function (args) {
let [,, lhs,, rhs] = splitAbbrev(args[0]);
dactyl.assert(lhs, "E474: Invalid argument");
let [,, lhs,, rhs] = splitAbbrev(args[0] || "");
dactyl.assert(lhs != null, "E474: Invalid argument");
if (rhs) {
if (args["-javascript"]) {

View File

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

View File

@@ -1562,7 +1562,7 @@ const CommandLine = Module("commandline", {
commands.add([command.name],
command.description,
function (args) {
let str = CommandLine.echoArgumentToString(args[0], true);
let str = CommandLine.echoArgumentToString(args[0] || "", true);
if (str != null)
command.action(str);
}, {
@@ -1597,7 +1597,7 @@ const CommandLine = Module("commandline", {
commands.add(["sil[ent]"],
"Run a command silently",
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),
literal: 0,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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