Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close #370: add * [ ] as task bullet to make todo list compatible with Markdown syntax #387

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
14 changes: 7 additions & 7 deletions PlainTasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ def runCommand(self, edit):
original = [r for r in self.view.sel()]
done_line_end, now = self.format_line_end(self.done_tag, tznow())
offset = len(done_line_end)
rom = r'^(\s*)(\[\s\]|.)(\s*.*)$'
rom = r'^(\s*)((?:\*\s)?\[\s\]|.)(\s*.*)$'
rdm = r'''
(?x)^(\s*)(\[x\]|.) # 0,1 indent & bullet
(?x)^(\s*)((?:\*\s)?\[x\]|.) # 0,1 indent & bullet
(\s*[^\b]*?(?:[^\@]|(?<!\s)\@|\@(?=\s))*?\s*) # 2 very task
(?=
((?:\s@done|@project|@[wl]asted|$).*) # 3 ending either w/ done or w/o it & no date
| # or
(?:[ \t](\([^()]*\))\s*([^@]*|(?:@project|@[wl]asted).*))?$ # 4 date & possible project tag after
)
''' # rcm is the same, except bullet & ending
rcm = r'^(\s*)(\[\-\]|.)(\s*[^\b]*?(?:[^\@]|(?<!\s)\@|\@(?=\s))*?\s*)(?=((?:\s@cancelled|@project|@[wl]asted|$).*)|(?:[ \t](\([^()]*\))\s*([^@]*|(?:@project|@[wl]asted).*))?$)'
rcm = r'^(\s*)((?:\*\s)?\[\-\]|.)(\s*[^\b]*?(?:[^\@]|(?<!\s)\@|\@(?=\s))*?\s*)(?=((?:\s@cancelled|@project|@[wl]asted|$).*)|(?:[ \t](\([^()]*\))\s*([^@]*|(?:@project|@[wl]asted).*))?$)'
started = r'^\s*[^\b]*?\s*@started(\([\d\w,\.:\-\/ @]*\)).*$'
toggle = r'@toggle(\([\d\w,\.:\-\/ @]*\))'

