From b2c2d5a4f411933c834d360e10cf21b48352d8d8 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 22 Jul 2016 23:18:14 -0400 Subject: [PATCH] Add --delete option to bookmark-load --- qutebrowser/browser/commands.py | 10 +++++++--- tests/end2end/features/urlmarks.feature | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 3b0e0bc51..c91cfca2b 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -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) diff --git a/tests/end2end/features/urlmarks.feature b/tests/end2end/features/urlmarks.feature index 4054e3f15..fe7b4b656 100644 --- a/tests/end2end/features/urlmarks.feature +++ b/tests/end2end/features/urlmarks.feature @@ -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)