1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 00:07:58 +01:00

move the bmadd() and bmdel() global functions into the corresponding command

definitions
This commit is contained in:
Doug Kearns
2007-07-04 11:59:53 +00:00
parent bade047430
commit 384d359749

View File

@@ -235,7 +235,31 @@ function Commands() //{{{
} }
)); ));
addDefaultCommand(new Command(["bma[dd]"], addDefaultCommand(new Command(["bma[dd]"],
bmadd, // takes: -t "foo" -T "tag1,tag2", myurl
// converts that string to a useful url and title, and calls addBookmark
// TODO: proper ex-style arg parsing
function(args)
{
var res = Bookmarks.parseBookmarkString(args);
if (res)
{
if (res.url == null)
{
res.url = getCurrentLocation();
// also guess title if the current url is :bmadded
if (res.title == null)
res.title = getCurrentTitle();
}
if (res.title == null) // title could still be null
res.title = res.url;
vimperator.bookmarks.add(res.title, res.url);
vimperator.echo("Bookmark `" + res.title + "' added with url `" + res.url + "'");
}
else
vimperator.echo("Usage: :bmadd [-t \"My Title\"] [-T tag1,tag2] <url>");
},
{ {
usage: ["bma[dd] [-tTk] [url]"], usage: ["bma[dd] [-tTk] [url]"],
short_help: "Add a bookmark", short_help: "Add a bookmark",
@@ -249,7 +273,21 @@ function Commands() //{{{
} }
)); ));
addDefaultCommand(new Command(["bmd[el]"], addDefaultCommand(new Command(["bmd[el]"],
bmdel, // TODO: proper ex-style arg parsing
function(args)
{
var res = Bookmarks.parseBookmarkString(args);
if (res)
{
if (res.url == null)
res.url = getCurrentLocation();
var del = vimperator.bookmarks.remove(res.url);
vimperator.echo(del + " bookmark(s) with url `" + res.url + "' deleted");
}
else
vimperator.echo("Usage: :bmdel <url>");
},
{ {
usage: ["bmd[el] [-T] {url}"], usage: ["bmd[el] [-T] {url}"],
short_help: "Delete a bookmark", short_help: "Delete a bookmark",
@@ -1286,50 +1324,6 @@ function yankCurrentSelection()
vimperator.echo("Yanked " + sel); vimperator.echo("Yanked " + sel);
} }
/////////////////////////////////////////////////////////////////////}}}
// high level bookmark/history related functions ///////////////////////
/////////////////////////////////////////////////////////////////////{{{
// takes: -t "foo" -T "tag1,tag2", myurl
// converts that string to a useful url and title, and calls addBookmark
function bmadd(str)
{
var res = Bookmarks.parseBookmarkString(str);
if (res)
{
if (res.url == null)
{
res.url = getCurrentLocation();
// also guess title if the current url is :bmadded
if (res.title == null)
res.title = getCurrentTitle();
}
if (res.title == null) // title could still be null
res.title = res.url;
vimperator.bookmarks.add(res.title, res.url);
vimperator.echo("Bookmark `" + res.title + "' added with url `" + res.url + "'");
}
else
vimperator.echo("Usage: :bmadd [-t \"My Title\"] [-T tag1,tag2] <url>");
}
function bmdel(str)
{
var res = Bookmarks.parseBookmarkString(str);
if (res)
{
if (res.url == null)
res.url = getCurrentLocation();
var del = vimperator.bookmarks.remove(res.url);
vimperator.echo(del + " bookmark(s) with url `" + res.url + "' deleted");
}
else
vimperator.echo("Usage: :bmdel <url>");
}
/////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////}}}
// tab/buffer related functions //////////////////////////////////////// // tab/buffer related functions ////////////////////////////////////////
/////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////{{{