Expand Down Expand Up @@ -244,9 +244,9 @@ def runCommand(self, edit):
original = [r for r in self.view.sel()]
canc_line_end, now = self.format_line_end(self.canc_tag, tznow())
offset = len(canc_line_end)
rom = r'^(\s*)(\[\s\]|.)(\s*.*)$'
rdm = r'^(\s*)(\[x\]|.)(\s*[^\b]*?(?:[^\@]|(?<!\s)\@|\@(?=\s))*?\s*)(?=((?:\s@done|@project|@[wl]asted|$).*)|(?:[ \t](\([^()]*\))\s*([^@]*|(?:@project|@[wl]asted).*))?$)'
rcm = r'^(\s*)(\[\-\]|.)(\s*[^\b]*?(?:[^\@]|(?<!\s)\@|\@(?=\s))*?\s*)(?=((?:\s@cancelled|@project|@[wl]asted|$).*)|(?:[ \t](\([^()]*\))\s*([^@]*|(?:@project|@[wl]asted).*))?$)'
rom = r'^(\s*)((?:\*\s)?\[\s\]|.)(\s*.*)$'
rdm = r'^(\s*)((?:\*\s)?\[x\]|.)(\s*[^\b]*?(?:[^\@]|(?<!\s)\@|\@(?=\s))*?\s*)(?=((?:\s@done|@project|@[wl]asted|$).*)|(?:[ \t](\([^()]*\))\s*([^@]*|(?:@project|@[wl]asted).*))?$)'
rcm = r'^(\s*)((?:\*\s)?\[\-\]|.)(\s*[^\b]*?(?:[^\@]|(?<!\s)\@|\@(?=\s))*?\s*)(?=((?:\s@cancelled|@project|@[wl]asted|$).*)|(?:[ \t](\([^()]*\))\s*([^@]*|(?:@project|@[wl]asted).*))?$)'
started = r'^\s*[^\b]*?\s*@started(\([\d\w,\.:\-\/ @]*\)).*$'
toggle = r'@toggle(\([\d\w,\.:\-\/ @]*\))'
regions = itertools.chain(*(reversed(self.view.lines(region)) for region in reversed(list(self.view.sel()))))
Expand Down Expand Up @@ -343,7 +343,7 @@ def runCommand(self, edit, partial=False):
# adding tasks to archive section
for task in all_tasks:
line_content = self.view.substr(task)
match_task = re.match(r'^\s*(\[[x-]\]|.)(\s+.*$)', line_content, re.U)
match_task = re.match(r'^\s*((?:\*\s)?\[[x-]\]|.)(\s+.*$)', line_content, re.U)
current_scope = self.view.scope_name(task.a)
if rds in current_scope or rcs in current_scope:
pr = self.get_task_project(task, projects)
Expand Down
8 changes: 4 additions & 4 deletions PlainTasks.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contexts:
main:
- match: '^\s*(\w+.*?:\s*?(\@[^\s]+(\(.*?\))?\s*?)*$\n?)'
scope: keyword.control.header.todo
- match: '^\s*(?:(\+|✓|✔|☑|√|\[x\])(\s+(?:[^\@\n]|(?<!\s)\@|\@(?=\s))*)([^\n]*))|^\s*(?:(-)(\s+(?:[^\@]|(?<!\s)\@|\@(?=\s))*)(.*\@done(?=\s|\(|$)[^\n]*))'
- match: '^\s*(?:(\+|✓|✔|☑|√|(?:\*\s)?\[x\])(\s+(?:[^\@\n]|(?<!\s)\@|\@(?=\s))*)([^\n]*))|^\s*(?:(-)(\s+(?:[^\@]|(?<!\s)\@|\@(?=\s))*)(.*\@done(?=\s|\(|$)[^\n]*))'
scope: meta.item.todo.completed
captures:
1: punctuation.definition.bullet.completed.todo
Expand All @@ -19,7 +19,7 @@ contexts:
4: punctuation.definition.bullet.completed.todo
5: comment.line.completed.todo
6: meta.tag.todo.completed
- match: '^\s*(?:(✘|x|\[-\])(\s+(?:[^\@\n]|(?<!\s)\@|\@(?=\s))*)(.*))|^\s*(?:(-)(\s+(?:[^\@]|(?<!\s)\@|\@(?=\s))*)(.*\@cancelled(?=\s|\(|$)[^\n]*))'
- match: '^\s*(?:(✘|x|(?:\*\s)?\[-\])(\s+(?:[^\@\n]|(?<!\s)\@|\@(?=\s))*)(.*))|^\s*(?:(-)(\s+(?:[^\@]|(?<!\s)\@|\@(?=\s))*)(.*\@cancelled(?=\s|\(|$)[^\n]*))'
scope: meta.item.todo.cancelled
captures:
1: punctuation.definition.bullet.cancelled.todo
Expand All @@ -28,15 +28,15 @@ contexts:
4: punctuation.definition.bullet.cancelled.todo
5: text.cancelled.todo
6: meta.tag.todo.cancelled
- match: '^\s*(?!-|\+|✓|✔|√|❍|❑|■|□|☐|▪|▫|–|—|≡|→|›|\[[\sx-]\]|_|✘|(x\s+))(?=\S)'
- match: '^\s*(?!-|\+|✓|✔|√|❍|❑|■|□|☐|▪|▫|–|—|≡|→|›|(?:\*\s)?\[[\sx-]\]|_|✘|(x\s+))(?=\S)'
push:
- meta_scope: notes.todo
- match: $\n?
pop: true
- include: italic
- include: bold
- include: url
- match: '^\s*(-|❍|❑|■|□|☐|▪|▫|–|—|≡|→|›|\[\s\])(?=(\s+(?:[^\@\n]|(?<![ \t])\@)*)(?!([^\n]*)?(\@done|\@cancelled)[\s\(]))'
- match: '^\s*(-|❍|❑|■|□|☐|▪|▫|–|—|≡|→|›|(?:\*\s)?\[\s\])(?=(\s+(?:[^\@\n]|(?<![ \t])\@)*)(?!([^\n]*)?(\@done|\@cancelled)[\s\(]))'
captures:
1: punctuation.definition.bullet.pending.todo
push:
Expand Down
Loading