I was probably a little too brief on the description of my problem...<br>I am trying to modify a command in the GTD bundle that is based on a command in the TODO bundle. The command goes through all of the files in a given directory, and creates a list grouped by the context of each line in the files that is displayed as an HTML document. The TODO version greps each line, which is problematic when I have similar contexts, such as TASK and WORK_TASK (also, having a context word in any other line will also generate a false true). I have modified the code to compare string values for the context and the first word in each line. I think that this comparison is working properly, but I am having trouble with the resulting list. It should show a context as a header, then the file name, line number, and content of each line for that context. It currently shows the filename and line number, but not the content.
<br><br>With that additional information, can anyone see what's going wrong? Thanks.<br><br>Mike<br><br><div><span class="gmail_quote">On 7/10/06, <b class="gmail_sendername">Mike Mellor</b> <<a href="mailto:alaskamike@gmail.com">
alaskamike@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I am trying to modify my view lists command. It is based on the TODO
<br>bundle command, but I am trying to use string comparison instead of<br>regexp to test lines. As far as I can tell, the sorting is going ok,<br>but I'm having trouble with the output. It seems to show everything<br>except for the task itself (the content). Here is the code, any idea
<br>what's going wrong? Thanks.<br><br>Mike<br><br><br>#!/usr/bin/env ruby<br><br>$myPath = ENV['TM_DIRECTORY']<br><br>$tags = [] #user defined contexts<br><br>def readContexts(a)<br> # processes contexts.gtd into script
<br> context, tabCommand, tabString, regex, color = a.split(/\|/)<br> $tags.push({:label => context, :regexp => regex, :color =><br>color, :matches => []})<br>end<br><br><br>require "#{ENV['TM_SUPPORT_PATH']}/lib/textmate"
<br>require "erb"<br>include ERB::Util<br><br>def TextMate.file_link (file, line = 0)<br> return "txmt://open/?url=file://" +<br> file.gsub(/[^a-zA-Z0-9.-\/]/) { |m| sprintf("%%%02X", m[0]) } +
<br> "&line=" + line.to_s<br>end<br><br># the contexts.gtd file is read, and converted into $contexts<br>file = File.open($myPath+"/contexts.gtd", "r")<br>file.each do |line|<br> readContexts(line)
<br>end<br><br># sorting happens<br>$tags.each do |tag|<br> context = tag[:label]<br> myFiles = Dir.entries($myPath)<br> myFiles.each do |fileName|<br> if (fileName[-3,3] == "gtd") and (fileName != "
contexts.gtd")<br> lineno = 0<br> mFile = File.open(fileName)<br> mFile.each do |line|<br> lineno = lineno + 1<br> re = /\s/<br> ctask = re.match(line)<br> if
ctask.pre_match == context<br> results = {<br> :file => fileName[0..-5],<br> :line => lineno,<br> :content => ctask.post_match<br> }<br> results[:match] = html_escape($1)
<br> tag[:matches] << results<br> end<br> end<br> end<br> end<br>end<br><br>tmpl_file = "#{ENV['TM_BUNDLE_SUPPORT']}/template.rhtml"<br>puts ERB.new(File.open(tmpl_file), 0, '<>').result
<br></blockquote></div><br>