From 413e01da4178755f57a755e36d60f1d37f53d7d2 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 6 Oct 2008 13:07:57 +0000 Subject: [PATCH] add some missing argCount specs to commands --- content/bookmarks.js | 6 ++---- content/buffer.js | 15 ++++++++++++--- content/events.js | 22 ++++++++-------------- content/io.js | 7 ++----- content/liberator.js | 6 +++++- content/tabs.js | 5 ++++- content/vimperator.js | 2 +- locale/en-US/repeat.txt | 2 +- 8 files changed, 35 insertions(+), 30 deletions(-) diff --git a/content/bookmarks.js b/content/bookmarks.js index 6b39db3e..552b6323 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -287,11 +287,9 @@ liberator.Bookmarks = function () //{{{ "Delete a bookmark", function (args) { - var url = args; - if (!url) - url = liberator.buffer.URL; + let url = args || liberator.buffer.URL; + let deletedCount = liberator.bookmarks.remove(url); - var deletedCount = liberator.bookmarks.remove(url); liberator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", liberator.commandline.FORCE_SINGLELINE); }, { completer: function (filter) [0, liberator.bookmarks.get(filter)] }); diff --git a/content/buffer.js b/content/buffer.js index e930634c..06476cf8 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -675,7 +675,10 @@ liberator.Buffer = function () //{{{ liberator.options.setPref("print.show_print_progress", spp); liberator.echo("Print job sent."); }, - { bang: true }); + { + argCount: "0", + bang: true + }); liberator.commands.add(["pa[geinfo]"], "Show various page information", @@ -724,7 +727,10 @@ liberator.Buffer = function () //{{{ //else saveDocument(window.content.document, special); }, - { bang: true, }); + { + argCount: "0", + bang: true + }); liberator.commands.add(["st[op]"], "Stop loading", @@ -795,7 +801,10 @@ liberator.Buffer = function () //{{{ liberator.commands.add(["vie[wsource]"], "View source code of current document", function (args, special) { liberator.buffer.viewSource(args, special); }, - { bang: true }); + { + argCount: "1", + bang: true + }); liberator.commands.add(["zo[om]"], "Set zoom value of current web page", diff --git a/content/events.js b/content/events.js index d90f9548..d78c1653 100644 --- a/content/events.js +++ b/content/events.js @@ -677,14 +677,11 @@ liberator.Events = function () //{{{ liberator.commands.add(["delmac[ros]"], "Delete macros", - function (args) + function (args) { liberator.events.deleteMacros(args); }, { - if (!args) - liberator.echoerr("E474: Invalid argument"); - else - liberator.events.deleteMacros(args); - }, - { completer: function (filter) liberator.completion.macro(filter) }); + argCount: "+", // pattern might contain whitespace + completer: function (filter) liberator.completion.macro(filter) + }); liberator.commands.add(["macros"], "List all macros", @@ -698,14 +695,11 @@ liberator.Events = function () //{{{ liberator.commands.add(["pl[ay]"], "Replay a recorded macro", - function (args) + function (args) { liberator.events.playMacro(args); }, { - if (!args) - liberator.echoerr("E474: Invalid argument"); - else - liberator.events.playMacro(args); - }, - { completer: function (filter) liberator.completion.macro(filter) }); + argCount: "1", + completer: function (filter) liberator.completion.macro(filter) + }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// diff --git a/content/io.js b/content/io.js index 6d0170c3..0173ec9e 100644 --- a/content/io.js +++ b/content/io.js @@ -178,13 +178,10 @@ liberator.IO = function () //{{{ }, { completer: function (filter) liberator.completion.file(filter, true) }); + // NOTE: this command is only used in :source liberator.commands.add(["fini[sh]"], "Stop sourcing a script file", - function () - { - // this command is only used in :source - liberator.echoerr("E168: :finish used outside of a sourced file"); - }, + function () { liberator.echoerr("E168: :finish used outside of a sourced file"); }, { argCount: "0" }); liberator.commands.add(["pw[d]"], diff --git a/content/liberator.js b/content/liberator.js index d946da8d..e325c28d 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -188,7 +188,10 @@ const liberator = (function () //{{{ return [0, liberator.completion.filter(liberator.config.dialogs || [], filter)]; } }, - { bang: true }); + { + argCount: "1", + bang: true + }); // TODO: move this function getMenuItems() @@ -485,6 +488,7 @@ const liberator = (function () //{{{ } }, { + argCount: "+", bang: true, completer: function (filter) { diff --git a/content/tabs.js b/content/tabs.js index 6250824c..af05ce63 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -358,7 +358,10 @@ liberator.Tabs = function () //{{{ liberator.execute(args); liberator.forceNewTab = false; }, - { completer: function (filter) liberator.completion.ex(filter) }); + { + argCount: "+", + completer: function (filter) liberator.completion.ex(filter) + }); liberator.commands.add(["tabl[ast]", "bl[ast]"], "Switch to the last tab", diff --git a/content/vimperator.js b/content/vimperator.js index c02dec59..a0b6d87d 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -302,7 +302,7 @@ liberator.config = { //{{{ "Close the sidebar window", function () { - if (document.getElementById("sidebar-box").hidden == false) + if (!document.getElementById("sidebar-box").hidden) toggleSidebar(); }, { argCount: "0" }); diff --git a/locale/en-US/repeat.txt b/locale/en-US/repeat.txt index 91fea872..b48d6480 100644 --- a/locale/en-US/repeat.txt +++ b/locale/en-US/repeat.txt @@ -24,7 +24,7 @@ ________________________________________________________________________________ |:delmac| |:delmacros| -||:delmac[ros] [args]|| + +||:delmac[ros] {args}|| + ________________________________________________________________________________ Delete recorded macros matching the regular expression [args]. ________________________________________________________________________________