Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions APlainTasksCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def run(self, edit, **kwargs):
self.open_tasks_bullet = settings.get('open_tasks_bullet', u'☐')
self.done_tasks_bullet = settings.get('done_tasks_bullet', u'✔')
self.canc_tasks_bullet = settings.get('cancelled_tasks_bullet', u'✘')
self.review_tasks_bullet = "⚑"
self.before_date_space = settings.get('before_date_space', ' ')

translate_tabs_to_spaces = settings.get('translate_tabs_to_spaces', False)
Expand Down
3 changes: 2 additions & 1 deletion Default (Linux).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
[
{ "key": "selector", "operator": "equal", "operand": "text.todo meta.tag.todo.completed, text.todo meta.tag.todo.cancelled" }
]
}
},
{ "keys": ["alt+x"], "command": "plain_tasks_toggle_review", "context": [{"key": "selector", "operator": "equal", "operand": "text.todo"}] },
]
3 changes: 2 additions & 1 deletion Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
[
{ "key": "selector", "operator": "equal", "operand": "text.todo meta.tag.todo.completed, text.todo meta.tag.todo.cancelled" }
]
}
},
{ "keys": ["super+x"], "command": "plain_tasks_toggle_review", "context": [{"key": "selector", "operator": "equal", "operand": "text.todo"}] },
]
3 changes: 2 additions & 1 deletion Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
[
{ "key": "selector", "operator": "equal", "operand": "text.todo meta.tag.todo.completed, text.todo meta.tag.todo.cancelled" }
]
}
},
{ "keys": ["alt+x"], "command": "plain_tasks_toggle_review", "context": [{"key": "selector", "operator": "equal", "operand": "text.todo"}] },
]
3 changes: 2 additions & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
{ "caption": "Tasks: Filter by tags under cursors", "command": "plain_tasks_fold_to_tags" },
{ "caption": "Tasks: Add due date tag", "command": "plain_tasks_inject_due_date" },
{ "caption": "Tasks: Sort items in the list under cursor by due date and priority", "command": "plain_tasks_sort_by_due_date_and_priority" },
{ "caption": "Tasks: Reverse sort items in the list under cursor by due date and priority", "command": "plain_tasks_sort_by_due_date_and_priority", "args": {"descending": true} }
{ "caption": "Tasks: Reverse sort items in the list under cursor by due date and priority", "command": "plain_tasks_sort_by_due_date_and_priority", "args": {"descending": true} },
{ "caption": "Tasks: Toggle Review", "command": "plain_tasks_toggle_review" },
]
40 changes: 40 additions & 0 deletions PlainTasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def runCommand(self, edit):
open_matches = re.match(rom, line_contents, re.U)
done_matches = re.match(rdm, line_contents, re.U)
canc_matches = re.match(rcm, line_contents, re.U)
review_matches = re.search(r'@review', line_contents)
started_matches = re.findall(started, line_contents, re.U)
toggle_matches = re.findall(toggle, line_contents, re.U)

Expand All @@ -358,6 +359,9 @@ def runCommand(self, edit):

current_scope = self.view.scope_name(line.a)
if 'pending' in current_scope:
if review_matches:
sublime.status_message('Cannot complete a task marked for review')
continue
grps = open_matches.groups()
len_cle = self.view.insert(edit, line.end(), canc_line_end)
replacement = u'%s%s%s' % (grps[0], self.canc_tasks_bullet, grps[2].rstrip())
Expand Down Expand Up @@ -405,6 +409,42 @@ def runCommand(self, edit):
PlainTasksStatsStatus.set_stats(self.view)
self.view.run_command('plain_tasks_toggle_highlight_past_due')

class PlainTasksToggleReviewCommand(PlainTasksBase):
def runCommand(self, edit):
for region in self.view.sel():
line = self.view.line(region)
line_contents = self.view.substr(line)
current_scope = self.view.scope_name(line.begin())

# Extract indentation
indent_match = re.match(r"^(\s*)", line_contents)
indentation = indent_match.group(1) if indent_match else ""

if "@review" in line_contents:
# Remove @review tag
new_contents = re.sub(r"@review(\([^)]*\))?", "", line_contents).strip()
if "review" in current_scope:
# Change bullet from review to open
new_contents = new_contents.replace(
self.review_tasks_bullet, self.open_tasks_bullet, 1
)
else:
# Remove existing bullet
new_contents = re.sub(
r"^\s*[☐❍▪▫–—≡→›✘xX✓✔⚑]\s*", "", line_contents
).strip()

# Add review bullet and tag
new_contents = self.review_tasks_bullet + " " + new_contents
new_contents = new_contents.rstrip() + " @review"

# Reapply indentation
new_contents = indentation + new_contents

self.view.replace(edit, line, new_contents)

PlainTasksStatsStatus.set_stats(self.view)


class PlainTasksArchiveCommand(PlainTasksBase):
def runCommand(self, edit, partial=False):
Expand Down
3 changes: 2 additions & 1 deletion PlainTasks.sublime-completions
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{ "trigger": "s\t@started", "contents": "@started" },
{ "trigger": "tg\t@toggle", "contents": "@toggle"},
{ "trigger": "d\t@due()", "contents": "@due( $0)"},
{ "trigger": "cr\t@created", "contents": "@created"}
{ "trigger": "cr\t@created", "contents": "@created"},
{ "trigger": "r\t@review", "contents": "@review" },
]
}
4 changes: 4 additions & 0 deletions PlainTasks.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ contexts:
main:
- match: '^\s*(\#?\s?\w+.*?:\s*?(\@[^\s]+(\(.*?\))?\s*?)*$\n?)'
scope: keyword.control.header.todo
- match: '^\s*(?:[⚑])(?=\s)'
scope: punctuation.definition.bullet.review.todo
- match: '(?<=\s)@review(?![\w\d])'
scope: keyword.other.tag.review.todo
- match: '^\s*(?:(\+|✓|✔|☑|√|\[x\])(\s+(?:[^\@\n]|(?<!\s)\@|\@(?=\s))*)([^\n]*))|^\s*(?:(-)(\s+(?:[^\@]|(?<!\s)\@|\@(?=\s))*)(.*\@done(?=\s|\(|$)[^\n]*))'
scope: meta.item.todo.completed
captures:
Expand Down
Loading