aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/ui/util/editor.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/ui/util/editor.py')
-rw-r--r--libbe/ui/util/editor.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/libbe/ui/util/editor.py b/libbe/ui/util/editor.py
index 859cedc..83262e7 100644
--- a/libbe/ui/util/editor.py
+++ b/libbe/ui/util/editor.py
@@ -28,12 +28,12 @@ import sys
import tempfile
import libbe
+import libbe.util.encoding
+
if libbe.TESTING == True:
import doctest
-default_encoding = sys.getfilesystemencoding() or locale.getpreferredencoding()
-
comment_marker = u"== Anything below this line will be ignored\n"
class CantFindEditor(Exception):
@@ -60,7 +60,7 @@ def editor_string(comment=None, encoding=None):
>>> del os.environ["VISUAL"]
"""
if encoding == None:
- encoding = default_encoding
+ encoding = libbe.util.encoding.get_filesystem_encoding()
for name in ('VISUAL', 'EDITOR'):
try:
editor = os.environ[name]
@@ -77,9 +77,8 @@ def editor_string(comment=None, encoding=None):
os.close(fhandle)
oldmtime = os.path.getmtime(fname)
os.system("%s %s" % (editor, fname))
- f = codecs.open(fname, "r", encoding)
- output = trimmed_string(f.read())
- f.close()
+ output = libbe.util.encoding.get_file_contents(
+ fname, encoding=encoding, decode=True)
if output.rstrip('\n') == "":
output = None
finally: