diff --git a/content/commands.js b/content/commands.js index 69578f88..cd24d986 100644 --- a/content/commands.js +++ b/content/commands.js @@ -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." } )); diff --git a/content/events.js b/content/events.js index a0588ba7..5ee99f97 100644 --- a/content/events.js +++ b/content/events.js @@ -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