[TxMt] View List Problem

Mike Mellor alaskamike at gmail.com
Tue Jul 11 07:01:20 UTC 2006


I am trying to modify my view lists command.  It is based on the TODO  
bundle command, but I am trying to use string comparison instead of  
regexp to test lines.  As far as I can tell, the sorting is going ok,  
but I'm having trouble with the output.  It seems to show everything  
except for the task itself (the content).  Here is the code, any idea  
what's going wrong?  Thanks.

Mike


#!/usr/bin/env ruby

$myPath = ENV['TM_DIRECTORY']
	
$tags = [] #user defined contexts

def readContexts(a)
   # processes contexts.gtd into script
   context, tabCommand, tabString, regex, color = a.split(/\|/)
   $tags.push({:label => context, :regexp => regex, :color =>  
color, :matches => []})
end


require "#{ENV['TM_SUPPORT_PATH']}/lib/textmate"
require "erb"
include ERB::Util

def TextMate.file_link (file, line = 0)
   return "txmt://open/?url=file://" +
     file.gsub(/[^a-zA-Z0-9.-\/]/) { |m| sprintf("%%%02X", m[0]) } +
     "&line=" + line.to_s
end

# the contexts.gtd file is read, and converted into $contexts
file = File.open($myPath+"/contexts.gtd", "r")
file.each do |line|
   readContexts(line)
end

# sorting happens
$tags.each do |tag|
     context = tag[:label]
     myFiles = Dir.entries($myPath)
     myFiles.each do |fileName|
       if (fileName[-3,3] == "gtd") and (fileName != "contexts.gtd")
         lineno = 0
         mFile = File.open(fileName)
         mFile.each do |line|
           lineno = lineno + 1
           re = /\s/
           ctask = re.match(line)
           if ctask.pre_match == context
             results = {
               :file => fileName[0..-5],
               :line => lineno,
               :content => ctask.post_match
             }
             results[:match] = html_escape($1)
             tag[:matches] << results
           end
         end
       end
     end
end

tmpl_file = "#{ENV['TM_BUNDLE_SUPPORT']}/template.rhtml"
puts ERB.new(File.open(tmpl_file), 0, '<>').result



More information about the textmate mailing list