mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-15 17:15:46 +01:00
Move util.identity to the base module.
Most other functions of its ilk live there.
This commit is contained in:
@@ -105,7 +105,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
|
||||
},
|
||||
|
||||
/** @property {boolean} True if there are no abbreviations. */
|
||||
get empty() { return !values(this._store).find(util.identity); },
|
||||
get empty() { return !values(this._store).find(identity); },
|
||||
|
||||
/**
|
||||
* Adds a new abbreviation.
|
||||
@@ -251,7 +251,7 @@ var Abbreviations = Module("abbreviations", {
|
||||
let match = this._match.exec(text);
|
||||
if (match)
|
||||
return this.hives.map(h => h.get(mode, match[2] || match[4] || match[6]))
|
||||
.find(util.identity);
|
||||
.find(identity);
|
||||
return null;
|
||||
},
|
||||
|
||||
|
||||
@@ -438,7 +438,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
for (b of bookmarkcache)
|
||||
if (b.tags))
|
||||
.flatten().uniq().array;
|
||||
context.keys = { text: util.identity, description: util.identity };
|
||||
context.keys = { text: identity, description: identity };
|
||||
},
|
||||
type: CommandOption.LIST
|
||||
};
|
||||
@@ -705,7 +705,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
}
|
||||
catch (e) {}
|
||||
return null;
|
||||
}).filter(util.identity);
|
||||
}).filter(identity);
|
||||
};
|
||||
});
|
||||
};
|
||||
@@ -742,7 +742,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
let ctxt = context.fork(name, 0);
|
||||
|
||||
ctxt.title = [/*L*/desc + " Suggestions"];
|
||||
ctxt.keys = { text: util.identity, description: function () "" };
|
||||
ctxt.keys = { text: identity, description: function () "" };
|
||||
ctxt.compare = CompletionContext.Sort.unsorted;
|
||||
ctxt.filterFunc = null;
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
this.elements[obj.name] = obj;
|
||||
|
||||
function get(prefix, map, id) {
|
||||
return (obj.getElement || util.identity)(map[id] || document.getElementById(prefix + id));
|
||||
return (obj.getElement || identity)(map[id] || document.getElementById(prefix + id));
|
||||
}
|
||||
|
||||
this.active.__defineGetter__(obj.name, () => this.activeGroup[obj.name][obj.name]);
|
||||
@@ -200,7 +200,7 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
else {
|
||||
highlight.highlightNode(elem,
|
||||
(val[0] != null ? val[0] : obj.defaultGroup)
|
||||
.split(/\s/).filter(util.identity)
|
||||
.split(/\s/).filter(identity)
|
||||
.map(g => g + " " + nodeSet.group + g)
|
||||
.join(" "));
|
||||
elem.value = val[1];
|
||||
|
||||
@@ -256,7 +256,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
{
|
||||
argCount: "*",
|
||||
completer: function (context, args) {
|
||||
context.keys.text = util.identity;
|
||||
context.keys.text = identity;
|
||||
context.keys.description = function () {
|
||||
return seen[this.text] + /*L*/" matching items";
|
||||
};
|
||||
@@ -662,7 +662,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
*/
|
||||
generateHelp: function generateHelp(obj, extraHelp, str, specOnly) {
|
||||
let link, tag, spec;
|
||||
link = tag = spec = util.identity;
|
||||
link = tag = spec = identity;
|
||||
let args = null;
|
||||
|
||||
if (obj instanceof Command) {
|
||||
@@ -1286,7 +1286,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
template.map(iter(dactyl.indices),
|
||||
([name, iter]) =>
|
||||
["dl", { insertafter: name + "-index" },
|
||||
template.map(iter(), util.identity)],
|
||||
template.map(iter(), identity)],
|
||||
"\n\n")]);
|
||||
}, true);
|
||||
|
||||
|
||||
@@ -777,7 +777,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
completion: function initCompletion() {
|
||||
completion.register = function complete_register(context) {
|
||||
context = context.fork("registers");
|
||||
context.keys = { text: util.identity, description: editor.bound.getRegister };
|
||||
context.keys = { text: identity, description: editor.bound.getRegister };
|
||||
|
||||
context.match = function (r) {
|
||||
return !this.filter || this.filter.contains(r);
|
||||
@@ -1413,7 +1413,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
let res = {};
|
||||
services.spell.getDictionaryList(res, {});
|
||||
context.completions = res.value;
|
||||
context.keys = { text: util.identity, description: util.identity };
|
||||
context.keys = { text: identity, description: identity };
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -331,7 +331,7 @@ var History = Module("history", {
|
||||
completion.domain = context => {
|
||||
context.anchored = false;
|
||||
context.compare = (a, b) => String.localeCompare(a.key, b.key);
|
||||
context.keys = { text: util.identity, description: util.identity,
|
||||
context.keys = { text: identity, description: identity,
|
||||
key: function (host) host.split(".").reverse().join(".") };
|
||||
|
||||
// FIXME: Schema-specific
|
||||
|
||||
@@ -196,7 +196,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
*/
|
||||
add: function (modes, keys, description, action, extra={}) {
|
||||
modes = Array.concat(modes);
|
||||
if (!modes.every(util.identity))
|
||||
if (!modes.every(identity))
|
||||
throw TypeError(/*L*/"Invalid modes: " + modes);
|
||||
|
||||
let map = Map(modes, keys, description, action, extra);
|
||||
|
||||
@@ -301,14 +301,14 @@ var Marks = Module("marks", {
|
||||
"(" + Math.round(mark.offset.x * 100),
|
||||
Math.round(mark.offset.y * 100) + ")",
|
||||
(tab && "tab: " + tabs.index(tab))
|
||||
].filter(util.identity).join(", ");
|
||||
].filter(identity).join(", ");
|
||||
|
||||
if (mark.position)
|
||||
return [name, mark.location,
|
||||
"(" + Math.round(mark.position.x * 100) + "%",
|
||||
Math.round(mark.position.y * 100) + "%)",
|
||||
(tab && "tab: " + tabs.index(tab))
|
||||
].filter(util.identity).join(", ");
|
||||
].filter(identity).join(", ");
|
||||
},
|
||||
|
||||
isLocalMark: bind("test", /^[a-z`']$/),
|
||||
|
||||
Reference in New Issue
Block a user