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

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

[nongnu] elpa/inf-ruby d1e6e9e669 003/265: Bugfix: Escape the completion


From: ELPA Syncer
Subject: [nongnu] elpa/inf-ruby d1e6e9e669 003/265: Bugfix: Escape the completion seed.
Date: Sat, 9 Jul 2022 21:59:09 -0400 (EDT)

branch: elpa/inf-ruby
commit d1e6e9e6693674a2a30bb6b2f931bd91399a9c84
Author: Cornelius Mika <cornelius.mika@gmail.com>
Commit: Cornelius Mika <cornelius.mika@gmail.com>

    Bugfix: Escape the completion seed.
---
 inf-ruby.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/inf-ruby.el b/inf-ruby.el
index 698825bf1c..6a639cdf00 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -312,13 +312,19 @@ Then switch to the process buffer."
                                               file-name
                                               "\"\)\n")))
 
+(defun ruby-escape-single-quoted (str)
+  (replace-regexp-in-string "'" "\\\\'"
+    (replace-regexp-in-string "\n" "\\\\n" 
+      (replace-regexp-in-string "\\\\" "\\\\\\\\" str))))
+
 (defun inf-ruby-completions (seed)
   "Return a list of completions for the line of ruby code starting with SEED."
   (let* ((proc (get-buffer-process inf-ruby-buffer))
         (comint-filt (process-filter proc))
         (kept "") completions)
     (set-process-filter proc (lambda (proc string) (setf kept (concat kept 
string))))
-    (process-send-string proc (format "puts 
IRB::InputCompletor::CompletionProc.call('%s').compact\n" seed))
+    (process-send-string proc (format "puts 
IRB::InputCompletor::CompletionProc.call('%s').compact\n"
+                                      (ruby-escape-single-quoted seed)))
     (while (not (string-match inf-ruby-prompt-pattern kept)) 
(accept-process-output proc))
     (if (string-match "^[[:alpha:]]+?Error: " kept) (error kept))
     (setf completions (butlast (split-string kept "[\r\n]") 2))



reply via email to

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