[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-ruby c749e54eee 063/265: Support Bond completion
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-ruby c749e54eee 063/265: Support Bond completion |
Date: |
Sat, 9 Jul 2022 21:59:14 -0400 (EDT) |
branch: elpa/inf-ruby
commit c749e54eee65c59c5221b2d77bd5f6f83364269a
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Support Bond completion
Most of it appropriated from https://github.com/pd/inf-ruby-bond.
---
inf-ruby.el | 50 ++++++++++++++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 14 deletions(-)
diff --git a/inf-ruby.el b/inf-ruby.el
index 0d0bb5884c..dab42c6db7 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -2,11 +2,15 @@
;; Copyright (C) 1999-2008 Yukihiro Matsumoto, Nobuyoshi Nakada
-;; Author: Yukihiro Matsumoto, Nobuyoshi Nakada
+;; Author: Yukihiro Matsumoto
+;; Nobuyoshi Nakada
+;; Cornelius Mika <cornelius.mika@gmail.com>
+;; Dmitry Gutov <dgutov@yandex.ru>
+;; Kyle Hargraves <pd@krh.me>
;; URL: http://github.com/nonsequitur/inf-ruby
;; Created: 8 April 1998
;; Keywords: languages ruby
-;; Version: 2.2.6
+;; Version: 2.2.7
;;; Commentary:
;;
@@ -358,9 +362,10 @@ The reason for this is unknown. Remove this line from
`completions'."
(cdr completions)
completions))
-(defun inf-ruby-completions (seed)
- "Return a list of completions for the line of ruby code starting with SEED."
+(defun inf-ruby-completions (expr)
+ "Return a list of completions for the Ruby expression starting with EXPR."
(let* ((proc (inf-ruby-proc))
+ (line (replace-regexp-in-string "\n$" "" (thing-at-point 'line)))
(comint-filt (process-filter proc))
(kept "") completions)
(set-process-filter proc (lambda (proc string) (setq kept (concat kept
string))))
@@ -368,12 +373,15 @@ The reason for this is unknown. Remove this line from
`completions'."
proc
(format (concat "if defined?(Pry.config) then "
"completor = Pry.config.completer"
- ".build_completion_proc(binding, defined?(_pry_) &&
_pry_)"
+ ".build_completion_proc(binding, defined?(_pry_) ? _pry_
: Pry.new)"
+ " elsif defined?(Bond.agent) && Bond.started? then "
+ "completor = Bond.agent"
" elsif defined?(IRB::InputCompletor::CompletionProc)
then "
"completor = IRB::InputCompletor::CompletionProc "
"end and "
- "puts completor.call('%s').compact\n")
- (ruby-escape-single-quoted seed)))
+ "puts completor.call('%s', '%s').compact\n")
+ (ruby-escape-single-quoted expr)
+ (ruby-escape-single-quoted line)))
(while (and (not (string-match inf-ruby-prompt-pattern kept))
(accept-process-output proc 2)))
(setq completions (butlast (split-string kept "\r?\n") 2))
@@ -381,25 +389,39 @@ The reason for this is unknown. Remove this line from
`completions'."
(set-process-filter proc comint-filt)
completions))
+(defconst inf-ruby-ruby-expr-break-chars " \t\n\"\'`><,;|&{(")
+
+(defun inf-ruby-completion-bounds-of-expr-at-point ()
+ (save-excursion
+ (let ((end (point)))
+ (skip-chars-backward (concat "^" inf-ruby-ruby-expr-break-chars))
+ (cons (point) end))))
+
+(defun inf-ruby-completion-expr-at-point ()
+ (let ((bounds (inf-ruby-completion-bounds-of-expr-at-point)))
+ (buffer-substring (car bounds) (cdr bounds))))
+
(defun inf-ruby-completion-at-point ()
(if inf-ruby-at-top-level-prompt-p
- (let* ((curr (replace-regexp-in-string "\n$" "" (thing-at-point 'line)))
- (completions (inf-ruby-completions curr)))
+ (let* ((expr (inf-ruby-completion-expr-at-point))
+ (completions (inf-ruby-completions expr)))
(if completions
(if (= (length completions) 1)
(car completions)
(completing-read "possible completions: "
- completions nil t curr))))
+ completions nil t expr))))
(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"
+ "Complete the Ruby code at point.
+Uses the first one available of Pry, Bond and the default IRB
+completion."
(interactive (list (inf-ruby-completion-at-point)))
(when command
- (kill-whole-line 0)
- (insert command)))
+ (let ((bounds (inf-ruby-completion-bounds-of-expr-at-point)))
+ (delete-region (car bounds) (cdr bounds)))
+ (insert command)))
(defun inf-ruby-complete-or-tab (&optional command)
"Either complete the ruby code at point or call
- [nongnu] elpa/inf-ruby 5fa2849dd0 028/265: Store non-whitespace input in the REPL history, regardless of character length., (continued)
- [nongnu] elpa/inf-ruby 5fa2849dd0 028/265: Store non-whitespace input in the REPL history, regardless of character length., ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 89147d2ab1 056/265: inf-ruby-completions: Get rid of the last semicolon, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby c08bb93df2 040/265: inf-ruby-load-file is not defined, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 90762203f3 055/265: inf-ruby-switch-from-compilation: Change the process filter, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 4873a66a4d 054/265: inf-ruby-completions: Use 'then' instead of semicolons, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 7fc1e32ae7 050/265: Bump the version, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 530ac4f2fc 036/265: inf-ruby-mode: Modify the docstring, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 98fac55a80 049/265: Define inf-ruby-switch-from-compilation, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby fc1dffaeed 052/265: inf-ruby-prompt-format: Include debugger prompt, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby ebceb38165 058/265: inf-ruby-prompt-format: Fix not to match single operator chars, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby c749e54eee 063/265: Support Bond completion,
ELPA Syncer <=
- [nongnu] elpa/inf-ruby b12e05a6bb 068/265: Add funtion switching to compilation mode., ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 8fe1c3d80a 061/265: Bump the version, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby a6daf44f67 067/265: Changed 'bundle exec irb' to 'bundle console', ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby b767d52caf 066/265: inf-ruby-console-gem: Pass -r arguments in the bundle exec case, too, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby d18e63e44e 102/265: Not real need for the third argument, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 3a68ee2bb1 086/265: Touch up docstrings, change the signatures of inf-ruby-complete[-or-tab], ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 9f0cea55f0 073/265: Extend usage section, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 870e27f1ee 125/265: Detect pry gem in case to run bundle exec pry., ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 6c85470ce4 110/265: inf-ruby-implementations: use '--noreadline', ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 524a86c90b 089/265: Set PAGER locally unless it's set, fixes #33, ELPA Syncer, 2022/07/09