1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-07 02:45:47 +01:00

:delmacros regex added

This commit is contained in:
Marco Candrian
2008-01-21 12:12:26 +00:00
parent 09a4c0e15b
commit 7982265c98
3 changed files with 26 additions and 3 deletions

2
NEWS
View File

@@ -9,7 +9,7 @@
* IMPORTANT: changed 'I' key to Ctrl-Q to also work in textboxes
* IMPORTANT: :bmarks! and :history! open the matching items now in a tab, instead
of bringing up the bookmarks/history window
* :macros [regex] for listing recorded macros
* :[del]macros [regex] for listing/deleting recorded macros
* :set! now lets you change about:config prefs similar to :set
* new :command to add user defined commands
* new setCustomMode for plugin writers

View File

@@ -1458,7 +1458,20 @@ vimperator.Commands = function () //{{{
help: "List recorded macros matching the optional regular expression. If no regex is given, list all."
}
));
commandManager.add(new vimperator.Command(["delmac[ros]"],
function (arg)
{
if (!arg)
vimperator.echoerr("E474: Invalid argument");
else
vimperator.events.delMacros(arg);
},
{
usage: ["delmac[ros] [regex]"],
shortHelp: "Delete macros matching a regex",
help: "Delete recorded macros matching a regular expression."
}
));
// 0 args -> list all maps
// 1 arg -> list the maps starting with args
// 2 args -> map arg1 to arg*

View File

@@ -485,7 +485,6 @@ vimperator.Events = function () //{{{
window.removeEventListener("keydown", this.onKeyDown, true);
},
startRecording: function (macro)
{
if (!/[a-zA-Z0-9]/.test(macro))
@@ -556,6 +555,17 @@ vimperator.Events = function () //{{{
return filtered; //XXX: returns a real copy, since this is only a 'var ..'?
},
delMacros: function (filter)
{
var re = new RegExp(filter);
for (var item in macros)
{
if (item.match(re))
delete macros[item];
}
},
// This method pushes keys into the event queue from vimperator
// it is similar to vim's feedkeys() method, but cannot cope with
// 2 partially feeded strings, you have to feed one parsable string