Permalink
Browse files

commands

  • Loading branch information...
James Wilson
James Wilson committed Apr 22, 2010
1 parent a1cf683 commit 5e25accdfc2fcee38e2540cdec3bf05a34a9fe0b
Showing with 78 additions and 0 deletions.
  1. +39 −0 Commands/Convert to Delete.tmCommand
  2. +39 −0 Commands/Convert to Set.tmCommand
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>#!/usr/bin/env ruby
+
+stack = Array.new
+action ||= 'delete'
+
+ENV['TM_SELECTED_TEXT'].each_line do |line|
+ if line =~ /([^\{]+)\{\s*$/ then
+ # Line ends with a {, push it on to the stack
+ stack &lt;&lt; $1.strip
+ end
+ if line =~ /([^;]+);\s*$/ then
+ # Line ends with a ;, print the full delete line
+ puts "#{action} #{stack * ' '} #{$1.strip}"
+ end
+ if line =~ /\}\s*$/ then
+ # Line ends with a }, pop last item off stack
+ stack.pop
+ end
+end
+</string>
+ <key>input</key>
+ <string>selection</string>
+ <key>keyEquivalent</key>
+ <string>@&lt;</string>
+ <key>name</key>
+ <string>Convert to Delete</string>
+ <key>output</key>
+ <string>replaceSelectedText</string>
+ <key>uuid</key>
+ <string>3E8B7E0E-B74E-45D3-930D-D3D91C4CD0CB</string>
+</dict>
+</plist>
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>#!/usr/bin/env ruby
+
+stack = Array.new
+action ||= 'set'
+
+ENV['TM_SELECTED_TEXT'].each_line do |line|
+ if line =~ /([^\{]+)\{\s*$/ then
+ # Line ends with a {, push it on to the stack
+ stack &lt;&lt; $1.strip
+ end
+ if line =~ /([^;]+);\s*$/ then
+ # Line ends with a ;, print the full delete line
+ puts "#{action} #{stack * ' '} #{$1.strip}"
+ end
+ if line =~ /\}\s*$/ then
+ # Line ends with a }, pop last item off stack
+ stack.pop
+ end
+end
+</string>
+ <key>input</key>
+ <string>selection</string>
+ <key>keyEquivalent</key>
+ <string>@&gt;</string>
+ <key>name</key>
+ <string>Convert to Set</string>
+ <key>output</key>
+ <string>replaceSelectedText</string>
+ <key>uuid</key>
+ <string>2BBAD1DB-87C1-443C-8C1D-B2BD1791E184</string>
+</dict>
+</plist>

0 comments on commit 5e25acc

Please sign in to comment.