1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 10:57:58 +01:00

Serialize the -group flag to :abbreviate with :mkp.

This commit is contained in:
Doug Kearns
2013-09-17 01:30:57 +10:00
parent 6ee830dfad
commit 041ad9ace7
2 changed files with 27 additions and 18 deletions

View File

@@ -227,6 +227,10 @@ var Abbreviations = Module("abbreviations", {
*/), "x", params); */), "x", params);
}, },
get allHives() contexts.allGroups.abbrevs,
get userHives() this.allHives.filter(h => h !== this.builtin),
get: deprecated("group.abbrevs.get", { get: function get() this.user.closure.get }), get: deprecated("group.abbrevs.get", { get: function get() this.user.closure.get }),
set: deprecated("group.abbrevs.set", { get: function set() this.user.closure.set }), set: deprecated("group.abbrevs.set", { get: function set() this.user.closure.set }),
remove: deprecated("group.abbrevs.remove", { get: function remove() this.user.closure.remove }), remove: deprecated("group.abbrevs.remove", { get: function remove() this.user.closure.remove }),
@@ -257,7 +261,7 @@ var Abbreviations = Module("abbreviations", {
* @optional * @optional
*/ */
list: function (modes, lhs, hives) { list: function (modes, lhs, hives) {
let hives = hives || contexts.allGroups.abbrevs.filter(h => !h.empty); let hives = (hives || this.userHives).filter(h => !h.empty);
function abbrevs(hive) function abbrevs(hive)
hive.merged.filter(ab => (ab.inModes(modes) && ab.lhs.indexOf(lhs) == 0)); hive.merged.filter(ab => (ab.inModes(modes) && ab.lhs.indexOf(lhs) == 0));
@@ -341,18 +345,22 @@ var Abbreviations = Module("abbreviations", {
description: "Expand this abbreviation by evaluating its right-hand-side as JavaScript" description: "Expand this abbreviation by evaluating its right-hand-side as JavaScript"
} }
], ],
serialize: function () [ serialize: function () array(abbreviations.userHives)
.filter(h => h.persist)
.map(hive => [
{ {
command: this.name, command: this.name,
arguments: [abbr.lhs], arguments: [abbr.lhs],
literalArg: abbr.rhs, literalArg: abbr.rhs,
options: { options: {
"-group": hive.name == "user" ? undefined : hive.name,
"-javascript": callable(abbr.rhs) ? null : undefined "-javascript": callable(abbr.rhs) ? null : undefined
} }
} }
for ([, abbr] in Iterator(abbreviations.user.merged)) for ([, abbr] in Iterator(hive.merged))
if (abbr.modesEqual(modes)) if (abbr.modesEqual(modes))
] ]).
flatten().array
}); });
commands.add([ch + "una[bbreviate]"], commands.add([ch + "una[bbreviate]"],

View File

@@ -284,12 +284,13 @@
<p> <p>
In addition to its own JavaScript context, each script is executed In addition to its own JavaScript context, each script is executed
with its own default <link topic="groups">group</link> into which with its own default <link topic="groups">group</link> into which
its styles, mappings, commands, and autocommands are placed. This its styles, mappings, commands, abbreviations and autocommands are
means that commands such as <ex>:delcommand!</ex> can be issued placed. This means that commands such as <ex>:delcommand!</ex> can
without fear of trampling other user-defined mappings. The command be issued without fear of trampling other user-defined mappings.
<ex>:group! default</ex> can be issued to clear all such items at The command <ex>:group! default</ex> can be issued to clear all
once, and should be placed at the head of most scripts to prevent such items at once, and should be placed at the head of most
the accumulation of stale items when the script is re-sourced. scripts to prevent the accumulation of stale items when the script
is re-sourced.
</p> </p>
<h3 tag=":source-css">Cascading Stylesheets</h3> <h3 tag=":source-css">Cascading Stylesheets</h3>