mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-18 18:14:11 +01:00
Add group filtering to :command and :autocommand listings.
This commit is contained in:
@@ -249,7 +249,7 @@ var Abbreviations = Module("abbreviations", {
|
||||
},
|
||||
|
||||
/**
|
||||
* Lists all abbreviations matching *modes*, *lhs*, and optionally *hives*.
|
||||
* Lists all abbreviations matching *modes*, *lhs* and optionally *hives*.
|
||||
*
|
||||
* @param {Array} modes List of modes.
|
||||
* @param {string} lhs The LHS of the abbreviation.
|
||||
|
||||
@@ -84,12 +84,17 @@ var AutoCommands = Module("autocommands", {
|
||||
remove: deprecated("group.autocmd.remove", { get: function remove() autocommands.user.closure.remove }),
|
||||
|
||||
/**
|
||||
* Lists all autocommands with a matching *event* and *regexp*.
|
||||
* Lists all autocommands with a matching *event*, *regexp* and optionally
|
||||
* *hives*.
|
||||
*
|
||||
* @param {string} event The event name filter.
|
||||
* @param {string} regexp The URL pattern filter.
|
||||
* @param {Hive[]} hives List of hives.
|
||||
* @optional
|
||||
*/
|
||||
list: function (event, regexp) {
|
||||
list: function (event, regexp, hives) {
|
||||
|
||||
let hives = hives || this.activeHives;
|
||||
|
||||
function cmds(hive) {
|
||||
let cmds = {};
|
||||
@@ -108,7 +113,7 @@ var AutoCommands = Module("autocommands", {
|
||||
<td colspan="3">----- Auto Commands -----</td>
|
||||
</tr>
|
||||
{
|
||||
template.map(this.activeHives, function (hive)
|
||||
template.map(hives, function (hive)
|
||||
<tr highlight="Title">
|
||||
<td colspan="3">{hive.name}</td>
|
||||
</tr> +
|
||||
@@ -200,7 +205,7 @@ var AutoCommands = Module("autocommands", {
|
||||
args["-group"].remove(event, regexp); // remove all
|
||||
}
|
||||
else
|
||||
autocommands.list(event, regexp); // list all
|
||||
autocommands.list(event, regexp, args.explicitOpts["-group"] ? [args["-group"]] : null); // list all
|
||||
}
|
||||
}, {
|
||||
bang: true,
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
<p>
|
||||
If the <em>-group</em>=<a>group</a> flag is given, add this autocmd
|
||||
to the named <t>group</t>. Any filters for <a>group</a> apply in
|
||||
addition to <oa>filter</oa>.
|
||||
addition to <oa>filter</oa>. When listing commands this limits the
|
||||
output to the specified group.
|
||||
</p>
|
||||
|
||||
<p>Available <oa>events</oa>:</p>
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
<dt>-count</dt> <dd>Accept a count before the requisite key press. Sets the <tt>count</tt> parameter to the result. (short name <em>-c</em>)</dd>
|
||||
<dt>-description</dt> <dd>A description of this mapping (short name <em>-d</em>)</dd>
|
||||
<dt>-ex</dt> <dd>Execute <a>rhs</a> as an Ex command rather than keys (short name <em>-e</em>)</dd>
|
||||
<dt>-group=<a>group</a></dt> <dd>Add this command to the given <t>group</t> (short name <em>-g</em>)</dd>
|
||||
<dt>-group=<a>group</a></dt> <dd>Add this command to the given <t>group</t> (short name <em>-g</em>). When listing commands this limits the output to the specified group.</dd>
|
||||
<dt>-javascript</dt> <dd>Execute <a>rhs</a> as JavaScript rather than keys (short names <em>-js</em>, <em>-j</em>)</dd>
|
||||
<dt>-literal=<a>n</a></dt> <dd>Parse the <a>n</a>th argument without specially processing any quote or meta characters. (short name <em>-l</em>)</dd>
|
||||
<dt>-modes=<a>modes</a></dt> <dd>Create this mapping in the given modes (short names <em>-mode</em>, <em>-m</em>)</dd>
|
||||
@@ -591,7 +591,8 @@
|
||||
|
||||
<p>
|
||||
The <em>-group</em> flag (short name: <em>-g</em>) can be used to
|
||||
assign this command to a specific <t>group</t>.
|
||||
assign this command to a specific <t>group</t>. When listing
|
||||
commands this limits the output to the specified group.
|
||||
</p>
|
||||
|
||||
<h3 tag="E175 E176 :command-nargs">Argument handling</h3>
|
||||
|
||||
@@ -641,12 +641,15 @@ var Commands = Module("commands", {
|
||||
},
|
||||
|
||||
/**
|
||||
* Displays a list of user-defined commands.
|
||||
* Lists all user-defined commands matching *filter* and optionally
|
||||
* *hives*.
|
||||
*
|
||||
* @param {string} filter Limits the list to those commands with a name
|
||||
* matching this anchored substring.
|
||||
* @param {Hive[]} hives List of hives.
|
||||
* @optional
|
||||
*/
|
||||
list: function list(filter) {
|
||||
list: function list(filter, hives) {
|
||||
const { commandline, completion } = this.modules;
|
||||
function completerToString(completer) {
|
||||
if (completer)
|
||||
@@ -656,7 +659,7 @@ var Commands = Module("commands", {
|
||||
// TODO: allow matching of aliases?
|
||||
function cmds(hive) hive._list.filter(function (cmd) cmd.name.indexOf(filter || "") == 0)
|
||||
|
||||
let hives = this.userHives.map(function (h) [h, cmds(h)]).filter(function ([h, c]) c.length);
|
||||
let hives = (hives || this.userHives).map(function (h) [h, cmds(h)]).filter(function ([h, c]) c.length);
|
||||
|
||||
let list = <table>
|
||||
<tr highlight="Title">
|
||||
@@ -1401,7 +1404,7 @@ var Commands = Module("commands", {
|
||||
_("command.invalidName", cmd));
|
||||
|
||||
if (args.length <= 1)
|
||||
commands.list(cmd);
|
||||
commands.list(cmd, args.explicitOpts["-group"] ? [args["-group"]] : null);
|
||||
else {
|
||||
util.assert(args["-group"].modifiable,
|
||||
_("group.cantChangeBuiltin", _("command.commands")));
|
||||
|
||||
Reference in New Issue
Block a user