rcodetools 0.7.0.0 → 0.8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +12 -0
- data/README +1 -1
- data/README.emacs +21 -4
- data/README.ja +1 -1
- data/README.xmpfilter +159 -74
- data/Rakefile +3 -37
- data/anything-rcodetools.el +142 -0
- data/bin/rct-complete +1 -1
- data/bin/rct-doc +1 -1
- data/bin/rct-meth-args +33 -2
- data/bin/xmpfilter +5 -1
- data/lib/rcodetools/compat.rb +14 -0
- data/lib/rcodetools/completion.rb +8 -6
- data/lib/rcodetools/fork.rb +15 -8
- data/lib/rcodetools/options.rb +8 -0
- data/lib/rcodetools/xmpfilter.rb +80 -33
- data/lib/rcodetools/xmptestunitfilter.rb +76 -21
- data/lib/ruby_toggle_file.rb +1 -1
- data/rcodetools.el +213 -20
- data/test/test_functional.rb +36 -68
- data/test/test_method_analyzer.rb +28 -20
- data/test/test_ruby_toggle_file.rb +118 -69
- data/test/test_xmpfilter.rb +75 -47
- data/test/test_xmptestunitfilter.rb +12 -11
- metadata +83 -133
- data/test/data/add_markers-input.rb +0 -2
- data/test/data/add_markers-output.rb +0 -2
- data/test/data/bindings-input.rb +0 -26
- data/test/data/bindings-output.rb +0 -31
- data/test/data/completion-input.rb +0 -1
- data/test/data/completion-output.rb +0 -2
- data/test/data/completion_class_info-input.rb +0 -1
- data/test/data/completion_class_info-output.rb +0 -10
- data/test/data/completion_class_info_no_candidates-input.rb +0 -1
- data/test/data/completion_class_info_no_candidates-output.rb +0 -1
- data/test/data/completion_detect_rbtest-input.rb +0 -7
- data/test/data/completion_detect_rbtest-output.rb +0 -2
- data/test/data/completion_detect_rbtest2-input.rb +0 -1
- data/test/data/completion_detect_rbtest2-output.rb +0 -2
- data/test/data/completion_emacs-input.rb +0 -1
- data/test/data/completion_emacs-output.rb +0 -6
- data/test/data/completion_emacs_icicles-input.rb +0 -1
- data/test/data/completion_emacs_icicles-output.rb +0 -6
- data/test/data/completion_in_method-input.rb +0 -3
- data/test/data/completion_in_method-output.rb +0 -1
- data/test/data/completion_in_method-test.rb +0 -6
- data/test/data/completion_rbtest-input.rb +0 -7
- data/test/data/completion_rbtest-output.rb +0 -2
- data/test/data/doc-input.rb +0 -1
- data/test/data/doc-output.rb +0 -1
- data/test/data/doc_detect_rbtest-input.rb +0 -1
- data/test/data/doc_detect_rbtest-output.rb +0 -1
- data/test/data/doc_detect_rbtest2-input.rb +0 -7
- data/test/data/doc_detect_rbtest2-output.rb +0 -1
- data/test/data/doc_rbtest-input.rb +0 -7
- data/test/data/doc_rbtest-output.rb +0 -1
- data/test/data/no_warnings-input.rb +0 -3
- data/test/data/no_warnings-output.rb +0 -4
- data/test/data/refe-input.rb +0 -1
- data/test/data/refe-output.rb +0 -1
- data/test/data/ri-input.rb +0 -1
- data/test/data/ri-output.rb +0 -1
- data/test/data/ri_emacs-input.rb +0 -1
- data/test/data/ri_emacs-output.rb +0 -1
- data/test/data/ri_vim-input.rb +0 -1
- data/test/data/ri_vim-output.rb +0 -1
- data/test/data/rspec-input.rb +0 -48
- data/test/data/rspec-output.rb +0 -52
- data/test/data/rspec_poetry-input.rb +0 -48
- data/test/data/rspec_poetry-output.rb +0 -52
- data/test/data/simple_annotation-input.rb +0 -8
- data/test/data/simple_annotation-output.rb +0 -8
- data/test/data/unit_test-input.rb +0 -50
- data/test/data/unit_test-output.rb +0 -52
- data/test/data/unit_test_detect_rbtest-input.rb +0 -50
- data/test/data/unit_test_detect_rbtest-output.rb +0 -52
- data/test/data/unit_test_detect_rbtest2-input.rb +0 -6
- data/test/data/unit_test_detect_rbtest2-output.rb +0 -6
- data/test/data/unit_test_poetry-input.rb +0 -50
- data/test/data/unit_test_poetry-output.rb +0 -52
- data/test/data/unit_test_rbtest-input.rb +0 -6
- data/test/data/unit_test_rbtest-output.rb +0 -6
- data/test/test_run.rb +0 -45
data/CHANGES
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
rcodetools history
|
2
2
|
==================
|
3
|
+
User-visible changes since 0.7.0
|
4
|
+
--------------------------------
|
5
|
+
* Support Ruby 1.9!
|
6
|
+
* xmpfilter: multi-line annotation
|
7
|
+
* xmpfilter --expectations generates expectations by Jay Fields
|
8
|
+
* anything-rcodetools.el: new elisp
|
9
|
+
* --tmpfile, --tempfile: use temporary file instead of open3 on un*x
|
10
|
+
* rcodetools.el: smarter xmpfilter-command
|
11
|
+
* rcodetools.el: rct-fork interface
|
12
|
+
* rct-fork: require 'rubygems' initially
|
13
|
+
* rct-fork: more stable
|
14
|
+
|
3
15
|
User-visible changes since 0.5.0
|
4
16
|
--------------------------------
|
5
17
|
* "test-driven completion" (TDC) support for Emacs and vim (see README.TDC)
|
data/README
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
rcodetools http://eigenclass.org/hiki.rb?rcodetools
|
3
3
|
Copyright (c) 2005-2007 Mauricio Fernandez <mfp@acm.org> http://eigenclass.org
|
4
|
-
Copyright (c) 2006-
|
4
|
+
Copyright (c) 2006-2008 rubikitch <rubikitch@ruby-lang.org> http://www.rubyist.net/~rubikitch/
|
5
5
|
Use and distribution subject to the terms of the Ruby license.
|
6
6
|
|
7
7
|
= Overview
|
data/README.emacs
CHANGED
@@ -21,8 +21,15 @@ If you use icicles copy <tt>icicles-rcodetools.el</tt> too.
|
|
21
21
|
Then require it.
|
22
22
|
(require 'icicles-rcodetools)
|
23
23
|
It provides wonderful `help on candidate' feature, RI document on each candidate during completion.
|
24
|
-
|
25
|
-
|
24
|
+
|
25
|
+
If you use anything.el copy <tt>anything-rcodetools.el</tt> too.
|
26
|
+
Then require it.
|
27
|
+
(require 'anything-rcodetools)
|
28
|
+
RI document on each candidate during completion.
|
29
|
+
I think anything-rcodetools is more convenient than icicles-rcodetools.
|
30
|
+
|
31
|
+
I'm addicted to anything!
|
32
|
+
http://www.emacswiki.org/cgi-bin/wiki/Anything
|
26
33
|
|
27
34
|
xmpfilter on buffer
|
28
35
|
===================
|
@@ -38,8 +45,9 @@ method/class/constant completion
|
|
38
45
|
|
39
46
|
# [EVAL IT] (describe-function 'rct-complete-symbol)
|
40
47
|
|
41
|
-
If you use icicles-rcodetools, you can browse RI document
|
42
|
-
by typing C-M-RET
|
48
|
+
If you use icicles-rcodetools or anything-rcodetools, you can browse RI document
|
49
|
+
for selected candidate by typing C-M-RET (icicles) or C-z (anything.
|
50
|
+
It is wonderful icicles and anything feature!!
|
43
51
|
|
44
52
|
show RI document / jump to the definition
|
45
53
|
=========================================
|
@@ -52,3 +60,12 @@ If use do not use this feature, evaluate:
|
|
52
60
|
(setq rct-find-tag-if-available nil)
|
53
61
|
|
54
62
|
# [EVAL IT] (describe-variable 'rct-find-tag-if-available)
|
63
|
+
|
64
|
+
speed-up xmpfilter and completion
|
65
|
+
=================================
|
66
|
+
|
67
|
+
# [EVAL IT] (describe-function 'rct-fork)
|
68
|
+
# [EVAL IT] (describe-function 'rct-fork-kill)
|
69
|
+
|
70
|
+
M-x rct-fork pre-loads heavy libraries (like rails).
|
71
|
+
You need not every time wait for loading them anymore!
|
data/README.ja
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
rcodetools http://eigenclass.org/hiki.rb?rcodetools
|
3
3
|
Copyright (c) 2005-2007 Mauricio Fernandez <mfp@acm.org> http://eigenclass.org
|
4
|
-
Copyright (c) 2006-
|
4
|
+
Copyright (c) 2006-2008 rubikitch <rubikitch@ruby-lang.org> http://www.rubyist.net/~rubikitch/
|
5
5
|
Use and distribution subject to the terms of the Ruby license.
|
6
6
|
|
7
7
|
= ����
|
data/README.xmpfilter
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
|
2
2
|
xmpfilter http://eigenclass.org/hiki.rb?xmpfilter
|
3
|
-
Copyright (c) 2005-
|
3
|
+
Copyright (c) 2005-2008 Mauricio Fernandez <mfp@acm.org> http://eigenclass.org
|
4
|
+
rubikitch <rubikitch@ruby-lang.org>
|
4
5
|
Use and distribution subject to the terms of the Ruby license.
|
5
6
|
|
6
7
|
Overview
|
7
8
|
========
|
8
9
|
xmpfilter is a small tool that can be used to
|
9
|
-
* generate Test::Unit assertions
|
10
|
+
* generate Test::Unit assertions, RSpec expectations and
|
11
|
+
expectations blocks semi-automatically
|
10
12
|
* annotate source code with intermediate results (a bit like irb
|
11
13
|
--simple-prompt but only for the lines explicitly marked with # =>)
|
12
14
|
Very useful for example code (such as postings to ruby-talk).
|
@@ -15,7 +17,7 @@ Usage
|
|
15
17
|
=====
|
16
18
|
xmpfilter takes its input from stdin and writes to stdout. It can run in
|
17
19
|
several modes (annotation, Test::Unit assertion expansion, RSpec expectation
|
18
|
-
generation, marker insertion); see
|
20
|
+
generation, expectations expectations generation, marker insertion); see
|
19
21
|
xmpfilter -h
|
20
22
|
README.emacs and README.vim describe how to use xmpfilter from your editor.
|
21
23
|
|
@@ -34,8 +36,33 @@ README.vim)
|
|
34
36
|
a + b # => "foobaz"
|
35
37
|
a.size # => 3
|
36
38
|
|
37
|
-
This saves much cut&pasting when you're posting to ruby-talk/ruby-core
|
38
|
-
it all the time).
|
39
|
+
This saves much cut&pasting when you're posting to ruby-list/ruby-talk/ruby-core
|
40
|
+
(We use it all the time).
|
41
|
+
|
42
|
+
|
43
|
+
Example: multi-line code annotation
|
44
|
+
===================================
|
45
|
+
Just add "# =>" markers to the next lines whose values you want to be shown with pp:
|
46
|
+
|
47
|
+
a = ["1111111111111111111111111111111111111111111111111111", 123334324234242342,
|
48
|
+
1332333333,6,8 ]
|
49
|
+
1 # =>
|
50
|
+
a
|
51
|
+
# =>
|
52
|
+
|
53
|
+
will be expanded to (in one keypress in a decent editor, see README.emacs and
|
54
|
+
README.vim)
|
55
|
+
|
56
|
+
a = ["1111111111111111111111111111111111111111111111111111", 123334324234242342,
|
57
|
+
1332333333,6,8 ]
|
58
|
+
1 # => 1
|
59
|
+
a
|
60
|
+
# => ["1111111111111111111111111111111111111111111111111111",
|
61
|
+
# 123334324234242342,
|
62
|
+
# 1332333333,
|
63
|
+
# 6,
|
64
|
+
# 8]
|
65
|
+
|
39
66
|
|
40
67
|
Example: assertion generation
|
41
68
|
=============================
|
@@ -114,88 +141,146 @@ Example: RSpec expectations
|
|
114
141
|
===========================
|
115
142
|
Here's some code before and after filtering it with xmpfilter:
|
116
143
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
144
|
+
class X
|
145
|
+
Y = Struct.new(:a)
|
146
|
+
def foo(b); b ? Y.new(2) : 2 end
|
147
|
+
def bar; raise "No good" end
|
148
|
+
def baz; nil end
|
149
|
+
def fubar(x); x ** 2.0 + 1 end
|
150
|
+
def babar; [1,2] end
|
151
|
+
A = 1
|
152
|
+
A = 1
|
153
|
+
end
|
154
|
+
|
155
|
+
context "Testing xmpfilter's expectation expansion" do
|
156
|
+
setup do
|
157
|
+
@o = X.new
|
126
158
|
end
|
127
159
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
160
|
+
specify "Should expand should_equal expectations" do
|
161
|
+
@o.foo(true) # =>
|
162
|
+
@o.foo(true).a # =>
|
163
|
+
@o.foo(false) # =>
|
164
|
+
end
|
132
165
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
@o.foo(false) # =>
|
137
|
-
end
|
138
|
-
|
139
|
-
specify "Should expand should_raise expectations" do
|
140
|
-
@o.bar # =>
|
141
|
-
end
|
166
|
+
specify "Should expand should_raise expectations" do
|
167
|
+
@o.bar # =>
|
168
|
+
end
|
142
169
|
|
143
|
-
|
144
|
-
|
145
|
-
|
170
|
+
specify "Should expand should_be_nil expectations" do
|
171
|
+
@o.baz # =>
|
172
|
+
end
|
146
173
|
|
147
|
-
|
148
|
-
|
149
|
-
|
174
|
+
specify "Should expand correct expectations for complex values" do
|
175
|
+
@o.babar # =>
|
176
|
+
end
|
150
177
|
|
151
|
-
|
152
|
-
|
153
|
-
end
|
178
|
+
specify "Should expand should_be_close expectations" do
|
179
|
+
@o.fubar(10) # =>
|
154
180
|
end
|
181
|
+
end
|
155
182
|
|
156
183
|
|
157
184
|
after piping it to xmpfilter -s:
|
158
185
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
186
|
+
class X
|
187
|
+
Y = Struct.new(:a)
|
188
|
+
def foo(b); b ? Y.new(2) : 2 end
|
189
|
+
def bar; raise "No good" end
|
190
|
+
def baz; nil end
|
191
|
+
def fubar(x); x ** 2.0 + 1 end
|
192
|
+
def babar; [1,2] end
|
193
|
+
A = 1
|
194
|
+
A = 1 # !> already initialized constant A
|
195
|
+
end
|
196
|
+
|
197
|
+
context "Testing xmpfilter's expectation expansion" do
|
198
|
+
setup do
|
199
|
+
@o = X.new
|
200
|
+
end
|
201
|
+
|
202
|
+
specify "Should expand should_equal expectations" do
|
203
|
+
(@o.foo(true)).should_be_a_kind_of X::Y
|
204
|
+
(@o.foo(true).inspect).should_equal "#<struct X::Y a=2>"
|
205
|
+
(@o.foo(true).a).should_equal 2
|
206
|
+
(@o.foo(false)).should_equal 2
|
207
|
+
end
|
208
|
+
|
209
|
+
specify "Should expand should_raise expectations" do
|
210
|
+
lambda{(@o.bar)}.should_raise RuntimeError
|
211
|
+
end
|
212
|
+
|
213
|
+
specify "Should expand should_be_nil expectations" do
|
214
|
+
(@o.baz).should_be_nil
|
215
|
+
end
|
216
|
+
|
217
|
+
specify "Should expand correct expectations for complex values" do
|
218
|
+
(@o.babar).should_equal [1, 2]
|
219
|
+
end
|
220
|
+
|
221
|
+
specify "Should expand should_be_close expectations" do
|
222
|
+
(@o.fubar(10)).should_be_close(101.0, 0.0001)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
Example: expectations expectations
|
228
|
+
==================================
|
229
|
+
Expectations is a light-weight unit testing framework by Jay Fields.
|
230
|
+
(http://expectations.rubyforge.org)
|
231
|
+
|
232
|
+
Here's some code before and after filtering it with xmpfilter:
|
233
|
+
|
234
|
+
require 'rubygems'
|
235
|
+
require 'expectations'
|
236
|
+
|
237
|
+
S = Struct.new :a
|
238
|
+
Expectations do
|
239
|
+
1 + 1 # =>
|
240
|
+
"a".length # =>
|
241
|
+
[][1] # =>
|
242
|
+
1.hoge # =>
|
243
|
+
1.1 + 1.0 # =>
|
244
|
+
S.new(1) # =>
|
245
|
+
end
|
246
|
+
|
247
|
+
after piping it to xmpfilter --expectations:
|
248
|
+
|
249
|
+
require 'rubygems'
|
250
|
+
require 'expectations'
|
251
|
+
|
252
|
+
S = Struct.new :a
|
253
|
+
Expectations do
|
254
|
+
expect 2 do
|
255
|
+
1 + 1
|
256
|
+
end
|
257
|
+
|
258
|
+
expect 1 do
|
259
|
+
"a".length
|
260
|
+
end
|
261
|
+
|
262
|
+
expect nil do
|
263
|
+
[][1]
|
264
|
+
end
|
265
|
+
|
266
|
+
expect NoMethodError do
|
267
|
+
1.hoge
|
268
|
+
end
|
269
|
+
|
270
|
+
expect 2.0999..2.1001 do
|
271
|
+
1.1 + 1.0
|
197
272
|
end
|
198
273
|
|
274
|
+
expect S do
|
275
|
+
S.new(1)
|
276
|
+
end
|
277
|
+
|
278
|
+
expect "#<struct S a=1>" do
|
279
|
+
S.new(1).inspect
|
280
|
+
end
|
281
|
+
|
282
|
+
end
|
283
|
+
|
199
284
|
|
200
285
|
License
|
201
286
|
=======
|
data/Rakefile
CHANGED
@@ -31,47 +31,13 @@ end
|
|
31
31
|
|
32
32
|
task :default => :test
|
33
33
|
|
34
|
-
## test data file dependency
|
35
|
-
basetestfiles = []
|
36
|
-
copy = lambda do |t|
|
37
|
-
cp t.prerequisites.first, t.name
|
38
|
-
end
|
39
|
-
|
40
|
-
# DO NOT EDIT!! EDITABLE
|
41
|
-
[ ["test/data/rspec_poetry-input.rb", "test/data/rspec-input.rb"],
|
42
|
-
["test/data/unit_test_poetry-input.rb", "test/data/unit_test-input.rb"],
|
43
|
-
["test/data/completion_emacs-input.rb", "test/data/completion-input.rb"],
|
44
|
-
["test/data/unit_test_detect_rbtest-input.rb", "test/data/unit_test-input.rb"],
|
45
|
-
["test/data/unit_test_detect_rbtest-output.rb", "test/data/unit_test-output.rb"],
|
46
|
-
["test/data/unit_test_detect_rbtest2-input.rb", "test/data/unit_test_rbtest-input.rb"],
|
47
|
-
["test/data/unit_test_detect_rbtest2-output.rb", "test/data/unit_test_rbtest-output.rb"],
|
48
|
-
["test/data/completion_detect_rbtest-input.rb", "test/data/completion_rbtest-input.rb"],
|
49
|
-
["test/data/completion_detect_rbtest-output.rb", "test/data/completion_rbtest-output.rb"],
|
50
|
-
["test/data/completion_detect_rbtest2-input.rb", "test/data/completion-input.rb"],
|
51
|
-
["test/data/completion_detect_rbtest2-output.rb", "test/data/completion-output.rb"],
|
52
|
-
["test/data/doc_detect_rbtest-input.rb", "test/data/doc-input.rb"],
|
53
|
-
["test/data/doc_detect_rbtest-output.rb", "test/data/doc-output.rb"],
|
54
|
-
["test/data/doc_detect_rbtest2-input.rb", "test/data/doc_rbtest-input.rb"],
|
55
|
-
["test/data/doc_detect_rbtest2-output.rb", "test/data/doc_rbtest-output.rb"],
|
56
|
-
|
57
|
-
].each do |outfile, infile|
|
58
|
-
basetestfiles << outfile
|
59
|
-
file(outfile => infile, ©)
|
60
|
-
end
|
61
|
-
for test in %w[refe ri ri_emacs ri_vim]
|
62
|
-
outfile = "test/data/#{test}-input.rb"
|
63
|
-
basetestfiles << outfile
|
64
|
-
file(outfile => "test/data/doc-input.rb", ©)
|
65
|
-
end
|
66
|
-
task :base_update => basetestfiles
|
67
|
-
task :test => :base_update
|
68
|
-
task :rcov => :base_update
|
69
34
|
|
70
35
|
#{{{ Package tasks
|
71
36
|
PKG_FILES = FileList[
|
72
37
|
"bin/rct-complete", "bin/rct-doc", "bin/xmpfilter", "bin/rct-meth-args",
|
73
38
|
"lib/**/*.rb",
|
74
|
-
"CHANGES", "rcodetools.*", "icicles-rcodetools.el", "
|
39
|
+
"CHANGES", "rcodetools.*", "icicles-rcodetools.el", "anything-rcodetools.el",
|
40
|
+
"README", "README.*", "THANKS",
|
75
41
|
"Rakefile", "Rakefile.method_analysis",
|
76
42
|
"setup.rb",
|
77
43
|
"test/**/*.rb",
|
@@ -126,7 +92,7 @@ EOF
|
|
126
92
|
|
127
93
|
end
|
128
94
|
|
129
|
-
task :gem
|
95
|
+
task :gem #=> [:test]
|
130
96
|
Rake::GemPackageTask.new(Spec) do |p|
|
131
97
|
#p.need_tar = true
|
132
98
|
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
;;; anything-rcodetools.el --- accurate Ruby method completion with anything
|
2
|
+
;; $Id: anything-rcodetools.el,v 1.6 2008/01/14 17:59:34 rubikitch Exp $
|
3
|
+
|
4
|
+
;;; Copyright (c) 2007 rubikitch
|
5
|
+
|
6
|
+
;; Author: rubikitch <rubikitch@ruby-lang.org>
|
7
|
+
;; URL: http://www.emacswiki.org/cgi-bin/wiki/download/anything-rcodetools.el
|
8
|
+
|
9
|
+
;;; Use and distribution subject to the terms of the Ruby license.
|
10
|
+
|
11
|
+
;;; Commentary:
|
12
|
+
|
13
|
+
;; (0) You need rcodetools, anything.el and FastRI. Note that you do not have to
|
14
|
+
;; configure anything.el if you use anything.el for this package.
|
15
|
+
;; (1) You need to add to .emacs:
|
16
|
+
;; (require 'anything)
|
17
|
+
;; (require 'anything-rcodetools)
|
18
|
+
;; ;; Command to get all RI entries.
|
19
|
+
;; (setq rct-get-all-methods-command "PAGER=cat fri -l")
|
20
|
+
;; ;; See docs
|
21
|
+
;; (define-key anything-map "\C-z" 'anything-execute-persistent-action)
|
22
|
+
|
23
|
+
;;; History:
|
24
|
+
|
25
|
+
;; $Log: anything-rcodetools.el,v $
|
26
|
+
;; Revision 1.6 2008/01/14 17:59:34 rubikitch
|
27
|
+
;; * uniform format (anything-c-source-complete-ruby, anything-c-source-complete-ruby-all)
|
28
|
+
;; * rename command: anything-c-ri -> anything-rct-ri
|
29
|
+
;;
|
30
|
+
;; Revision 1.5 2008/01/13 17:54:04 rubikitch
|
31
|
+
;; anything-current-buffer advice.
|
32
|
+
;;
|
33
|
+
;; Revision 1.4 2008/01/08 14:47:34 rubikitch
|
34
|
+
;; Added (require 'rcodetools).
|
35
|
+
;; Revised commentary.
|
36
|
+
;;
|
37
|
+
;; Revision 1.3 2008/01/04 09:32:29 rubikitch
|
38
|
+
;; *** empty log message ***
|
39
|
+
;;
|
40
|
+
;; Revision 1.2 2008/01/04 09:21:23 rubikitch
|
41
|
+
;; fixed typo
|
42
|
+
;;
|
43
|
+
;; Revision 1.1 2008/01/04 09:21:05 rubikitch
|
44
|
+
;; Initial revision
|
45
|
+
;;
|
46
|
+
|
47
|
+
;;; Code:
|
48
|
+
|
49
|
+
(require 'rcodetools)
|
50
|
+
|
51
|
+
;;;; Compatibility code
|
52
|
+
(unless (fboundp 'anything-execute-persistent-action)
|
53
|
+
(defun anything-execute-persistent-action ()
|
54
|
+
"If a candidate was selected then perform the associated action without quitting anything."
|
55
|
+
(interactive)
|
56
|
+
(save-selected-window
|
57
|
+
(select-window (get-buffer-window anything-buffer))
|
58
|
+
(select-window (setq minibuffer-scroll-window
|
59
|
+
(if (one-window-p t) (split-window) (next-window (selected-window) 1))))
|
60
|
+
(let* ((anything-window (get-buffer-window anything-buffer))
|
61
|
+
(selection (if anything-saved-sources
|
62
|
+
;; the action list is shown
|
63
|
+
anything-saved-selection
|
64
|
+
(anything-get-selection)))
|
65
|
+
(default-action (anything-get-action))
|
66
|
+
(action (assoc-default 'persistent-action (anything-get-current-source))))
|
67
|
+
(setq action (or action default-action))
|
68
|
+
(if (and (listp action)
|
69
|
+
(not (functionp action))) ; lambda
|
70
|
+
;; select the default action
|
71
|
+
(setq action (cdar action)))
|
72
|
+
(set-window-dedicated-p anything-window t)
|
73
|
+
(unwind-protect
|
74
|
+
(and action selection (funcall action selection))
|
75
|
+
(set-window-dedicated-p anything-window nil))))))
|
76
|
+
|
77
|
+
(unless (boundp 'anything-current-buffer)
|
78
|
+
(defvar anything-current-buffer nil)
|
79
|
+
(defadvice anything (before get-current-buffer activate)
|
80
|
+
(setq anything-current-buffer (current-buffer))))
|
81
|
+
|
82
|
+
;;;; Main code
|
83
|
+
(defun anything-rct-ri (pair)
|
84
|
+
(ri (substring (cadr (split-string pair "\t")) 1 -1)))
|
85
|
+
|
86
|
+
(defun anything-rct-complete (pair)
|
87
|
+
(save-excursion
|
88
|
+
(set-buffer anything-current-buffer)
|
89
|
+
(search-backward pattern)
|
90
|
+
(delete-char (length pattern)))
|
91
|
+
(insert (car (split-string pair "\t"))))
|
92
|
+
|
93
|
+
(setq rct-complete-symbol-function 'rct-complete-symbol--anything)
|
94
|
+
(defvar anything-c-source-complete-ruby
|
95
|
+
'((name . "Ruby Method Completion")
|
96
|
+
(candidates . rct-method-completion-table)
|
97
|
+
(init
|
98
|
+
. (lambda ()
|
99
|
+
(condition-case x
|
100
|
+
(rct-exec-and-eval rct-complete-command-name "--completion-emacs-icicles")
|
101
|
+
((error) (setq rct-method-completion-table nil)))))
|
102
|
+
(action
|
103
|
+
("Completion" . anything-rct-complete)
|
104
|
+
("RI" . anything-rct-ri))
|
105
|
+
(volatile)
|
106
|
+
(persistent-action . anything-rct-ri)))
|
107
|
+
|
108
|
+
(defvar rct-get-all-methods-command "PAGER=cat fri -l")
|
109
|
+
(defun rct-get-all-methods ()
|
110
|
+
(interactive)
|
111
|
+
(setq rct-all-methods
|
112
|
+
(mapcar (lambda (fullname)
|
113
|
+
(replace-regexp-in-string "^.+[:#.]\\([^:#.]+\\)$"
|
114
|
+
"\\1\t[\\&]" fullname))
|
115
|
+
(split-string (shell-command-to-string rct-get-all-methods-command) "\n"))))
|
116
|
+
|
117
|
+
(defvar rct-all-methods (rct-get-all-methods))
|
118
|
+
(defvar anything-c-source-complete-ruby-all
|
119
|
+
'((name . "Ruby Method Completion (ALL)")
|
120
|
+
(candidates
|
121
|
+
. (lambda ()
|
122
|
+
(let ((case-fold-search nil)
|
123
|
+
(re (format "[:#.]%s" (with-current-buffer anything-current-buffer
|
124
|
+
(symbol-at-point)))))
|
125
|
+
(remove-if-not
|
126
|
+
(lambda (meth) (string-match re meth))
|
127
|
+
rct-all-methods))))
|
128
|
+
(action
|
129
|
+
("Completion" . anything-rct-complete)
|
130
|
+
("RI" . anything-rct-ri))
|
131
|
+
(persistent-action . anything-rct-ri)))
|
132
|
+
|
133
|
+
(defun rct-complete-symbol--anything ()
|
134
|
+
(interactive)
|
135
|
+
(let ((anything-sources (list anything-c-source-complete-ruby anything-c-source-complete-ruby-all)))
|
136
|
+
(anything)))
|
137
|
+
|
138
|
+
(provide 'anything-rcodetools)
|
139
|
+
|
140
|
+
;; How to save (DO NOT REMOVE!!)
|
141
|
+
;; (emacswiki-post "anything-rcodetools.el")
|
142
|
+
;;; install-elisp.el ends here
|