diff --git a/autoload/__init__.py b/autoload/__init__.py deleted file mode 100644 index 177cfab..0000000 --- a/autoload/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# (c) 2014, Tomas Babej diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index e6e4f5b..dab041f 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -1,5 +1,5 @@ -let s:plugin_path = escape(expand(':p:h'), '\') -execute 'pyfile ' . s:plugin_path . '/../autoload/taskwiki.py' +let s:plugin_path = escape(expand(':p:h:h'), '\') +execute 'pyfile ' . s:plugin_path . '/taskwiki/taskwiki.py' augroup taskwiki " when saving the file sync the tasks from vimwiki to TW diff --git a/autoload/.gitignore b/taskwiki/.gitignore similarity index 100% rename from autoload/.gitignore rename to taskwiki/.gitignore diff --git a/taskwiki/__init__.py b/taskwiki/__init__.py new file mode 100644 index 0000000..ecb49bb --- /dev/null +++ b/taskwiki/__init__.py @@ -0,0 +1 @@ +# (c) 2014-2015, Tomas Babej diff --git a/taskwiki/regexp.py b/taskwiki/regexp.py new file mode 100644 index 0000000..7f005d3 --- /dev/null +++ b/taskwiki/regexp.py @@ -0,0 +1,45 @@ +import re + +# Unnamed building blocks +UUID_UNNAMED = r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}' +DUE_UNNAMED = r'\(\d{4}-\d\d-\d\d( \d\d:\d\d)?\)' +SPACE_UNNAMED = r'\s*' +NONEMPTY_SPACE_UNNAMED = r'\s+' +FINAL_SEGMENT_SEPARATOR_UNNAMED = r'(\s+|$)' + +TEXT_FORBIDDEN_SUFFIXES = ( + r'\s', # Text cannot end with whitespace + r' !', r' !!', r' !!!', # Any priority value + r'\(\d{4}-\d\d-\d\d\)', r'\(\d{4}-\d\d-\d\d \d\d:\d\d\)', # Any datetime value + r'\(\d{4}-\d\d-\d\d', # Any datetime value + UUID_UNNAMED, # Text cannot end with UUID +) + +# Building blocks +BRACKET_OPENING = re.escape('* [') +BRACKET_CLOSING = re.escape('] ') +EMPTY_SPACE = r'(?P\s*)' +UUID = r'(?P{0})'.format(UUID_UNNAMED) +DUE = r'(?P{0})'.format(DUE_UNNAMED) +UUID_COMMENT = '#{0}'.format(UUID) +TEXT = r'(?P.+' + ''.join(['(?.)' +PRIORITY = r'(?P!{1,3})' + +GENERIC_TASK = re.compile(''.join([ + EMPTY_SPACE, + BRACKET_OPENING, + COMPLETION_MARK, + BRACKET_CLOSING, + TEXT, + FINAL_SEGMENT_SEPARATOR_UNNAMED, + '(', PRIORITY, FINAL_SEGMENT_SEPARATOR_UNNAMED, ')?' + '(', DUE, FINAL_SEGMENT_SEPARATOR_UNNAMED, ')?' + '(', UUID_COMMENT, FINAL_SEGMENT_SEPARATOR_UNNAMED, ')?' # UUID is not there for new tasks +])) + +PROJECT_DEFINITION = re.compile(r'Project: (?P.*)(?\s*)' -UUID = r'(?P{0})'.format(UUID_UNNAMED) -DUE = r'(?P{0})'.format(DUE_UNNAMED) -UUID_COMMENT = '#{0}'.format(UUID) -TEXT = r'(?P.+' + ''.join(['(?.)' -PRIORITY = r'(?P!{1,3})' - -GENERIC_TASK = re.compile(''.join([ - EMPTY_SPACE, - BRACKET_OPENING, - COMPLETION_MARK, - BRACKET_CLOSING, - TEXT, - FINAL_SEGMENT_SEPARATOR_UNNAMED, - '(', PRIORITY, FINAL_SEGMENT_SEPARATOR_UNNAMED, ')?' - '(', DUE, FINAL_SEGMENT_SEPARATOR_UNNAMED, ')?' - '(', UUID_COMMENT, FINAL_SEGMENT_SEPARATOR_UNNAMED, ')?' # UUID is not there for new tasks -])) - -PROJECT_DEFINITION = re.compile(r'Project: (?P.*)(?