# Encoding: UTF-8

[{beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby\n$:<< ENV['TM_BUNDLE_SUPPORT'] << ENV['TM_SUPPORT_PATH']\nrequire \"lib/GTD.rb\"\nrequire \"lib/ui\"\ninclude GTD\nword = STDIN.read\ncase word\nwhen /^@?(\\w+)$/\n  w = $1\nwhen /\\s+@(\\w+)\\s*.*/\n  w = $1\nend\nif GTD.get_contexts.include?(word) then\n\tcontext = word\nelse\n  context = TextMate::UI.request_item(:title => 'Listing actions for context', :prompt =>  'Choose the new context', :items => GTD.contexts)\n  exit unless context\nend\nactions = GTD.actions_for_context(context).map{|r| [r[0],r[1].to_s,r[2]]}\nputs prettify(actions)\n",
  fallbackInput: "word",
  input: "selection",
  name: "Actions for Context (Text)",
  output: "openAsNewDocument",
  scope: "text.gtdalt",
  uuid: "C78ECFD8-DABE-4E2C-B628-0DDF2A3A3B21"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby\nrequire ENV['TM_BUNDLE_SUPPORT'] + '/lib/GTD.rb'\ninclude GTD\nfile = ENV['TM_FILEPATH']\nobj = GTDFile.new(file)\nobj.cleanup_projects\nlog = File.open(File.join(File.dirname(file),\"GTD.gtdlog\"),\"a\")\n\tlog.write MyLogger.dump + \"\\n\"\nlog.close\nputs obj.dump_object",
  fallbackInput: "document",
  input: "none",
  keyEquivalent: "~@/",
  name: "Archive Completed",
  output: "replaceDocument",
  scope: "text.gtdalt",
  uuid: "2803EE1A-6878-47C7-BB7F-3C1B69315209"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nrequire ENV['TM_BUNDLE_SUPPORT'] + '/lib/GTDUtils.rb'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'\nline = STDIN.read\ncontextList = GTDContexts.contexts\nchoice = TextMate::UI.menu(contextList)\nif choice then\n  print line.sub(/@(\\S+)($|\\s+)/) {|text,space| \"@\" + e_sn(contextList[choice]) + ((space.nil? or space == \"\") ? \" \" : space)+\"$0\"}\nelse\n  print e_sn(line)\nend\n",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "@",
  name: "Change Context",
  output: "insertAsSnippet",
  scope: "text.gtdalt meta.action",
  uuid: "2B282247-5930-462F-8D6E-54ADF228EC49"},
 {beforeRunningCommand: "nop",
  command: "\"$TM_BUNDLE_SUPPORT/bin/KinklessToGTDConverter.rb\"\n",
  fallbackInput: "line",
  input: "document",
  name: "Convert From Kinkless",
  output: "openAsNewDocument",
  uuid: "40ABCA1E-A154-47C7-8EBC-D22DC078D295"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby\nrequire ENV['TM_BUNDLE_SUPPORT'] + '/lib/GTD.rb'\ninclude GTD\nobjects = GTD.process_directory\nacts = objects.map{|o| o.actions}.flatten\nacts.sort! do |a,b|\n  da, db = *[a.due, b.due].map {|i| i || \"\"}  # convert nils to empty strings\n#  puts a,b, da, db\n  if a.context == b.context then\n    if da == db then\n      a.parent.name <=> b.parent.name\n    else\n      da <=> db\n    end\n  else\n    a.context <=> b.context\n  end\nend\npr = Printer.new\nb = <<HTML\n<html>\n  <head>\n    <link rel=\"stylesheet\" href=\"tm-file://\#{ENV['TM_SUPPORT_PATH']}/css/default.css\" type=\"text/css\" media=\"screen\" title=\"no title\" charset=\"utf-8\" />\n    <link rel=\"stylesheet\" href=\"tm-file://\#{ENV['TM_BUNDLE_SUPPORT']}/css/sidebar.css\" type=\"text/css\" media=\"screen\" title=\"no title\" charset=\"utf-8\" />\n    <script src=\"tm-file://\#{ENV['TM_BUNDLE_SUPPORT']}/js/sidebar.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n    <script src=\"tm-file://\#{ENV['TM_BUNDLE_SUPPORT']}/js/sorttable.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n    <style type=\"text/css\">\n      .nobr {white-space: nowrap}\n    </style>\n  </head>\n  <body>\n    <body class=\"\">\n  <ul id=\"toggles\">\n    <p>Next Actions Only <input type=\"checkbox\" name=\"next-show\" value=\"\" id=\"next-show-button\"></p>\n    <li class=\"collapse\" tablecolumn=\"0\">Contexts</li>\n    <li class=\"collapse\" tablecolumn=\"2\">Projects</li>\n    <li class=\"collapse\" tablecolumn=\"3\">Files</li>\n  </ul>\nHTML\ne = <<HTML\n  </body>\n</html>\nHTML\npr.raw b\npr.table do\n  pr.title \"List of all Actions\"\n  pr.headers([ \"Context\", \"Action\", \"Project\", \"File\" , \"Due by\",\"Completed\"])\n  acts.each do |a|\n    proj = a.parent.link\n    due = case a.due\n      when \"\",nil\n        \"\"\n      when DateLate\n        \"<span style=\\\"color:red\\\">\#{a.due}</span>\"\n      else\n        a.due\n    end\n    note_part = (a.note != \"\") ? \" title=\\\"\#{a.note}\\\"\" : \"\"\n    text = \"<a href=\\\"\#{a.txmt}\\\"\#{note_part}>\#{a.name}</a>\"\n    if a.is_next_action?\n      pr.row_next([a.context, text, proj, a.root.link , \"<span class=\\\"nobr\\\">\#{due}</span>\", a.mark_completed_link])\n    else\n      pr.row([a.context, text, proj, a.root.link , \"<span class=\\\"nobr\\\">\#{due}</span>\", a.mark_completed_link])\n    end\n  end\nend\npr.raw e\nputs pr.to_html",
  fallbackInput: "word",
  input: "none",
  keyEquivalent: "^~@0",
  name: "Current Actions",
  output: "showAsHTML",
  scope: "text.gtdalt",
  uuid: "F4884C32-9046-48E8-AB57-1784AF8C264C"},
 {beforeRunningCommand: "nop",
  command: 
   "\"$TM_BUNDLE_SUPPORT/bin/fill_remind_file.rb\"\necho \"Your remind files are now filled!\"",
  fallbackInput: "document",
  input: "none",
  keyEquivalent: "^~@+",
  name: "Fill Remind Files",
  output: "showAsTooltip",
  scope: "text.gtdalt",
  uuid: "7A8587A6-743D-4449-A0E2-BFD9A97893BC"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby\nrequire ENV['TM_BUNDLE_SUPPORT'] + '/lib/GTD.rb'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'\ninclude GTD\nfiles = GTD.process_directory\nprojects = files.map{|i| i.projects}.flatten\nsearch_string = TextMate::UI.request_string(:title => \"Finding projects\", :prompt => \"Abbreviated words to seach for:\")\nexit unless search_string && !(search_string =~ /^\\s*$/)\nsearch_terms = search_string.downcase.split(\" \")\nfor term in search_terms do\n  projects = projects.find_all { |proj| proj.name.downcase.index(term) != nil }\nend\ncase projects.length\nwhen 0\n  project = nil\nwhen 1\n  project = projects[0]\nelse\n  project = TextMate::UI.request_item(:title => \"Finding projects\",:prompt => \"Too many possible matches found! Please select one:\",:items => projects.map{|i| i.name+\" : \"+i.root.name} )\n  project = projects.find{|proj| proj.name+\" : \"+proj.root.name == project} if project\nend\nif project then\n#  project.root.update!\n `open \"\#{project.txmt}\"`\nend\n",
  fallbackInput: "word",
  input: "none",
  keyEquivalent: "^F",
  name: "Find",
  output: "discard",
  scope: "text.gtdalt",
  uuid: "255E029C-7B95-49F2-B7AC-0FAB4F7FBA58"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\ntext = STDIN.read\nlines = text.split(\"\\n\")\nrow = ENV['TM_LINE_NUMBER'].to_i\nm = lines[row-1].scan(/^\\[\\d+\\]/)[0]\ntxt = text.slice(0..text.index(m))\nlines = txt.split(\"\\n\")\nline = lines.length\nlast_line = lines.last\ncolumn = last_line.scan(/^\\s*@[^\\s]+\\s+/)[0].length + 1\n`open \"txmt://open?line=\#{line}&column=\#{column}\"`\n",
  fallbackInput: "document",
  input: "document",
  keyEquivalent: "^{",
  name: "Go to Action",
  output: "discard",
  scope: "text.gtdalt meta.note",
  uuid: "14CE2968-B4F4-4AB5-8A26-5F0EC156E1D0"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nrequire ENV['TM_SUPPORT_PATH'] + \"/lib/exit_codes.rb\"\nrequire ENV['TM_SUPPORT_PATH'] + \"/lib/escape.rb\"\ntext = STDIN.read\nlines = text.split(\"\\n\")\nrow = ENV['TM_LINE_NUMBER'].to_i\ncol = ENV['TM_LINE_INDEX'].to_i\ncurrentLine = lines[row-1]\nfound = currentLine.scan(/\\[\\d+\\]/)[0]\nif found then\n# No need to change the file at all in this case. Just locate the proper \n# line and use the txmt scheme to take us there.\n  txt = text.slice(0..text.rindex(found)+found.length)\n  lines = txt.split(\"\\n\")\n  line = lines.length\n  column = lines.last.length + 1\n  `open \"txmt://open?line=\#{line}&column=\#{column}\"`\n  TextMate.exit_discard \n  # print text.insert(text.rindex(found)+found.length + 1,\"$0\")\nelse\n  m = text.scan(/\\[(\\d+)\\]/).map{|i| i[0].to_i}.max || 0\n  before = []\n  (row-1).times do before << lines.shift end\n  # cl = lines.shift\n  if lines[0] =~ /(?:due|at|from):/ then\n    before << lines[0].slice!(/^.*(?=\\s(?:due|at|from):)/)\n  else\n    before << lines.shift\n    lines.unshift(\"\")\n  end\n  print e_sn(before.join(\"\\n\") + \" [\#{m+1}]\" + lines.join(\"\\n\")) + \"\\n[\#{m+1}] $0\"\nend",
  fallbackInput: "document",
  input: "selection",
  keyEquivalent: "^{",
  name: "Go to Note",
  output: "insertAsSnippet",
  scope: "text.gtdalt - meta.note",
  uuid: "BF20459A-D83B-4821-A68D-06F3D885309C"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby\nrequire ENV['TM_BUNDLE_SUPPORT'] + '/lib/GTD.rb'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'\ninclude GTD\nfiles = GTD.process_directory\nprojects = files.map{|i| i.projects}.flatten\nprojectNames = projects.map{|i| i.name+\" : \"+i.root.name}\nrequire 'pp'\nchoice = TextMate::UI.menu(projectNames)\nif choice then\n\tprojectName = projectNames[choice]\n  project = projects.find{|i| i.name+\" : \"+i.root.name == projectName}\nputs project.txmt\n  `open \"\#{project.txmt}\"`\nend",
  fallbackInput: "word",
  input: "none",
  keyEquivalent: "^G",
  name: "Go to Project",
  output: "discard",
  scope: "text.gtdalt",
  uuid: "A54CF0C9-ECBF-4A20-B345-3EA167ABD6A0"},
 {beforeRunningCommand: "nop",
  bundleUUID: "30FA6EB3-2180-46F8-B2DD-EDA6B443CBB6",
  command: 
   ". \"$TM_SUPPORT_PATH/lib/webpreview.sh\"\nhtml_header \"GTDalt Help\" \"Getting Things Done (alternative)\"\nMarkdown.pl \"$TM_BUNDLE_SUPPORT/README.txt\"\nhtml_footer",
  fallbackInput: "word",
  input: "none",
  name: "Help",
  output: "showAsHTML",
  scope: "text.gtdalt",
  uuid: "8E083C6C-9C1A-4AD9-AA39-3BCABF925B73"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nrequire 'date'\nlines = STDIN.readlines\nfor line in lines\n  if line =~ /^(#completed:)(\\[\\d{4}-\\d{2}-\\d{2}\\])(.*)/ then\n  \tprint $3\n  elsif line =~ /^\\s*@/\n\tprint \"#completed:[\#{Date.today}]\#{line}\"\n  else\n\tprint line\n  end\nend\n",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "@/",
  name: "Mark as Complete",
  output: "replaceSelectedText",
  scope: "text.gtdalt",
  uuid: "A9C04B17-6A04-4D4D-81ED-2F4EFCD61FA3"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nrequire ENV['TM_BUNDLE_SUPPORT'] + '/lib/GTDUtils.rb'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'\ncontextList = GTDContexts.contexts\nchoice = TextMate::UI.menu(contextList)\nif choice then\n  print \"@\#{contextList[choice]} \"\nelse\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes.rb'\n  TextMate.exit_discard\nend\n",
  input: "none",
  keyEquivalent: "@",
  name: "New",
  output: "afterSelectedText",
  scope: "text.gtdalt - meta.action - meta.line.project - meta.note",
  uuid: "BBA04431-8960-4017-A684-7FBACB0F7FFF"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nline = ENV['TM_CURRENT_LINE']\nrequire ENV['TM_SUPPORT_PATH'] + \"/lib/escape.rb\"\nmatch = line.match('(\\s*@\\S+)')\nprint \"\#{e_sn line}\\n\#{e_sn match[1]} $0\"\n",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "$",
  name: "New With Same Context",
  output: "insertAsSnippet",
  scope: "text.gtdalt meta.action",
  uuid: "65FAC309-42DC-4C48-AC0D-BC7AA5864C71"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nlinks = STDIN.read.scan(/<([^>]*)>/)\nlinks.each do |link|\n  `open \"\#{link}\"`\nend",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "^l",
  name: "Open Links in Line",
  output: "discard",
  scope: "text.gtdalt",
  uuid: "65E842B0-D1A6-40E7-91C0-3215930AC0EA"},
 {beforeRunningCommand: "nop",
  bundleUUID: "30FA6EB3-2180-46F8-B2DD-EDA6B443CBB6",
  command: 
   "#!/usr/bin/env ruby\nrequire 'date'\n$: << ENV['TM_BUNDLE_SUPPORT']\nrequire \"lib/GTD.rb\"\ninclude GTD\n\nobjects = GTD.process_directory\ngtdacts = objects.map{|o| o.actions}.flatten\ngtdprojects = objects.map{|o| o.projects}.flatten\n\nclass LogProject\n  def initialize(date,name)\n    @date = date\n    @name = name\n  end\n  def getprojects\n    return @name\n  end\nend\n\nclass LogAction\n  def initialize(date,project,context,name)\n    @date = date\n    @project = project\n    @context = context\n    @name = name\n  end\n  def getcontexts\n    return @context\n  end\n  def getprojects\n    return @project\n  end\nend\n\nacts = Array.new\nprojects = Array.new\n\ntoday = Date.today\nreview = today - 7\n\nlogfile = File.join(GTD.get_gtd_directory,\"GTD.gtdlog\")\nif File.exists?(logfile) then\n  log = File.open(logfile)\nelse\n  puts \"Log file \#{logfile} not found. Review requires this file. You should run the Clean Current File command to generate a log file.\"\n  exit\nend\n\nlog.readlines.each { |line|\n  if line =~ /^\\/(.*)\\/(.*)(\\/@(\\S+))?/ then\n    logdate = Date.strptime($1, '%Y-%m-%d')\n    if logdate >= review then\n      project = $2\n      if line =~ /^\\/(.*)\\/(.*)\\/@(\\S+)\\s(.*)$/\n        logact = LogAction.new($1.to_s,$2.to_s,$3.to_s,$4.to_s)\n        acts << logact\n      else\n        # logproj = LogProject.new(logdate.to_s,project)\n        projects << LogProject.new(logdate.to_s,project)\n      end\n    end\n  end\n}\n\npr = Printer.new\nb = <<HTML\n<html>\n  <head>\n    <link rel=\"stylesheet\" href=\"tm-file://\#{ENV['TM_SUPPORT_PATH']}/css/default.css\" type=\"text/css\" media=\"screen\" title=\"no title\" charset=\"utf-8\" />\n    <style type=\"text/css\">\n      .nobr {white-space: nowrap}\n    </style>\n  </head>\n  <body>\n  <h1>GTD Review (\#{review} - \#{Date.today})</h1>\nHTML\ne = <<HTML\n  </body>\n</html>\nHTML\npr.raw b\n\n\npComplete = Array.new\nprojects.each {|p| pComplete << p.getprojects }\nif not pComplete.empty? then\n  pComplete = pComplete.uniq.sort\n  pr.raw \"<h2>Projects completed</h2><ul>\"\n  pComplete.each {|p| \n    pr.raw \"<li>\#{p}\"\n  }\n  pr.raw \"</ul>\"\nend\n\nif not acts.empty? then\n  pUsed = Array.new\n  acts.each {|p| pUsed << p.getprojects }\n  pUsed = pUsed.uniq.sort\n  diffarray = Array.new\n  gtdprojects.each{|p| diffarray << p.name }\n  projectsDiff = diffarray - pUsed\n  projectsDiff = projectsDiff.uniq.sort\n  if not projectsDiff.empty? then\n    pr.raw \"<h2>Projects not acted on</h2>\"\n    pr.table do\n      pr.headers([ \"Project\", \"Next Action\", \"Context\", \"Due by\", \"Completed\"])\n      projectsDiff.each{|p| \n      project = gtdprojects.find{|i| i.name == p}\n\t  if project.next_action then\n        if project.next_action.note then\n          text = \"\#{project.next_action.link} / \#{project.next_action.note}\"\n        else\n          text = project.next_action.link\n        end\n        due = case project.next_action.due\n          when \"\",nil\n            \"\"\n          when DateLate\n            \"<span style=\\\"color:red\\\">\#{project.next_action.due}</span>\"\n          else\n            project.next_action.due\n        end\n        pr.row([project.link, text, \"<span class=\\\"nobr\\\">\#{project.next_action.context}</span>\", \"<span class=\\\"nobr\\\">\#{due}</span>\", project.next_action.mark_completed_link])\n    end\n    }\n    end # pr.table\n  end\nelse  # if acts is empty\n  pr.raw \"<h2>No logged activity to report</h2>\"\nend\n  \npr.raw \"<h2>Dated Actions</h2>\"\npr.table do\n  pr.headers([ \"Context\", \"Action\", \"Project\", \"Due by\", \"Completed\"])\n  gtdacts.delete_if {|a| a.due == nil }\n  gtdacts.sort{|a,b| a.due <=> b.due}.each do |a|\n    proj = if a.project != nil then a.project.link else \"none\" end\n    if a.due != nil then\n      due = case a.due\n        when \"\",nil\n          \"\"\n        when DateLate\n          \"<span style=\\\"color:red\\\">\#{a.due}</span>\"\n        else\n          a.due\n      end\n      text = \"<a href=\\\"\#{a.txmt}\\\">\#{a.name}</a>\"\n      pr.row([a.context, text, proj , \"<span class=\\\"nobr\\\">\#{due}</span>\", a.mark_completed_link])\n    end\n  end\nend\n\npr.raw e\nputs pr.to_html",
  input: "selection",
  keyEquivalent: "^~@-",
  name: "Past Activity",
  output: "showAsHTML",
  scope: "text.gtdalt",
  uuid: "BB5DCAEF-2D31-47BC-B4D5-C221F026B2F3"},
 {beforeRunningCommand: "nop",
  command: 
   "####  NOT VERY MUCH TESTED  ####\n####      USE WITH CARE     ####\n\"$TM_BUNDLE_SUPPORT/bin/process_inbox.rb\"\n",
  fallbackInput: "word",
  input: "none",
  keyEquivalent: "^~@=",
  name: "Process Actions From Inbox File",
  output: "openAsNewDocument",
  scope: "text.gtdalt",
  uuid: "FCAAFD28-1765-4618-851D-20AA52499F77"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n$:<< ENV['TM_BUNDLE_SUPPORT'] << ENV['TM_SUPPORT_PATH']\nrequire \"lib/GTD.rb\"\nrequire \"lib/ui\"\ninclude GTD\nGTD.process_directory\nprojects = GTD.projects.find_all{|proj| !proj.completed?}\npr = Printer.new\nb = <<HTML\n<html>\n  <head>\n    <link rel=\"stylesheet\" href=\"tm-file://\#{ENV['TM_SUPPORT_PATH']}/css/default.css\" type=\"text/css\" media=\"screen\" title=\"no title\" charset=\"utf-8\" />\n  </head>\n  <body>\nHTML\ne = <<HTML\n  </body>\n</html>\nHTML\npr.raw b\npr.table do\n  pr.title \"List of all incomplete Projects\"\n  pr.headers([ \"Project\", \"Items\", \"Next Action\"])\n  projects.each do |project|\n    pr.row([project.link,\n            project.flatten.reject{|i| i.completed? }.length-1,\n            project.next_action.link])\n  end\nend\npr.raw e\nputs pr.to_html",
  fallbackInput: "line",
  input: "none",
  keyEquivalent: "^~@p",
  name: "Project Statistics",
  output: "showAsHTML",
  scope: "text.gtdalt",
  uuid: "BF7C70D8-A0D9-44A3-9CB4-8D99372E68B6"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\ndialog = ENV['TM_SUPPORT_PATH'] + '/bin/tm_dialog'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/osx/plist'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/escape'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes'\nrequire 'date'\nline = STDIN.read\nif line =~ / (at|due|from):\\[(\\d{4})-(\\d{2})-(\\d{2})\\]$/\nabsoluteYear, absoluteMonth, absoluteDay = $2.to_i, $3.to_i, $4.to_i\nweekdayDay = 0\ndate = Date.new(absoluteYear,absoluteMonth,absoluteDay)\nelse\n  date = Date.today\n  absoluteYear, absoluteMonth, absoluteDay = date.year, date.month, date.day\n  weekdayDay = date.wday\nend\ntod = Date.today\ndef to_cocoa_date(date)\n  ((date - Date.new(2001, 1, 1)+1)* 3600 * 24).to_i\nend\ndef from_cocoa_date(number)\n  Date.new(2001,1,1)+number.to_i/(3600 * 24) - 1\nend\ndef myformat(date)\n  date.strftime(\"%A, %m/%d/%Y\")\nend\nplist = { \n  'currentDeadline' => \"Current value: \" + myformat(date),\n  'daysFromToday' => \"Current value: \" + (date - tod).to_s,\n  'newDeadlineDate' => to_cocoa_date(date),\n  'newDaysFromToday' => (date - tod).to_i,\n  'today' => \"Today is \" + myformat(tod)\n}.to_plist\nstr = `\#{e_sh dialog} datePicker -mp \#{e_sh plist}`\nres=OSX::PropertyList.load(str)\nif res['returnButton'].to_s != \"OK\" then\n  newDate = nil\nelse\n  newDate = res['newDeadlineDate'].to_s\n  if newDate =~ /^[\\d\\+\\-*]+$/\n    newDate = (tod + eval(res['newDaysFromToday'].to_s).to_i)\n  else\n    newDate =~ /^\\w{3} (\\w{3}) (\\d{2}) \\d{2}:\\d{2}:\\d{2} \\w{3} (\\d{4})/\n    newDate = Date.new($3.to_i,Date::ABBR_MONTHNAMES.index($1),$2.to_i)-1\n  end\nend\n#puts res['newDeadlineDate']/(3600*24)\n#pp from_cocoa_date(res['newDeadlineDate']).to_s\nif newDate.nil?\n  TextMate.exit_discard\nelse\n  print e_sn(line).gsub(/ (at|due|from):\\[\\d{4}-\\d{2}-\\d{2}\\]$/,\"\") + \" \#{if $1 && $1 != \"\" then $1 else \"\\$0due\" end}:[\#{newDate}]\"\nend\n",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "#",
  name: "Set Date",
  output: "insertAsSnippet",
  scope: "text.gtdalt meta.action",
  uuid: "7FBD47E6-F919-45C0-956C-3996106E0C49"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nlines = STDIN.readlines\nrow = ENV['TM_LINE_NUMBER'].to_i\ncurrentLine = lines[row-1]\nfound = currentLine[/\\[\\d+\\]/]\nif found then\n  note = lines.find{ |line| line[/^\\[\\d+\\]/] == found }\n  note.slice!(/^\\[\\d+\\]\\s+/)\n  print note\nelse\n  print \"This action does not have a note.\"\nend",
  fallbackInput: "document",
  input: "document",
  keyEquivalent: "^?",
  name: "Show Note as Tool Tip",
  output: "showAsTooltip",
  scope: "text.gtdalt meta.action",
  uuid: "3BF349AD-3452-4CA4-AAA7-8836565E3A5F"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nrequire ENV['TM_SUPPORT_PATH']+\"/lib/progress.rb\"\nTextMate.call_with_progress(:title=> \"Synchronizing with iCal\" , :message =>\"This may take a while...\") {\n#`osascript \"$TM_BUNDLE_SUPPORT/bin/gtdalt_ical_synchronization.applescript\"`\n\n`osascript \"$TM_BUNDLE_SUPPORT/bin/gtdalt_ical_synchronization.scpt\"`\n}",
  input: "none",
  keyEquivalent: "^~@i",
  name: "Synchronize with iCal",
  output: "discard",
  scope: "text.gtdalt",
  uuid: "EB99AA83-E73B-42F6-88E1-6F8AB29F9BFD"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby\nlines = STDIN.read.gsub(/\\$/,\"\\\\$\").split(\"\\n\")\ncurrentTab = lines[0].scan(/^\\s*/)[0]\nunless ENV['TM_SOFT_TABS'] == \"YES\" then\n\textraTab = \"\\t\"\nelse\n\textraTab = (\" \" * ENV['TM_TAB_SIZE'].to_i)\nend\nprint lines.map{|i| extraTab + i}.unshift(currentTab + \"project $0\").push(currentTab + \"end\").join(\"\\n\") + \"\\n\"",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "^W",
  name: "With Selection",
  output: "insertAsSnippet",
  scope: "text.gtdalt",
  uuid: "253F6CF9-0E14-48C8-8468-005018E4E301"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby\nrequire ENV['TM_BUNDLE_SUPPORT']+\"/lib/GTD.rb\"\ninclude GTD\nfile = ENV['TM_FILEPATH']\nobj = GTDFile.new(file)\nobj.cleanup_projects\nlog = File.open(File.join(File.dirname(file),\"GTD.gtdlog\"),\"a\")\n\tlog.write MyLogger.dump + \"\\n\"\nlog.close\nputs obj.dump_object",
  input: "none",
  keyEquivalent: "*",
  name: "clean completed tasks",
  output: "replaceDocument",
  scope: "text.gtdalt",
  uuid: "7118880F-C5BA-4359-87A1-480FB61E416B"}]
