From 83005bc0723bdb4282ca0a3532739b678fd62852 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 21 Jul 2016 20:46:44 -0400 Subject: [PATCH 01/12] Make bookmark_del with no argument delete the current page's mark --- qutebrowser/browser/commands.py | 15 +++++++++++++++ qutebrowser/browser/urlmarks.py | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 5192ac895..ff6dfd3fe 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1147,6 +1147,21 @@ class CommandDispatcher: raise cmdexc.CommandError(e) self._open(url, tab, bg, window) + @cmdutils.register(instance='command-dispatcher', scope='window', + maxsplit=0) + @cmdutils.argument('url', completion=usertypes.Completion.bookmark_by_url) + def bookmark_del(self, url=None): + """Delete a bookmark. + + Args: + url: The url of the bookmark to delete. If None, use the + current page's url. + """ + if url is None: + url = self._current_url().toString(QUrl.RemovePassword + | QUrl.FullyEncoded) + objreg.get('bookmark-manager').bookmark_del(url) + @cmdutils.register(instance='command-dispatcher', hide=True, scope='window') def follow_selected(self, *, tab=False): diff --git a/qutebrowser/browser/urlmarks.py b/qutebrowser/browser/urlmarks.py index df1302535..4a6dcd1eb 100644 --- a/qutebrowser/browser/urlmarks.py +++ b/qutebrowser/browser/urlmarks.py @@ -285,8 +285,6 @@ class BookmarkManager(UrlMarkManager): self.changed.emit() self.added.emit(title, urlstr) - @cmdutils.register(instance='bookmark-manager', maxsplit=0) - @cmdutils.argument('url', completion=usertypes.Completion.bookmark_by_url) def bookmark_del(self, url): """Delete a bookmark. From 19949101c6fee34f8e4bc1747a924b70af68cdb5 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 21 Jul 2016 21:15:15 -0400 Subject: [PATCH 02/12] Make quickmark_del with no argument delete the current page's mark (fixes #1661) --- qutebrowser/browser/commands.py | 23 +++++++++++++++++++++++ qutebrowser/browser/urlmarks.py | 21 ++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index ff6dfd3fe..33e330cd1 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1095,6 +1095,29 @@ class CommandDispatcher: raise cmdexc.CommandError(str(e)) self._open(url, tab, bg, window) + @cmdutils.register(instance='command-dispatcher', scope='window', + maxsplit=0) + @cmdutils.argument('name', + completion=usertypes.Completion.quickmark_by_name) + def quickmark_del(self, name=None): + """Delete a quickmark. + + Args: + name: The name of the quickmark to delete. If none, delete the + quickmark for the current page (choosing one arbitrarily + if there are more than one). + """ + quickmark_manager = objreg.get('quickmark-manager') + if name is None: + url = self._current_url() + try: + name = quickmark_manager.get_by_qurl(url) + except ValueError: + urlutils.invalid_url_error(self._win_id, url, + "delete quickmark") + return + quickmark_manager.quickmark_del(name) + @cmdutils.register(instance='command-dispatcher', scope='window') def bookmark_add(self, url=None, title=None): """Save the current page as a bookmark, or a specific url. diff --git a/qutebrowser/browser/urlmarks.py b/qutebrowser/browser/urlmarks.py index 4a6dcd1eb..994d1f986 100644 --- a/qutebrowser/browser/urlmarks.py +++ b/qutebrowser/browser/urlmarks.py @@ -204,9 +204,6 @@ class QuickmarkManager(UrlMarkManager): else: set_mark() - @cmdutils.register(instance='quickmark-manager', maxsplit=0) - @cmdutils.argument('name', - completion=usertypes.Completion.quickmark_by_name) def quickmark_del(self, name): """Delete a quickmark. @@ -218,6 +215,24 @@ class QuickmarkManager(UrlMarkManager): except KeyError: raise cmdexc.CommandError("Quickmark '{}' not found!".format(name)) + def get_by_qurl(self, url): + """Look up a quickmark by QUrl, returning its name. + + Takes O(n) time, where n is the number of quickmarks. + Use a name instead where possible. + """ + if not url.isValid(): + raise ValueError("Invalid URL: {}".format(url.errorString())) + urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded) + + try: + index = list(self.marks.values()).index(urlstr) + key = list(self.marks.keys())[index] + except ValueError: + raise cmdexc.CommandError( + "Quickmark for '{}' not found!".format(urlstr)) + return key + def get(self, name): """Get the URL of the quickmark named name as a QUrl.""" if name not in self.marks: From ff682606ab8cabdd81c51c209d5d46a5caec6e26 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 21 Jul 2016 22:34:10 -0400 Subject: [PATCH 03/12] Add tests for bookmark-del and quickmark-del with no arguments --- tests/end2end/features/urlmarks.feature | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/end2end/features/urlmarks.feature b/tests/end2end/features/urlmarks.feature index 8f0136e59..3059188a0 100644 --- a/tests/end2end/features/urlmarks.feature +++ b/tests/end2end/features/urlmarks.feature @@ -86,6 +86,17 @@ Feature: quickmarks and bookmarks And I run :bookmark-del http://localhost:(port)/data/numbers/5.txt Then the bookmark file should not contain "http://localhost:*/data/numbers/5.txt " + Scenario: Deleting the current page's bookmark if it doesn't exist + When I open about:blank + And I run :bookmark-del + Then the error "Bookmark 'about:blank' not found!" should be shown + + Scenario: Deleting the current page's bookmark + When I open data/numbers/5.txt + And I run :bookmark-add + And I run :bookmark-del + Then the bookmark file should not contain "http://localhost:*/data/numbers/5.txt " + ## quickmarks Scenario: Saving a quickmark (:quickmark-add) @@ -186,3 +197,17 @@ Feature: quickmarks and bookmarks When I run :quickmark-add http://localhost:(port)/data/numbers/15.txt fifteen And I run :quickmark-del fifteen Then the quickmark file should not contain "fourteen http://localhost:*/data/numbers/15.txt " + + Scenario: Deleting the current page's quickmark if it has none + When I open about:blank + And I run :quickmark-del + Then the error "Quickmark for 'about:blank' not found!" should be shown + + Scenario: Deleting the current page's quickmark + When I open data/numbers/7.txt + And I run :quickmark-save + And I wait for "Entering mode KeyMode.prompt (reason: question asked)" in the log + And I press the keys "seven" + And I press the keys "" + And I run :quickmark-del + Then the quickmark file should not contain "seven http://localhost:*/data/numbers/7.txt" From e9660ad676c3de3240d4684794c78eb4d607b765 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 21 Jul 2016 22:45:36 -0400 Subject: [PATCH 04/12] Fix incorrect number in test --- tests/end2end/features/urlmarks.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end2end/features/urlmarks.feature b/tests/end2end/features/urlmarks.feature index 3059188a0..6c9c40b40 100644 --- a/tests/end2end/features/urlmarks.feature +++ b/tests/end2end/features/urlmarks.feature @@ -196,7 +196,7 @@ Feature: quickmarks and bookmarks Scenario: Deleting a quickmark When I run :quickmark-add http://localhost:(port)/data/numbers/15.txt fifteen And I run :quickmark-del fifteen - Then the quickmark file should not contain "fourteen http://localhost:*/data/numbers/15.txt " + Then the quickmark file should not contain "fifteen http://localhost:*/data/numbers/15.txt " Scenario: Deleting the current page's quickmark if it has none When I open about:blank From cba25d2bbb9fad8af3d0e3f3ceb949b68c21ea10 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 23 Jul 2016 10:55:57 -0400 Subject: [PATCH 05/12] Remove quickmark_del and bookmark_del from the urlmark classes (use delete instead) --- qutebrowser/browser/commands.py | 11 +++++++++-- qutebrowser/browser/urlmarks.py | 22 ---------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 33e330cd1..064d555bf 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1116,7 +1116,10 @@ class CommandDispatcher: urlutils.invalid_url_error(self._win_id, url, "delete quickmark") return - quickmark_manager.quickmark_del(name) + try: + quickmark_manager.delete(name) + except KeyError: + raise cmdexc.CommandError("Quickmark '{}' not found!".format(name)) @cmdutils.register(instance='command-dispatcher', scope='window') def bookmark_add(self, url=None, title=None): @@ -1183,7 +1186,11 @@ class CommandDispatcher: if url is None: url = self._current_url().toString(QUrl.RemovePassword | QUrl.FullyEncoded) - objreg.get('bookmark-manager').bookmark_del(url) + try: + objreg.get('bookmark-manager').delete(url) + except KeyError: + raise cmdexc.CommandError("Bookmark '{}' not found!".format(url)) + @cmdutils.register(instance='command-dispatcher', hide=True, scope='window') diff --git a/qutebrowser/browser/urlmarks.py b/qutebrowser/browser/urlmarks.py index 994d1f986..f8b011439 100644 --- a/qutebrowser/browser/urlmarks.py +++ b/qutebrowser/browser/urlmarks.py @@ -204,17 +204,6 @@ class QuickmarkManager(UrlMarkManager): else: set_mark() - def quickmark_del(self, name): - """Delete a quickmark. - - Args: - name: The name of the quickmark to delete. - """ - try: - self.delete(name) - except KeyError: - raise cmdexc.CommandError("Quickmark '{}' not found!".format(name)) - def get_by_qurl(self, url): """Look up a quickmark by QUrl, returning its name. @@ -299,14 +288,3 @@ class BookmarkManager(UrlMarkManager): self.marks[urlstr] = title self.changed.emit() self.added.emit(title, urlstr) - - def bookmark_del(self, url): - """Delete a bookmark. - - Args: - url: The URL of the bookmark to delete. - """ - try: - self.delete(url) - except KeyError: - raise cmdexc.CommandError("Bookmark '{}' not found!".format(url)) From 02731743c0f4fec68f701cdc211a2fe2995d76bb Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 23 Jul 2016 11:07:01 -0400 Subject: [PATCH 06/12] Use qtutils.ensure_valid instead of testing isValid in get_by_qurl --- qutebrowser/browser/urlmarks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/urlmarks.py b/qutebrowser/browser/urlmarks.py index f8b011439..caabf72fa 100644 --- a/qutebrowser/browser/urlmarks.py +++ b/qutebrowser/browser/urlmarks.py @@ -32,7 +32,8 @@ import collections from PyQt5.QtCore import pyqtSignal, QUrl, QObject -from qutebrowser.utils import message, usertypes, urlutils, standarddir, objreg +from qutebrowser.utils import (message, usertypes, qtutils, urlutils, + standarddir, objreg) from qutebrowser.commands import cmdexc, cmdutils from qutebrowser.misc import lineparser @@ -210,8 +211,7 @@ class QuickmarkManager(UrlMarkManager): Takes O(n) time, where n is the number of quickmarks. Use a name instead where possible. """ - if not url.isValid(): - raise ValueError("Invalid URL: {}".format(url.errorString())) + qtutils.ensure_valid(url) urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded) try: From 9758b52d91ad9d16b910b3427f0efb82765cb3af Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 23 Jul 2016 11:10:54 -0400 Subject: [PATCH 07/12] Assume _current_url is valid (remove try/except) --- qutebrowser/browser/commands.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 064d555bf..f80bcad9e 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1110,12 +1110,7 @@ class CommandDispatcher: quickmark_manager = objreg.get('quickmark-manager') if name is None: url = self._current_url() - try: - name = quickmark_manager.get_by_qurl(url) - except ValueError: - urlutils.invalid_url_error(self._win_id, url, - "delete quickmark") - return + name = quickmark_manager.get_by_qurl(url) try: quickmark_manager.delete(name) except KeyError: From 1781d0fba3e2d79bff4d2bdba45312991e266f14 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 23 Jul 2016 11:21:27 -0400 Subject: [PATCH 08/12] Use DoesNotExistError rather than CommandError in get_by_qurl --- qutebrowser/browser/commands.py | 5 ++++- qutebrowser/browser/urlmarks.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index f80bcad9e..d7cbd6a3e 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1110,7 +1110,10 @@ class CommandDispatcher: quickmark_manager = objreg.get('quickmark-manager') if name is None: url = self._current_url() - name = quickmark_manager.get_by_qurl(url) + try: + name = quickmark_manager.get_by_qurl(url) + except urlmarks.DoesNotExistError as e: + raise cmdexc.CommandError(str(e)) try: quickmark_manager.delete(name) except KeyError: diff --git a/qutebrowser/browser/urlmarks.py b/qutebrowser/browser/urlmarks.py index caabf72fa..bfa26d12b 100644 --- a/qutebrowser/browser/urlmarks.py +++ b/qutebrowser/browser/urlmarks.py @@ -34,7 +34,7 @@ from PyQt5.QtCore import pyqtSignal, QUrl, QObject from qutebrowser.utils import (message, usertypes, qtutils, urlutils, standarddir, objreg) -from qutebrowser.commands import cmdexc, cmdutils +from qutebrowser.commands import cmdutils from qutebrowser.misc import lineparser @@ -218,7 +218,7 @@ class QuickmarkManager(UrlMarkManager): index = list(self.marks.values()).index(urlstr) key = list(self.marks.keys())[index] except ValueError: - raise cmdexc.CommandError( + raise DoesNotExistError( "Quickmark for '{}' not found!".format(urlstr)) return key From 9eeda62adfb992f4d258b2b273400ebecf097117 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 23 Jul 2016 11:25:04 -0400 Subject: [PATCH 09/12] Use quickmark-add rather than quickmark-save in test --- tests/end2end/features/urlmarks.feature | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/end2end/features/urlmarks.feature b/tests/end2end/features/urlmarks.feature index 6c9c40b40..bc97aa8df 100644 --- a/tests/end2end/features/urlmarks.feature +++ b/tests/end2end/features/urlmarks.feature @@ -205,9 +205,6 @@ Feature: quickmarks and bookmarks Scenario: Deleting the current page's quickmark When I open data/numbers/7.txt - And I run :quickmark-save - And I wait for "Entering mode KeyMode.prompt (reason: question asked)" in the log - And I press the keys "seven" - And I press the keys "" + And I run :quickmark-add http://localhost:(port)/data/numbers/7.txt seven And I run :quickmark-del Then the quickmark file should not contain "seven http://localhost:*/data/numbers/7.txt" From f52c7f13d391fd3d743ec62162cc6cf64c1e82a7 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 23 Jul 2016 11:47:33 -0400 Subject: [PATCH 10/12] Update numbers in urlmarks test --- tests/end2end/features/urlmarks.feature | 84 ++++++++++++------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/tests/end2end/features/urlmarks.feature b/tests/end2end/features/urlmarks.feature index bc97aa8df..e654309d8 100644 --- a/tests/end2end/features/urlmarks.feature +++ b/tests/end2end/features/urlmarks.feature @@ -92,38 +92,38 @@ Feature: quickmarks and bookmarks Then the error "Bookmark 'about:blank' not found!" should be shown Scenario: Deleting the current page's bookmark - When I open data/numbers/5.txt + When I open data/numbers/6.txt And I run :bookmark-add And I run :bookmark-del - Then the bookmark file should not contain "http://localhost:*/data/numbers/5.txt " + Then the bookmark file should not contain "http://localhost:*/data/numbers/6.txt " ## quickmarks Scenario: Saving a quickmark (:quickmark-add) - When I run :quickmark-add http://localhost:(port)/data/numbers/6.txt six - Then the quickmark file should contain "six http://localhost:*/data/numbers/6.txt" - - Scenario: Saving a quickmark (:quickmark-save) - When I open data/numbers/7.txt - And I run :quickmark-save - And I wait for "Entering mode KeyMode.prompt (reason: question asked)" in the log - And I press the keys "seven" - And I press the keys "" + When I run :quickmark-add http://localhost:(port)/data/numbers/7.txt seven Then the quickmark file should contain "seven http://localhost:*/data/numbers/7.txt" - Scenario: Saving a duplicate quickmark (without override) - When I run :quickmark-add http://localhost:(port)/data/numbers/8.txt eight - And I run :quickmark-add http://localhost:(port)/data/numbers/8_2.txt eight - And I wait for "Entering mode KeyMode.yesno (reason: question asked)" in the log - And I run :prompt-no + Scenario: Saving a quickmark (:quickmark-save) + When I open data/numbers/8.txt + And I run :quickmark-save + And I wait for "Entering mode KeyMode.prompt (reason: question asked)" in the log + And I press the keys "eight" + And I press the keys "" Then the quickmark file should contain "eight http://localhost:*/data/numbers/8.txt" - Scenario: Saving a duplicate quickmark (with override) + Scenario: Saving a duplicate quickmark (without override) When I run :quickmark-add http://localhost:(port)/data/numbers/9.txt nine And I run :quickmark-add http://localhost:(port)/data/numbers/9_2.txt nine And I wait for "Entering mode KeyMode.yesno (reason: question asked)" in the log + And I run :prompt-no + Then the quickmark file should contain "nine http://localhost:*/data/numbers/9.txt" + + Scenario: Saving a duplicate quickmark (with override) + When I run :quickmark-add http://localhost:(port)/data/numbers/10.txt ten + And I run :quickmark-add http://localhost:(port)/data/numbers/10_2.txt ten + And I wait for "Entering mode KeyMode.yesno (reason: question asked)" in the log And I run :prompt-yes - Then the quickmark file should contain "nine http://localhost:*/data/numbers/9_2.txt" + Then the quickmark file should contain "ten http://localhost:*/data/numbers/10_2.txt" Scenario: Adding a quickmark with an empty name When I run :quickmark-add about:blank "" @@ -135,38 +135,38 @@ Feature: quickmarks and bookmarks Scenario: Loading a quickmark Given I have a fresh instance - When I run :quickmark-add http://localhost:(port)/data/numbers/10.txt ten - And I run :quickmark-load ten - Then data/numbers/10.txt should be loaded + When I run :quickmark-add http://localhost:(port)/data/numbers/11.txt eleven + And I run :quickmark-load eleven + Then data/numbers/11.txt should be loaded And the following tabs should be open: - - data/numbers/10.txt (active) + - data/numbers/11.txt (active) Scenario: Loading a quickmark in a new tab Given I open about:blank When I run :tab-only - And I run :quickmark-add http://localhost:(port)/data/numbers/11.txt eleven - And I run :quickmark-load -t eleven - Then data/numbers/11.txt should be loaded + And I run :quickmark-add http://localhost:(port)/data/numbers/12.txt twelve + And I run :quickmark-load -t twelve + Then data/numbers/12.txt should be loaded And the following tabs should be open: - about:blank - - data/numbers/11.txt (active) + - data/numbers/12.txt (active) Scenario: Loading a quickmark in a background tab Given I open about:blank When I run :tab-only - And I run :quickmark-add http://localhost:(port)/data/numbers/12.txt twelve - And I run :quickmark-load -b twelve - Then data/numbers/12.txt should be loaded + And I run :quickmark-add http://localhost:(port)/data/numbers/13.txt thirteen + And I run :quickmark-load -b thirteen + Then data/numbers/13.txt should be loaded And the following tabs should be open: - about:blank (active) - - data/numbers/12.txt + - data/numbers/13.txt Scenario: Loading a quickmark in a new window Given I open about:blank When I run :tab-only - And I run :quickmark-add http://localhost:(port)/data/numbers/13.txt thirteen - And I run :quickmark-load -w thirteen - And I wait until data/numbers/13.txt is loaded + And I run :quickmark-add http://localhost:(port)/data/numbers/14.txt fourteen + And I run :quickmark-load -w fourteen + And I wait until data/numbers/14.txt is loaded Then the session should look like: windows: - tabs: @@ -178,15 +178,15 @@ Feature: quickmarks and bookmarks - active: true history: - active: true - url: http://localhost:*/data/numbers/13.txt + url: http://localhost:*/data/numbers/14.txt Scenario: Loading a quickmark which does not exist When I run :quickmark-load -b doesnotexist Then the error "Quickmark 'doesnotexist' does not exist!" should be shown Scenario: Loading a quickmark with -t and -b - When I run :quickmark-add http://localhost:(port)/data/numbers/14.txt fourteen - When I run :quickmark-load -t -b fourteen + When I run :quickmark-add http://localhost:(port)/data/numbers/15.txt fifteen + When I run :quickmark-load -t -b fifteen Then the error "Only one of -t/-b/-w can be given!" should be shown Scenario: Deleting a quickmark which does not exist @@ -194,9 +194,9 @@ Feature: quickmarks and bookmarks Then the error "Quickmark 'doesnotexist' not found!" should be shown Scenario: Deleting a quickmark - When I run :quickmark-add http://localhost:(port)/data/numbers/15.txt fifteen - And I run :quickmark-del fifteen - Then the quickmark file should not contain "fifteen http://localhost:*/data/numbers/15.txt " + When I run :quickmark-add http://localhost:(port)/data/numbers/16.txt sixteen + And I run :quickmark-del sixteen + Then the quickmark file should not contain "sixteen http://localhost:*/data/numbers/16.txt " Scenario: Deleting the current page's quickmark if it has none When I open about:blank @@ -204,7 +204,7 @@ Feature: quickmarks and bookmarks Then the error "Quickmark for 'about:blank' not found!" should be shown Scenario: Deleting the current page's quickmark - When I open data/numbers/7.txt - And I run :quickmark-add http://localhost:(port)/data/numbers/7.txt seven + When I open data/numbers/1.txt + And I run :quickmark-add http://localhost:(port)/data/numbers/1.txt seventeen And I run :quickmark-del - Then the quickmark file should not contain "seven http://localhost:*/data/numbers/7.txt" + Then the quickmark file should not contain "seventeen http://localhost:*/data/numbers/1.txt" From 028e7239ed74899c7f15ed70dfdd261326fe1884 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 25 Jul 2016 15:37:02 -0400 Subject: [PATCH 11/12] Add more number files --- tests/end2end/data/numbers/15.txt | 1 + tests/end2end/data/numbers/16.txt | 1 + tests/end2end/data/numbers/17.txt | 1 + tests/end2end/features/urlmarks.feature | 6 +++--- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 tests/end2end/data/numbers/15.txt create mode 100644 tests/end2end/data/numbers/16.txt create mode 100644 tests/end2end/data/numbers/17.txt diff --git a/tests/end2end/data/numbers/15.txt b/tests/end2end/data/numbers/15.txt new file mode 100644 index 000000000..e228c03ca --- /dev/null +++ b/tests/end2end/data/numbers/15.txt @@ -0,0 +1 @@ +fifteen diff --git a/tests/end2end/data/numbers/16.txt b/tests/end2end/data/numbers/16.txt new file mode 100644 index 000000000..64b765f18 --- /dev/null +++ b/tests/end2end/data/numbers/16.txt @@ -0,0 +1 @@ +sixteen diff --git a/tests/end2end/data/numbers/17.txt b/tests/end2end/data/numbers/17.txt new file mode 100644 index 000000000..5615fadf4 --- /dev/null +++ b/tests/end2end/data/numbers/17.txt @@ -0,0 +1 @@ +seventeen diff --git a/tests/end2end/features/urlmarks.feature b/tests/end2end/features/urlmarks.feature index b99bc2d87..3490cc4a0 100644 --- a/tests/end2end/features/urlmarks.feature +++ b/tests/end2end/features/urlmarks.feature @@ -204,10 +204,10 @@ Feature: quickmarks and bookmarks Then the error "Quickmark for 'about:blank' not found!" should be shown Scenario: Deleting the current page's quickmark - When I open data/numbers/1.txt - And I run :quickmark-add http://localhost:(port)/data/numbers/1.txt seventeen + When I open data/numbers/17.txt + And I run :quickmark-add http://localhost:(port)/data/numbers/17.txt seventeen And I run :quickmark-del - Then the quickmark file should not contain "seventeen http://localhost:*/data/numbers/1.txt" + Then the quickmark file should not contain "seventeen http://localhost:*/data/numbers/17.txt" Scenario: Listing quickmarks When I run :quickmark-add http://localhost:(port)/data/numbers/15.txt fifteen From da64db853e16af9e579f8b75c13d30289a296ac5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 26 Jul 2016 08:36:16 +0200 Subject: [PATCH 12/12] Update docs --- CHANGELOG.asciidoc | 2 ++ README.asciidoc | 1 + doc/help/commands.asciidoc | 11 +++++++---- qutebrowser/browser/commands.py | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 6ebc25e6d..f0bd07795 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -44,6 +44,8 @@ Changed rather than the current page. - New `taskadd` userscript to add a taskwarrior task annotated with the current URL. +- `:bookmark-del` and `:quickmark-del` now delete the current page's URL if none + is given. Fixed ----- diff --git a/README.asciidoc b/README.asciidoc index acf7fbc09..422b87db8 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -165,6 +165,7 @@ Contributors, sorted by the number of commits in descending order: * Kevin Velghe * Austin Anderson * Jimmy +* Marshall Lochbaum * Alexey "Averrin" Nabrodov * avk * ZDarian diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 713b75d60..eea3f0d7f 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -128,12 +128,13 @@ If no url and title are provided, then save the current page as a bookmark. If a [[bookmark-del]] === bookmark-del -Syntax: +:bookmark-del 'url'+ +Syntax: +:bookmark-del ['url']+ Delete a bookmark. ==== positional arguments -* +'url'+: The URL of the bookmark to delete. +* +'url'+: The url of the bookmark to delete. If not given, use the current page's url. + ==== note * This command does not split arguments after the last argument and handles quotes literally. @@ -520,12 +521,14 @@ You can view all saved quickmarks on the link:qute://bookmarks[bookmarks page]. [[quickmark-del]] === quickmark-del -Syntax: +:quickmark-del 'name'+ +Syntax: +:quickmark-del ['name']+ Delete a quickmark. ==== positional arguments -* +'name'+: The name of the quickmark to delete. +* +'name'+: The name of the quickmark to delete. If not given, delete the quickmark for the current page (choosing one arbitrarily + if there are more than one). + ==== note * This command does not split arguments after the last argument and handles quotes literally. diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index dba95fa8f..49eaa5dcb 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1103,7 +1103,7 @@ class CommandDispatcher: """Delete a quickmark. Args: - name: The name of the quickmark to delete. If none, delete the + name: The name of the quickmark to delete. If not given, delete the quickmark for the current page (choosing one arbitrarily if there are more than one). """ @@ -1181,7 +1181,7 @@ class CommandDispatcher: """Delete a bookmark. Args: - url: The url of the bookmark to delete. If None, use the + url: The url of the bookmark to delete. If not given, use the current page's url. """ if url is None: