1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 15:02:26 +01:00

regex instead of string compare on :macros and :macrosdump

This commit is contained in:
Marco Candrian
2008-01-20 21:07:44 +00:00
parent d21dccfff7
commit 76ab7e9616
2 changed files with 12 additions and 5 deletions

View File

@@ -1453,7 +1453,9 @@ vimperator.Commands = function () //{{{
vimperator.echo(str, vimperator.commandline.FORCE_MULTILINE);
},
{
shortHelp: "List macros matching the argument; or all macros if no argument is given."
usage: ["mac[ros] [regex]"],
shortHelp: "List macros matching a regex",
help: "List recorded macros matching the optional regular expression. If no regex is given, list all."
}
));

View File

@@ -541,13 +541,18 @@ vimperator.Events = function () //{{{
getMacros: function (filter)
{
var mfiltered = {};
if (!filter)
return macros;
var filtered = {};
var re = new RegExp(filter);
for (var item in macros)
{
if (filter == null || item.indexOf(filter) != -1)
mfiltered[item] = macros[item];
if (item.match(re))
filtered[item] = macros[item];
}
return mfiltered; //XXX: returns a real copy, since this is only a 'var ..'?
return filtered; //XXX: returns a real copy, since this is only a 'var ..'?
},
// This method pushes keys into the event queue from vimperator