Commit 0482ecee18b58258dc3fab91501f53ce31806447

initial import

git-svn-id: https://productivity-bundle.googlecode.com/svn/trunk@2 5d95301e-d744-0410-833b-1f084d6e47ab

Commit diff

Commands/Cleanup windows.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>"$TMTOOLS" close allAuxiliaryWindows</string>
9 <key>input</key>
10 <string>none</string>
11 <key>name</key>
12 <string>Cleanup windows</string>
13 <key>output</key>
14 <string>discard</string>
15 <key>uuid</key>
16 <string>7BEFC54B-D3FD-4B88-916A-2E80304D5CD2</string>
17</dict>
18</plist>
toggle raw diff

Commands/Complete word from all open documents.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_tm_helpers.rb"
11require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
12
13project_directory = ENV["TM_PROJECT_DIRECTORY"]
14
15if project_directory.nil?
16 puts "This command can only be used in a project"
17 exit_show_tool_tip
18end
19
20open_files = `"$TMTOOLS" get openProjectFiles '{format=plain;}'`.split("\n")
21
22
23# phase one - autocomplete from all words, regardless of order
24# current_file = ENV['TM_FILEPATH']
25
26file_contents = open_files.map{|f| File.read(f) }
27
28file_words = file_contents.map{|fc| fc.gsub(/[^a-z0-9_]/i, " ").split(/ +/).uniq}.flatten.uniq.sort
29
30current_word = `"$TMTOOLS" get wordHead`
31current_word_regexp = Regexp.new(/^#{current_word}.+/)
32matching_words = file_words.select{|w| current_word_regexp.match(w) }
33
34word =
35 if matching_words.length&gt;1
36 w_index = TextMate::UI.menu(matching_words)
37 exit_discard if w_index.nil?
38 matching_words[w_index]
39 else
40 matching_words.first
41 end
42
43if word.nil?
44 puts "No matches"
45 exit_show_tool_tip
46end
47
48$&gt; &lt;&lt; word[current_word.length..-1]
49
50exit_insert_text</string>
51 <key>input</key>
52 <string>document</string>
53 <key>keyEquivalent</key>
54 <string>@;</string>
55 <key>name</key>
56 <string>Complete word from all open documents</string>
57 <key>output</key>
58 <string>showAsTooltip</string>
59 <key>uuid</key>
60 <string>5011F1E1-74CF-4D63-B901-1E2FB7760AFE</string>
61</dict>
62</plist>
toggle raw diff

Commands/Convert XML to Builder::XMLMarkup.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_tm_helpers.rb"
11input = $stdin.read
12
13if input.empty?
14 puts "Please select something"
15 exit_show_tool_tip
16end
17
18
19cdatas = []
20input.gsub!(/&lt;!\[CDATA\[(.+?)\]\]&gt;/m) { |m| cdatas &lt;&lt; $1; "&lt;!!CDATA!!&gt;"}
21
22output = ""
23
24def convert_params(params = "")
25 params = params.dup
26 prefix = ""
27 params.gsub!(/ *([a-z0-9_]+) *= *(['"])(.*?)\2/i) do
28 o="#{prefix}:#{$1} =&gt; #{$2}#{$3}#{$2}"
29 prefix = ", "
30 o
31 end
32 params.strip!
33 params
34end
35
36ignore_next_close = false
37
38input.scan(/(&lt;[^&gt;]+&gt;)([^&lt;]*)/m).each do |tag, space|
39 new_line_required = false
40 case tag
41 when "&lt;!!CDATA!!&gt;"
42 output &lt;&lt; "x.cdata!(#{cdatas.shift.inspect})"
43 new_line_required = true
44 when /&lt;\?([^\s\/&gt;]+)\s*(.*?)\?&gt;/
45 tag_name = $1
46 params = $2.strip
47
48 output &lt;&lt; "x.instruct! :#{tag_name}"
49 output &lt;&lt; ", #{convert_params(params)}" unless params.empty?
50 new_line_required = true
51 when /^&lt;\/([^\s\/&gt;]+)\s*&gt;/
52 unless ignore_next_close
53 output &lt;&lt; "}"
54 end
55 new_line_required = true
56 ignore_next_close = false
57 when /^&lt;([^\s\/&gt;]+)\s*(.*?)(\/){0,1}\s*&gt;/
58 tag_name = $1
59 params = $2
60 self_closing = ($3 == "/")
61
62 tag_name.strip!
63 params = convert_params(params)
64 has_params = ! params.empty?
65
66 if /[^\s]/.match(space)
67 output &lt;&lt; "x.#{tag_name} #{space.inspect}"
68 output &lt;&lt; ", #{params}" unless params.empty?
69 ignore_next_close = true
70 new_line_required = false
71 space = ""
72 else
73 output &lt;&lt; "x.#{tag_name}"
74 if self_closing
75 new_line_required = true
76 output &lt;&lt; " #{params}" if has_params
77 else
78 output &lt;&lt; "(#{params})" if has_params
79 output &lt;&lt; " { "
80 end
81 end
82 end
83
84 output &lt;&lt; "; " if new_line_required unless space.include?("\n")
85
86 output &lt;&lt; space
87end
88
89puts output</string>
90 <key>fallbackInput</key>
91 <string>none</string>
92 <key>input</key>
93 <string>selection</string>
94 <key>name</key>
95 <string>Convert XML to Builder::XMLMarkup</string>
96 <key>output</key>
97 <string>replaceSelectedText</string>
98 <key>uuid</key>
99 <string>3E287237-8082-4068-8B31-0F814338710E</string>
100</dict>
101</plist>
toggle raw diff

Commands/Debug - Copy inspection to clipboard as YAML.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_inspect_helpers.rb"
11
12i = RDebugInspect.new
13
14IO.popen('pbcopy', 'w'){ |pb| pb.puts( i.inspect_as_yaml )};
15
16puts "Copied value of #{i.what} to clipboard"</string>
17 <key>input</key>
18 <string>document</string>
19 <key>keyEquivalent</key>
20 <string>^~i</string>
21 <key>name</key>
22 <string>Debug - Copy inspection to clipboard as YAML</string>
23 <key>output</key>
24 <string>showAsTooltip</string>
25 <key>uuid</key>
26 <string>90E13791-96CC-4380-8344-48EB84D9E616</string>
27</dict>
28</plist>
toggle raw diff

Commands/Debug - Copy inspection to clipboard as pretty print.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_inspect_helpers.rb"
11
12i = RDebugInspect.new
13
14IO.popen('pbcopy', 'w'){ |pb| pb.puts( i.inspect_as_pp )};
15
16puts "Copied value of #{i.what} to clipboard"</string>
17 <key>input</key>
18 <string>document</string>
19 <key>keyEquivalent</key>
20 <string>^~i</string>
21 <key>name</key>
22 <string>Debug - Copy inspection to clipboard as pretty print</string>
23 <key>output</key>
24 <string>showAsTooltip</string>
25 <key>uuid</key>
26 <string>B79A89E1-3301-499B-9D5E-5E0B87EB15BD</string>
27</dict>
28</plist>
toggle raw diff

Commands/Debug - Copy inspection to clipboard as string.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_inspect_helpers.rb"
11
12i = RDebugInspect.new
13
14IO.popen('pbcopy', 'w'){ |pb| pb &lt;&lt; ( i.inspect_as_string )};
15
16puts "Copied value of #{i.what} to clipboard"
17</string>
18 <key>input</key>
19 <string>document</string>
20 <key>keyEquivalent</key>
21 <string>^~i</string>
22 <key>name</key>
23 <string>Debug - Copy inspection to clipboard as string</string>
24 <key>output</key>
25 <string>showAsTooltip</string>
26 <key>uuid</key>
27 <string>C6EC1187-A816-4B38-9975-F2E84C67B7C6</string>
28</dict>
29</plist>
toggle raw diff

Commands/Debug Experiment RSpec.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/spec_debugger"
10
11SpecDebugger.run(:file)</string>
12 <key>fallbackInput</key>
13 <string>line</string>
14 <key>input</key>
15 <string>selection</string>
16 <key>name</key>
17 <string>Debug - RSpec Examples</string>
18 <key>output</key>
19 <string>showAsHTML</string>
20 <key>scope</key>
21 <string>source.ruby.rspec</string>
22 <key>uuid</key>
23 <string>95931CFC-B32A-46A6-9214-CA33D2880981</string>
24</dict>
25</plist>
toggle raw diff

Commands/Debug Experiment.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/rdebug_helpers.rb"
10
11
12Thread.new {
13 # fire up an external terminal window for the debug console
14 require 'appscript'
15 term = Appscript::app("Terminal")
16 term.activate
17 term.do_script "cd #{ENV['TM_PROJECT_DIRECTORY'].to_s.inspect} &amp;&amp; rdebug -c"
18}
19
20init_dbg_breakpoint("load #{ENV['TM_FILEPATH'].to_s.inspect}")
21
22ARGV &lt;&lt; "-s"
23ARGV &lt;&lt; RUN_FILE
24
25load 'rdebug'</string>
26 <key>fallbackInput</key>
27 <string>line</string>
28 <key>input</key>
29 <string>selection</string>
30 <key>name</key>
31 <string>Debug - Run current file</string>
32 <key>output</key>
33 <string>showAsHTML</string>
34 <key>uuid</key>
35 <string>61FE0786-CB5F-4E8F-8DFD-03C0128CDE50</string>
36</dict>
37</plist>
toggle raw diff

Commands/Delete All Breakpoints.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_cmd.rb"
11
12cmd = "del"
13msg = 'Breakpoints deleted.'
14
15dcmd = DebuggerCmd.new
16dcmd.send_command(cmd, msg)</string>
17 <key>fallbackInput</key>
18 <string>line</string>
19 <key>input</key>
20 <string>selection</string>
21 <key>keyEquivalent</key>
22 <string>^@b</string>
23 <key>name</key>
24 <string>Debug - Delete All Breakpoints</string>
25 <key>output</key>
26 <string>showAsTooltip</string>
27 <key>uuid</key>
28 <string>5193D698-4392-494D-946B-7D9BF1B7C9CA</string>
29</dict>
30</plist>
toggle raw diff

Commands/Go to file.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_tm_helpers.rb"
11require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/grep_helpers.rb"
12require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
13project_directory = ENV['TM_PROJECT_DIRECTORY']
14
15filepath = tm_expanded_selection(
16 :backward =&gt; /[\w\/.]+/,
17 :forward =&gt; /[\w\/.]+(:\d+){0,1}/
18).strip
19
20filepath = TextMate::UI.request_string(:title =&gt; "Go to file", :prompt =&gt; "Enter a filename with path", :default =&gt; "" ) if filepath.empty?
21
22if filepath.nil? || filepath.empty?
23 puts "Canceled"
24 exit_show_tool_tip
25end
26
27
28if /^\//.match(filepath) &amp;&amp; File.exists?(filepath)
29 tm_open(filepath)
30 exit_show_tool_tip
31end
32
33line = nil
34if /^(.+):(\d+)$/.match(filepath)
35 filepath = $1
36 line = $2
37end
38
39filepath.gsub!(/\.{1,2}\//, "")
40filepath.gsub!(/^\//, "") # remove the beginning slash
41
42/^(.*\/){0,1}([^\/]+)$/.match(filepath)
43dir = $1
44file = $2
45regexp = /(^|\/)#{dir}_{0,1}#{file}($|\b[^\/]*$)/
46
47
48Dir.chdir(project_directory)
49results = Finder.new(".").results
50
51matches = []
52
53results.each do |result|
54 matches &lt;&lt; result if regexp.match(result)
55end
56
57if matches.length &gt; 1
58 i = TextMate::UI.menu(matches)
59 exit_discard if i.nil?
60 selected_match = matches[i]
61elsif matches.length==1
62 selected_match = matches.first
63else
64 puts "No filenames matching '#{filepath}'"
65 exit_show_tool_tip
66end
67
68tm_open(selected_match, line)
69
70exit_discard</string>
71 <key>fallbackInput</key>
72 <string>word</string>
73 <key>input</key>
74 <string>document</string>
75 <key>keyEquivalent</key>
76 <string>~g</string>
77 <key>name</key>
78 <string>Go to file</string>
79 <key>output</key>
80 <string>showAsTooltip</string>
81 <key>uuid</key>
82 <string>7443155B-3A9B-4B0A-8D3D-0B533B3B9125</string>
83</dict>
84</plist>
toggle raw diff

Commands/Grep for Class.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>bundleUUID</key>
8 <string>5A9D4FC6-6CBE-11D9-A21B-000D93589AF6</string>
9 <key>command</key>
10 <string>#!/usr/bin/env ruby
11require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/grep_helpers.rb"
12
13grepper = GrepperMenu.new("Grep in Project")
14grepper.run {
15 m = $stdin.read
16
17 m = TextMate::UI.request_string(:title =&gt; "Grep for class", :prompt =&gt; "Enter a class you'd like to find:", :default =&gt; "" ).strip if m.empty?
18
19 if m.nil? || m.empty?
20 puts "Canceled"
21 exit_show_tool_tip
22 end
23
24 if /^[a-z]/.match(m)
25 require 'rubygems'
26 require 'activesupport'
27 m = m.classify
28 end
29
30 grepper.include_files &lt;&lt; ["*.rb"]
31 grepper.query = /(^|;) *(class|module) ([^&lt;#]+::|)*#{m}\b([^:]|$)/
32 grepper.query_highlight_regexp = Regexp.new(Regexp.escape(m))
33 grepper.title = "Searching for Class/Module “#{ m }”"
34}
35</string>
36 <key>fallbackInput</key>
37 <string>word</string>
38 <key>input</key>
39 <string>selection</string>
40 <key>keyEquivalent</key>
41 <string>@C</string>
42 <key>name</key>
43 <string>Grep for Class/Module</string>
44 <key>output</key>
45 <string>showAsTooltip</string>
46 <key>uuid</key>
47 <string>23D5F39E-73CA-43FC-90B3-18BDBEDDD56B</string>
48</dict>
49</plist>
toggle raw diff

Commands/Grep for Fixture.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>bundleUUID</key>
8 <string>5A9D4FC6-6CBE-11D9-A21B-000D93589AF6</string>
9 <key>command</key>
10 <string>#!/usr/bin/env ruby
11require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/grep_helpers.rb"
12
13grepper = GrepperMenu.new("Grep for Fixture")
14grepper.run {
15 m = $stdin.read
16
17 m = TextMate::UI.request_string(:title =&gt; "Grep for fixture", :prompt =&gt; "Enter a fixture you'd like to find:", :default =&gt; "" ).strip if m.empty?
18
19 if m.nil? || m.empty?
20 puts "Canceled"
21 exit_show_tool_tip
22 end
23
24 grepper.include_files &lt;&lt; ["*.yml"]
25 if /^[A-Z]/.match(m)
26 require 'rubygems'
27 require 'activesupport'
28 table_name = m.to_s.tableize
29 grepper.query = /^(#{m}|# Table name: (#{m}[ies]*|#{table_name}))\b/
30 else
31 grepper.query = /^(#{m}|# Table name: #{m}[ies]*)\b/
32 end
33
34 grepper.query_highlight_regexp = Regexp.new(Regexp.escape(m))
35 grepper.title = "Searching for fixture “#{ m }”"
36}</string>
37 <key>fallbackInput</key>
38 <string>word</string>
39 <key>input</key>
40 <string>selection</string>
41 <key>keyEquivalent</key>
42 <string>@X</string>
43 <key>name</key>
44 <string>Grep for Fixture</string>
45 <key>output</key>
46 <string>showAsTooltip</string>
47 <key>uuid</key>
48 <string>E2D2F075-81CE-4604-9813-A08145995F96</string>
49</dict>
50</plist>
toggle raw diff

Commands/Grep for method.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>bundleUUID</key>
8 <string>5A9D4FC6-6CBE-11D9-A21B-000D93589AF6</string>
9 <key>command</key>
10 <string>#!/usr/bin/env ruby
11require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/grep_helpers.rb"
12
13grepper = GrepperMenu.new("Grep for Method")
14grepper.run {
15 m = $stdin.read.strip
16
17 m = TextMate::UI.request_string(:title =&gt; "Grep for method", :prompt =&gt; "Enter a method you'd like to find:", :default =&gt; "" ).strip if m.empty?
18
19 if m.nil? || m.empty?
20 puts "Canceled"
21 exit_show_tool_tip
22 end
23
24 grepper.include_files &lt;&lt; ["*.rb"]
25
26 grepper.query = /(^|;) *((def +(self\.|)#{m}\b)|(def_delegators[\( ][^,]+,.*\b#{m}\b)|(attr_(reader|writer|accessor).*\b#{m}\b)|((belongs_to|belongs_to_reciprocated|has_many|has_and_belongs_to_many)[\(: ]+#{m}\b)|(# #{m} +:)|(alias :{0,1}#{m}\b))/
27 grepper.query_highlight_regexp = Regexp.new(Regexp.escape(m))
28 grepper.title = "Searching for method “#{ m }”"
29}</string>
30 <key>fallbackInput</key>
31 <string>word</string>
32 <key>input</key>
33 <string>selection</string>
34 <key>keyEquivalent</key>
35 <string>@M</string>
36 <key>name</key>
37 <string>Grep for Method</string>
38 <key>output</key>
39 <string>showAsTooltip</string>
40 <key>uuid</key>
41 <string>17830567-BC2D-4B99-B20F-F68903DA83A2</string>
42</dict>
43<