diff --git a/content/commands.js b/content/commands.js index f57a1b6f..fad5da76 100644 --- a/content/commands.js +++ b/content/commands.js @@ -469,8 +469,9 @@ function Commands() //{{{ if (!argCount) argCount = "*"; + if (literal) - argCount = parseInt(argCount); + var literalIndex = parseInt(argCount) - 1 || 0; var args = {}; // parsed options args.arguments = []; // remaining arguments @@ -594,9 +595,10 @@ function Commands() //{{{ } } - if (literal && args.arguments.length == argCount) + if (literal && args.arguments.length == literalIndex) { args.literalArg = sub; + args.arguments.push(sub); break; } @@ -619,9 +621,6 @@ function Commands() //{{{ i += count; // hopefully count is always > 0, otherwise we get an endless loop } - if (literal) - return args; - // check for correct number of arguments if (args.arguments.length == 0 && (argCount == "1" || argCount == "+")) { @@ -787,8 +786,7 @@ function Commands() //{{{ } }, { - literal: true, - argCount: 1, + argCount: "2", bang: true, completer: function (filter) completion.userCommand(filter), options: [ @@ -796,6 +794,7 @@ function Commands() //{{{ [["-bang"], commandManager.OPTION_NOARG], [["-count"], commandManager.OPTION_NOARG], ], + literal: true, serial: function () [ { command: this.name, diff --git a/content/editor.js b/content/editor.js index 9b441eeb..c7148004 100644 --- a/content/editor.js +++ b/content/editor.js @@ -174,7 +174,7 @@ function Editor() //{{{ editor.listAbbreviations(mode, lhs || ""); }, { - argCount: 1, + argCount: "2", literal: true, serial: function () [ { diff --git a/content/events.js b/content/events.js index 9555c66b..e3c3120a 100644 --- a/content/events.js +++ b/content/events.js @@ -111,10 +111,10 @@ function AutoCommands() //{{{ } }, { - argCount: 2, + argCount: "3", bang: true, - literal: true, - completer: function (filter) completion.event(filter) + completer: function (filter) completion.event(filter), + literal: true }); // TODO: expand target to all buffers diff --git a/content/mappings.js b/content/mappings.js index 8db1afa0..c73a3444 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -180,11 +180,11 @@ function Mappings() //{{{ modeDescription = modeDescription ? " in " + modeDescription + " mode" : ""; const opts = { + argCount: "2", completer: function (filter) completion.userMapping(filter, modes), options: [ [["", ""], commands.OPTION_NOARG] ], - argCount: 1, literal: true, serial: function () { let noremap = this.name.indexOf("noremap") > -1; diff --git a/content/style.js b/content/style.js index f779a300..c414d059 100644 --- a/content/style.js +++ b/content/style.js @@ -429,6 +429,8 @@ liberator.registerObserver("load_commands", function () } }, { + argCount: "2", + bang: true, completer: function (filter) { let compl = []; try @@ -440,8 +442,6 @@ liberator.registerObserver("load_commands", function () comp = compl.concat([[s, ""] for each (s in styles.sites)]) return [0, completion.filter(compl, filter)]; }, - argCount: 1, - bang: true, hereDoc: true, literal: true, options: [[["-name", "-n"], commands.OPTION_STRING], @@ -463,7 +463,7 @@ liberator.registerObserver("load_commands", function () styles.removeSheet(args["-name"], args.arguments[0], args.literalArg, args["-index"], false); }, { - argCount: 1, + argCount: "2", completer: function (filter) [0, completion.filter( [[i, <>{s.sites.join(",")}: {s.css.replace("\n", "\\n")}] for ([i, s] in styles.userSheets) @@ -507,13 +507,13 @@ liberator.registerObserver("load_commands", function () liberator.echoerr(error); }, { + argCount: "2", + bang: true, // TODO: add this as a standard highlight completion function? // I agree. It could (should) be much more sophisticated. --Kris completer: function (filter) [0, completion.filter([[v.class, ""] for (v in highlight)], filter) ], - argCount: 1, - bang: true, hereDoc: true, literal: true, options: [[["-append", "-a"], commands.OPTION_NOARG]], diff --git a/content/tabs.js b/content/tabs.js index 93354a65..e2699a2b 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -481,7 +481,7 @@ function Tabs() //{{{ "Show a list of all buffers", function (args) { tabs.list(args.literalArg); }, { - argCount: "0", + argCount: "?", literal: true });