diff --git a/content/bookmarks.js b/content/bookmarks.js index 56e7193b..6b39db3e 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -628,7 +628,8 @@ liberator.History = function () //{{{ completions.push([url, title]); } return [0, completions]; - } + }, + count: true }); liberator.commands.add(["fo[rward]", "fw"], @@ -675,7 +676,8 @@ liberator.History = function () //{{{ completions.push([url, title]); } return [0, completions]; - } + }, + count: true }); liberator.commands.add(["hist[ory]", "hs"], diff --git a/content/commands.js b/content/commands.js index 1080f038..4c9570ba 100644 --- a/content/commands.js +++ b/content/commands.js @@ -79,6 +79,7 @@ liberator.Command = function (specs, description, action, extraInfo) //{{{ this.hereDoc = extraInfo.hereDoc || false; this.options = extraInfo.options || []; this.bang = extraInfo.bang || false; + this.count = extraInfo.count || false; this.isUserCommand = extraInfo.isUserCommand || false; this.replacementText = extraInfo.replacementText || null; diff --git a/content/liberator.js b/content/liberator.js index 4d8bc312..d946da8d 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -492,7 +492,8 @@ const liberator = (function () //{{{ return liberator.completion.ex(filter); else return liberator.completion.javascript(filter); - } + }, + count: true }); liberator.commands.add(["ve[rsion]"], @@ -710,34 +711,34 @@ const liberator = (function () //{{{ if (/^\s*("|$)/.test(str)) return; - if (!modifiers) - modifiers = {}; + modifiers = modifiers || {}; - var [count, cmd, special, args] = liberator.commands.parseCommand(str.replace(/^'(.*)'$/, "$1")); - var command = liberator.commands.get(cmd); + let err = null; + let [count, cmd, special, args] = liberator.commands.parseCommand(str.replace(/^'(.*)'$/, "$1")); + let command = liberator.commands.get(cmd); if (command === null) { - liberator.echoerr("E492: Not a browser command: " + str); + err = "E492: Not a browser command: " + str; liberator.focusContent(); - return; } - - // TODO: need to perform this test? -- djk - if (command.action === null) + else if (command.action === null) { - liberator.echoerr("E666: Internal error: command.action === null"); - return; + err = "E666: Internal error: command.action === null"; // TODO: need to perform this test? -- djk } - - if (special && !command.bang) + else if (count != -1 && !command.count) { - liberator.echoerr("E477: No ! allowed"); - return; + err = "E481: No range allowed"; + } + else if (special && !command.bang) + { + err = "E477: No ! allowed"; } - // valid command, call it: - command.execute(args, special, count, modifiers); + if (!err) + command.execute(args, special, count, modifiers); + else + liberator.echoerr(err); }, // TODO: move to liberator.buffer.focus()? diff --git a/content/mail.js b/content/mail.js index cb96fb43..e2ed5b77 100644 --- a/content/mail.js +++ b/content/mail.js @@ -678,11 +678,14 @@ liberator.Mail = function () //{{{ else SelectFolder(folder.URI); }, - { completer: function (filter) getFolderCompletions(filter) }); + { + completer: function (filter) getFolderCompletions(filter), + count: true + }); liberator.commands.add(["m[essage]"], "Write a new message", - function (args, special, count) + function (args) { var mailargs = {}; mailargs.to = args.arguments.join(", "); diff --git a/content/options.js b/content/options.js index 1fcd9292..d4904ef4 100644 --- a/content/options.js +++ b/content/options.js @@ -390,6 +390,7 @@ liberator.Options = function () //{{{ }, { bang: true, + count: true, completer: function (filter, special, count) { return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_LOCAL }); @@ -405,6 +406,7 @@ liberator.Options = function () //{{{ }, { bang: true, + count: true, completer: function (filter, special, count) { return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_GLOBAL }); diff --git a/content/tabs.js b/content/tabs.js index 8a4d5f41..6250824c 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -345,6 +345,7 @@ liberator.Tabs = function () //{{{ }, { bang: true, + count: true, completer: function (filter) liberator.completion.buffer(filter) }); @@ -385,7 +386,8 @@ liberator.Tabs = function () //{{{ { liberator.tabs.select("-1", true); } - }); + }, + { count: true }); // TODO: "Zero count" if 0 specified as arg liberator.commands.add(["tabn[ext]", "tn[ext]", "bn[ext]"], @@ -423,7 +425,8 @@ liberator.Tabs = function () //{{{ { liberator.tabs.select("+1", true); } - }); + }, + { count: true }); liberator.commands.add(["tabr[ewind]", "tabfir[st]", "br[ewind]", "bf[irst]"], "Switch to the first tab", @@ -457,6 +460,7 @@ liberator.Tabs = function () //{{{ }, { bang: true, + count: true, completer: function (filter) liberator.completion.buffer(filter) }); @@ -528,11 +532,8 @@ liberator.Tabs = function () //{{{ liberator.commands.add(["tabde[tach]"], "Detach current tab to its own window", - function (args, special, count) { liberator.tabs.detachTab(null); }, - { - argCount: "0", - bang: true - }); + function () { liberator.tabs.detachTab(null); }, + { argCount: "0" }); liberator.commands.add(["tabd[uplicate]"], "Duplicate current tab", @@ -552,7 +553,8 @@ liberator.Tabs = function () //{{{ }, { argCount: "0", - bang: true + bang: true, + count: true }); } @@ -598,7 +600,8 @@ liberator.Tabs = function () //{{{ completions.push([url, title]); } return [0, completions]; - } + }, + count: true }); liberator.commands.add(["undoa[ll]"], @@ -624,7 +627,8 @@ liberator.Tabs = function () //{{{ }, { argCount: "0", - bang: true + bang: true, + count: true }); liberator.commands.add(["wqa[ll]", "wq", "xa[ll]"], diff --git a/content/vimperator.js b/content/vimperator.js index 4b90e3d8..c02dec59 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -345,10 +345,7 @@ liberator.config = { //{{{ liberator.commands.add(["winc[lose]", "wc[lose]"], "Close window", - function () - { - window.close(); - }, + function () { window.close(); }, { argCount: "0" }); liberator.commands.add(["wino[pen]", "wo[pen]", "wine[dit]"],