|
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") |
@@ -83,6 +84,10 @@ def __init__(self): |
83 | 84 | if not self.tasks: |
84 | 85 | print("No tasks selected.") |
85 | 86 |
|
| 87 | + self.taskopen_notes_folder = ( |
| 88 | + util.get_var("taskwiki_taskopen_notes_folder") or "~/tasknotes" |
| 89 | + ) |
| 90 | + |
86 | 91 | @classmethod |
87 | 92 | def save_action(cls, method, *args): |
88 | 93 | cls.last_action = {'method': method, 'args': args} |
@@ -123,6 +128,34 @@ def info(self): |
123 | 128 | util.show_in_split(out, name='info', activate_cursorline=True) |
124 | 129 | break # Show only one task |
125 | 130 |
|
| 131 | + @errors.pretty_exception_handler |
| 132 | + def open(self): |
| 133 | + compatible_annotation_found = False |
| 134 | + for vimwikitask in self.tasks: |
| 135 | + for annotation in vimwikitask.task["annotations"]: |
| 136 | + annotation = annotation["description"] |
| 137 | + proc = subprocess.Popen(["xdg-open", annotation]) |
| 138 | + try: |
| 139 | + proc.wait(0.3) |
| 140 | + except subprocess.TimeoutExpired: |
| 141 | + compatible_annotation_found = True |
| 142 | + |
| 143 | + if not compatible_annotation_found: |
| 144 | + print("No compatible annotation found.") |
| 145 | + |
| 146 | + @errors.pretty_exception_handler |
| 147 | + def note(self): |
| 148 | + for vimwikitask in self.tasks: |
| 149 | + if "Notes" not in [ |
| 150 | + a["description"] for a in vimwikitask.task["annotations"] |
| 151 | + ]: |
| 152 | + self.annotate("Notes") |
| 153 | + |
| 154 | + note_path = os.path.join(self.taskopen_notes_folder, |
| 155 | + vimwikitask.task["uuid"] + ".md") |
| 156 | + vim.command("edit " + note_path) |
| 157 | + break # Add not to only one task |
| 158 | + |
126 | 159 | @errors.pretty_exception_handler |
127 | 160 | def edit(self): |
128 | 161 | for vimwikitask in self.tasks: |
|
0 commit comments