diff --git a/content/buffer.js b/content/buffer.js index 9f60ab24..66a0880e 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -189,7 +189,6 @@ liberator.Buffer = function () //{{{ "Show the destination of the link under the cursor in the status bar", "number", 1, { - validator: function (value) value >= 0 && value <= 2, completer: function (filter) { return [ @@ -197,7 +196,8 @@ liberator.Buffer = function () //{{{ ["1", "Show the link in the status line"], ["2", "Show the link in the command line"] ]; - } + }, + validator: function (value) value >= 0 && value <= 2 }); liberator.options.add(["usermode", "um"], diff --git a/content/events.js b/content/events.js index 192d736a..0d2bf059 100644 --- a/content/events.js +++ b/content/events.js @@ -47,7 +47,19 @@ liberator.AutoCommands = function () //{{{ liberator.options.add(["eventignore", "ei"], "List of autocommand event names which should be ignored", - "stringlist", ""); + "stringlist", "", + { + completer: function (value) Array(liberator.config.autocommands).push(["all", "All events"]), + validator: function (value) + { + let values = value.split(","); + let events = liberator.config.autocommands.map(function (e) e[0]); + + events.push("all"); + + return values.every(function (event) events.indexOf(event) >= 0); + } + }); liberator.options.add(["focuscontent", "fc"], "Try to stay in normal mode after loading a web page", diff --git a/content/hints.js b/content/hints.js index e281fc7f..205d52c0 100644 --- a/content/hints.js +++ b/content/hints.js @@ -591,11 +591,11 @@ liberator.Hints = function () //{{{ "How links are matched", "string", "contains", { - validator: function (value) /^(?:contains|wordstartswith|firstletters|custom)$/.test(value), completer: function (filter) { return ["contains", "wordstartswith", "firstletters", "custom"].map(function (m) [m, ""]); - } + }, + validator: function (value) /^(contains|wordstartswith|firstletters|custom)$/.test(value) }); liberator.options.add(["wordseparators", "wsp"], diff --git a/content/mail.js b/content/mail.js index 38bbc8d8..54e2a665 100644 --- a/content/mail.js +++ b/content/mail.js @@ -207,8 +207,7 @@ liberator.Mail = function () //{{{ "Set the layout of the mail window", "string", "inherit", { - validator: function (value) /^(classic|wide|vertical|inherit)$/.test(value), - setter: function (value) + setter: function (value) { switch (value) { @@ -219,7 +218,8 @@ liberator.Mail = function () //{{{ } return value; - } + }, + validator: function (value) /^(classic|wide|vertical|inherit)$/.test(value) }); /*liberator.options.add(["threads"], diff --git a/content/tabs.js b/content/tabs.js index 247721cc..ed80cd88 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -142,7 +142,6 @@ liberator.Tabs = function () //{{{ return value; }, - validator: function (value) (value >= 0 && value <= 2), completer: function (filter) { return [ @@ -151,6 +150,7 @@ liberator.Tabs = function () //{{{ ["2", "Always show tab bar"], ]; }, + validator: function (value) value >= 0 && value <= 2 }); if (liberator.config.name == "Vimperator") diff --git a/content/ui.js b/content/ui.js index 92f0f0a7..dd92bca4 100644 --- a/content/ui.js +++ b/content/ui.js @@ -281,8 +281,7 @@ liberator.CommandLine = function () //{{{ "number", 500, { validator: function (value) value >= 0 - } - ); + }); liberator.options.add(["more"], "Pause the message list window when more than one screen of listings is displayed", @@ -311,15 +310,25 @@ liberator.CommandLine = function () //{{{ "Engine Alias which has a feature of suggest", "stringlist", "google", { - validator: function (value) - { - var ss = Components.classes["@mozilla.org/browser/search-service;1"] - .getService(Components.interfaces.nsIBrowserSearchService); - return value.split(",").every(function (item) { - var e = ss.getEngineByAlias(item); - return (e && e.supportsResponseType("application/x-suggestions+json")) ? true : false; - }); - } + completer: function (value) + { + let ss = Components.classes["@mozilla.org/browser/search-service;1"] + .getService(Components.interfaces.nsIBrowserSearchService); + let engines = ss.getEngines({}) + .filter(function (engine) engine.supportsResponseType("application/x-suggestions+json")); + + return engines.map(function (engine) [engine.alias, engine.description]); + }, + validator: function (value) + { + let ss = Components.classes["@mozilla.org/browser/search-service;1"] + .getService(Components.interfaces.nsIBrowserSearchService); + + return value.split(",").every(function (alias) { + let engine = ss.getEngineByAlias(alias); + return engine && engine.supportsResponseType("application/x-suggestions+json"); + }); + } }); liberator.options.add(["showmode", "smd"], @@ -330,12 +339,6 @@ liberator.CommandLine = function () //{{{ "Define how command line completion works", "stringlist", "list:full", { - validator: function (value) - { - return value.split(",").every( - function (item) /^(full|longest|list|list:full|list:longest|)$/.test(item) - ); - }, completer: function (filter) { return [ @@ -347,6 +350,12 @@ liberator.CommandLine = function () //{{{ ["list:longest", "List all and complete common string"], ]; }, + validator: function (value) + { + return value.split(",").every( + function (item) /^(full|longest|list|list:full|list:longest|)$/.test(item) + ); + } }); liberator.options.add(["wildignore", "wig"], @@ -1406,7 +1415,6 @@ liberator.StatusLine = function () //{{{ return value; }, - validator: function (value) value >= 0 && value <= 2, completer: function (filter) { return [ @@ -1414,7 +1422,8 @@ liberator.StatusLine = function () //{{{ ["1", "Display status line only if there are multiple windows"], ["2", "Always display status line"], ]; - } + }, + validator: function (value) value >= 0 && value <= 2 }); /////////////////////////////////////////////////////////////////////////////}}} diff --git a/content/vimperator.js b/content/vimperator.js index 01f11cfd..068a8738 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -380,7 +380,6 @@ liberator.config = { //{{{ return value; }, - getter: function () { return Components.classes['@mozilla.org/network/io-service;1']