From 88ea6e62b1054099b2ae4cb903cd0386c33df86f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 18 Feb 2014 10:28:34 +0100 Subject: [PATCH] Unify auto_search/addressbar_dns_lookup --- TODO | 1 - qutebrowser/qutebrowser.conf | 12 ++++++------ qutebrowser/utils/url.py | 21 ++++++++++++++++++--- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index aeeeae355..8a46c419e 100644 --- a/TODO +++ b/TODO @@ -46,7 +46,6 @@ Minor features Hiding scrollbars :bind Ctrl+A/X to increase/decrease last number in URL -unify dns/autosearch position remembering multiple commands with ; diff --git a/qutebrowser/qutebrowser.conf b/qutebrowser/qutebrowser.conf index 77782b908..97b5d190c 100644 --- a/qutebrowser/qutebrowser.conf +++ b/qutebrowser/qutebrowser.conf @@ -20,16 +20,16 @@ # wrapsearch: bool, whether to wrap search to the top when arriving at the end. # startpage: The default pages to open at the start, multiple pages can be # separated with commas. -# addressbar_dns_lookup: bool, whether to do a lookup in the DNS to figure out -# if something is a search term or not. Might be slow. -# auto_search: bool, whether to start a search automatically when something -# which is not an url is entered. +# auto_search: Whether to start a search automatically when something +# which is not an url is entered. +# true/naive: Use simple/naive check +# dns: Use DNS matching (might be slow) +# false: Never search automatically show_completion = true ignorecase = true wrapsearch = true startpage = http://www.duckduckgo.com/ -addressbar_dns_lookup = false -auto_search = true +auto_search = fuzzy [tabbar] # movable: bool, whether tabs should be movable diff --git a/qutebrowser/utils/url.py b/qutebrowser/utils/url.py index b48a97ece..618601d32 100644 --- a/qutebrowser/utils/url.py +++ b/qutebrowser/utils/url.py @@ -49,7 +49,7 @@ def fuzzy_url(url): """ u = qurl(url) urlstr = urlstring(url) - if (not config.config.getboolean('general', 'auto_search')) or is_url(u): + if is_url(u): # probably an address logging.debug("url is a fuzzy address") newurl = QUrl.fromUserInput(urlstr) @@ -94,14 +94,29 @@ def is_url(url): """Return True if url (QUrl) seems to be a valid URL.""" urlstr = urlstring(url) logging.debug('Checking if "{}" is an URL'.format(urlstr)) + + try: + autosearch = config.config.getboolean('general', 'auto_search') + except ValueError: + autosearch = config.config.get('general', 'auto_search') + else: + if autosearch: + autosearch = 'naive' + else: + autosearch = None + + if autosearch is None: + # no autosearch, so everything is an URL. + return True + if ' ' in urlstr: # An URL will never contain a space logging.debug('Contains space -> no url') return False - elif config.config.getboolean('general', 'addressbar_dns_lookup'): + elif autosearch == 'dns': logging.debug('Checking via DNS') return _is_url_dns(QUrl.fromUserInput(urlstr)) - else: + elif autosearch == 'naive': logging.debug('Checking via naive check') return _is_url_naive(url)