CompleteAndRepeat


Outdated!!!

This information is for TaskPaper 2 which is old and outdated. TaskPaper 3 is the current version of TaskPaper. For TaskPaper 3 support please visit the support forums.


Teamwork of Bob Pankratz and Stefano F. Rausch:

(*
 * Script: Complete and Repeat
 *
 * Version: 120325-1
 *
 * This script does target TaskPaper for Mac (C) Hog Bay Software: www.hogbaysoftware.com/products/taskpaper and is based on some key concepts taken from the script http://www.​hogbaysoftware.com/wiki/​TogglePreselectedTasksAndMoveT​oEndOfProject.
 *
 * The following main features have been implemented and / or enhanced:
 *
 * - Marking the preselected tasks with @done(YYYY-MM-DD).
 * - Re-enter a not preselected copy to the end of the current project.
 *
 * Do the following to select:
 *
 * - a single active done entry : position the cursor anywhere on the done item to archive.
 * - multiple active done entries : double click anywhere on the first done item and repeat for all others while keeping the CMD key pressed to archive in one batch.
 *
 * Notice: If you are not following the Final Version ™ System of Mark Forster you can set the flag "toggleEntryType" to false and just work with TaskPaper tasks instead as usual.
 *
 * In addition it removes existing "tagsToDelete", if the flag "deleteTags" is set to true.
 *
 * Feel free to edit the respective script properties in the "Public User Interface" section according to your needs.
 *
 * History:
 *
 * - 25.03.2012: Initial release.
 *
 * Copyright (C) 2012 Bob Pankratz. All rights reserved.
 *)

-- Public User Interface

property deleteTags : true
property tagsToDelete : {"done", "today"}

property toggleEntryType : true

-- Private Top Level Script Code

tell application "TaskPaper"
    tell front document

        -- Get selected entries.

        set selectedEntries to get selected entries

        set theDate to (do shell script "date +'%Y-%m-%d'")

        repeat with each in selectedEntries
            tell each
                if (entry type is task type) then

                    -- remove tags

                    if ( deleteTags is true ) then
                        repeat with |tag| in tagsToDelete
                            if ( exists tag named |tag| ) then
                                delete tag named |tag|
                            end if
                        end repeat
                    end if

                    if ( toggleEntryType )
                        set entry type to note type
                    end if

                    duplicate each to end of entries of container

                    if ( toggleEntryType )
                        set entry type to task type
                    end if

                    make tag with properties {name:"done(" & theDate & ")"}
                end if
            end tell
        end repeat

    end tell
end tell

-- End of Script