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

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

[nongnu] elpa/inf-ruby dc7df6541e 091/265: inf-ruby-completions: Make sa


From: ELPA Syncer
Subject: [nongnu] elpa/inf-ruby dc7df6541e 091/265: inf-ruby-completions: Make safer
Date: Sat, 9 Jul 2022 21:59:16 -0400 (EDT)

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

    inf-ruby-completions: Make safer
    
    #35
---
 inf-ruby.el | 42 +++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/inf-ruby.el b/inf-ruby.el
index af5ac02d3b..798f8a415e 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -414,26 +414,30 @@ subprocess echoes input."
          (line (buffer-substring (save-excursion (beginning-of-thing 'line))
                                  (point)))
          (comint-filt (process-filter proc))
-         (kept "") completions)
+         (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))))
-    (process-send-string
-     proc
-     (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 "
-                     "completor = Bond.agent"
-                     " elsif defined?(IRB::InputCompletor::CompletionProc) 
then "
-                     "completor = IRB::InputCompletor::CompletionProc "
-                     "end and "
-                     "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))
-    (setq completions (inf-ruby-fix-completions-on-windows completions))
-    (set-process-filter proc comint-filt)
+    (unwind-protect
+        (progn
+          (process-send-string
+           proc
+           (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 "
+                           "completor = Bond.agent"
+                           " elsif 
defined?(IRB::InputCompletor::CompletionProc) then "
+                           "completor = IRB::InputCompletor::CompletionProc "
+                           "end and "
+                           "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))
+          (setq completions (inf-ruby-fix-completions-on-windows completions)))
+      (set-process-filter proc comint-filt))
     completions))
 
 (defconst inf-ruby-ruby-expr-break-chars " \t\n\"\'`><,;|&{(")



reply via email to

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