summaryrefslogtreecommitdiff
path: root/alot/ui.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/ui.py')
-rw-r--r--alot/ui.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/alot/ui.py b/alot/ui.py
index ef593a23..68a21f6d 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -6,6 +6,7 @@ from __future__ import absolute_import
import logging
import os
import signal
+import codecs
from twisted.internet import reactor, defer, task
import urwid
@@ -18,6 +19,7 @@ from .commands import CommandCanceled
from .commands import CommandParseError
from .helper import split_commandline
from .helper import string_decode
+from .helper import get_xdg_env
from .widgets.globals import CompleteEdit
from .widgets.globals import ChoiceWidget
@@ -83,7 +85,7 @@ class UI(object):
# load histories
self._cache = os.path.join(
- os.environ.get('XDG_CACHE_HOME', os.path.expanduser('~/.cache')),
+ get_xdg_env('XDG_CACHE_HOME', os.path.expanduser('~/.cache')),
'alot', 'history')
self._cmd_hist_file = os.path.join(self._cache, 'commands')
self._sender_hist_file = os.path.join(self._cache, 'senders')
@@ -735,7 +737,7 @@ class UI(object):
if size == 0:
return []
if os.path.exists(path):
- with open(path) as histfile:
+ with codecs.open(path, 'r', encoding='utf-8') as histfile:
lines = [line.rstrip('\n') for line in histfile]
if size > 0:
lines = lines[-size:]
@@ -765,7 +767,7 @@ class UI(object):
if not os.path.exists(directory):
os.makedirs(directory)
# Write linewise to avoid building a large string in menory.
- with open(path, 'w') as histfile:
+ with codecs.open(path, 'w', encoding='utf-8') as histfile:
for line in history:
histfile.write(line)
histfile.write('\n')