Skip to content

Commit

Permalink
close aziz#370: add * [ ] as task bullet to make todo list compatible…
Browse files Browse the repository at this point in the history
… with Markdown syntax
  • Loading branch information
JimmyLv authored and fnmeyer committed May 2, 2024
1 parent 6563925 commit 7a7c6d1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
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 @@ -335,9 +335,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 @@ -434,7 +434,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*(\#?\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
8 changes: 4 additions & 4 deletions PlainTasks.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</dict>
</dict>
<key>match</key>
<string>^\s*(?:(\+|✓|✔|☑|√|\[x\])(\s+(?:[^\@\n]|(?&lt;!\s)\@|\@(?=\s))*)([^\n]*))|^\s*(?:(-)(\s+(?:[^\@]|(?&lt;!\s)\@|\@(?=\s))*)(.*\@done(?=\s|\(|$)[^\n]*))</string>
<string>^\s*(?:(\+|✓|✔|☑|√|\*?\s?\[x\])(\s+(?:[^\@\n]|(?&lt;!\s)\@|\@(?=\s))*)([^\n]*))|^\s*(?:(-)(\s+(?:[^\@]|(?&lt;!\s)\@|\@(?=\s))*)(.*\@done(?=\s|\(|$)[^\n]*))</string>
<key>name</key>
<string>meta.item.todo.completed</string>
</dict>
Expand Down Expand Up @@ -96,14 +96,14 @@
</dict>
</dict>
<key>match</key>
<string>^\s*(?:(✘|❌|x|\[-\])(\s+(?:[^\@\n]|(?&lt;!\s)\@|\@(?=\s))*)(.*))|^\s*(?:(-)(\s+(?:[^\@]|(?&lt;!\s)\@|\@(?=\s))*)(.*\@cancelled(?=\s|\(|$)[^\n]*))</string>
<string>^\s*(?:(✘|❌|x|\*?\s?\[-\])(\s+(?:[^\@\n]|(?&lt;!\s)\@|\@(?=\s))*)(.*))|^\s*(?:(-)(\s+(?:[^\@]|(?&lt;!\s)\@|\@(?=\s))*)(.*\@cancelled(?=\s|\(|$)[^\n]*))</string>
<key>name</key>
<string>meta.item.todo.cancelled</string>
</dict>

<dict>
<key>begin</key>
<string>^\s*(?!-|\+|✓|✔|√|❍|❑|■|□|☐|▪|▫|–|—|≡|→|›|\[[\sx-]\]|_|✘|❌|(x\s+))(?=\S)</string>
<string>^\s*(?!-|\+|✓|✔|√|❍|❑|■|□|☐|▪|▫|–|—|≡|→|›|\*?\s?\[[\sx-]\]|_|✘|❌|(x\s+))(?=\S)</string>
<key>end</key>
<string>$\n?</string>
<key>name</key>
Expand Down Expand Up @@ -135,7 +135,7 @@
</dict>
</dict>
<key>begin</key>
<string>^\s*(-|❍|❑|■|□|☐|▪|▫|–|—|≡|→|›|\[\s\])(?=(\s+(?:[^\@\n]|(?&lt;![ \t])\@)*)(?!([^\n]*)?(\@done|\@cancelled)[\s\(]))</string>
<string>^\s*(-|❍|❑|■|□|☐|▪|▫|–|—|≡|→|›|\*?\s?\[\s\])(?=(\s+(?:[^\@\n]|(?&lt;![ \t])\@)*)(?!([^\n]*)?(\@done|\@cancelled)[\s\(]))</string>
<key>end</key>
<string>$</string>
<key>name</key>
Expand Down
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ Here is a list of PlainTasks’ specific settings:

| Setting | Default | Options/Description |
| ------------------------------ | ---------------- | ----------------------------------------------------------------------- |
| **open_tasks_bullet** | `` | `-` `` `` `` `` `` `` `` `` `` `` `` `` `[ ]` |
| **done_tasks_bullet** | `` | `` `` `+` `[x]` |
| **cancelled_tasks_bullet** | `` | `x` `[-]` |
| **open_tasks_bullet** | `` | `-` `` `` `` `` `` `` `` `` `` `` `` `` `[ ]` `* [ ]` |
| **done_tasks_bullet** | `` | `` `` `+` `[x]` `* [x]` |
| **cancelled_tasks_bullet** | `` | `x` `[-]` `* [-]` |
| **date_format** | `(%y-%m-%d %H:%M)` | See [strfti.me](http://www.strfti.me/) for quick reference; detailed documentation: [ST2](https://docs.python.org/2.6/library/datetime.html#strftime-and-strptime-behavior), [ST3](https://docs.python.org/3.3/library/datetime.html#strftime-and-strptime-behavior) |
| **done_tag** | true | Determines whether done tasks should gain a `@done` tag or not |
| **done_date** | true | Determines whether done tasks should gain a date or not |
Expand Down

0 comments on commit 7a7c6d1

Please sign in to comment.