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

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

[nongnu] elpa/inf-ruby f9c856bd54: Improve compatibility with advanced c


From: ELPA Syncer
Subject: [nongnu] elpa/inf-ruby f9c856bd54: Improve compatibility with advanced completion styles
Date: Wed, 10 Aug 2022 21:58:42 -0400 (EDT)

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

    Improve compatibility with advanced completion styles
    
    Fixes #162
---
 inf-ruby.el | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/inf-ruby.el b/inf-ruby.el
index 226a72647f..27b0c1d4b8 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -833,11 +833,15 @@ Then switch to the process buffer."
 (defun inf-ruby-completions (prefix)
   "Return a list of completions for the Ruby expression starting with EXPR."
   (let* ((proc (inf-ruby-proc))
-         (line (buffer-substring (save-excursion (move-beginning-of-line 1)
-                                                 (point))
-                                 (point)))
-         (expr (inf-ruby-completion-expr-at-point))
-         (prefix-offset (- (length expr) (length prefix)))
+         (line
+          (concat
+           (buffer-substring (save-excursion (move-beginning-of-line 1)
+                                             (point))
+                             (car (inf-ruby-completion-bounds-of-prefix)))
+           ;; prefix can be different, as requested by completion style.
+           prefix))
+         (target (inf-ruby-completion-target-at-point))
+         (prefix-offset (length target))
          (comint-filt (process-filter proc))
          (kept "") completions
          ;; Guard against running completions in parallel:
@@ -871,7 +875,7 @@ Then switch to the process buffer."
                    "    Bond.agent.instance_variable_set('@weapon', old_wp) if 
old_wp "
                    "  end "
                    "}.call('%s', '%s')\n")
-                  (ruby-escape-single-quoted expr)
+                  (ruby-escape-single-quoted (concat target prefix))
                   (ruby-escape-single-quoted line))))
             (process-send-string proc completion-snippet)
             (while (and (not (string-match inf-ruby-prompt-pattern kept))
@@ -908,6 +912,13 @@ Then switch to the process buffer."
     (and bounds
          (buffer-substring (car bounds) (cdr bounds)))))
 
+(defun inf-ruby-completion-target-at-point ()
+  (let ((bounds (inf-ruby-completion-bounds-of-expr-at-point)))
+    (and bounds
+         (buffer-substring
+          (car bounds)
+          (car (inf-ruby-completion-bounds-of-prefix))))))
+
 (defun inf-ruby-completion-at-point ()
   "Retrieve the list of completions and prompt the user.
 Returns the selected completion or nil."



reply via email to

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