[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-ruby 441cda957c 101/265: Support completion in Pry 1.0
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-ruby 441cda957c 101/265: Support completion in Pry 1.0.0.pre1 |
Date: |
Sat, 9 Jul 2022 21:59:17 -0400 (EDT) |
branch: elpa/inf-ruby
commit 441cda957c08fb3f836877dd3ce3f1fda3418a3d
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Support completion in Pry 1.0.0.pre1
* Closes #45
* Explicitly drop completion support in rdebug, if it was even still
working. The complexity isn't worth it.
---
inf-ruby.el | 60 +++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 23 deletions(-)
diff --git a/inf-ruby.el b/inf-ruby.el
index bc478bee9f..dfe2fb0289 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -441,29 +441,43 @@ Then switch to the process buffer."
(kept "") completions
;; Guard against running completions in parallel:
inf-ruby-at-top-level-prompt-p)
- (set-process-filter proc (lambda (proc string) (setq kept (concat kept
string))))
- (unwind-protect
- (let ((completion-snippet
- (format (concat "proc { |expr, line| "
- "if defined?(Pry.config) then "
- "completor = Pry.config.completer"
- ".build_completion_proc(binding, defined?(_pry_) ?
_pry_ : Pry.new)"
- " elsif defined?(Bond.agent) && Bond.started? then "
- "completor = Bond.agent"
- " end ? (puts completor.call(expr, line).compact) :
"
- "if defined?(IRB::InputCompletor::CompletionProc)
then "
- "puts
IRB::InputCompletor::CompletionProc.call(expr).compact "
- "end }.call('%s', '%s')\n")
- (ruby-escape-single-quoted expr)
- (ruby-escape-single-quoted line))))
- (process-send-string proc completion-snippet)
- (while (and (not (string-match inf-ruby-prompt-pattern kept))
- (accept-process-output proc 2)))
- (setq completions (butlast (split-string kept "\r?\n") 2))
- ;; Subprocess echoes output on Windows and OS X.
- (when (and completions (string= (concat (car completions) "\n")
completion-snippet))
- (setq completions (cdr completions))))
- (set-process-filter proc comint-filt))
+ (unless (equal "(rdb:1) " (buffer-substring (car comint-last-prompt)
+ (cdr comint-last-prompt)))
+ (set-process-filter proc (lambda (proc string) (setq kept (concat kept
string))))
+ (unwind-protect
+ (let ((completion-snippet
+ (format
+ (concat
+ "proc { |expr, line, old_wp|"
+ " require 'ostruct';"
+ " begin"
+ " Bond.agent.instance_variable_set('@weapon',"
+ " OpenStruct.new(line_buffer: line)) if old_wp;"
+ " if defined?(_pry_.complete) then"
+ " puts _pry_.complete(expr)"
+ " else"
+ " completer = if defined?(_pry_) then"
+ "
Pry.config.completer.build_completion_proc(binding, _pry_)"
+ " elsif old_wp then"
+ " Bond.agent"
+ " elsif defined?(IRB::InputCompletor::CompletionProc)
then"
+ " IRB::InputCompletor::CompletionProc"
+ " end and puts completer.call(expr).compact"
+ " end"
+ " ensure"
+ " Bond.agent.instance_variable_set('@weapon', old_wp) if
old_wp "
+ " end "
+ "}.call('%s', '%s', defined?(Bond) && Bond.started? &&
Bond.agent.weapon)\n")
+ (ruby-escape-single-quoted expr)
+ (ruby-escape-single-quoted line))))
+ (process-send-string proc completion-snippet)
+ (while (and (not (string-match inf-ruby-prompt-pattern kept))
+ (accept-process-output proc 2)))
+ (setq completions (butlast (split-string kept "\r?\n") 2))
+ ;; Subprocess echoes output on Windows and OS X.
+ (when (and completions (string= (concat (car completions) "\n")
completion-snippet))
+ (setq completions (cdr completions))))
+ (set-process-filter proc comint-filt)))
completions))
(defconst inf-ruby-ruby-expr-break-chars " \t\n\"\'`><,;|&{(")
- [nongnu] elpa/inf-ruby 57b3419be3 175/265: Allow single quoted gemspec name, (continued)
- [nongnu] elpa/inf-ruby 57b3419be3 175/265: Allow single quoted gemspec name, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 73e2142a99 194/265: Add new option inf-ruby-console-environment, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 7aa37e9154 199/265: Add ruby-send-line function, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 05984b3d24 201/265: inf-ruby-console-read-directory: Fix for predicates with wildcards, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 401f191d53 045/265: Touch up docstrings, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby d308394e7a 041/265: inf-ruby-output-filter: Ignore empty strings, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 5fa2f80d4e 057/265: inf-ruby-completions: Pass _pry_ when it's defined, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 2c28bc9f57 060/265: inf-ruby-prompt-format: Include whitespace after rdb prompt, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby c5d2178f17 072/265: Add a basic README, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 819e67542a 114/265: inf-ruby-console-gem: really skip directories under lib, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 441cda957c 101/265: Support completion in Pry 1.0.0.pre1,
ELPA Syncer <=
- [nongnu] elpa/inf-ruby 8c0aa0911b 118/265: Add "Bugs" section, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby b3747e9574 127/265: Merge pull request #59 from proofit404/master, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 9157d9c561 115/265: inf-ruby-console-gem: when gemspec doesn't modify LOAD_PATH, -I lib, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 4da1cca555 079/265: Set process filter in inf-ruby-switch-to-compilation, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby a960434970 096/265: run-ruby: write better docstring, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby dbb8d63324 082/265: Add missing license section to comment front-matter, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 27143433e4 083/265: A few doc fixes, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby d91f395070 080/265: Add missing require for thingatpt, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 4c39cd1509 123/265: Fix a couple of compilation warnings, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 00237986d8 130/265: Turn `inf-ruby-implementations` into custom form, ELPA Syncer, 2022/07/09