TagWithDoneAlternativeImplementations

TaskPaper has a built in tag with @done (Command-D) command. It's very useful, but some people have wanted to tweak its behavior to fit their particular workflow. Applescript is a great way to do that. First here's the current @done command, but this time implemented in AppleScript:

tell application "TaskPaper"
    set selected_entries to get selected entries

    -- Iterate over selection to determine if we are adding or removing done tag
    set add_done to false
    repeat with each in selected_entries
        tell each
            if not (exists tag named "done") then
                set add_done to true
            end if
        end tell
    end repeat

    -- Iterate over selection and add or remove done tag as needed
    repeat with each in selected_entries
        tell each
            if add_done and not (exists tag named "done") then
                make tag with properties {name:"done"}
            else if not add_done and (exists tag named "done") then
                delete tag named "done"
            end if
        end tell
    end repeat
end tell

Now lets say (a number of people already have) that you want the done command to also automatically remove the @today tag from items that you mark with @done. To do that you can modify the above script by adding these lines right after the make tag with properties {name:"done"} line:

if exists tag named "today" then
    delete tag named "today"
end if

Or if you'd like to play a sound when marking a task with @done, at the top of the script file describe the sound file you're going to use:

set donefile to (path to me as string) & "Contents:Resources:task done.aiff" as alias
set donesound to quoted form of (POSIX path of (donefile as alias))

And then right after the make tag with properties {name:"done"} line:

do shell script ("afplay " & donesound & " > /dev/null 2>&1 &")

Before this will work, you need to make sure that you save the script as an Application (from the Save dialog of Apple Script Editor`, and copy a suitable sound into the Application Resources with the Terminal:

$ TASKPAPER=$HOME/Library/Application\ Support/TaskPaper/Scripts
$ cd /System/Library/Components/CoreAudio.component/Contents/Resources/SystemSounds
$ cp "dock/drag to trash.aif" \
"$TASKPAPER/Tag With Done.app/Contents/Resources/task done.aiff"

Download the complete script, incorporating all of the above!