Scripts for moving the @next tag on (and marking as @done) (FT2 + TP3)


Move the @next tag on, marking the current line as @done(yyyy-mm-dd hh:mm)

Automating @done and @next

When I am working through the finer detail of a project I like to use a @next tag to mark which item I’m on.

I assign a keystroke to:

  • Marking the current line as @done(yyy-mm-dd hh:mm),
  • and moving the @next tag on (to the next item in the current project which is not tagged @done).

If we are on the last remaining line of a project:

  • The project/heading section itself is flagged as @done(yyy-mm-dd hh:mm) if no uncompleted items remain.
  • If any earlier lines remain uncompleted, then the @next tag jumps to the first of them.
  • The script then backs up the project outline to any containing project and walks the whole outline recursively in search of an eligible @next
    • (continuing until the whole document is complete)

To use the script

  • Choose the appropriate version (FoldingText or TaskPaper 3 Dev)
  • If there is no @next tag in your project, put your cursor on the line you want to start with.
  • If there is already a @next somewhere in the project, you can leave your cursor anywhere in the project – no need to move it.
  • Run the script from something like KeyBoard Maestro or FastScripts
  • A line which had no @next tag will simply get one,
  • but if one of the project lines already had a @next tag:
    1. It will be stamped as @done(yyyy-mm-dd hh:mm)
    2. the @next tag will move to the next eligible line, and
    3. if all lines in this project are now @done, the project itself will be stamped as done, and the @next tag will move on to the next project in the file, if there is one.

FoldingText 2 and TaskPaper 3 scripts

FoldingText 2 and TaskPaper 3 now allow us to do these things in Javascript, which is becoming Apple’s general direction in OS X Yosemite too.

We can call the Javascript from an Applescript, and perhaps use that from something like Keyboard Maestro, or we can put it in a pure javascript plugin for FoldingText itself.

Here are two sample scripts, one for FoldingText 2, and one for TaskPaper 3 which automate the business of marking a line as @done(yyy-mm-dd hh:mm) and moving the @next tag to the next line in the project which isn’t completed, and which doesn’t have any other disqualifying tags.

Customising the scripts

  1. @next versus @now etc:
    To specify an alternative ‘bookmarking’ tag to @next, edit the value of pstrTag at the top of the text
  2. Other disqualifying tags:
    By default, the script assumes that lines marked @done should be skipped by the bookmarking tag (@next, @now or whatever you have chosen). If you want to specify any other disqualifying tags which should be skipped, like @wait, @tomorrow, @snooze etc, add quoted tag names to the comma-delimited plstExcept list at the top of the script.

Experimenting with the new FoldingText debugger

Note that you can run these scripts in a debug mode and trace their execution if you want. To do that:

  1. Edit pblnDebug at the start of the script to true
  2. insert the line debugger; wherever you want a break-point,
  3. and open the SDK version of the editor through FoldingText > Help > Software Development Kit > Run Editor > Inspector
  4. Paste a bit of text into the SDK editor, and
  5. run the script.

You can then:

  • Step through the code line by line with F7 or ⌘;
    • (other debugging icons to the left)
    • and watch variables changing their values in the Scope Chain panel to the right.

FoldingText Extensions Wiki