Editorial Workflows

[TP] Archive @done & return

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Moves all @done tasks in a TaskPaper document to the "Archive" project (created if needed).
Also returns to position in the file where the cursor was before the archiving happens.

Shared by: @macmanuk

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set Variable ?
Variable Name
Sel. Range: Start
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import re
import sys

text = editor.get_text()
archive_match = re.search('\\s*Archive:\\s*', text)
if archive_match:
	archive_loc = archive_match.start(0)
	archive_loc = sys.maxint

# Find tasks that are done and above the Archive project:
done_task_ranges = []
done_tasks = []
for m in re.finditer('.*@done.*\\n', text):
	if m.start(0) < archive_loc:

# Remove the tasks from their original position:
for r in reversed(done_task_ranges):
	editor.replace_text(r[0], r[1], '')

# Add them at the top of the Archive project:
done_tasks_str = ''.join(done_tasks)
text = editor.get_text()
if len(done_tasks) > 0:
	archive_match = re.search('\\s*Archive:\\s*', text)
	if archive_match:
		archive_loc = archive_match.end(0)
		done_tasks_str = '\nArchive:\n' + done_tasks_str
		archive_loc = len(text) - 1
	editor.replace_text(archive_loc, archive_loc, done_tasks_str)
Select Range ?
Range (from:to)
Relative to
  • Entire Document
  • Current Selection