diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index efe83cd4c..d0e412ced 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -147,6 +147,8 @@ Changed `prev`/`next`/`last-used` to remove ambiguity. - The `ui -> user-stylesheet` setting now only takes filenames, not CSS snippets - `ui -> window-title-format` now has a new `{backend} ` replacement +- `:hint` has a new `--add-history` argument to add the URL to the history for + yank/spawn targets. Deprecated ~~~~~~~~~~ diff --git a/README.asciidoc b/README.asciidoc index 28614d3ae..fea1101b6 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -188,6 +188,7 @@ Contributors, sorted by the number of commits in descending order: * Jonas Schürmann * error800 * Michael Hoang +* Maciej Wołczyk * Liam BEGUIN * Julie Engel * skinnay diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 478e82258..4151eb892 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -341,7 +341,8 @@ Show help about a command or setting. [[hint]] === hint -Syntax: +:hint [*--rapid*] [*--mode* 'mode'] ['group'] ['target'] ['args' ['args' ...]]+ +Syntax: +:hint [*--rapid*] [*--mode* 'mode'] [*--add-history*] + ['group'] ['target'] ['args' ['args' ...]]+ Start hinting. @@ -406,6 +407,8 @@ Start hinting. +* +*-a*+, +*--add-history*+: Whether to add the spawned or yanked link to the browsing history. + ==== note * This command does not split arguments after the last argument and handles quotes literally. diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index c01207e56..b895c7db1 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -152,6 +152,7 @@ class HintContext: to_follow: The link to follow when enter is pressed. args: Custom arguments for userscript/spawn rapid: Whether to do rapid hinting. + add_history: Whether to add yanked or spawned link to the history. filterstr: Used to save the filter string for restoring in rapid mode. tab: The WebTab object we started hinting in. group: The group of web elements to hint. @@ -164,6 +165,7 @@ class HintContext: self.baseurl = None self.to_follow = None self.rapid = False + self.add_history = False self.filterstr = None self.args = [] self.tab = None @@ -601,13 +603,15 @@ class HintManager(QObject): star_args_optional=True, maxsplit=2) @cmdutils.argument('win_id', win_id=True) def start(self, rapid=False, group=webelem.Group.all, target=Target.normal, - *args, win_id, mode=None): + *args, win_id, mode=None, add_history=False): """Start hinting. Args: rapid: Whether to do rapid hinting. This is only possible with targets `tab` (with background-tabs=true), `tab-bg`, `window`, `run`, `hover`, `userscript` and `spawn`. + add_history: Whether to add the spawned or yanked link to the + browsing history. group: The element types to hint. - `all`: All clickable elements. @@ -690,6 +694,7 @@ class HintManager(QObject): self._context.target = target self._context.rapid = rapid self._context.hint_mode = mode + self._context.add_history = add_history try: self._context.baseurl = tabbed_browser.current_url() except qtutils.QtValueError: @@ -859,6 +864,8 @@ class HintManager(QObject): return handler = functools.partial(url_handlers[self._context.target], url, self._context) + if self._context.add_history: + objreg.get('web-history').add_url(url, "") else: raise ValueError("No suitable handler found!") diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py index 6a29c3410..2628ba282 100755 --- a/scripts/dev/src2asciidoc.py +++ b/scripts/dev/src2asciidoc.py @@ -432,6 +432,7 @@ def _get_authors(): 'Alexey Glushko': 'haitaka', 'Corentin Jule': 'Corentin Julé', 'Claire C.C': 'Claire Cavanaugh', + 'Rahid': 'Maciej Wołczyk', } commits = subprocess.check_output(['git', 'log', '--format=%aN']) authors = [corrections.get(author, author) diff --git a/tests/end2end/features/history.feature b/tests/end2end/features/history.feature index 05a896be2..f4f57dcb7 100644 --- a/tests/end2end/features/history.feature +++ b/tests/end2end/features/history.feature @@ -58,6 +58,13 @@ Feature: Page history And I run :history-clear Then the history file should be empty + Scenario: History with yanked URL and 'add to history' flag + When I open data/hints/html/simple.html + And I hint with args "--add-history links yank" and follow a + Then the history file should contain: + http://localhost:(port)/data/hints/html/simple.html Simple link + http://localhost:(port)/data/hello.txt + ## Bugs @qtwebengine_skip