From e8a7d157f12028c9fab905aa4194ac792b01a5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kn=C3=AD=C5=BEek?= Date: Mon, 1 Jan 2024 10:35:47 +0100 Subject: [PATCH 1/2] Add alias completion Partially fixes #32. --- qutebrowser/completion/completer.py | 7 ++++++- tests/unit/completion/test_completer.py | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py index 408660c3a..06be1de17 100644 --- a/qutebrowser/completion/completer.py +++ b/qutebrowser/completion/completer.py @@ -90,7 +90,12 @@ class Completer(QObject): log.completion.debug('Starting command completion') return miscmodels.command try: - cmd = objects.commands[before_cursor[0]] + cmdname = before_cursor[0] + if before_cursor[0] in config.cache['aliases']: + cmdname = config.cache['aliases'][before_cursor[0]].split( + maxsplit=1)[0] + + cmd = objects.commands[cmdname] except KeyError: log.completion.debug("No completion for unknown command: {}" .format(before_cursor[0])) diff --git a/tests/unit/completion/test_completer.py b/tests/unit/completion/test_completer.py index 5a012c634..4f43ab03d 100644 --- a/tests/unit/completion/test_completer.py +++ b/tests/unit/completion/test_completer.py @@ -189,12 +189,18 @@ def _set_cmd_prompt(cmd, txt): (':config-cycle option |', 'value', '', ['option']), (':config-cycle option one |', 'value', '', ['option', 'one']), (':config-cycle option one two |', 'value', '', ['option', 'one', 'two']), + (':openalias |', 'url', '', []), + (':bindalias |', None, '', []), + (':bindalias |', 'command', '', ['']), + (':bindalias foo|', 'command', 'foo', ['']), + (':bindalias | foo', None, '', []), ]) def test_update_completion(txt, kind, pattern, pos_args, status_command_stub, completer_obj, completion_widget_stub, config_stub, key_config_stub): """Test setting the completion widget's model based on command text.""" # this test uses | as a placeholder for the current cursor position + config_stub.val.aliases = {"bindalias": "bind", "openalias": "open -t"} _set_cmd_prompt(status_command_stub, txt) completer_obj.schedule_completion_update() if kind is None: From 906f7c4f249a8d99105f2815d80a77ac35c30253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kn=C3=AD=C5=BEek?= Date: Wed, 25 Dec 2024 17:43:53 +0100 Subject: [PATCH 2/2] refs #6663: add documentation for rule-based ad blocking --- doc/install.asciidoc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/install.asciidoc b/doc/install.asciidoc index 1e9b8ed64..337b3527c 100644 --- a/doc/install.asciidoc +++ b/doc/install.asciidoc @@ -501,3 +501,29 @@ with the newest dependencies. Alternatively, you can update your local copy of the code (e.g. by pulling the git repo, or extracting a new version) and the virtualenv should automatically use the updated versions. However, dependencies won't be updated that way. + +Ad blocking +------------ +Blocking ads in qutebrowser can be done in two ways; host-based or rules-based blocking. +Host-based blocking works by preventing a list of urls from loading +and can be turned on with a single option +(see documentation of settings for `content.blocking`). + +More advanced rule based blocking uses Brave's adblocking library via + a python library `adblock`, which is an optional dependency of +qutebrowser. + +Some linux distributions ship this library in official repositories, +but in general you can only get it by installing +a library `adblock` via pip, e.g. run: + +`pip3 install adblock` + +By default, this library is used if found and +the host-based blocking servers as a fallback. + +If not, make sure blocking is on by having +`content.blocking.enabled` set to `true` and +settings `content.blocking.method` set to `auto`, +see documentation for other options. +