From c22909691669d8dd5da571b880407f5a53ade9f1 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 10 Mar 2014 01:10:24 +0100 Subject: [PATCH] Fix writing values with spaces --- TODO | 1 - qutebrowser/config/config.py | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index a473c0f40..5f13eca5e 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ New config TODO =============== -- Writing _monospace doesn't work correctly (indented too much?) - How to handle interpolation correctly? Maybe we really should handle interpolation ourselves? Main problem: When re-writing the value, we don't know about the interpolation anymore, so we write the wrong value. - Tabbing through setting completion does not work diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 2d4f4a37e..cd73853c6 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -17,6 +17,7 @@ """Configuration storage and config-related utilities.""" +import re import os import os.path import logging @@ -148,6 +149,11 @@ class Config: subsequent_indent=' ' * 4, drop_whitespace=False, **self._wrapper_args) + # Other than the default TextWrapper would, we want to count a word and + # the whitespace following it as one chunk, so lines will always be + # split *after* whitespace, because whitespace at the beginning of a + # line could confuse configparser. Monkeypatching ftw! + keyval_wrapper.wordsep_simple_re = re.compile(r'(\S+\s*)') lines = [] for optname, option in section.items(): keyval = '{} = {}'.format(optname, option)