diff --git a/common/content/abbreviations.js b/common/content/abbreviations.js index 10d29e55..97d26ed8 100644 --- a/common/content/abbreviations.js +++ b/common/content/abbreviations.js @@ -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"]) { diff --git a/common/content/buffer.js b/common/content/buffer.js index 488c6508..f8a30123 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -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); diff --git a/common/content/commandline.js b/common/content/commandline.js index 5decc939..166c3ac3 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -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, diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 59214079..9841d279 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -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); diff --git a/common/content/history.js b/common/content/history.js index 14e6a6b6..e1b5d475 100644 --- a/common/content/history.js +++ b/common/content/history.js @@ -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(); diff --git a/common/content/io.js b/common/content/io.js index c069105a..96687452 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -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 diff --git a/common/content/marks.js b/common/content/marks.js index 39d907af..19f7cc11 100644 --- a/common/content/marks.js +++ b/common/content/marks.js @@ -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), diff --git a/common/content/options.js b/common/content/options.js index 01a4f869..e10739e0 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -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:") { diff --git a/common/content/tabs.js b/common/content/tabs.js index 2bbbe1b3..ac1b59bb 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -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 });