From b46255f7cdb6ebc8a9f2ba8fe35185d20023e95d Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Sun, 18 Nov 2007 00:51:54 +0000 Subject: [PATCH] new a and A mappings --- NEWS | 1 + content/bookmarks.js | 21 +++++++++++++++++++++ content/commands.js | 7 ++++++- content/mappings.js | 14 ++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 274814e8..7bbe8bde 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ read up the new help for the f, F and ; commands for details removed the following hint options: 'hintchars' 'maxhints' added the following hint options: 'hinttimeout' + * new a and A mappings to deal with bookmarks * added ]n and ]p to navigate to the next/previous document based on the regexp specified in 'nextpattern' and 'previouspattern' (thanks kidd) * abbreviations for text fields (:abbr etc.) (thanks calmar) diff --git a/content/bookmarks.js b/content/bookmarks.js index 58ded943..df71f51f 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -148,6 +148,27 @@ vimperator.Bookmarks = function () //{{{ return true; }, + toggle: function(url) + { + if (!url) + return; + + var count = this.remove(url); + if (count > 0) + { + vimperator.commandline.echo("Removed bookmark: " + url, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_SINGLELINE); + } + else + { + var title = vimperator.buffer.title || url; + var extra = ""; + if (title != url) + extra = " (" + title + ")"; + this.add(title, url); + vimperator.commandline.echo("Added bookmark: " + url + extra, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_SINGLELINE); + } + }, + // returns number of deleted bookmarks remove: function (url) { diff --git a/content/commands.js b/content/commands.js index 1ba1c3db..2e4bbd38 100644 --- a/content/commands.js +++ b/content/commands.js @@ -605,7 +605,12 @@ vimperator.Commands = function () //{{{ var tags = getOption(res.opts, "-tags", []); if (vimperator.bookmarks.add(title, url, keyword, tags)) - vimperator.echo("Bookmark `" + title + "' added with url `" + url + "'", vimperator.commandline.FORCE_SINGLELINE); + { + var extra = ""; + if (title != url) + extra = " (" + title + ")"; + vimperator.echo("Added bookmark: " + url + extra, vimperator.commandline.FORCE_SINGLELINE); + } else vimperator.echoerr("Exxx: Could not add bookmark `" + title + "'", vimperator.commandline.FORCE_SINGLELINE); }, diff --git a/content/mappings.js b/content/mappings.js index af3e6e74..0e69c9ac 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -430,6 +430,20 @@ vimperator.Mappings = function () //{{{ flags: vimperator.Mappings.flags.COUNT } )); + addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["a"], + function () { vimperator.commandline.open(":", "bmark " + vimperator.buffer.URL, vimperator.modes.EX); }, + { + short_help: "Open a prompt to bookmark the current URL", + help: "Look at :bmark for more information." + } + )); + addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["A"], + function () { vimperator.bookmarks.toggle(vimperator.buffer.URL); }, + { + short_help: "Toggle bookmarked state of current URL", + help: "Add/remove a bookmark for the current location, depending if it already is bookmarked or not." + } + )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["b"], function () { vimperator.commandline.open(":", "buffer! ", vimperator.modes.EX); }, {