Daniel Von Fange

Life, Code, and Cool Stuff

TextMate Todo

I just changed to having my “todo lists” in TextMate. Previously I’ve used Omni Outliner and Tinderbox, but I wanted to experience the unix way for a few months. Pervasive user scripting inside a text editor is a major mental shift.

Here is a bit of scripting that fetches my current assigned tickets from our project’s trac site and replaces my current selection with todo items for the tickets:

# Note: This script requires ruby 1.8

require 'open-uri'
require "rexml/document"


xml = open("http://devsupport/cgi-bin/trac.cgi/report/4?format=rss").read
rss = REXML::Document.new xml
rss.elements.each("//item[author/text()='DanielVonFange']/title") { |element|
   task = /(#[0-9]+): (.+)/.match(element.text)
   puts "[ ] #{task[2]} - #{task[1]}"

Another small script is for my completed todo items. I click on a line, press command-shift-D, and the todo item vanishes from the list, and appears in a log file along with the time that I finished it, and what file it came from.

Log entry:

[X] Blog Textmate converting me to a unix head - Tasks rip, GTD completion.
      in Blog 08:48 20041019 Tue

Log script:


task_text = $stdin.read
task_text.gsub!(/[ ] /,"[X] ")

from = File.basename(ARGV[0],".txt")

   archive_file.puts task_text
   archive_file.puts "      in #{from} #{`date "+%H:%M %Y%m%d %a"`}"

This script must be saved to a file, and then called as command, passing along the name of the current file being edited. So it the command in TextMate would look something like this:

ruby /path/to/script/task_completed.rb  $TM_FILEPATH

These are just quick hacks, but I’m slowly learning the way of the scripted editor.