|
6 | 6 | import six |
7 | 7 | import sys |
8 | 8 | import vim # pylint: disable=F0401 |
| 9 | +import subprocess |
9 | 10 |
|
10 | 11 | # Insert the taskwiki on the python path |
11 | 12 | BASE_DIR = vim.eval("s:plugin_path") |
@@ -85,6 +86,14 @@ def __init__(self): |
85 | 86 | if not self.tasks: |
86 | 87 | print("No tasks selected.") |
87 | 88 |
|
| 89 | + self.taskopen_notes_folder = ( |
| 90 | + util.get_var("taskwiki_taskopen_notes_folder", default="~/tasknotes") |
| 91 | + ) |
| 92 | + |
| 93 | + self.taskopen_notes_regex = ( |
| 94 | + util.get_var("taskwiki_taskopen_notes_regex") or "Notes" |
| 95 | + ) |
| 96 | + |
88 | 97 | @classmethod |
89 | 98 | def save_action(cls, method, *args): |
90 | 99 | cls.last_action = {'method': method, 'args': args} |
@@ -125,6 +134,34 @@ def info(self): |
125 | 134 | util.show_in_split(out, name='info', activate_cursorline=True) |
126 | 135 | break # Show only one task |
127 | 136 |
|
| 137 | + @errors.pretty_exception_handler |
| 138 | + def open(self): |
| 139 | + compatible_annotation_found = False |
| 140 | + for vimwikitask in self.tasks: |
| 141 | + for annotation in vimwikitask.task["annotations"]: |
| 142 | + annotation = annotation["description"] |
| 143 | + proc = subprocess.Popen(["xdg-open", annotation]) |
| 144 | + try: |
| 145 | + proc.wait(0.3) |
| 146 | + except subprocess.TimeoutExpired: |
| 147 | + compatible_annotation_found = True |
| 148 | + |
| 149 | + if not compatible_annotation_found: |
| 150 | + print("No compatible annotation found.") |
| 151 | + |
| 152 | + @errors.pretty_exception_handler |
| 153 | + def note(self): |
| 154 | + for vimwikitask in self.tasks: |
| 155 | + if self.taskopen_notes_regex not in [ |
| 156 | + a["description"] for a in vimwikitask.task["annotations"] |
| 157 | + ]: |
| 158 | + self.annotate(self.taskopen_notes_regex) |
| 159 | + |
| 160 | + note_path = os.path.join(self.taskopen_notes_folder, |
| 161 | + vimwikitask.task["uuid"] + ".md") |
| 162 | + vim.command("edit " + note_path) |
| 163 | + break # Add not to only one task |
| 164 | + |
128 | 165 | @errors.pretty_exception_handler |
129 | 166 | def edit(self): |
130 | 167 | for vimwikitask in self.tasks: |
|
0 commit comments