Add --delete option to bookmark-load

This commit is contained in:
Marshall Lochbaum 2016-07-22 23:18:14 -04:00
parent 1ac45d8971
commit b2c2d5a4f4
2 changed files with 12 additions and 3 deletions

View File

@ -1162,7 +1162,8 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window',
maxsplit=0)
@cmdutils.argument('url', completion=usertypes.Completion.bookmark_by_url)
def bookmark_load(self, url, tab=False, bg=False, window=False):
def bookmark_load(self, url, tab=False, bg=False, window=False,
delete=False):
"""Load a bookmark.
Args:
@ -1170,12 +1171,15 @@ class CommandDispatcher:
tab: Load the bookmark in a new tab.
bg: Load the bookmark in a new background tab.
window: Load the bookmark in a new window.
delete: Whether to delete the bookmark afterwards.
"""
try:
url = urlutils.fuzzy_url(url)
qurl = urlutils.fuzzy_url(url)
except urlutils.InvalidUrlError as e:
raise cmdexc.CommandError(e)
self._open(url, tab, bg, window)
self._open(qurl, tab, bg, window)
if delete:
self.bookmark_del(url)
@cmdutils.register(instance='command-dispatcher', scope='window',
maxsplit=0)

View File

@ -103,6 +103,11 @@ Feature: quickmarks and bookmarks
And I run :bookmark-add --toggle
Then the bookmark file should not contain "http://localhost:*/data/numbers/7.txt "
Scenario: Loading a bookmark with --delete
When I run :bookmark-add http://localhost:(port)/data/numbers/8.txt "eight"
And I run :bookmark-load -d http://localhost:(port)/data/numbers/8.txt
Then the bookmark file should not contain "http://localhost:*/data/numbers/8.txt "
## quickmarks
Scenario: Saving a quickmark (:quickmark-add)