summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-21 14:11:25 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-21 14:11:25 +0100
commit2d6ac9e84d691192d17a6423ee4884123141a379 (patch)
treef854f97e9492e4987327d9da2e3d41259d9dfc0b /alot
parent4f338f321c7530ae00e7c29bf3131768230ec914 (diff)
added global tabwidth config
no. of spaces to replace tabs in body _and_ headers. issues #99, #106
Diffstat (limited to 'alot')
-rw-r--r--alot/defaults/alot.rc3
-rw-r--r--alot/message.py11
-rw-r--r--alot/widgets.py4
3 files changed, 12 insertions, 6 deletions
diff --git a/alot/defaults/alot.rc b/alot/defaults/alot.rc
index 9ed75928..9c5a81f2 100644
--- a/alot/defaults/alot.rc
+++ b/alot/defaults/alot.rc
@@ -12,6 +12,9 @@ bufferclose_focus_offset=-1
# number of colours your terminal supports
colourmode = 256
+# number of spaces used to replace tab characters
+tabwidth = 8
+
# fill threadline with message content
display_content_in_threadline = False
diff --git a/alot/message.py b/alot/message.py
index 0459649c..c2927a85 100644
--- a/alot/message.py
+++ b/alot/message.py
@@ -182,6 +182,7 @@ class Message(object):
def extract_body(mail):
body_parts = []
+ tab_width = config.getint('general', 'tabwidth')
for part in mail.walk():
ctype = part.get_content_type()
enc = part.get_content_charset()
@@ -213,10 +214,11 @@ def extract_body(mail):
#remove tempfile
os.unlink(tmpfile.name)
if rendered_payload: # handler had output
- body_parts.append(rendered_payload.strip())
+ payload = rendered_payload.strip()
elif part.get_content_maintype() == 'text':
- body_parts.append(raw_payload)
+ payload = raw_payload
# else drop
+ body_parts.append(payload.replace('\t', ' ' * tab_width))
return '\n\n'.join(body_parts)
@@ -244,10 +246,11 @@ def decode_header(header):
valuelist = email.header.decode_header(header)
decoded_list = []
+ tab_width = config.getint('general', 'tabwidth')
for v, enc in valuelist:
if enc:
- v = v.decode(enc, errors='replace')
- #v = re.sub('^\s+', ' ', v, flags=re.MULTILINE)
+ v = v.decode(enc, errors='replace').strip()
+ v = v.replace('\t', ' ' * tab_width)
decoded_list.append(v)
return u' '.join(decoded_list)
diff --git a/alot/widgets.py b/alot/widgets.py
index 3f3fde42..393c9198 100644
--- a/alot/widgets.py
+++ b/alot/widgets.py
@@ -549,8 +549,8 @@ class MessageHeaderWidget(urwid.AttrMap):
class MessageBodyWidget(urwid.AttrMap):
"""displays printable parts of an email"""
- def __init__(self, msg, tab_width=8):
- bodytxt = message.extract_body(msg).replace('\t', ' ' * tab_width)
+ def __init__(self, msg):
+ bodytxt = message.extract_body(msg)
urwid.AttrMap.__init__(self, urwid.Text(bodytxt), 'message_body')