mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-16 21:23:41 +01:00
use argCount: "?" for :tab{previous,next,close}
This commit is contained in:
@@ -301,14 +301,14 @@ function Tabs() //{{{
|
|||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let special = args.bang;
|
let special = args.bang;
|
||||||
let count = args.count;
|
let count = args.count;
|
||||||
args = args.string;
|
let arg = args.literalArg;
|
||||||
|
|
||||||
if (args)
|
if (arg)
|
||||||
{
|
{
|
||||||
args = args.toLowerCase();
|
arg = arg.toLowerCase();
|
||||||
let removed = 0;
|
let removed = 0;
|
||||||
let matches = args.match(/^(\d+):?/);
|
let matches = arg.match(/^(\d+):?/);
|
||||||
|
|
||||||
if (matches)
|
if (matches)
|
||||||
{
|
{
|
||||||
@@ -324,8 +324,8 @@ function Tabs() //{{{
|
|||||||
let uri = browsers[i].currentURI.spec.toLowerCase();
|
let uri = browsers[i].currentURI.spec.toLowerCase();
|
||||||
let host = browsers[i].currentURI.host.toLowerCase();
|
let host = browsers[i].currentURI.host.toLowerCase();
|
||||||
|
|
||||||
if (host.indexOf(args) >= 0 || uri == args ||
|
if (host.indexOf(arg) >= 0 || uri == arg ||
|
||||||
(special && (title.indexOf(args) >= 0 || uri.indexOf(args) >= 0)))
|
(special && (title.indexOf(arg) >= 0 || uri.indexOf(arg) >= 0)))
|
||||||
{
|
{
|
||||||
tabs.remove(tabs.getTab(i));
|
tabs.remove(tabs.getTab(i));
|
||||||
removed++;
|
removed++;
|
||||||
@@ -336,12 +336,13 @@ function Tabs() //{{{
|
|||||||
if (removed > 0)
|
if (removed > 0)
|
||||||
liberator.echomsg(removed + " fewer tab(s)", 9);
|
liberator.echomsg(removed + " fewer tab(s)", 9);
|
||||||
else
|
else
|
||||||
liberator.echoerr("E94: No matching tab for " + args);
|
liberator.echoerr("E94: No matching tab for " + arg);
|
||||||
}
|
}
|
||||||
else // just remove the current tab
|
else // just remove the current tab
|
||||||
tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
|
tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
argCount: "?",
|
||||||
bang: true,
|
bang: true,
|
||||||
count: true,
|
count: true,
|
||||||
completer: function (context) completion.buffer(context),
|
completer: function (context) completion.buffer(context),
|
||||||
@@ -374,13 +375,13 @@ function Tabs() //{{{
|
|||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let count = args.count;
|
let count = args.count;
|
||||||
args = args.string;
|
let arg = args[0];
|
||||||
|
|
||||||
// count is ignored if an arg is specified, as per Vim
|
// count is ignored if an arg is specified, as per Vim
|
||||||
if (args)
|
if (arg)
|
||||||
{
|
{
|
||||||
if (/^\d+$/.test(args))
|
if (/^\d+$/.test(arg))
|
||||||
tabs.select("-" + args, true); // FIXME: urgh!
|
tabs.select("-" + arg, true); // FIXME: urgh!
|
||||||
else
|
else
|
||||||
liberator.echoerr("E488: Trailing characters");
|
liberator.echoerr("E488: Trailing characters");
|
||||||
}
|
}
|
||||||
@@ -393,7 +394,10 @@ function Tabs() //{{{
|
|||||||
tabs.select("-1", true);
|
tabs.select("-1", true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ count: true });
|
{
|
||||||
|
argCount: "?",
|
||||||
|
count: true
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: "Zero count" if 0 specified as arg
|
// TODO: "Zero count" if 0 specified as arg
|
||||||
commands.add(["tabn[ext]", "tn[ext]", "bn[ext]"],
|
commands.add(["tabn[ext]", "tn[ext]", "bn[ext]"],
|
||||||
@@ -401,18 +405,18 @@ function Tabs() //{{{
|
|||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let count = args.count;
|
let count = args.count;
|
||||||
args = args.string;
|
let arg = args[0];
|
||||||
|
|
||||||
if (args || count > 0)
|
if (arg || count > 0)
|
||||||
{
|
{
|
||||||
let index;
|
let index;
|
||||||
|
|
||||||
// count is ignored if an arg is specified, as per Vim
|
// count is ignored if an arg is specified, as per Vim
|
||||||
if (args)
|
if (arg)
|
||||||
{
|
{
|
||||||
if (/^\d+$/.test(args))
|
if (/^\d+$/.test(arg))
|
||||||
{
|
{
|
||||||
index = args - 1;
|
index = arg - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -435,7 +439,10 @@ function Tabs() //{{{
|
|||||||
tabs.select("+1", true);
|
tabs.select("+1", true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ count: true });
|
{
|
||||||
|
argCount: "?",
|
||||||
|
count: true
|
||||||
|
});
|
||||||
|
|
||||||
commands.add(["tabr[ewind]", "tabfir[st]", "br[ewind]", "bf[irst]"],
|
commands.add(["tabr[ewind]", "tabfir[st]", "br[ewind]", "bf[irst]"],
|
||||||
"Switch to the first tab",
|
"Switch to the first tab",
|
||||||
@@ -449,16 +456,16 @@ function Tabs() //{{{
|
|||||||
"Switch to a buffer",
|
"Switch to a buffer",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let count = args.count;
|
|
||||||
let special = args.special;
|
let special = args.special;
|
||||||
args = args.string;
|
let count = args.count;
|
||||||
|
let arg = args.literalArg;
|
||||||
|
|
||||||
// if a numeric arg is specified any count is ignored; if a
|
// if a numeric arg is specified any count is ignored; if a
|
||||||
// count and non-numeric arg are both specified then E488
|
// count and non-numeric arg are both specified then E488
|
||||||
if (args && count > 0)
|
if (arg && count > 0)
|
||||||
{
|
{
|
||||||
if (/^\d+$/.test(args))
|
if (/^\d+$/.test(arg))
|
||||||
tabs.switchTo(args, special);
|
tabs.switchTo(arg, special);
|
||||||
else
|
else
|
||||||
liberator.echoerr("E488: Trailing characters");
|
liberator.echoerr("E488: Trailing characters");
|
||||||
}
|
}
|
||||||
@@ -468,7 +475,7 @@ function Tabs() //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tabs.switchTo(args, special);
|
tabs.switchTo(arg, special);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ ________________________________________________________________________________
|
|||||||
|
|
||||||
|
|
||||||
|b| |:b| |:buffer|
|
|b| |:b| |:buffer|
|
||||||
||:[count]b[uffer][!] {url|index}|| +
|
||:[count]b[uffer][!] [a][url|index][a]|| +
|
||||||
||b||
|
||b||
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
Go to the specified buffer from the buffer list. Argument can be either the
|
Go to the specified buffer from the buffer list. Argument can be either the
|
||||||
@@ -96,6 +96,8 @@ selected, even if it cannot be identified uniquely. Use [m]b[m] as a
|
|||||||
shortcut to open this prompt.
|
shortcut to open this prompt.
|
||||||
|
|
||||||
If argument is [a]#[a], the alternate buffer will be selected (see [m]<C-^>[m]).
|
If argument is [a]#[a], the alternate buffer will be selected (see [m]<C-^>[m]).
|
||||||
|
|
||||||
|
If no argument is given the current buffer remains current.
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user