Skip to content
Browse files

Added Feature: multiline properties

in PROPERTIES-DRAWER only single lines are allowed -> so multiline properities are converted to single line properties and then outside of the DRAWER presented too (in multiline format)
Signed-off-by: Armin Wieser <armin.wieser@gmail.com>
  • Loading branch information...
1 parent 9e161ed commit c2a36f3c6bfa5d26cdb814fea5f2b5eeb90c0d98 @awieser awieser committed Jun 3, 2012
Showing with 28 additions and 3 deletions.
  1. +26 −2 memacs/lib/orgproperty.py
  2. +2 −1 memacs/lib/orgwriter.py
View
28 memacs/lib/orgproperty.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Time-stamp: <2012-03-09 14:39:17 armin>
+# Time-stamp: <2012-06-03 11:16:03 armin>
import hashlib
@@ -22,6 +22,7 @@ def __init__(self, data_for_hashing=""):
you can add here data only for hash generation
"""
self.__properties = {}
+ self.__properties_multiline = {}
self.__data_for_hashing = data_for_hashing
self.__id = None
@@ -33,10 +34,20 @@ def add(self, tag, value):
"""
tag = unicode(tag).strip().upper()
value = unicode(value).strip()
+
if tag == "ID":
raise Exception("you should not specify an :ID: property " + \
"it will be generated automatically")
+ value_multiline = value.splitlines()
+
+ if len(value_multiline) > 1:
+ # we do have multiline value
+ multiline_value = [" " + v for v in value_multiline]
+ self.__properties_multiline[tag] = multiline_value
+
+ value = " ".join(value_multiline)
+
self.__properties[tag] = unicode(value)
def set_id(self, value):
@@ -50,7 +61,11 @@ def delete(self, key):
delete a pair out of properties
@param key index
"""
- del self.__properties[key]
+ try:
+ del self.__properties[key]
+ del self.__properties_multiline[key]
+ except Keyerror, e:
+ pass
def __get_property_max_tag_width(self):
width = 10 # :PROPERTIES: has width 10
@@ -120,3 +135,12 @@ def get_value_delete_but_add_for_hashing(self, key):
self.delete(key)
self.add_data_for_hashing(ret)
return ret
+
+ def get_multiline_properties(self):
+ ret = ""
+ for key in self.__properties_multiline.keys():
+ ret += "\n " + key + ":\n"
+ ret += "\n".join(self.__properties_multiline[key])
+ ret += "\n"
+
+ return ret
View
3 memacs/lib/orgwriter.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Time-stamp: <2012-04-16 20:13:03 armin>
+# Time-stamp: <2012-06-03 10:59:09 armin>
import codecs
import sys
@@ -147,6 +147,7 @@ def __write_org_subitem(self,
for n in note.splitlines():
self.writeln(" " + n)
self.writeln(unicode(properties))
+ self.write(properties.get_multiline_properties())
def write_org_subitem(self,
timestamp,

0 comments on commit c2a36f3

Please sign in to comment.
Something went wrong with that request. Please try again.