diff --git a/messages/install.org b/messages/install.org
index 12734cc..6bb8203 100644
--- a/messages/install.org
+++ b/messages/install.org
@@ -70,15 +70,15 @@
- Checkbox checked: "cc"
- Checkbox summary: "cs"
-* Todo [14/31]
+* Todo [15/31]
- [X] Persistant folding of headlines
- needs indented formatting to work.
- [X] Autocomplete for inserting current date, write "date" => 2013-05-25 18:53
- [X] configure in settings
- [X] Port to Sublime Text 3
- - [X] test
- - [X] mac,
- - [X] win,
+ - [X] test
+ - [X] mac,
+ - [X] win,
- [X] linux
- [X] merge into sub2 branch, test both versions
- [X] [[mailto:daniel@testtest.se]]
@@ -130,7 +130,7 @@
- [ ] Open call [[email:ok@ryotic.de/inbox/some title]]
- [X] Create call [[mailto:ok@ryotic.de]]
- [X] Create call with subject [[mailto:ok@ryotic.de/some subject]]
- - [ ] Pressing return on a TODO chain shall set it to DONE
+ - [X] Pressing return on a TODO chain shall set it to DONE
- [ ] ASCII tables.
- [ ] Code remark collector. Recursively scans a specified folder for files with given filename pattern for code remarks and shows them as a list. Should be realized with begin and end markers to support later update on pressing enter on either marker.
diff --git a/orgmode.py b/orgmode.py
index 111eb43..c77edf9 100644
--- a/orgmode.py
+++ b/orgmode.py
@@ -367,6 +367,54 @@ def toggle_checkbox(self, edit, region, checked=None, recurse_up=False, recurse_
self.update_line(edit, parent)
+class OrgmodeCycleTodoCommand(sublime_plugin.TextCommand):
+
+ def __init__(self, *args, **kwargs):
+ super(OrgmodeCycleTodoCommand, self).__init__(*args, **kwargs)
+
+ self.status = ["TODO", "WORKING", "DONE"]
+ todo_pattern = r"|".join(self.status)
+ self.todo_regex = re.compile(todo_pattern)
+
+
+ def run(self, edit):
+
+ print("run")
+
+ view = self.view
+ sels = view.sel()
+ sel = sels[0]
+
+ if 'orgmode.todo' not in view.scope_name(sel.end()):
+ return
+
+ region = view.extract_scope(sel.end())
+
+ todo = self.get_todo(region)
+ content = self.view.substr(todo)
+
+ next_status_index = (self.status.index(content) + 1) % len(self.status)
+ view.replace(edit, todo, self.status[next_status_index])
+
+
+ def get_todo(self, line):
+ view = self.view
+ row, _ = view.rowcol(line.begin())
+ content = view.substr(line)
+ # print content
+ match = self.todo_regex.search(content)
+ if not match:
+ return None
+ # checkbox = match.group(1)
+ # print repr(checkbox)
+ # print dir(match), match.start(), match.span()
+ col_start, col_stop = match.span()
+ return sublime.Region(
+ view.text_point(row, col_start),
+ view.text_point(row, col_stop),
+ )
+
+
class OrgmodeToggleCheckboxCommand(AbstractCheckboxCommand):
def run(self, edit):
@@ -477,4 +525,4 @@ def has_file_ext(view, ext):
if not ext.startswith('.'):
ext = '.' + ext
- return view.file_name().endswith(ext)
\ No newline at end of file
+ return view.file_name().endswith(ext)
diff --git a/orgmode.tmLanguage b/orgmode.tmLanguage
index 0258b25..e391c12 100644
--- a/orgmode.tmLanguage
+++ b/orgmode.tmLanguage
@@ -106,6 +106,12 @@
match
(^|\s):[\w\d:]+:
+
+ name
+ orgmode.todo
+ match
+ TODO|WORKING|DONE
+
name
orgmode.python.traceback