From f6cc6677dd78e83c0e9885fe3bac3144fb809633 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 13 Nov 2017 07:59:54 +0100 Subject: [PATCH] Remove hiding of commands This was often confusing for people - let's instead just hide commands which are not available in normal mode. --- doc/contributing.asciidoc | 1 - doc/help/commands.asciidoc | 440 ++++++++++---------- qutebrowser/browser/commands.py | 102 ++--- qutebrowser/browser/hints.py | 2 +- qutebrowser/commands/command.py | 21 +- qutebrowser/completion/completionwidget.py | 6 +- qutebrowser/completion/models/util.py | 9 +- qutebrowser/keyinput/modeman.py | 7 +- qutebrowser/mainwindow/prompt.py | 6 +- qutebrowser/mainwindow/statusbar/command.py | 6 +- qutebrowser/misc/readline.py | 30 +- qutebrowser/misc/utilcmds.py | 15 +- scripts/dev/src2asciidoc.py | 14 +- tests/helpers/stubs.py | 1 + tests/unit/commands/test_cmdutils.py | 8 - tests/unit/completion/test_models.py | 5 +- 16 files changed, 326 insertions(+), 347 deletions(-) diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc index 2dda2f817..b39f3d902 100644 --- a/doc/contributing.asciidoc +++ b/doc/contributing.asciidoc @@ -470,7 +470,6 @@ The following arguments are supported for `@cmdutils.argument`: - `flag`: Customize the short flag (`-x`) the argument will get. - `win_id=True`: Mark the argument as special window ID argument. - `count=True`: Mark the argument as special count argument. -- `hide=True`: Hide the argument from the documentation. - `completion`: A completion function (see `qutebrowser.completions.models.*`) to use when completing arguments for the given command. - `choices`: The allowed string choices for the argument. diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 367439e34..04377c055 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -30,6 +30,9 @@ It is possible to run or bind multiple commands by separating them with `;;`. |<>|Delete a bookmark. |<>|Load a bookmark. |<>|Select tab by index or url/title best match. +|<>|Clear the currently entered key chain. +|<>|Clear all message notifications. +|<>|Click the element matching the given filter. |<>|Close the current window. |<>|Set all settings back to their default. |<>|Cycle an option between multiple values. @@ -45,7 +48,9 @@ It is possible to run or bind multiple commands by separating them with `;;`. |<>|Remove the last/[count]th download from the list. |<>|Retry the first failed/[count]th download. |<>|Navigate to a url formed in an external editor. +|<>|Enter a key mode. |<>|Send a fake keypress or key string to the website or qutebrowser. +|<>|Follow the selected text. |<>|Go forward in the history of the current tab. |<>|Toggle fullscreen mode. |<>|Show help about a command or setting. @@ -56,9 +61,14 @@ It is possible to run or bind multiple commands by separating them with `;;`. |<>|Insert text at cursor position. |<>|Toggle the web inspector. |<>|Evaluate a JavaScript string. +|<>|Jump to the mark named by `key`. |<>|Execute a command after some time. +|<>|Show an error message in the statusbar. +|<>|Show an info message in the statusbar. +|<>|Show a warning message in the statusbar. |<>|Show a log of past messages. |<>|Open typical prev/next links or navigate using the URL path. +|<>|Do nothing. |<>|Open a URL in the current/[count]th tab. |<>|Open an external editor with the currently selected form field. |<>|Print the current/[count]th tab. @@ -70,16 +80,25 @@ It is possible to run or bind multiple commands by separating them with `;;`. |<>|Start or stop recording a macro. |<>|Reload the current/[count]th tab. |<>|Repeat a given command. +|<>|Repeat the last executed command. |<>|Report a bug in qutebrowser. |<>|Restart qutebrowser while keeping existing tabs open. |<>|Run a recorded macro. +|<>|Run a command with the given count. |<>|Save configs and state. +|<>|Scroll the current tab in the given direction. +|<>|Scroll the frame page-wise. +|<>|Scroll the current tab by 'count * dx/dy' pixels. +|<>|Scroll to a specific percentage of the page. |<>|Search for a text on the current page. With no text, clear results. +|<>|Continue the search to the ([count]th) next term. +|<>|Continue the search to the ([count]th) previous term. |<>|Delete a session. |<>|Load a session. |<>|Save a session. |<>|Set an option. |<>|Preset the statusbar to some text. +|<>|Set a mark at the current scroll position in the current tab. |<>|Spawn a command in a shell. |<>|Stop loading in the current/[count]th tab. |<>|Duplicate the current tab. @@ -209,6 +228,31 @@ The tab index to focus, starting with 1. ==== note * This command does not split arguments after the last argument and handles quotes literally. +[[clear-keychain]] +=== clear-keychain +Clear the currently entered key chain. + +[[clear-messages]] +=== clear-messages +Clear all message notifications. + +[[click-element]] +=== click-element +Syntax: +:click-element [*--target* 'target'] [*--force-event*] 'filter' 'value'+ + +Click the element matching the given filter. + +The given filter needs to result in exactly one element, otherwise, an error is shown. + +==== positional arguments +* +'filter'+: How to filter the elements. id: Get an element based on its ID. + +* +'value'+: The value to filter for. + +==== optional arguments +* +*-t*+, +*--target*+: How to open the clicked element (normal/tab/tab-bg/window). +* +*-f*+, +*--force-event*+: Force generating a fake click event. + [[close]] === close Close the current window. @@ -382,6 +426,15 @@ The editor which should be launched can be configured via the `editor.command` c * +*-r*+, +*--related*+: If opening a new tab, position the tab as related to the current one (like clicking on a link). +[[enter-mode]] +=== enter-mode +Syntax: +:enter-mode 'mode'+ + +Enter a key mode. + +==== positional arguments +* +'mode'+: The mode to enter. + [[fake-key]] === fake-key Syntax: +:fake-key [*--global*] 'keystring'+ @@ -396,6 +449,15 @@ Send a fake keypress or key string to the website or qutebrowser. ==== optional arguments * +*-g*+, +*--global*+: If given, the keys are sent to the qutebrowser UI. +[[follow-selected]] +=== follow-selected +Syntax: +:follow-selected [*--tab*]+ + +Follow the selected text. + +==== optional arguments +* +*-t*+, +*--tab*+: Load the selected link in a new tab. + [[forward]] === forward Syntax: +:forward [*--tab*] [*--bg*] [*--window*]+ @@ -576,6 +638,15 @@ Evaluate a JavaScript string. * This command does not split arguments after the last argument and handles quotes literally. * With this command, +;;+ is interpreted literally instead of splitting off a second command. +[[jump-mark]] +=== jump-mark +Syntax: +:jump-mark 'key'+ + +Jump to the mark named by `key`. + +==== positional arguments +* +'key'+: mark identifier; capital indicates a global mark + [[later]] === later Syntax: +:later 'ms' 'command'+ @@ -591,6 +662,36 @@ Execute a command after some time. * With this command, +;;+ is interpreted literally instead of splitting off a second command. * This command does not replace variables like +\{url\}+. +[[message-error]] +=== message-error +Syntax: +:message-error 'text'+ + +Show an error message in the statusbar. + +==== positional arguments +* +'text'+: The text to show. + +[[message-info]] +=== message-info +Syntax: +:message-info 'text'+ + +Show an info message in the statusbar. + +==== positional arguments +* +'text'+: The text to show. + +==== count +How many times to show the message + +[[message-warning]] +=== message-warning +Syntax: +:message-warning 'text'+ + +Show a warning message in the statusbar. + +==== positional arguments +* +'text'+: The text to show. + [[messages]] === messages Syntax: +:messages [*--plain*] [*--tab*] [*--bg*] [*--window*] ['level']+ @@ -636,6 +737,10 @@ This tries to automatically click on typical _Previous Page_ or _Next Page_ link For `increment` and `decrement`, the number to change the URL by. For `up`, the number of levels to go up in the URL. +[[nop]] +=== nop +Do nothing. + [[open]] === open Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*] @@ -778,6 +883,13 @@ Repeat a given command. * With this command, +;;+ is interpreted literally instead of splitting off a second command. * This command does not replace variables like +\{url\}+. +[[repeat-command]] +=== repeat-command +Repeat the last executed command. + +==== count +Which count to pass the command. + [[report]] === report Report a bug in qutebrowser. @@ -798,6 +910,26 @@ Run a recorded macro. ==== count How many times to run the macro. +[[run-with-count]] +=== run-with-count +Syntax: +:run-with-count 'count-arg' 'command'+ + +Run a command with the given count. + +If run_with_count itself is run with a count, it multiplies count_arg. + +==== positional arguments +* +'count-arg'+: The count to pass to the command. +* +'command'+: The command to run, with optional args. + +==== count +The count that run_with_count itself received. + +==== note +* This command does not split arguments after the last argument and handles quotes literally. +* With this command, +;;+ is interpreted literally instead of splitting off a second command. +* This command does not replace variables like +\{url\}+. + [[save]] === save Syntax: +:save ['what' ['what' ...]]+ @@ -808,6 +940,70 @@ Save configs and state. * +'what'+: What to save (`config`/`key-config`/`cookies`/...). If not given, everything is saved. +[[scroll]] +=== scroll +Syntax: +:scroll 'direction'+ + +Scroll the current tab in the given direction. + +Note you can use `:run-with-count` to have a keybinding with a bigger scroll increment. + +==== positional arguments +* +'direction'+: In which direction to scroll (up/down/left/right/top/bottom). + + +==== count +multiplier + +[[scroll-page]] +=== scroll-page +Syntax: +:scroll-page [*--top-navigate* 'ACTION'] [*--bottom-navigate* 'ACTION'] 'x' 'y'+ + +Scroll the frame page-wise. + +==== positional arguments +* +'x'+: How many pages to scroll to the right. +* +'y'+: How many pages to scroll down. + +==== optional arguments +* +*-t*+, +*--top-navigate*+: :navigate action (prev, decrement) to run when scrolling up at the top of the page. + +* +*-b*+, +*--bottom-navigate*+: :navigate action (next, increment) to run when scrolling down at the bottom of the page. + + +==== count +multiplier + +[[scroll-px]] +=== scroll-px +Syntax: +:scroll-px 'dx' 'dy'+ + +Scroll the current tab by 'count * dx/dy' pixels. + +==== positional arguments +* +'dx'+: How much to scroll in x-direction. +* +'dy'+: How much to scroll in y-direction. + +==== count +multiplier + +[[scroll-to-perc]] +=== scroll-to-perc +Syntax: +:scroll-to-perc [*--horizontal*] ['perc']+ + +Scroll to a specific percentage of the page. + +The percentage can be given either as argument or as count. If no percentage is given, the page is scrolled to the end. + +==== positional arguments +* +'perc'+: Percentage to scroll. + +==== optional arguments +* +*-x*+, +*--horizontal*+: Scroll horizontally instead of vertically. + +==== count +Percentage to scroll. + [[search]] === search Syntax: +:search [*--reverse*] ['text']+ @@ -823,6 +1019,20 @@ Search for a text on the current page. With no text, clear results. ==== note * This command does not split arguments after the last argument and handles quotes literally. +[[search-next]] +=== search-next +Continue the search to the ([count]th) next term. + +==== count +How many elements to ignore. + +[[search-prev]] +=== search-prev +Continue the search to the ([count]th) previous term. + +==== count +How many elements to ignore. + [[session-delete]] === session-delete Syntax: +:session-delete [*--force*] 'name'+ @@ -907,6 +1117,15 @@ The count if given. ==== note * This command does not split arguments after the last argument and handles quotes literally. +[[set-mark]] +=== set-mark +Syntax: +:set-mark 'key'+ + +Set a mark at the current scroll position in the current tab. + +==== positional arguments +* +'key'+: mark identifier; capital indicates a global mark + [[spawn]] === spawn Syntax: +:spawn [*--userscript*] [*--verbose*] [*--detach*] 'cmdline'+ @@ -1132,14 +1351,11 @@ Decrease the zoom level for the current tab. How many steps to zoom out. -== Hidden commands +== Commands not usable in normal mode .Quick reference [options="header",width="75%",cols="25%,75%"] |============== |Command|Description -|<>|Clear the currently entered key chain. -|<>|Clear all message notifications. -|<>|Click the element matching the given filter. |<>|Execute the command currently in the commandline. |<>|Go forward in the commandline history. |<>|Go back in the commandline history. @@ -1147,14 +1363,8 @@ How many steps to zoom out. |<>|Shift the focus of the completion menu to another item. |<>|Yank the current completion item into the clipboard. |<>|Drop selection and keep selection mode enabled. -|<>|Enter a key mode. |<>|Follow a hint. -|<>|Follow the selected text. -|<>|Jump to the mark named by `key`. |<>|Leave the mode we're currently in. -|<>|Show an error message in the statusbar. -|<>|Show an info message in the statusbar. -|<>|Show a warning message in the statusbar. |<>|Move the cursor or selection to the end of the document. |<>|Move the cursor or selection to the end of line. |<>|Move the cursor or selection to the end of next block. @@ -1170,11 +1380,9 @@ How many steps to zoom out. |<>|Move the cursor or selection to the start of the line. |<>|Move the cursor or selection to the start of next block. |<>|Move the cursor or selection to the start of previous block. -|<>|Do nothing. |<>|Accept the current prompt. |<>|Shift the focus of the prompt file completion menu to another item. |<>|Immediately open a download. -|<>|Repeat the last executed command. |<>|Move back a character. |<>|Delete the character before the cursor. |<>|Remove chars from the cursor to the beginning of the word. @@ -1190,41 +1398,8 @@ How many steps to zoom out. |<>|Remove chars backward from the cursor to the beginning of the line. |<>|Remove chars from the cursor to the beginning of the word. |<>|Paste the most recently deleted text. -|<>|Run a command with the given count. -|<>|Scroll the current tab in the given direction. -|<>|Scroll the frame page-wise. -|<>|Scroll the current tab by 'count * dx/dy' pixels. -|<>|Scroll to a specific percentage of the page. -|<>|Continue the search to the ([count]th) next term. -|<>|Continue the search to the ([count]th) previous term. -|<>|Set a mark at the current scroll position in the current tab. |<>|Toggle caret selection mode. |============== -[[clear-keychain]] -=== clear-keychain -Clear the currently entered key chain. - -[[clear-messages]] -=== clear-messages -Clear all message notifications. - -[[click-element]] -=== click-element -Syntax: +:click-element [*--target* 'target'] [*--force-event*] 'filter' 'value'+ - -Click the element matching the given filter. - -The given filter needs to result in exactly one element, otherwise, an error is shown. - -==== positional arguments -* +'filter'+: How to filter the elements. id: Get an element based on its ID. - -* +'value'+: The value to filter for. - -==== optional arguments -* +*-t*+, +*--target*+: How to open the clicked element (normal/tab/tab-bg/window). -* +*-f*+, +*--force-event*+: Force generating a fake click event. - [[command-accept]] === command-accept Execute the command currently in the commandline. @@ -1263,15 +1438,6 @@ Yank the current completion item into the clipboard. === drop-selection Drop selection and keep selection mode enabled. -[[enter-mode]] -=== enter-mode -Syntax: +:enter-mode 'mode'+ - -Enter a key mode. - -==== positional arguments -* +'mode'+: The mode to enter. - [[follow-hint]] === follow-hint Syntax: +:follow-hint ['keystring']+ @@ -1281,58 +1447,10 @@ Follow a hint. ==== positional arguments * +'keystring'+: The hint to follow. -[[follow-selected]] -=== follow-selected -Syntax: +:follow-selected [*--tab*]+ - -Follow the selected text. - -==== optional arguments -* +*-t*+, +*--tab*+: Load the selected link in a new tab. - -[[jump-mark]] -=== jump-mark -Syntax: +:jump-mark 'key'+ - -Jump to the mark named by `key`. - -==== positional arguments -* +'key'+: mark identifier; capital indicates a global mark - [[leave-mode]] === leave-mode Leave the mode we're currently in. -[[message-error]] -=== message-error -Syntax: +:message-error 'text'+ - -Show an error message in the statusbar. - -==== positional arguments -* +'text'+: The text to show. - -[[message-info]] -=== message-info -Syntax: +:message-info 'text'+ - -Show an info message in the statusbar. - -==== positional arguments -* +'text'+: The text to show. - -==== count -How many times to show the message - -[[message-warning]] -=== message-warning -Syntax: +:message-warning 'text'+ - -Show a warning message in the statusbar. - -==== positional arguments -* +'text'+: The text to show. - [[move-to-end-of-document]] === move-to-end-of-document Move the cursor or selection to the end of the document. @@ -1426,10 +1544,6 @@ Move the cursor or selection to the start of previous block. ==== count How many blocks to move. -[[nop]] -=== nop -Do nothing. - [[prompt-accept]] === prompt-accept Syntax: +:prompt-accept ['value']+ @@ -1466,13 +1580,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. -[[repeat-command]] -=== repeat-command -Repeat the last executed command. - -==== count -Which count to pass the command. - [[rl-backward-char]] === rl-backward-char Move back a character. @@ -1563,113 +1670,6 @@ Paste the most recently deleted text. This acts like readline's yank. -[[run-with-count]] -=== run-with-count -Syntax: +:run-with-count 'count-arg' 'command'+ - -Run a command with the given count. - -If run_with_count itself is run with a count, it multiplies count_arg. - -==== positional arguments -* +'count-arg'+: The count to pass to the command. -* +'command'+: The command to run, with optional args. - -==== count -The count that run_with_count itself received. - -==== note -* This command does not split arguments after the last argument and handles quotes literally. -* With this command, +;;+ is interpreted literally instead of splitting off a second command. -* This command does not replace variables like +\{url\}+. - -[[scroll]] -=== scroll -Syntax: +:scroll 'direction'+ - -Scroll the current tab in the given direction. - -Note you can use `:run-with-count` to have a keybinding with a bigger scroll increment. - -==== positional arguments -* +'direction'+: In which direction to scroll (up/down/left/right/top/bottom). - - -==== count -multiplier - -[[scroll-page]] -=== scroll-page -Syntax: +:scroll-page [*--top-navigate* 'ACTION'] [*--bottom-navigate* 'ACTION'] 'x' 'y'+ - -Scroll the frame page-wise. - -==== positional arguments -* +'x'+: How many pages to scroll to the right. -* +'y'+: How many pages to scroll down. - -==== optional arguments -* +*-t*+, +*--top-navigate*+: :navigate action (prev, decrement) to run when scrolling up at the top of the page. - -* +*-b*+, +*--bottom-navigate*+: :navigate action (next, increment) to run when scrolling down at the bottom of the page. - - -==== count -multiplier - -[[scroll-px]] -=== scroll-px -Syntax: +:scroll-px 'dx' 'dy'+ - -Scroll the current tab by 'count * dx/dy' pixels. - -==== positional arguments -* +'dx'+: How much to scroll in x-direction. -* +'dy'+: How much to scroll in y-direction. - -==== count -multiplier - -[[scroll-to-perc]] -=== scroll-to-perc -Syntax: +:scroll-to-perc [*--horizontal*] ['perc']+ - -Scroll to a specific percentage of the page. - -The percentage can be given either as argument or as count. If no percentage is given, the page is scrolled to the end. - -==== positional arguments -* +'perc'+: Percentage to scroll. - -==== optional arguments -* +*-x*+, +*--horizontal*+: Scroll horizontally instead of vertically. - -==== count -Percentage to scroll. - -[[search-next]] -=== search-next -Continue the search to the ([count]th) next term. - -==== count -How many elements to ignore. - -[[search-prev]] -=== search-prev -Continue the search to the ([count]th) previous term. - -==== count -How many elements to ignore. - -[[set-mark]] -=== set-mark -Syntax: +:set-mark 'key'+ - -Set a mark at the current scroll position in the current tab. - -==== positional arguments -* +'key'+: mark identifier; capital indicates a global mark - [[toggle-selection]] === toggle-selection Toggle caret selection mode. diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 95865b3bf..e007de76d 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -565,8 +565,8 @@ class CommandDispatcher: tabbed_browser.tabopen(self._current_url()) self._tabbed_browser.close_tab(self._current_widget(), add_undo=False) - @cmdutils.register(instance='command-dispatcher', hide=True, - scope='window', deprecated='Use :tab-give instead!') + @cmdutils.register(instance='command-dispatcher', scope='window', + deprecated='Use :tab-give instead!') def tab_detach(self): """Deprecated way to detach a tab.""" self.tab_give() @@ -677,8 +677,7 @@ class CommandDispatcher: except navigate.Error as e: raise cmdexc.CommandError(e) - @cmdutils.register(instance='command-dispatcher', hide=True, - scope='window') + @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) def scroll_px(self, dx: int, dy: int, count=1): """Scroll the current tab by 'count * dx/dy' pixels. @@ -694,8 +693,7 @@ class CommandDispatcher: cmdutils.check_overflow(dy, 'int') self._current_widget().scroller.delta(dx, dy) - @cmdutils.register(instance='command-dispatcher', hide=True, - scope='window') + @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) def scroll(self, direction: typing.Union[str, int], count=1): """Scroll the current tab in the given direction. @@ -732,8 +730,7 @@ class CommandDispatcher: else: func(count=count) - @cmdutils.register(instance='command-dispatcher', hide=True, - scope='window') + @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) @cmdutils.argument('horizontal', flag='x') def scroll_to_perc(self, perc: float = None, horizontal=False, count=None): @@ -764,8 +761,7 @@ class CommandDispatcher: self._current_widget().scroller.to_perc(x, y) - @cmdutils.register(instance='command-dispatcher', hide=True, - scope='window') + @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) @cmdutils.argument('top_navigate', metavar='ACTION', choices=('prev', 'decrement')) @@ -1388,8 +1384,7 @@ class CommandDispatcher: except KeyError: raise cmdexc.CommandError("Bookmark '{}' not found!".format(url)) - @cmdutils.register(instance='command-dispatcher', hide=True, - scope='window') + @cmdutils.register(instance='command-dispatcher', scope='window') def follow_selected(self, *, tab=False): """Follow the selected text. @@ -1674,8 +1669,7 @@ class CommandDispatcher: tab.elements.find_focused(_insert_text_cb) - @cmdutils.register(instance='command-dispatcher', scope='window', - hide=True) + @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('filter_', choices=['id']) def click_element(self, filter_: str, value, *, target: usertypes.ClickTarget = @@ -1780,8 +1774,7 @@ class CommandDispatcher: tab.search.search(text, **options) - @cmdutils.register(instance='command-dispatcher', hide=True, - scope='window') + @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) def search_next(self, count=1): """Continue the search to the ([count]th) next term. @@ -1815,8 +1808,7 @@ class CommandDispatcher: tab.search.next_result() tab.search.next_result(result_cb=cb) - @cmdutils.register(instance='command-dispatcher', hide=True, - scope='window') + @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) def search_prev(self, count=1): """Continue the search to the ([count]th) previous term. @@ -1850,8 +1842,8 @@ class CommandDispatcher: tab.search.prev_result() tab.search.prev_result(result_cb=cb) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_next_line(self, count=1): """Move the cursor or selection to the next line. @@ -1861,8 +1853,8 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_next_line(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_prev_line(self, count=1): """Move the cursor or selection to the prev line. @@ -1872,8 +1864,8 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_prev_line(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_next_char(self, count=1): """Move the cursor or selection to the next char. @@ -1883,8 +1875,8 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_next_char(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_prev_char(self, count=1): """Move the cursor or selection to the previous char. @@ -1894,8 +1886,8 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_prev_char(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_end_of_word(self, count=1): """Move the cursor or selection to the end of the word. @@ -1905,8 +1897,8 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_end_of_word(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_next_word(self, count=1): """Move the cursor or selection to the next word. @@ -1916,8 +1908,8 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_next_word(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_prev_word(self, count=1): """Move the cursor or selection to the previous word. @@ -1927,20 +1919,20 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_prev_word(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') def move_to_start_of_line(self): """Move the cursor or selection to the start of the line.""" self._current_widget().caret.move_to_start_of_line() - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') def move_to_end_of_line(self): """Move the cursor or selection to the end of line.""" self._current_widget().caret.move_to_end_of_line() - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_start_of_next_block(self, count=1): """Move the cursor or selection to the start of next block. @@ -1950,8 +1942,8 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_start_of_next_block(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_start_of_prev_block(self, count=1): """Move the cursor or selection to the start of previous block. @@ -1961,8 +1953,8 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_start_of_prev_block(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_end_of_next_block(self, count=1): """Move the cursor or selection to the end of next block. @@ -1972,8 +1964,8 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_end_of_next_block(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') @cmdutils.argument('count', count=True) def move_to_end_of_prev_block(self, count=1): """Move the cursor or selection to the end of previous block. @@ -1983,26 +1975,26 @@ class CommandDispatcher: """ self._current_widget().caret.move_to_end_of_prev_block(count) - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') def move_to_start_of_document(self): """Move the cursor or selection to the start of the document.""" self._current_widget().caret.move_to_start_of_document() - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') def move_to_end_of_document(self): """Move the cursor or selection to the end of the document.""" self._current_widget().caret.move_to_end_of_document() - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') def toggle_selection(self): """Toggle caret selection mode.""" self._current_widget().caret.toggle_selection() - @cmdutils.register(instance='command-dispatcher', hide=True, - modes=[KeyMode.caret], scope='window') + @cmdutils.register(instance='command-dispatcher', modes=[KeyMode.caret], + scope='window') def drop_selection(self): """Drop selection and keep selection mode enabled.""" self._current_widget().caret.drop_selection() @@ -2145,8 +2137,7 @@ class CommandDispatcher: ed.edit(url or old_url) - @cmdutils.register(instance='command-dispatcher', scope='window', - hide=True) + @cmdutils.register(instance='command-dispatcher', scope='window') def set_mark(self, key): """Set a mark at the current scroll position in the current tab. @@ -2155,8 +2146,7 @@ class CommandDispatcher: """ self._tabbed_browser.set_mark(key) - @cmdutils.register(instance='command-dispatcher', scope='window', - hide=True) + @cmdutils.register(instance='command-dispatcher', scope='window') def jump_mark(self, key): """Jump to the mark named by `key`. diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index d5e00e828..8d8a5ae68 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -902,7 +902,7 @@ class HintManager(QObject): except HintingError as e: message.error(str(e)) - @cmdutils.register(instance='hintmanager', scope='tab', hide=True, + @cmdutils.register(instance='hintmanager', scope='tab', modes=[usertypes.KeyMode.hint]) def follow_hint(self, keystring=None): """Follow a hint. diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index 43a8824d1..bbc79a0d8 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -58,7 +58,6 @@ class Command: name: The main name of the command. maxsplit: The maximum amount of splits to do for the commandline, or None. - hide: Whether to hide the arguments or not. deprecated: False, or a string to describe why a command is deprecated. desc: The description of the command. handler: The handler function to call. @@ -69,39 +68,37 @@ class Command: backend: Which backend the command works with (or None if it works with both) no_replace_variables: Don't replace variables like {url} + modes: The modes the command can be executed in. _qute_args: The saved data from @cmdutils.argument - _modes: The modes the command can be executed in. _count: The count set for the command. _instance: The object to bind 'self' to. _scope: The scope to get _instance for in the object registry. """ def __init__(self, *, handler, name, instance=None, maxsplit=None, - hide=False, modes=None, not_modes=None, debug=False, - deprecated=False, no_cmd_split=False, - star_args_optional=False, scope='global', backend=None, - no_replace_variables=False): + modes=None, not_modes=None, debug=False, deprecated=False, + no_cmd_split=False, star_args_optional=False, scope='global', + backend=None, no_replace_variables=False): if modes is not None and not_modes is not None: raise ValueError("Only modes or not_modes can be given!") if modes is not None: for m in modes: if not isinstance(m, usertypes.KeyMode): raise TypeError("Mode {} is no KeyMode member!".format(m)) - self._modes = set(modes) + self.modes = set(modes) elif not_modes is not None: for m in not_modes: if not isinstance(m, usertypes.KeyMode): raise TypeError("Mode {} is no KeyMode member!".format(m)) - self._modes = set(usertypes.KeyMode).difference(not_modes) + self.modes = set(usertypes.KeyMode).difference(not_modes) else: - self._modes = set(usertypes.KeyMode) + self.modes = set(usertypes.KeyMode) if scope != 'global' and instance is None: raise ValueError("Setting scope without setting instance makes " "no sense!") self.name = name self.maxsplit = maxsplit - self.hide = hide self.deprecated = deprecated self._instance = instance self._scope = scope @@ -508,8 +505,8 @@ class Command: Args: mode: The usertypes.KeyMode to check. """ - if mode not in self._modes: - mode_names = '/'.join(sorted(m.name for m in self._modes)) + if mode not in self.modes: + mode_names = '/'.join(sorted(m.name for m in self.modes)) raise cmdexc.PrerequisitesError( "{}: This command is only allowed in {} mode, not {}.".format( self.name, mode_names, mode.name)) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index a5f8e51b5..3917a8c2a 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -222,7 +222,7 @@ class CompletionView(QTreeView): self.scrollTo(idx) return idx.child(0, 0) - @cmdutils.register(instance='completion', hide=True, + @cmdutils.register(instance='completion', modes=[usertypes.KeyMode.command], scope='window') @cmdutils.argument('which', choices=['next', 'prev', 'next-category', 'prev-category']) @@ -369,7 +369,7 @@ class CompletionView(QTreeView): scrollbar.setValue(scrollbar.minimum()) super().showEvent(e) - @cmdutils.register(instance='completion', hide=True, + @cmdutils.register(instance='completion', modes=[usertypes.KeyMode.command], scope='window') def completion_item_del(self): """Delete the current completion item.""" @@ -378,7 +378,7 @@ class CompletionView(QTreeView): raise cmdexc.CommandError("No item selected!") self.model().delete_cur_item(index) - @cmdutils.register(instance='completion', hide=True, + @cmdutils.register(instance='completion', modes=[usertypes.KeyMode.command], scope='window') def completion_item_yank(self, sel=False): """Yank the current completion item into the clipboard. diff --git a/qutebrowser/completion/models/util.py b/qutebrowser/completion/models/util.py index 717355bdf..40d5de8dc 100644 --- a/qutebrowser/completion/models/util.py +++ b/qutebrowser/completion/models/util.py @@ -19,7 +19,7 @@ """Utility functions for completion models.""" -from qutebrowser.utils import objreg +from qutebrowser.utils import objreg, usertypes from qutebrowser.commands import cmdutils @@ -28,7 +28,7 @@ def get_cmd_completions(info, include_hidden, include_aliases, prefix=''): Args: info: The CompletionInfo. - include_hidden: True to include commands annotated with hide=True. + include_hidden: Include commands which are not in normal mode. include_aliases: True to include command aliases. prefix: String to append to the command name. @@ -39,8 +39,9 @@ def get_cmd_completions(info, include_hidden, include_aliases, prefix=''): cmd_to_keys = info.keyconf.get_reverse_bindings_for('normal') for obj in set(cmdutils.cmd_dict.values()): hide_debug = obj.debug and not objreg.get('args').debug - hide_hidden = obj.hide and not include_hidden - if not (hide_debug or hide_hidden or obj.deprecated): + hide_mode = (usertypes.KeyMode.normal not in obj.modes and + not include_hidden) + if not (hide_debug or hide_mode or obj.deprecated): bindings = ', '.join(cmd_to_keys.get(obj.name, [])) cmdlist.append((prefix + obj.name, obj.desc, bindings)) diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index 6a6dd5459..cd35913ad 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -251,7 +251,7 @@ class ModeManager(QObject): self.mode = mode self.entered.emit(mode, self._win_id) - @cmdutils.register(instance='mode-manager', hide=True, scope='window') + @cmdutils.register(instance='mode-manager', scope='window') def enter_mode(self, mode): """Enter a key mode. @@ -301,8 +301,7 @@ class ModeManager(QObject): self.left.emit(mode, self.mode, self._win_id) @cmdutils.register(instance='mode-manager', name='leave-mode', - not_modes=[usertypes.KeyMode.normal], hide=True, - scope='window') + not_modes=[usertypes.KeyMode.normal], scope='window') def leave_current_mode(self): """Leave the mode we're currently in.""" if self.mode == usertypes.KeyMode.normal: @@ -328,7 +327,7 @@ class ModeManager(QObject): else: return self._eventFilter_keyrelease(event) - @cmdutils.register(instance='mode-manager', scope='window', hide=True) + @cmdutils.register(instance='mode-manager', scope='window') def clear_keychain(self): """Clear the currently entered key chain.""" self._parsers[self.mode].clear_keystring() diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index d00e57174..bd72d47ea 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -364,7 +364,7 @@ class PromptContainer(QWidget): widget.hide() widget.deleteLater() - @cmdutils.register(instance='prompt-container', hide=True, scope='window', + @cmdutils.register(instance='prompt-container', scope='window', modes=[usertypes.KeyMode.prompt, usertypes.KeyMode.yesno]) def prompt_accept(self, value=None): @@ -388,7 +388,7 @@ class PromptContainer(QWidget): message.global_bridge.prompt_done.emit(self._prompt.KEY_MODE) question.done() - @cmdutils.register(instance='prompt-container', hide=True, scope='window', + @cmdutils.register(instance='prompt-container', scope='window', modes=[usertypes.KeyMode.prompt], maxsplit=0) def prompt_open_download(self, cmdline: str = None): """Immediately open a download. @@ -407,7 +407,7 @@ class PromptContainer(QWidget): except UnsupportedOperationError: pass - @cmdutils.register(instance='prompt-container', hide=True, scope='window', + @cmdutils.register(instance='prompt-container', scope='window', modes=[usertypes.KeyMode.prompt]) @cmdutils.argument('which', choices=['next', 'prev']) def prompt_item_focus(self, which): diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py index b3d7a50e6..9ca870605 100644 --- a/qutebrowser/mainwindow/statusbar/command.py +++ b/qutebrowser/mainwindow/statusbar/command.py @@ -124,7 +124,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): else: self.set_cmd_text(text) - @cmdutils.register(instance='status-command', hide=True, + @cmdutils.register(instance='status-command', modes=[usertypes.KeyMode.command], scope='window') def command_history_prev(self): """Go back in the commandline history.""" @@ -139,7 +139,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): if item: self.set_cmd_text(item) - @cmdutils.register(instance='status-command', hide=True, + @cmdutils.register(instance='status-command', modes=[usertypes.KeyMode.command], scope='window') def command_history_next(self): """Go forward in the commandline history.""" @@ -152,7 +152,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): if item: self.set_cmd_text(item) - @cmdutils.register(instance='status-command', hide=True, + @cmdutils.register(instance='status-command', modes=[usertypes.KeyMode.command], scope='window') def command_accept(self): """Execute the command currently in the commandline.""" diff --git a/qutebrowser/misc/readline.py b/qutebrowser/misc/readline.py index 2bc999c4d..51ce6bb94 100644 --- a/qutebrowser/misc/readline.py +++ b/qutebrowser/misc/readline.py @@ -48,7 +48,7 @@ class ReadlineBridge: else: return None - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_backward_char(self): """Move back a character. @@ -60,7 +60,7 @@ class ReadlineBridge: return widget.cursorBackward(False) - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_forward_char(self): """Move forward a character. @@ -72,7 +72,7 @@ class ReadlineBridge: return widget.cursorForward(False) - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_backward_word(self): """Move back to the start of the current or previous word. @@ -84,7 +84,7 @@ class ReadlineBridge: return widget.cursorWordBackward(False) - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_forward_word(self): """Move forward to the end of the next word. @@ -96,7 +96,7 @@ class ReadlineBridge: return widget.cursorWordForward(False) - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_beginning_of_line(self): """Move to the start of the line. @@ -108,7 +108,7 @@ class ReadlineBridge: return widget.home(False) - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_end_of_line(self): """Move to the end of the line. @@ -120,7 +120,7 @@ class ReadlineBridge: return widget.end(False) - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_unix_line_discard(self): """Remove chars backward from the cursor to the beginning of the line. @@ -134,7 +134,7 @@ class ReadlineBridge: self._deleted[widget] = widget.selectedText() widget.del_() - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_kill_line(self): """Remove chars from the cursor to the end of the line. @@ -173,7 +173,7 @@ class ReadlineBridge: self._deleted[widget] = widget.selectedText() widget.del_() - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_unix_word_rubout(self): """Remove chars from the cursor to the beginning of the word. @@ -183,7 +183,7 @@ class ReadlineBridge: """ self._rubout([' ']) - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_unix_filename_rubout(self): """Remove chars from the cursor to the previous path separator. @@ -192,7 +192,7 @@ class ReadlineBridge: """ self._rubout([' ', '/']) - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_backward_kill_word(self): """Remove chars from the cursor to the beginning of the word. @@ -207,7 +207,7 @@ class ReadlineBridge: self._deleted[widget] = widget.selectedText() widget.del_() - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_kill_word(self): """Remove chars from the cursor to the end of the current word. @@ -221,7 +221,7 @@ class ReadlineBridge: self._deleted[widget] = widget.selectedText() widget.del_() - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_yank(self): """Paste the most recently deleted text. @@ -233,7 +233,7 @@ class ReadlineBridge: return widget.insert(self._deleted[widget]) - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_delete_char(self): """Delete the character after the cursor. @@ -245,7 +245,7 @@ class ReadlineBridge: return widget.del_() - @cmdutils.register(instance='readline-bridge', hide=True, + @cmdutils.register(instance='readline-bridge', modes=[typ.KeyMode.command, typ.KeyMode.prompt]) def rl_backward_delete_char(self): """Delete the character before the cursor. diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index d52793669..386282a25 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -87,8 +87,7 @@ def repeat(times: int, command, win_id): commandrunner.run_safely(command) -@cmdutils.register(maxsplit=1, hide=True, no_cmd_split=True, - no_replace_variables=True) +@cmdutils.register(maxsplit=1, no_cmd_split=True, no_replace_variables=True) @cmdutils.argument('win_id', win_id=True) @cmdutils.argument('count', count=True) def run_with_count(count_arg: int, command, win_id, count=1): @@ -104,7 +103,7 @@ def run_with_count(count_arg: int, command, win_id, count=1): runners.CommandRunner(win_id).run(command, count_arg * count) -@cmdutils.register(hide=True) +@cmdutils.register() def message_error(text): """Show an error message in the statusbar. @@ -114,7 +113,7 @@ def message_error(text): message.error(text) -@cmdutils.register(hide=True) +@cmdutils.register() @cmdutils.argument('count', count=True) def message_info(text, count=1): """Show an info message in the statusbar. @@ -127,7 +126,7 @@ def message_info(text, count=1): message.info(text) -@cmdutils.register(hide=True) +@cmdutils.register() def message_warning(text): """Show a warning message in the statusbar. @@ -137,7 +136,7 @@ def message_warning(text): message.warning(text) -@cmdutils.register(hide=True) +@cmdutils.register() def clear_messages(): """Clear all message notifications.""" message.global_bridge.clear_messages.emit() @@ -265,7 +264,7 @@ def debug_set_fake_clipboard(s=None): utils.fake_clipboard = s -@cmdutils.register(hide=True) +@cmdutils.register() @cmdutils.argument('win_id', win_id=True) @cmdutils.argument('count', count=True) def repeat_command(win_id, count=None): @@ -347,7 +346,7 @@ def window_only(current_win_id): window.close() -@cmdutils.register(hide=True) +@cmdutils.register() def nop(): """Do nothing.""" return diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py index 6e5581ad8..a0ddfb795 100755 --- a/scripts/dev/src2asciidoc.py +++ b/scripts/dev/src2asciidoc.py @@ -347,19 +347,19 @@ def generate_commands(filename): f.write("= Commands\n\n") f.write(commands.__doc__) normal_cmds = [] - hidden_cmds = [] + other_cmds = [] debug_cmds = [] for name, cmd in cmdutils.cmd_dict.items(): if cmd.deprecated: continue - if cmd.hide: - hidden_cmds.append((name, cmd)) + if usertypes.KeyMode.normal not in cmd.modes: + other_cmds.append((name, cmd)) elif cmd.debug: debug_cmds.append((name, cmd)) else: normal_cmds.append((name, cmd)) normal_cmds.sort() - hidden_cmds.sort() + other_cmds.sort() debug_cmds.sort() f.write("\n") f.write("== Normal commands\n") @@ -368,10 +368,10 @@ def generate_commands(filename): for name, cmd in normal_cmds: f.write(_get_command_doc(name, cmd)) f.write("\n") - f.write("== Hidden commands\n") + f.write("== Commands not usable in normal mode\n") f.write(".Quick reference\n") - f.write(_get_command_quickref(hidden_cmds) + '\n') - for name, cmd in hidden_cmds: + f.write(_get_command_quickref(other_cmds) + '\n') + for name, cmd in other_cmds: f.write(_get_command_doc(name, cmd)) f.write("\n") f.write("== Debugging commands\n") diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index 1de7a2ade..878c9e166 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -338,6 +338,7 @@ class FakeCommand: completion = attr.ib(None) maxsplit = attr.ib(None) takes_count = attr.ib(lambda: False) + modes = attr.ib((usertypes.KeyMode.normal, )) class FakeTimer(QObject): diff --git a/tests/unit/commands/test_cmdutils.py b/tests/unit/commands/test_cmdutils.py index cc4313211..e123ce2d2 100644 --- a/tests/unit/commands/test_cmdutils.py +++ b/tests/unit/commands/test_cmdutils.py @@ -142,14 +142,6 @@ class TestRegister: pass assert cmdutils.cmd_dict['fun']._instance == 'foobar' - def test_kwargs(self): - """Make sure the other keyword arguments get passed to Command.""" - @cmdutils.register(hide=True) - def fun(): - """Blah.""" - pass - assert cmdutils.cmd_dict['fun'].hide - def test_star_args(self): """Check handling of *args.""" @cmdutils.register() diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index 6c4d0d0bb..fc251ba4e 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -68,9 +68,10 @@ def cmdutils_stub(monkeypatch, stubs): 'quit': stubs.FakeCommand(name='quit', desc='quit qutebrowser'), 'open': stubs.FakeCommand(name='open', desc='open a url'), 'prompt-yes': stubs.FakeCommand(name='prompt-yes', deprecated=True), - 'scroll': stubs.FakeCommand(name='scroll', + 'scroll': stubs.FakeCommand( + name='scroll', desc='Scroll the current tab in the given direction.', - hide=True), + modes=()), })