From 54e5996863fe0597ce9087e1e15159f0f6717abe Mon Sep 17 00:00:00 2001 From: Nicolas Hohm Date: Fri, 31 Jan 2014 22:32:26 +0100 Subject: [PATCH] Add support for github todo lists --- smart_list.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/smart_list.py b/smart_list.py index c1e229f..5de1b94 100644 --- a/smart_list.py +++ b/smart_list.py @@ -9,7 +9,8 @@ ORDER_LIST_PATTERN = re.compile(r"(\s*)(\d+)(\.\s+)\S+") UNORDER_LIST_PATTERN = re.compile(r"(\s*[-+\**]+)(\s+)\S+") -EMPTY_LIST_PATTERN = re.compile(r"(\s*([-+\**]|\d+\.+))\s+$") +EMPTY_LIST_PATTERN = re.compile(r"(\s*([-+\**]|\d+\.+))\s*(\[[^\]]*\])?\s+$") +UNORDER_TODO_LIST_PATTERN = re.compile(r"(\s*[-+\**]+)(\s+)\[[^\]]*\](\s+)\S+") class SmartListCommand(sublime_plugin.TextCommand): @@ -43,6 +44,12 @@ def run(self, edit): self.view.insert(edit, region.a, "\n" + insert_text) break + match = UNORDER_TODO_LIST_PATTERN.match(before_point_content) + if match: + insert_text = match.group(1) + match.group(2) + "[ ]" + match.group(3) + self.view.insert(edit, region.a, "\n" + insert_text) + break + match = UNORDER_LIST_PATTERN.match(before_point_content) if match: insert_text = match.group(1) + match.group(2)