rcodetools 0.8.3.0 → 0.8.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,8 +26,12 @@ If you use anything.el copy <tt>anything-rcodetools.el</tt> too.
26
26
  Then require it.
27
27
  (require 'anything-rcodetools)
28
28
  RI document on each candidate during completion.
29
- I think anything-rcodetools is more convenient than icicles-rcodetools.
30
29
 
30
+ anything-show-completion.el shows selection (mehod) in buffer for completion.
31
+ It is available in:
32
+ http://www.emacswiki.org/cgi-bin/wiki/download/anything-show-completion.el
33
+
34
+ I think anything-rcodetools is more convenient than icicles-rcodetools.
31
35
  I'm addicted to anything!
32
36
  http://www.emacswiki.org/cgi-bin/wiki/Anything
33
37
 
@@ -1,5 +1,5 @@
1
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 $
2
+ ;; $Id: anything-rcodetools.el,v 1.12 2009/04/18 10:12:02 rubikitch Exp $
3
3
 
4
4
  ;;; Copyright (c) 2007 rubikitch
5
5
 
@@ -20,9 +20,39 @@
20
20
  ;; ;; See docs
21
21
  ;; (define-key anything-map "\C-z" 'anything-execute-persistent-action)
22
22
 
23
+ ;;; Commands:
24
+ ;;
25
+ ;; Below are complete command list:
26
+ ;;
27
+ ;;
28
+ ;;; Customizable Options:
29
+ ;;
30
+ ;; Below are customizable option list:
31
+ ;;
32
+
23
33
  ;;; History:
24
34
 
25
35
  ;; $Log: anything-rcodetools.el,v $
36
+ ;; Revision 1.12 2009/04/18 10:12:02 rubikitch
37
+ ;; Adjust to change of `use-anything-show-completion'
38
+ ;;
39
+ ;; Revision 1.11 2009/04/17 20:21:47 rubikitch
40
+ ;; * require anything
41
+ ;; * require anything-show-completion.el if available
42
+ ;;
43
+ ;; Revision 1.10 2009/04/17 20:11:03 rubikitch
44
+ ;; removed old code
45
+ ;;
46
+ ;; Revision 1.9 2009/04/17 20:07:52 rubikitch
47
+ ;; * use --completion-emacs-anything option
48
+ ;; * New implementation of `anything-c-source-complete-ruby-all'
49
+ ;;
50
+ ;; Revision 1.8 2009/04/15 10:25:25 rubikitch
51
+ ;; Set `anything-execute-action-at-once-if-one' t
52
+ ;;
53
+ ;; Revision 1.7 2009/04/15 10:24:23 rubikitch
54
+ ;; regexp bug fix
55
+ ;;
26
56
  ;; Revision 1.6 2008/01/14 17:59:34 rubikitch
27
57
  ;; * uniform format (anything-c-source-complete-ruby, anything-c-source-complete-ruby-all)
28
58
  ;; * rename command: anything-c-ri -> anything-rct-ri
@@ -46,49 +76,21 @@
46
76
 
47
77
  ;;; Code:
48
78
 
79
+ (require 'anything)
49
80
  (require 'rcodetools)
81
+ (when (require 'anything-show-completion nil t)
82
+ (use-anything-show-completion 'rct-complete-symbol--anything
83
+ '(length pattern)))
50
84
 
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)
85
+ (defun anything-rct-ri (meth)
86
+ (ri (get-text-property 0 'desc meth)))
87
+
88
+ (defun anything-rct-complete (meth)
87
89
  (save-excursion
88
90
  (set-buffer anything-current-buffer)
89
91
  (search-backward pattern)
90
92
  (delete-char (length pattern)))
91
- (insert (car (split-string pair "\t"))))
93
+ (insert meth))
92
94
 
93
95
  (setq rct-complete-symbol-function 'rct-complete-symbol--anything)
94
96
  (defvar anything-c-source-complete-ruby
@@ -97,7 +99,7 @@
97
99
  (init
98
100
  . (lambda ()
99
101
  (condition-case x
100
- (rct-exec-and-eval rct-complete-command-name "--completion-emacs-icicles")
102
+ (rct-exec-and-eval rct-complete-command-name "--completion-emacs-anything")
101
103
  ((error) (setq rct-method-completion-table nil)))))
102
104
  (action
103
105
  ("Completion" . anything-rct-complete)
@@ -106,34 +108,37 @@
106
108
  (persistent-action . anything-rct-ri)))
107
109
 
108
110
  (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
111
  (defvar anything-c-source-complete-ruby-all
119
112
  '((name . "Ruby Method Completion (ALL)")
120
- (candidates
113
+ (init
121
114
  . (lambda ()
122
- (let ((case-fold-search nil)
123
- (re (format "[:#.]%s" (with-current-buffer anything-current-buffer
124
- (regexp-quote (or (thing-at-point 'symbol) ""))))))
125
- (remove-if-not
126
- (lambda (meth) (string-match re meth))
127
- rct-all-methods))))
115
+ (unless (anything-candidate-buffer)
116
+ (with-current-buffer (anything-candidate-buffer 'global)
117
+ (call-process-shell-command rct-get-all-methods-command nil t)
118
+ (goto-char 1)
119
+ (while (re-search-forward "^.+[:#.]\\([^:#.]+\\)$" nil t)
120
+ (replace-match "\\1\t[\\&]"))))))
121
+ (candidates-in-buffer
122
+ . (lambda ()
123
+ (let ((anything-pattern (format "^%s.*%s" (regexp-quote pattern) anything-pattern)))
124
+ (anything-candidates-in-buffer))))
125
+ (display-to-real
126
+ . (lambda (line)
127
+ (if (string-match "\t\\[\\(.+\\)\\]$" line)
128
+ (propertize (substring line 0 (match-beginning 0))
129
+ 'desc (match-string 1 line))
130
+ line)))
128
131
  (action
129
132
  ("Completion" . anything-rct-complete)
130
133
  ("RI" . anything-rct-ri))
131
134
  (persistent-action . anything-rct-ri)))
132
135
 
136
+
133
137
  (defun rct-complete-symbol--anything ()
134
138
  (interactive)
135
- (let ((anything-sources (list anything-c-source-complete-ruby anything-c-source-complete-ruby-all)))
136
- (anything)))
139
+ (let ((anything-execute-action-at-once-if-one t))
140
+ (anything '(anything-c-source-complete-ruby
141
+ anything-c-source-complete-ruby-all))))
137
142
 
138
143
  (provide 'anything-rcodetools)
139
144
 
@@ -1,4 +1,4 @@
1
- #! /pkgs/ruby19/bin/ruby19
1
+ #! /usr/local/bin/ruby18
2
2
  require 'rcodetools/xmpfilter'
3
3
  require 'rcodetools/completion'
4
4
  require 'rcodetools/options'
@@ -22,6 +22,9 @@ opts = OptionParser.new do |opts|
22
22
  opts.on("--completion-emacs-icicles", "Generate completion code for Emacs/Icicles.") do
23
23
  klass = XMPCompletionEmacsIciclesFilter
24
24
  end
25
+ opts.on("--completion-emacs-anything", "Generate completion code for Emacs/Anything.") do
26
+ klass = XMPCompletionEmacsAnythingFilter
27
+ end
25
28
  opts.on("--completion-class-info", "List completion candidates with class.") do
26
29
  klass = XMPCompletionClassInfoFilter
27
30
  end
@@ -1,4 +1,4 @@
1
- #! /pkgs/ruby19/bin/ruby19
1
+ #! /usr/local/bin/ruby18
2
2
  require 'rcodetools/xmpfilter'
3
3
  require 'rcodetools/doc'
4
4
  require 'rcodetools/options'
@@ -1,4 +1,4 @@
1
- #! /pkgs/ruby19/bin/ruby19
1
+ #! /usr/local/bin/ruby18
2
2
  # Copyright (c)
3
3
  # 2006-2007 Mauricio Fernandez <mfp@acm.org> http://eigenclass.org
4
4
  # 2006-2007 rubikitch <rubikitch@ruby-lang.org> http://www.rubyist.net/~rubikitch/
@@ -1,4 +1,4 @@
1
- #! /pkgs/ruby19/bin/ruby19
1
+ #! /usr/local/bin/ruby18
2
2
  require 'rcodetools/xmpfilter'
3
3
  require 'rcodetools/options'
4
4
 
@@ -378,4 +378,29 @@ class XMPCompletionEmacsIciclesFilter < XMPCompletionEmacsFilter
378
378
  end
379
379
  end
380
380
 
381
+ class XMPCompletionEmacsAnythingFilter < XMPCompletionEmacsFilter
382
+ @candidates_with_description_flag = true
383
+
384
+ def completion_code(code, lineno, column=nil)
385
+ elisp = "(progn\n"
386
+ table = "(setq rct-method-completion-table `("
387
+
388
+ begin
389
+ klass, cands = candidates_with_class(code, lineno, column)
390
+ cands.sort.each do |minfo|
391
+ meth, description = split_method_info(minfo)
392
+ table << format('("%s\\t[%s]" . ,(propertize "%s" \'desc "%s")) ',
393
+ meth, description, meth, description)
394
+ end
395
+ table << "))\n"
396
+ rescue Exception => err
397
+ return error_code(err)
398
+ end
399
+ elisp << table
400
+ elisp << %Q[(setq pattern "#{prefix}")\n]
401
+ elisp << %Q[(setq klass "#{klass}")\n]
402
+ elisp << ")" # /progn
403
+ end
404
+ end
405
+
381
406
  end
@@ -15,7 +15,7 @@ require 'tmpdir'
15
15
  module Rcodetools
16
16
 
17
17
  class XMPFilter
18
- VERSION = "0.8.3"
18
+ VERSION = "0.8.4"
19
19
 
20
20
  MARKER = "!XMP#{Time.new.to_i}_#{Process.pid}_#{rand(1000000)}!"
21
21
  XMP_RE = Regexp.new("^" + Regexp.escape(MARKER) + '\[([0-9]+)\] (=>|~>|==>) (.*)')
@@ -157,7 +157,10 @@ See also `rct-interactive'."
157
157
  command opt (or rct-option-local "")
158
158
  (rct-current-line)
159
159
  ;; specify column in BYTE
160
- (string-bytes (buffer-substring (point-at-bol) (point)))
160
+ (string-bytes
161
+ (encode-coding-string
162
+ (buffer-substring (point-at-bol) (point))
163
+ buffer-file-coding-system))
161
164
  (if rct-use-test-script (rct-test-script-option-string) ""))
162
165
  eval-buffer)
163
166
  (message "")
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcodetools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3.0
4
+ version: 0.8.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubikitch and Mauricio Fernandez
@@ -9,11 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-09 00:00:00 +09:00
12
+ date: 2009-04-18 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: "rcodetools is a collection of Ruby code manipulation tools. It includes xmpfilter and editor-independent Ruby development helper tools, as well as emacs and vim interfaces. Currently, rcodetools comprises: * xmpfilter: Automagic Test::Unit assertions/RSpec expectations and code annotations * rct-complete: Accurate method/class/constant etc. completions * rct-doc: Document browsing and code navigator * rct-meth-args: Precise method info (meta-prog. aware) and TAGS generation"
16
+ description: |
17
+ rcodetools is a collection of Ruby code manipulation tools.
18
+ It includes xmpfilter and editor-independent Ruby development helper tools,
19
+ as well as emacs and vim interfaces.
20
+
21
+ Currently, rcodetools comprises:
22
+ * xmpfilter: Automagic Test::Unit assertions/RSpec expectations and code annotations
23
+ * rct-complete: Accurate method/class/constant etc. completions
24
+ * rct-doc: Document browsing and code navigator
25
+ * rct-meth-args: Precise method info (meta-prog. aware) and TAGS generation
26
+
17
27
  email: "\"rubikitch\" <rubikitch@ruby-lang.org>, \"Mauricio Fernandez\" <mfp@acm.org>"
18
28
  executables:
19
29
  - rct-complete
@@ -176,6 +186,8 @@ files:
176
186
  - test/data/xmpfilter/multi_line_annotation_5.taf
177
187
  has_rdoc: true
178
188
  homepage: http://eigenclass.org/hiki.rb?rcodetools
189
+ licenses: []
190
+
179
191
  post_install_message: |+
180
192
 
181
193
  ==============================================================================
@@ -215,9 +227,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
227
  requirements: []
216
228
 
217
229
  rubyforge_project:
218
- rubygems_version: 1.3.1
230
+ rubygems_version: 1.3.2
219
231
  signing_key:
220
- specification_version: 2
232
+ specification_version: 3
221
233
  summary: rcodetools is a collection of Ruby code manipulation tools
222
234
  test_files:
223
235
  - test/test_functional.rb