[TxMt] Little problem with c++ macro
José Manuel
buscarini at gmail.com
Sat Apr 22 20:07:41 UTC 2006
Wow, thank you very much, the new macro should be really usefull.
I think I may have a problem with the installation of TextMate,
because running /usr/local/bin/mate inside the command makes TextMate
freeze. This is the whole command:
#!/usr/bin/env ruby
require '/Library/Scripts/scopeHandler.rb'
handler = ScopeHandler.new(STDIN)
caret = ENV['TM_LINE_NUMBER'].to_i
found = false
line = 0
notIncludes = true;
for classNode in handler.find_all{|n|
(n.scopeName == "string.quoted.lt-gt.include.c") &&
(n.parent.scopeName == "other.preprocessor.c.include")}
notIncludes = false;
txt = classNode.data
txt = txt.gsub(%r{\A\<\;|\>\;\z},"")
if (txt == "iostream")
found = true
end
line = classNode.coords[0]
end
if (!found)
if (notIncludes)
print "#include <iostream>\n"
caret +=1
end
for textNode in handler.find_all{|n| n.text?}
print textNode.data.unescapeScope
if ((textNode.coords[0]==line)&&
(textNode.data.unescapeScope[-1,1]=="\n"))
print "#include <iostream>\n\n"
caret +=1
end
end
else
for textNode in handler.find_all{|n| n.text?}
print textNode.data.unescapeScope
end
end
print caret
ENV['CARET'] = caret.to_s
`/usr/local/bin/mate "$TM_FILEPATH" 2>/dev/null &`
This is probably not the best way to do it, but I'm new to this, so
feel free to correct me.
José Manuel Sánchez
Polytechnical University of Valencia
Spain
El 22/04/2006, a las 2:05, Allan Odgaard escribió:
> On 21/4/2006, at 17:26, José Manuel wrote:
>
>> [...] I have tried with this line at the end of the command (which
>> is in Ruby):
>>
>> `/usr/local/bin/mate "$TM_FILEPATH" -l $CARET'`
>>
>> but it makes TextMate freeze.
>
> I assume $CARET is the new line number? Try instead this (I wrapped
> $CARET as I think you meant it to be):
>
> `/usr/local/bin/mate "$TM_FILEPATH" -l #{$CARET} 2>/dev/null &`
>
> An alternative approach is the “replace document with snippet” as
> recently discussed [1].
>
> Inspired by this letter, I put a macro in the C bundle which
> inserts missing includes in the top of the document. The key
> equivalent is ctrl-# -- it’s not perfect, but it’s a good start :)
>
>
> [1] http://lists.macromates.com/pipermail/textmate/2006-April/
> 009742.html
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
More information about the textmate
mailing list