From d0cf452ec8e8a4bfe8201a37fb8af05aa3234fe1 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 9 Sep 2016 15:57:15 +0200 Subject: [PATCH] Remove :prompt-yes and :prompt-no Those are replaced by :prompt-accept yes and :prompt-accept no --- CHANGELOG.asciidoc | 5 ++++- doc/help/commands.asciidoc | 10 ---------- qutebrowser/config/configdata.py | 11 +++++++---- qutebrowser/mainwindow/statusbar/prompter.py | 6 ++++-- tests/end2end/features/prompts.feature | 16 ++++++++-------- tests/end2end/features/urlmarks.feature | 4 ++-- tests/unit/config/test_config.py | 3 +++ 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index fe09de709..efb85c0d1 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -112,7 +112,8 @@ Changed - `content -> javascript-can-open-windows` got renamed to `javascript-can-open-windows-automatically`. - `:prompt-accept` now optionally accepts a value which overrides the one - entered in the input box. + entered in the input box. `yes` and `no` can be used as values for yes/no + questions. Deprecated ~~~~~~~~~~ @@ -121,6 +122,8 @@ Deprecated `{primary}` can be used instead. - The `:paste-primary` command got deprecated as `:insert-text {primary}` can be used instead. +- The `:prompt-yes` and `:prompt-no` commands got deprecated as + `:prompt-accept yes` and `:prompt-accept no` can be used instead. Removed ~~~~~~~ diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index b9fff178a..ba4154a01 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -974,9 +974,7 @@ How many steps to zoom out. |<>|Move the cursor or selection to the start of previous block. |<>|Open an external editor with the currently selected form field. |<>|Accept the current prompt. -|<>|Answer no to a yes/no prompt. |<>|Immediately open a download. -|<>|Answer yes to a yes/no prompt. |<>|Repeat the last executed command. |<>|Move back a character. |<>|Delete the character before the cursor. @@ -1227,10 +1225,6 @@ Accept the current prompt. * +'value'+: If given, uses this value instead of the entered one. For boolean prompts, "yes"/"no" are accepted as value. -[[prompt-no]] -=== prompt-no -Answer no to a yes/no prompt. - [[prompt-open-download]] === prompt-open-download Syntax: +:prompt-open-download ['cmdline']+ @@ -1248,10 +1242,6 @@ If no specific command is given, this will use the system's default application ==== note * This command does not split arguments after the last argument and handles quotes literally. -[[prompt-yes]] -=== prompt-yes -Answer yes to a yes/no prompt. - [[repeat-command]] === repeat-command Repeat the last executed command. diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 3979edf19..43923a795 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -1455,8 +1455,8 @@ KEY_SECTION_DESC = { "bind special keys.\n" "Useful hidden commands to map in this section:\n\n" " * `prompt-accept`: Confirm the entered value.\n" - " * `prompt-yes`: Answer yes to a yes/no question.\n" - " * `prompt-no`: Answer no to a yes/no question."), + " * `prompt-accept yes`: Answer yes to a yes/no question.\n" + " * `prompt-accept no`: Answer no to a yes/no question."), 'caret': ( ""), } @@ -1631,8 +1631,8 @@ KEY_DATA = collections.OrderedDict([ ('prompt', collections.OrderedDict([ ('prompt-accept', RETURN_KEYS), - ('prompt-yes', ['y']), - ('prompt-no', ['n']), + ('prompt-accept yes', ['y']), + ('prompt-accept no', ['n']), ('prompt-open-download', ['']), ])), @@ -1741,4 +1741,7 @@ CHANGED_KEY_COMMANDS = [ (re.compile(r'^set-cmd-text -s :search -r$'), r'set-cmd-text ?'), (re.compile(r'^set-cmd-text -s :$'), r'set-cmd-text :'), (re.compile(r'^set-cmd-text -s :set keybind$'), r'set-cmd-text -s :bind'), + + (re.compile(r'^prompt-yes$'), r'prompt-accept yes'), + (re.compile(r'^prompt-no$'), r'prompt-accept no'), ] diff --git a/qutebrowser/mainwindow/statusbar/prompter.py b/qutebrowser/mainwindow/statusbar/prompter.py index 66f3d58d0..c93f5912a 100644 --- a/qutebrowser/mainwindow/statusbar/prompter.py +++ b/qutebrowser/mainwindow/statusbar/prompter.py @@ -304,7 +304,8 @@ class Prompter(QObject): raise ValueError("Invalid question mode!") @cmdutils.register(instance='prompter', hide=True, scope='window', - modes=[usertypes.KeyMode.yesno]) + modes=[usertypes.KeyMode.yesno], + deprecated='Use :prompt-accept yes instead!') def prompt_yes(self): """Answer yes to a yes/no prompt.""" if self._question.mode != usertypes.PromptMode.yesno: @@ -316,7 +317,8 @@ class Prompter(QObject): self._question.done() @cmdutils.register(instance='prompter', hide=True, scope='window', - modes=[usertypes.KeyMode.yesno]) + modes=[usertypes.KeyMode.yesno], + deprecated='Use :prompt-accept no instead!') def prompt_no(self): """Answer no to a yes/no prompt.""" if self._question.mode != usertypes.PromptMode.yesno: diff --git a/tests/end2end/features/prompts.feature b/tests/end2end/features/prompts.feature index 2f2d3fd98..05324061f 100644 --- a/tests/end2end/features/prompts.feature +++ b/tests/end2end/features/prompts.feature @@ -23,14 +23,14 @@ Feature: Prompts When I open data/prompt/jsconfirm.html And I run :click-element id button And I wait for a prompt - And I run :prompt-yes + And I run :prompt-accept yes Then the javascript message "confirm reply: true" should be logged Scenario: Javascript confirm - no When I open data/prompt/jsconfirm.html And I run :click-element id button And I wait for a prompt - And I run :prompt-no + And I run :prompt-accept no Then the javascript message "confirm reply: false" should be logged Scenario: Javascript confirm - aborted @@ -101,7 +101,7 @@ Feature: Prompts And I set network -> ssl-strict to ask And I load an SSL page And I wait for a prompt - And I run :prompt-yes + And I run :prompt-accept yes And I wait until the SSL page finished loading Then the page should contain the plaintext "Hello World via SSL!" @@ -110,7 +110,7 @@ Feature: Prompts And I set network -> ssl-strict to ask And I load an SSL page And I wait for a prompt - And I run :prompt-no + And I run :prompt-accept no Then "Error while loading *: SSL handshake failed" should be logged And the page should contain the plaintext "Unable to load page" @@ -135,7 +135,7 @@ Feature: Prompts And I open data/prompt/geolocation.html in a new tab And I run :click-element id button And I wait for a prompt - And I run :prompt-yes + And I run :prompt-accept yes Then the javascript message "geolocation permission denied" should not be logged Scenario: geolocation with ask -> false @@ -143,7 +143,7 @@ Feature: Prompts And I open data/prompt/geolocation.html in a new tab And I run :click-element id button And I wait for a prompt - And I run :prompt-no + And I run :prompt-accept no Then the javascript message "geolocation permission denied" should be logged Scenario: geolocation with ask -> abort @@ -173,7 +173,7 @@ Feature: Prompts And I open data/prompt/notifications.html in a new tab And I run :click-element id button And I wait for a prompt - And I run :prompt-no + And I run :prompt-accept no Then the javascript message "notification permission denied" should be logged Scenario: notifications with ask -> true @@ -181,7 +181,7 @@ Feature: Prompts And I open data/prompt/notifications.html in a new tab And I run :click-element id button And I wait for a prompt - And I run :prompt-yes + And I run :prompt-accept yes Then the javascript message "notification permission granted" should be logged # This actually gives us a denied rather than an aborted diff --git a/tests/end2end/features/urlmarks.feature b/tests/end2end/features/urlmarks.feature index 8ae5aae35..cbee648b0 100644 --- a/tests/end2end/features/urlmarks.feature +++ b/tests/end2end/features/urlmarks.feature @@ -126,14 +126,14 @@ Feature: quickmarks and bookmarks When I run :quickmark-add http://localhost:(port)/data/numbers/11.txt eleven And I run :quickmark-add http://localhost:(port)/data/numbers/11_2.txt eleven And I wait for "Entering mode KeyMode.yesno (reason: question asked)" in the log - And I run :prompt-no + And I run :prompt-accept no Then the quickmark file should contain "eleven http://localhost:*/data/numbers/11.txt" Scenario: Saving a duplicate quickmark (with override) When I run :quickmark-add http://localhost:(port)/data/numbers/12.txt twelve And I run :quickmark-add http://localhost:(port)/data/numbers/12_2.txt twelve And I wait for "Entering mode KeyMode.yesno (reason: question asked)" in the log - And I run :prompt-yes + And I run :prompt-accept yes Then the quickmark file should contain "twelve http://localhost:*/data/numbers/12_2.txt" Scenario: Adding a quickmark with an empty name diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index 8e903c6c8..37b5c9676 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -345,6 +345,9 @@ class TestKeyConfigParser: ('set-cmd-text -s :search -r', 'set-cmd-text ?'), ('set-cmd-text -s :', 'set-cmd-text :'), ('set-cmd-text -s :set keybind', 'set-cmd-text -s :bind'), + + ('prompt-yes', 'prompt-accept yes'), + ('prompt-no', 'prompt-accept no'), ] ) def test_migrations(self, old, new_expected):