GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: a pretty tool to invoke your favorite editor and open errored file automatically.
Clone URL: git://github.com/kwatch/editorkicker.git
Enhanced to support ENV['EDITOR_KICKER_INCLUDE'] and 
ENV['EDITOR_KICKER_EXCLUDE'].
kwatch (author)
Sun Sep 14 03:56:04 -0700 2008
commit  fcd6f4997f46e9fa71d314f0ee0cf0e566442e93
tree    8306b9fc58fd30af4c78d7828f854f45c1195760
parent  6fe5c6f5e2614bd56149d275f69f23561556cb79
...
28
29
30
31
32
33
 
 
 
34
35
36
...
42
43
44
45
46
 
 
47
48
49
...
75
76
77
 
 
 
78
 
 
 
 
79
80
81
...
87
88
89
90
 
91
92
93
...
105
106
107
108
 
109
110
111
...
28
29
30
 
 
 
31
32
33
34
35
36
...
42
43
44
 
 
45
46
47
48
49
...
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
94
95
96
 
97
98
99
100
...
112
113
114
 
115
116
117
118
0
@@ -28,9 +28,9 @@ You must install CGI-Exception library, too.
0
     $ sudo gem install editorkicker
0
     ## or
0
     $ cd /tmp
0
- $ wget http://rubyforge.org/projects/editorkicker/.../editorkicker-XXX.tar.gz
0
- $ tar xzf editorkicker-XXX.tar.gz
0
- $ cd editorkicker-XXX/
0
+ $ wget http://rubyforge.org/projects/editorkicker/.../editorkicker-$Release$.tar.gz
0
+ $ tar xzf editorkicker-$Release$.tar.gz
0
+ $ cd editorkicker-$Release$/
0
     $ sudo ruby install.rb
0
   
0
     ## install cgi-exception
0
@@ -42,8 +42,8 @@ You must install CGI-Exception library, too.
0
     $ cd cgi-exception-XXX/
0
     $ sudo ruby install.rb
0
 
0
-It is not recommended to install by RubyGems, because 'require rubygems'
0
-is an heavy-weight operation for CGI.
0
+It is not recommended to install libraries by RubyGems, because
0
+'require rubygems' is an heavy-weight operation for CGI.
0
 
0
 
0
 
0
@@ -75,7 +75,14 @@ EditorKicker will detect TextMate or Emacs automatically.
0
       ## for Emacs
0
       emacsclient = '/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'
0
       ENV['EDITOR_KICKER'] = "#{emacsclient} -n -s /tmp/emacs501/server +%s '%s'"
0
+ ## for NetBeans
0
+ netbeans = "#{ENV['HOME']}/netbeans-6.1/bin/netbeans"
0
+ ENV['EDITOR_KICKER'] = "#{netbeans} --open %2$s:%1$s"
0
     end
0
+
0
+ ## you can specify include and/or exclude path to find file.
0
+ ENV['EDITOR_KICKER_INCLUDE'] = '/usr/local/lib/ruby/1.8/site_ruby'
0
+ ENV['EDITOR_KICKER_EXCLUDE'] = '/usr/local/lib:/usr/lib'
0
     
0
     cgi = CGI.new
0
     print cgi.header
0
@@ -87,7 +94,7 @@ If you're Emacs user, you have to change owner of socket file
0
 
0
     ### assume that CGI script is executed by 'daemon' user.
0
     ### ('/tmp/emacs501/server' will be created by M-x server-strart)
0
- $ sudo chown -R daemon /tmp/emacs501/server
0
+ $ sudo chown -R daemon /tmp/emacs501
0
 
0
 
0
 
0
@@ -105,7 +112,7 @@ Solution:
0
 
0
 Type 'M-x server start' in your Emacs.
0
 
0
-In addition if you are CGI user, set $EDITOR_KICKER environment variable
0
+In addition if you are CGI user, set ENV['EDITOR_KICKER'] environment variable
0
 to "emacsclient -n -s /tmp/emacs501/server +%s '%s'" in your CGI script
0
 to specify socket file by '-s' option.
0
 (Notice that '-s' option of emacsclient is available from Emacs 22.)
...
63
64
65
 
 
 
66
67
68
...
78
79
80
 
 
 
 
 
 
81
82
83
84
85
86
 
 
 
 
 
 
 
 
 
87
88
89
...
95
96
97
 
 
 
 
 
 
 
 
 
98
99
100
...
63
64
65
66
67
68
69
70
71
...
81
82
83
84
85
86
87
88
89
90
91
92
 
 
 
93
94
95
96
97
98
99
100
101
102
103
104
...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
0
@@ -63,6 +63,9 @@ module EditorKicker
0
     def detect_location(ex, backtrace=nil)
0
       filepath = linenum = nil
0
       backtrace ||= ex.backtrace
0
+ @include, @exclude = detect_paths()
0
+ $stderr.puts "*** debug: @include=#{@include.inspect}"
0
+ $stderr.puts "*** debug: @exclude=#{@exclude.inspect}"
0
       if backtrace && !backtrace.empty?
0
         tuple = nil
0
         if backtrace.find {|str| tuple = get_location(str) }
0
@@ -78,12 +81,24 @@ module EditorKicker
0
       return filepath, linenum
0
     end
0
 
0
+ def _match_to(filename, path_list)
0
+ return path_list.any? {|path|
0
+ $stderr.puts "*** debug: filename[0, path.length]=#{filename[0, path.length].inspect}"
0
+ filename[0, path.length] == path }
0
+ end
0
+
0
     ## get filepath and linenum from string
0
     def get_location(str)
0
       return nil unless str =~ /^(.+):(\d+)(:in `.+'|$)/
0
- return nil unless File.exist?($1)
0
- return nil unless @writable_check && File.writable?($1)
0
- return [$1, $2.to_i]
0
+ filename, linenum = $1, $2.to_i
0
+ arr = [filename, linenum]
0
+ return nil unless File.exist?(filename)
0
+ $stderr.puts "*** debug: _match_to(filename, @include)=#{_match_to(filename, @include).inspect}"
0
+ $stderr.puts "*** debug: _match_to(filename, @exclude)=#{_match_to(filename, @exclude).inspect}"
0
+ return arr if _match_to(filename, @include)
0
+ return nil if _match_to(filename, @exclude)
0
+ return nil if @writable_check && !File.writable?(filename)
0
+ return arr
0
     end
0
 
0
     ## detect command to invoke editor
0
@@ -95,6 +110,15 @@ module EditorKicker
0
       return "emacsclient -n +%s '%s'"
0
     end
0
 
0
+ def detect_paths
0
+ sep = File::PATH_SEPARATOR
0
+ s = ENV['EDITOR_KICKER_INCLUDE']
0
+ include = s ? s.split(sep) : []
0
+ s = ENV['EDITOR_KICKER_EXCLUDE']
0
+ exclude = s ? s.split(sep) : []
0
+ return include, exclude
0
+ end
0
+
0
     ## open file with editor
0
     def kick(filepath, linenum)
0
       if File.exists?(filepath)

Comments