From 38803375f5feba112d5c5a102d69fedd4f895cfc Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Fri, 18 Dec 2015 22:28:37 +0100 Subject: [PATCH] add dictionary config value and fix wrong variable --- qutebrowser/browser/hints.py | 5 +++-- qutebrowser/config/configdata.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 94a29257f..87a1e2f9a 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -25,6 +25,7 @@ import functools import math import os import re +import string from PyQt5.QtCore import (pyqtSignal, pyqtSlot, QObject, QEvent, Qt, QUrl, QTimer) @@ -159,7 +160,7 @@ class HintManager(QObject): def _initialize_word_hints(self): if not self._words: - with open("/usr/share/dict/words") as wordfile: + with open(config.get("hints", "dictionary")) as wordfile: alphabet = set(string.ascii_lowercase) hints = set() lines = (line.rstrip().lower() for line in wordfile) @@ -280,7 +281,7 @@ class HintManager(QObject): new = filter(bool, new) new = filter(lambda h: len(h) > 4, new) new = filter(lambda h: not any_prefix(h, existing), new) - return next(hint, None) # either the first good, or None + return next(new, None) # either the first good, or None hints = [] used_hints = set() diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index a9fbb2669..2ee19f652 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -863,7 +863,8 @@ def data(readonly=False): valid_values=typ.ValidValues( ('number', "Use numeric hints."), ('letter', "Use the chars in the hints -> " - "chars setting.") + "chars setting."), + ('word', "Use hints words based on the html elements and the extra words."), )), 'letter'), "Mode to use for hints."), @@ -888,6 +889,10 @@ def data(readonly=False): SettingValue(typ.Bool(), 'false'), "Make chars in hint strings uppercase."), + ('dictionary', + SettingValue(typ.File(), '/usr/share/dict/words'), + "The dictionary file to be used by the word hints."), + ('auto-follow', SettingValue(typ.Bool(), 'true'), "Whether to auto-follow a hint if there's only one left."),