mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-18 12:08:31 +02:00
Merge 0f5bc645cf
into 9ffca1a7a6
This commit is contained in:
commit
184d67256f
1 changed files with 2 additions and 1 deletions
|
@ -126,13 +126,14 @@ def load_and_fix_json(json_path):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def get_text_from_editor(config, template=""):
|
def get_text_from_editor(config, template=""):
|
||||||
_, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=".txt")
|
filehandle, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=".txt")
|
||||||
with codecs.open(tmpfile, 'w', "utf-8") as f:
|
with codecs.open(tmpfile, 'w', "utf-8") as f:
|
||||||
if template:
|
if template:
|
||||||
f.write(template)
|
f.write(template)
|
||||||
subprocess.call(config['editor'].split() + [tmpfile])
|
subprocess.call(config['editor'].split() + [tmpfile])
|
||||||
with codecs.open(tmpfile, "r", "utf-8") as f:
|
with codecs.open(tmpfile, "r", "utf-8") as f:
|
||||||
raw = f.read()
|
raw = f.read()
|
||||||
|
os.close(filehandle);
|
||||||
os.remove(tmpfile)
|
os.remove(tmpfile)
|
||||||
if not raw:
|
if not raw:
|
||||||
prompt('[Nothing saved to file]')
|
prompt('[Nothing saved to file]')
|
||||||
|
|
Loading…
Add table
Reference in a new issue