branch: elpa/inf-ruby
commit 13c0040b6e8646ce4c9b62f41afef73b38111731
Author: Cornelius Mika <[email protected]>
Commit: Cornelius Mika <[email protected]>
Create non-indenting completion function 'inf-ruby-complete'.
Retain 'inf-ruby-complete-or-tab' for use outside of inf-ruby buffers.
---
inf-ruby.el | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/inf-ruby.el b/inf-ruby.el
index 5852da808b..e0f10654bb 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -50,7 +50,7 @@
(let ((map (copy-keymap comint-mode-map)))
(define-key map (kbd "C-c C-l") 'inf-ruby-load-file)
(define-key map (kbd "C-x C-e") 'ruby-send-last-sexp)
- (define-key map (kbd "TAB") 'inf-ruby-complete-or-tab)
+ (define-key map (kbd "TAB") 'inf-ruby-complete)
map)
"*Mode map for inf-ruby-mode")
@@ -344,26 +344,34 @@ Then switch to the process buffer."
(set-process-filter proc comint-filt)
completions))
+(defun inf-ruby-completion-at-point ()
+ (if inf-ruby-at-top-level-prompt-p
+ (let* ((curr (thing-at-point 'line))
+ (completions (inf-ruby-completions curr)))
+ (case (length completions)
+ (0 nil)
+ (1 (car completions))
+ (t (completing-read "possible completions: "
+ completions nil t curr))))
+ (message "Completion aborted: Not at a top-level prompt")
+ nil))
+
+(defun inf-ruby-complete (command)
+ "Complete the ruby code at point. Relies on the irb/completion
+Module used by readline when running irb through a terminal"
+ (interactive (list (inf-ruby-completion-at-point)))
+ (when command
+ (move-beginning-of-line 1)
+ (kill-line 1)
+ (insert command)))
+
(defun inf-ruby-complete-or-tab (&optional command)
"Either complete the ruby code at point or call
-`indent-for-tab-command' if no completion is available. Relies
-on the irb/completion Module used by readline when running irb
-through a terminal."
- (interactive (list (if inf-ruby-at-top-level-prompt-p
- (let* ((curr (thing-at-point 'line))
- (completions (inf-ruby-completions curr)))
- (case (length completions)
- (0 nil)
- (1 (car completions))
- (t (completing-read "possible completions: "
- completions nil t curr))))
- (message "Completion aborted: Not at a top-level
prompt")
- nil)))
+`indent-for-tab-command' if no completion is available."
+ (interactive (list (inf-ruby-completion-at-point)))
(if (not command)
(call-interactively 'indent-for-tab-command)
- (move-beginning-of-line 1)
- (kill-line 1)
- (insert command)))
+ (inf-ruby-complete command)))
;;;###autoload
(eval-after-load 'ruby-mode