diff --git a/AUTHORS b/AUTHORS index 70d8c6c2..f5e2884d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,6 +12,7 @@ Inactive/former developers: * Viktor Kojouharov (Виктор Кожухаров) Patches (in no special order): + * Konstantin Stepanov (:%foo support) * Lukas Mai * Guido Van Hoecke * Daniel Trstenjak (various things with hints) diff --git a/NEWS b/NEWS index 65f4efeb..8916a3e2 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ generous donation which made this behavior possible) * IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just too unpredictable + * support for :%foo as a count for commands (not yet widely used) * show informative message when a background tab was loaded, especially useful with a hidden tab bar. * new "l" flag for 'complete' to reuse the Firefox awesome bar for getting better diff --git a/content/commands.js b/content/commands.js index 2eb29d6e..9e873939 100644 --- a/content/commands.js +++ b/content/commands.js @@ -181,14 +181,18 @@ liberator.Commands = function () //{{{ // Idea: If v.commands.add() specifies args or opts in extraInfo, don't call the function // with args as a string, but already pass an object like: // args = { -option: value, -anotheroption: true, arguments: [] } - OPTION_ANY: 0, // can be given no argument or an argument of any type, - // caller is responsible for parsing the return value - OPTION_NOARG: 1, - OPTION_BOOL:2, + OPTION_ANY: 0, // can be given no argument or an argument of any type, + // caller is responsible for parsing the return value + OPTION_NOARG: 1, + OPTION_BOOL: 2, OPTION_STRING: 3, - OPTION_INT: 4, - OPTION_FLOAT: 5, - OPTION_LIST: 6, + OPTION_INT: 4, + OPTION_FLOAT: 5, + OPTION_LIST: 6, + + COUNT_NONE: -1, + COUNT_ALL: -2, // :%... + __iterator__: function () { @@ -591,16 +595,16 @@ liberator.Commands = function () //{{{ } // 0 - count, 1 - cmd, 2 - special, 3 - args, 4 - heredoc tag - var matches = str.match(/^:*(\d+)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/); + var matches = str.match(/^:*(\d+|%)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/); if (!matches) return [null, null, null, null, null]; matches.shift(); // parse count if (matches[0]) - matches[0] = parseInt(matches[0], 10); + matches[0] = matches[0] == "%" ? this.COUNT_ALL: parseInt(matches[0], 10); else - matches[0] = -1; + matches[0] = this.COUNT_NONE; matches[2] = !!matches[2]; matches.push(null);