diff --git a/content/commands.js b/content/commands.js
index ba8a4436..b8b72ba5 100644
--- a/content/commands.js
+++ b/content/commands.js
@@ -853,8 +853,9 @@ function Commands() //{{{
bang: true,
// Yeah, this is a bit scary. Perhaps I'll fix it when I'm
// awake.
- options: util.Array.assocToObj(util.map({argCount: "-nargs", bang: "-bang", count: "-count"},
- function ([k, v]) k in cmd && cmd[k] != "0" && [v, typeof cmd[k] == "boolean" ? null : cmd[k]])
+ options: util.Array.assocToObj(
+ util.map({argCount: "-nargs", bang: "-bang", count: "-count"},
+ function ([k, v]) k in cmd && cmd[k] != "0" && [v, typeof cmd[k] == "boolean" ? null : cmd[k]])
.filter(function (k) k)),
arguments: [cmd.name],
literalArg: cmd.replacementText
diff --git a/content/completion.js b/content/completion.js
index eb986557..c952aef6 100644
--- a/content/completion.js
+++ b/content/completion.js
@@ -27,7 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/
// An eval with a cleaner lexical scope.
-modules._cleanEval = function (__liberator_eval_arg, __liberator_eval_tmp)
+modules._cleanEval = function _cleanEval(__liberator_eval_arg, __liberator_eval_tmp)
{
return window.eval(__liberator_eval_arg);
}
@@ -54,6 +54,7 @@ function CompletionContext(editor, name, offset)
this.offset = parent.offset + (offset || 0);
this.__defineGetter__("tabPressed", function () this.parent.tabPressed);
this.__defineGetter__("onUpdate", function () this.parent.onUpdate);
+ this.__defineGetter__("updateAsync", function () this.parent.updateAsync);
this.__defineGetter__("value", function () this.parent.value);
this.__defineGetter__("selectionTypes", function () this.parent.selectionTypes);
this.incomplete = false;
@@ -114,18 +115,19 @@ CompletionContext.prototype = {
{
this.hasItems = items.length > 0;
this._items = items;
- this.onUpdate.call(this);
+ if (this.updateAsync)
+ this.onUpdate.call(this);
},
get title() this._title || ["Completions"], // XXX
set title(val) this._title = val,
- advance: function (count)
+ advance: function advance(count)
{
this.offset += count;
},
- fork: function (name, offset, completer, self)
+ fork: function fork(name, offset, completer, self)
{
let context = new CompletionContext(this, name, offset);
if (completer)
@@ -133,7 +135,7 @@ CompletionContext.prototype = {
return context;
},
- highlight: function (start, length, type)
+ highlight: function highlight(start, length, type)
{
try // Firefox <3.1 doesn't have repaintSelection
{
@@ -157,7 +159,7 @@ CompletionContext.prototype = {
catch (e) {}
},
- reset: function ()
+ reset: function reset()
{
let self = this;
if (this.parent)
@@ -165,6 +167,7 @@ CompletionContext.prototype = {
// Not ideal.
for (let type in this.selectionTypes)
this.highlight(0, 0, type);
+ this.updateAsync = false;
this.selectionTypes = {};
this.tabPressed = false;
this.offset = 0;
@@ -269,7 +272,7 @@ function Completion() //{{{
if (!(objects instanceof Array))
objects = [objects];
- completion.filterMap = [null, function (v) template.highlight(v, true)];
+ completion.filterMap = [null, function highlight(v) template.highlight(v, true)];
let [obj, key] = objects;
let cache = this.context.cache.objects || {};
@@ -485,7 +488,7 @@ function Completion() //{{{
lastIdx = i;
}
- this.complete = function (context)
+ this.complete = function _complete(context)
{
this.context = context;
let string = context.filter;
@@ -787,13 +790,13 @@ function Completion() //{{{
return {
- setFunctionCompleter: function (funcs, completers)
+ setFunctionCompleter: function setFunctionCompleter(funcs, completers)
{
if (!(funcs instanceof Array))
funcs = [funcs];
for (let [,func] in Iterator(funcs))
{
- func.liberatorCompleter = function (func, obj, string, args) {
+ func.liberatorCompleter = function liberatorCompleter(func, obj, string, args) {
let completer = completers[args.length - 1];
if (!completer)
return [];
@@ -834,7 +837,7 @@ function Completion() //{{{
},
// cancel any ongoing search
- cancel: function()
+ cancel: function cancel()
{
if (completionService)
completionService.stopSearch();
@@ -936,7 +939,7 @@ function Completion() //{{{
autocmdEvent: function autocmdEvent(filter) [0, this.filter(config.autocommands, filter)],
- bookmark: function (filter)
+ bookmark: function bookmark(filter)
{
return {
start: 0,
@@ -1033,7 +1036,7 @@ function Completion() //{{{
dialog: function dialog(filter) [0, this.filter(config.dialogs, filter)],
- directory: function (context, tail)
+ directory: function directory(context, tail)
{
this.file(context, tail);
context.items = context.items.filter(function (i) i[1] == "Directory");
@@ -1081,25 +1084,26 @@ function Completion() //{{{
if (command)
{
[prefix] = context.filter.match(/^(?:\w*[\s!]|!)\s*/);
- context = context.fork(cmd, prefix.length);
- let argContext = context.fork("args", args.completeStart);
- args = command.parseArgs(context.filter, argContext);
+ let cmdContext = context.fork(cmd, prefix.length);
+ let argContext = cmdContext.fork("args", args.completeStart);
+ args = command.parseArgs(cmdContext.filter, argContext);
if (args)
{
// XXX, XXX, XXX
if (!args.completeOpt && command.completer)
{
- context.advance(args.completeStart);
- compObject = command.completer.call(command, context, args, special, count);
+ cmdContext.advance(args.completeStart);
+ compObject = command.completer.call(command, cmdContext, args, special, count);
if (compObject instanceof Array) // for now at least, let completion functions return arrays instead of objects
compObject = { start: compObject[0], items: compObject[1] };
if (compObject != null)
{
- context.advance(compObject.start);
- context.title = ["Completions"];
- context.items = compObject.items;
+ cmdContext.advance(compObject.start);
+ cmdContext.title = ["Completions"];
+ cmdContext.items = compObject.items;
}
}
+ cmdContext.updateAsync = true;
}
//liberator.dump([[v.name, v.offset, v.items.length, v.hasItems] for each (v in context.contexts)]);
}
@@ -1112,7 +1116,7 @@ function Completion() //{{{
let [dir] = context.filter.match(/^(?:.*[\/\\])?/);
// dir == "" is expanded inside readDirectory to the current dir
- let generate = function ()
+ let generate = function generate()
{
let files = [], mapped = [];
@@ -1173,7 +1177,7 @@ function Completion() //{{{
get javascriptCompleter() javascript,
- javascript: function (context)
+ javascript: function _javascript(context)
{
return javascript.complete(context);
},
@@ -1229,7 +1233,7 @@ function Completion() //{{{
},
// XXX: Move to bookmarks.js?
- searchEngineSuggest: function (context, engineAliases)
+ searchEngineSuggest: function searchEngineSuggest(context, engineAliases)
{
if (!filter)
return [0, []];
@@ -1273,7 +1277,7 @@ function Completion() //{{{
shellCommand: function shellCommand(filter)
{
- let generate = function ()
+ let generate = function generate()
{
const environmentService = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment);
@@ -1345,10 +1349,10 @@ function Completion() //{{{
s: this.search,
f: this.file,
S: this.searchEngineSuggest,
- b: function (context)
+ b: function b(context)
{
context.title = ["Bookmark", "Title"];
- context.createRow = function (context, item, class)
+ context.createRow = function createRow(context, item, class)
{
// FIXME
if (class)
@@ -1357,7 +1361,7 @@ function Completion() //{{{
}
context.items = bookmarks.get(context.filter)
},
- l: function (context)
+ l: function l(context)
{
if (!completionService)
return
@@ -1392,7 +1396,7 @@ function Completion() //{{{
},
// FIXME: Temporary
- _url: function (filter, complete)
+ _url: function _url(filter, complete)
{
let context = new CompletionContext(filter);
this.url(context, complete);
diff --git a/content/editor.js b/content/editor.js
index 059e9b2d..76aeaa0e 100644
--- a/content/editor.js
+++ b/content/editor.js
@@ -166,8 +166,7 @@ function Editor() //{{{
"Abbreviate a key sequence" + modeDescription,
function (args)
{
- let lhs = args.arguments[0];
- let rhs = args.literalArg;
+ let [lhs, rhs] = args.arguments;
if (rhs)
editor.addAbbreviation(mode, lhs, rhs);
else
diff --git a/content/events.js b/content/events.js
index a15819f1..4809230e 100644
--- a/content/events.js
+++ b/content/events.js
@@ -72,8 +72,7 @@ function AutoCommands() //{{{
"Execute commands automatically on events",
function (args, special)
{
- let [event, regex] = args.arguments;
- let cmd = args.literalArg;
+ let [event, regex, cmd] = args.arguments;
let events = null;
if (event)
{
diff --git a/content/mappings.js b/content/mappings.js
index 87e08c10..69994d31 100644
--- a/content/mappings.js
+++ b/content/mappings.js
@@ -158,8 +158,7 @@ function Mappings() //{{{
}
// ?:\s+ <- don't remember; (...)? optional = rhs
- let [lhs] = args.arguments;
- let rhs = args.literalArg;
+ let [lhs, rhs] = args.arguments;
if (!rhs) // list the mapping
{
diff --git a/content/style.js b/content/style.js
index fd79ae7a..41905375 100644
--- a/content/style.js
+++ b/content/style.js
@@ -128,7 +128,6 @@ function Highlights(name, store, serial)
.replace(";!important;", ";", "g"); // Seeming Spidermonkey bug
css = style.selector + " { " + css + " }";
- style.filter; // FIXME: needed for FF 3.0 (not 3.1) - track down when I'm awake...
let error = styles.addSheet(style.selector, style.filter, css, true, force);
if (!error)
style.value = newStyle;
@@ -396,9 +395,8 @@ liberator.registerObserver("load_commands", function ()
"Add or list user styles",
function (args, special)
{
- let [filter] = args.arguments;
+ let [filter, css] = args.arguments;
let name = args["-name"];
- let css = args.literalArg;
if (!css)
{
@@ -491,8 +489,7 @@ liberator.registerObserver("load_commands", function ()
height: 1em !important; min-height: 1em !important; max-height: 1em !important;
overflow: hidden !important;
]]>;
- let key = args.arguments[0];
- let css = args.literalArg;
+ let [key, css] = args.arguments[0];
if (!css && !(key && special))
{
let str = template.tabular(["Key", "Sample", "CSS"],
diff --git a/content/template.js b/content/template.js
index 66e745ea..89547a19 100644
--- a/content/template.js
+++ b/content/template.js
@@ -1,8 +1,8 @@
const template = {
- add: function (a, b) a + b,
- join: function (c) function (a, b) a + c + b,
+ add: function add(a, b) a + b,
+ join: function join(c) function (a, b) a + c + b,
- map: function (iter, fn, sep)
+ map: function map(iter, fn, sep)
{
if (iter.length) /* Kludge? */
iter = util.Array.iterator(iter);
@@ -20,7 +20,7 @@ const template = {
return ret;
},
- maybeXML: function (xml)
+ maybeXML: function maybeXML(xml)
{
if (typeof xml == "xml")
return xml;
@@ -32,7 +32,7 @@ const template = {
return <>{xml}>;
},
- completionRow: function (context, item, class)
+ completionRow: function completionRow(context, item, class)
{
let text = item.text || item[0] || "";
let description = item.description || item[1] || "";
@@ -66,7 +66,7 @@ const template = {
// if "processStrings" is true, any passed strings will be surrounded by " and
// any line breaks are displayed as \n
- highlight: function (arg, processStrings)
+ highlight: function highlight(arg, processStrings)
{
// some objects like window.JSON or getBrowsers()._browsers need the try/catch
try
@@ -107,7 +107,7 @@ const template = {
}
},
- highlightFilter: function (str, filter)
+ highlightFilter: function highlightFilter(str, filter)
{
if (typeof str == "xml")
return str;
@@ -125,7 +125,7 @@ const template = {
})());
},
- highlightRegexp: function (str, re)
+ highlightRegexp: function highlightRegexp(str, re)
{
if (typeof str == "xml")
return str;
@@ -137,7 +137,7 @@ const template = {
})());
},
- highlightSubstrings: function (str, iter)
+ highlightSubstrings: function highlightSubstrings(str, iter)
{
if (typeof str == "xml")
return str;
@@ -157,7 +157,7 @@ const template = {
return s + <>{str.substr(start)}>;
},
- highlightURL: function (str, force)
+ highlightURL: function highlightURL(str, force)
{
if (force || /^[a-zA-Z]+:\/\//.test(str))
return {str};
@@ -165,14 +165,14 @@ const template = {
return str;
},
- generic: function (xml)
+ generic: function generic(xml)
{
return <>:{commandline.getCommand()}
> + xml;
},
// every item must have a .xml property which defines how to draw itself
// @param headers is an array of strings, the text for the header columns
- genericTable: function (headers, items)
+ genericTable: function genericTable(headers, items)
{
return this.generic(