emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/inf-ruby 422cc1be93 093/265: Fix #35


From: ELPA Syncer
Subject: [nongnu] elpa/inf-ruby 422cc1be93 093/265: Fix #35
Date: Sat, 9 Jul 2022 21:59:17 -0400 (EDT)

branch: elpa/inf-ruby
commit 422cc1be939b9ba8d8816dae67631c5e168d7aab
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Fix #35
---
 inf-ruby.el | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/inf-ruby.el b/inf-ruby.el
index bf1811af06..5ee62366c1 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -401,15 +401,6 @@ Then switch to the process buffer."
     (replace-regexp-in-string "\n" "\\\\n"
       (replace-regexp-in-string "\\\\" "\\\\\\\\" str))))
 
-(defsubst inf-ruby-fix-completions-on-windows (completions)
-  "Maybe remove the first item from COMPLETIONS.
-On Windows, the string received by `accept-process-output' starts
-with the last line that was sent to the Ruby process because the
-subprocess echoes input."
-  (if (eq system-type 'windows-nt)
-      (cdr completions)
-    completions))
-
 (defun inf-ruby-completions (expr)
   "Return a list of completions for the Ruby expression starting with EXPR."
   (let* ((proc (inf-ruby-proc))
@@ -421,10 +412,8 @@ subprocess echoes input."
          inf-ruby-at-top-level-prompt-p)
     (set-process-filter proc (lambda (proc string) (setq kept (concat kept 
string))))
     (unwind-protect
-        (progn
-          (process-send-string
-           proc
-           (format (concat "if defined?(Pry.config) then "
+        (let ((completion-snippet
+               (format (concat "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 "
@@ -434,11 +423,14 @@ subprocess echoes input."
                            "end and "
                            "puts completor.call('%s', '%s').compact\n")
                    (ruby-escape-single-quoted expr)
-                   (ruby-escape-single-quoted line)))
+                   (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))
-          (setq completions (inf-ruby-fix-completions-on-windows completions)))
+          ;; 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))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]