Touch tmpfiles before opening

This commit is contained in:
Manuel Ebert 2014-01-02 07:48:57 +01:00
parent 534dc63ec0
commit 01703af728
4 changed files with 20 additions and 8 deletions

View file

@ -4,6 +4,7 @@ Changelog
### 1.7 (December 22, 2013)
* __1.7.3__ Touches temporary files before opening them to allow more external editors.
* __1.7.2__ Dateutil added to requirements.
* __1.7.1__ Fixes issues with parsing time information in entries.
* __1.7.0__ Edit encrypted or DayOne journals with `jrnl --edit`.

View file

@ -24,6 +24,18 @@ You can do things like ::
To get a short summary of the 10 most recent, favourited entries before January 1, 2013 that are tagged with ``@fixed``.
Using iA Writer to write entries
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On OS X, you can use the fabulous `iA Writer <http://www.iawriter.com/mac>` to write entries. Configure your ``.jrnl_conf`` like this:
.. code-block:: javascript
"editor": "open -b jp.informationarchitects.WriterForMacOSX -Wn"
What does this do? ``open -b ...`` opens a file using the application identified by the bundle identifier (a unique string for every app out there). ``-Wn`` tells the application to wait until it's closed before passing back control, and to use a new instance of the application.
Known Issues
------------

View file

@ -7,7 +7,7 @@ jrnl is a simple journal application for your command line.
"""
__title__ = 'jrnl'
__version__ = '1.7.2'
__version__ = '1.7.3'
__author__ = 'Manuel Ebert'
__license__ = 'MIT License'
__copyright__ = 'Copyright 2013 Manuel Ebert'

View file

@ -129,14 +129,13 @@ def get_text_from_editor(config, template=""):
if template:
with codecs.open(tmpfile, 'w', "utf-8") as f:
f.write(template)
with open(tmpfile, 'w'):
pass
subprocess.call(config['editor'].split() + [tmpfile])
if os.path.exists(tmpfile):
with codecs.open(tmpfile, "r", "utf-8") as f:
raw = f.read()
os.remove(tmpfile)
else:
with codecs.open(tmpfile, "r", "utf-8") as f:
raw = f.read()
os.remove(tmpfile)
if not raw:
prompt('[Nothing saved to file]')
raw = ''
return raw