From 01703af7289a557520cf3e180f226887b6946d67 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Thu, 2 Jan 2014 07:48:57 +0100 Subject: [PATCH] Touch tmpfiles before opening --- CHANGELOG.md | 1 + docs/recipes.rst | 12 ++++++++++++ jrnl/__init__.py | 2 +- jrnl/util.py | 13 ++++++------- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 963f141a..e644f568 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. diff --git a/docs/recipes.rst b/docs/recipes.rst index 9ae55a86..9583e6d0 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -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 ` 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 ------------ diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 001bf160..50b30f18 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -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' diff --git a/jrnl/util.py b/jrnl/util.py index e1766c9d..504be650 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -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