mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
External editor can be used for composing by specifying the editor config option
This commit is contained in:
parent
5b5570f41e
commit
04cc68a29a
1 changed files with 24 additions and 10 deletions
22
jrnl.py
22
jrnl.py
|
@ -1,20 +1,24 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import parsedatetime.parsedatetime as pdt
|
||||
import parsedatetime.parsedatetime_consts as pdc
|
||||
import subprocess
|
||||
import re
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
import time
|
||||
import json
|
||||
import sys
|
||||
|
||||
config = {
|
||||
'journal': "/home/manuel/Dropbox/Notes/journal.txt",
|
||||
'journal': "/Users/dedan/Dropbox/Notes/journal_neu.txt",
|
||||
'editor': "subl -w",
|
||||
'default_hour': 9,
|
||||
'default_minute': 0,
|
||||
'timeformat': "%Y-%m-%d %H:%M",
|
||||
'tagsymbols': '#@'
|
||||
'tagsymbols': '@'
|
||||
}
|
||||
|
||||
class Entry:
|
||||
|
@ -198,6 +202,7 @@ class Journal:
|
|||
self.sort()
|
||||
|
||||
if __name__ == "__main__":
|
||||
print sys.argv
|
||||
parser = argparse.ArgumentParser()
|
||||
composing = parser.add_argument_group('Composing', 'Will make an entry out of whatever follows as arguments')
|
||||
composing.add_argument('-date', dest='date', help='Date, e.g. "yesterday at 5pm"')
|
||||
|
@ -210,6 +215,7 @@ if __name__ == "__main__":
|
|||
reading.add_argument('-n', dest='limit', default=None, metavar="N", help='Shows the last n entries matching the filter', nargs="?", type=int)
|
||||
reading.add_argument('-json', dest='json', action="store_true", help='Returns a JSON-encoded version of the Journal')
|
||||
args = parser.parse_args()
|
||||
print args
|
||||
|
||||
# open journal
|
||||
journal = Journal(config=config)
|
||||
|
@ -225,6 +231,14 @@ if __name__ == "__main__":
|
|||
|
||||
# No text? Query
|
||||
if compose and not args.text:
|
||||
if config['editor']:
|
||||
tmpfile = os.path.join(tempfile.gettempdir(), "jrnl")
|
||||
subprocess.call(config['editor'].split() + [tmpfile])
|
||||
with open(tmpfile) as f:
|
||||
raw = f.read()
|
||||
os.remove(tmpfile)
|
||||
|
||||
else:
|
||||
raw = raw_input("Compose Entry: ")
|
||||
if raw:
|
||||
args.text = [raw]
|
||||
|
|
Loading…
Add table
Reference in a new issue