1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-15 06:35:48 +01:00

Cleanup crufty apply code.

This commit is contained in:
Kris Maglione
2015-02-21 22:43:41 -08:00
parent 7ee579200f
commit 1ee5668cac
26 changed files with 65 additions and 69 deletions

View File

@@ -957,7 +957,7 @@ var CommandLine = Module("commandline", {
}
this.savingOutput = true;
dactyl.trapErrors.apply(dactyl, [fn, self].concat(args));
apply(dactyl, "trapErrors", [fn, self].concat(args));
this.savingOutput = false;
return output.map(elem => elem instanceof Node ? DOM.stringify(elem) : elem)
.join("\n");
@@ -1755,7 +1755,7 @@ var CommandLine = Module("commandline", {
return Events.PASS;
});
let bind = function bind(...args) mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(args));
let bind = function bind(...args) apply(mappings, "add", [[modes.COMMAND_LINE]].concat(args));
bind(["<Esc>", "<C-[>"], "Stop waiting for completions or exit Command Line mode",
function ({ self }) {

View File

@@ -1334,7 +1334,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
},
{ count: true });
bind = function bind(...args) mappings.add.apply(mappings, [[modes.AUTOCOMPLETE]].concat(args));
bind = function bind(...args) apply(mappings, "add", [[modes.AUTOCOMPLETE]].concat(args));
bind(["<Esc>"], "Return to Insert mode",
() => Events.PASS_THROUGH);

View File

@@ -57,7 +57,7 @@ var EventHive = Class("EventHive", Contexts.Hive, {
capture,
allowUntrusted];
target.addEventListener.apply(target, args.slice(2));
apply(target, "addEventListener", args.slice(2));
this.sessionListeners.push(args);
}
},
@@ -83,7 +83,7 @@ var EventHive = Class("EventHive", Contexts.Hive, {
&& args[3].wrapped == events[args[2]]
&& args[4] == capture) {
elem.removeEventListener.apply(elem, args.slice(2));
apply(elem, "removeEventListener", args.slice(2));
return false;
}
return elem;
@@ -426,7 +426,7 @@ var Events = Module("events", {
canonicalKeys: deprecated("DOM.Event.canonicalKeys", { get: function canonicalKeys() DOM.Event.bound.canonicalKeys }),
create: deprecated("DOM.Event", function create() DOM.Event.apply(null, arguments)),
dispatch: deprecated("DOM.Event.dispatch", function dispatch() DOM.Event.dispatch.apply(DOM.Event, arguments)),
dispatch: deprecated("DOM.Event.dispatch", function dispatch() apply(DOM.Event, "dispatch", arguments)),
fromString: deprecated("DOM.Event.parse", { get: function fromString() DOM.Event.bound.parse }),
iterKeys: deprecated("DOM.Event.iterKeys", { get: function iterKeys() DOM.Event.bound.iterKeys }),
@@ -435,7 +435,7 @@ var Events = Module("events", {
return toString.supercall(this);
deprecated.warn(toString, "toString", "DOM.Event.stringify");
return DOM.Event.stringify.apply(DOM.Event, arguments);
return apply(DOM.Event, "stringify", arguments);
},
get defaultTarget() dactyl.focusedElement || content.document.body || document.documentElement,

View File

@@ -354,7 +354,7 @@ var History = Module("history", {
completion.addUrlCompleter("history", "History", completion.history);
},
mappings: function initMappings() {
function bind(...args) mappings.add.apply(mappings, [config.browserModes].concat(args));
function bind(...args) apply(mappings, "add", [config.browserModes].concat(args));
bind(["<C-o>"], "Go to an older position in the jump list",
function ({ count }) { history.stepTo(-Math.max(count, 1), true); },

View File

@@ -252,13 +252,13 @@ var KeyProcessor = Class("KeyProcessor", {
execute: function execute(map, args)
() => {
if (this.preExecute)
this.preExecute.apply(this, args);
apply(this, "preExecute", args);
args.self = this.main.params.mappingSelf || this.main.mappingSelf || map;
let res = map.execute.call(map, args);
if (this.postExecute)
this.postExecute.apply(this, args);
apply(this, "postExecute", args);
return res;
},

View File

@@ -414,7 +414,7 @@ var Mappings = Module("mappings", {
group = this.user;
}
let map = group.add.apply(group, arguments);
let map = apply(group, "add", arguments);
map.definedAt = contexts.getCaller(Components.stack.caller);
return map;
},
@@ -431,7 +431,7 @@ var Mappings = Module("mappings", {
* @optional
*/
addUserMap: deprecated("group.mappings.add", function addUserMap() {
let map = this.user.add.apply(this.user, arguments);
let map = apply(this.user, "add", arguments);
map.definedAt = contexts.getCaller(Components.stack.caller);
return map;
}),

View File

@@ -450,7 +450,7 @@ var Modes = Module("modes", {
for (let mode of array.iterValues(queue))
if (!seen.add(mode)) {
res.push(mode);
queue.push.apply(queue, mode.bases);
apply(queue, "push", mode.bases);
}
return res;
}),
@@ -649,7 +649,7 @@ var Modes = Module("modes", {
},
prefs: function initPrefs() {
prefs.watch("accessibility.browsewithcaret",
function () { modes.onCaretChange.apply(modes, arguments); });
function () { apply(modes, "onCaretChange", arguments); });
}
});

View File

@@ -66,7 +66,7 @@ var MOW = Module("mow", {
});
},
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)),
__noSuchMethod__: function (meth, args) apply(Buffer, meth, [this.body].concat(args)),
get widget() this.widgets.multilineOutput,

View File

@@ -237,7 +237,7 @@ var StatusLine = Module("statusline", {
},
unsafeURI: deprecated("util.unsafeURI", { get: function unsafeURI() util.unsafeURI }),
losslessDecodeURI: deprecated("util.losslessDecodeURI", function losslessDecodeURI() util.losslessDecodeURI.apply(util, arguments)),
losslessDecodeURI: deprecated("util.losslessDecodeURI", function losslessDecodeURI() apply(util, "losslessDecodeURI", arguments)),
/**
* Update the URL displayed in the status line. Also displays status