[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-ruby d130ede56a 133/265: Define a proper completion fu
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-ruby d130ede56a 133/265: Define a proper completion function |
Date: |
Sat, 9 Jul 2022 21:59:20 -0400 (EDT) |
branch: elpa/inf-ruby
commit d130ede56a1203d0aa1c8e5bca5fedbfb14e7ce8
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Define a proper completion function
inf-ruby-mode: Add to completion-at-point-functions.
inf-ruby-completion-at-point: Adhere to that interface.
inf-ruby-completion-bounds-of-expr-at-point: Return nil when inside a word.
inf-ruby-complete, inf-ruby-complete-replace-expr,
inf-ruby-complete-or-tab: Remove.
---
inf-ruby.el | 55 ++++++++++++++++---------------------------------------
1 file changed, 16 insertions(+), 39 deletions(-)
diff --git a/inf-ruby.el b/inf-ruby.el
index f9ed36e4e6..9264d1c075 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -10,7 +10,7 @@
;; URL: http://github.com/nonsequitur/inf-ruby
;; Created: 8 April 1998
;; Keywords: languages ruby
-;; Version: 2.3.3
+;; Version: 2.4.0
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -129,7 +129,7 @@ graphical char in all other prompts.")
(let ((map (copy-keymap comint-mode-map)))
(define-key map (kbd "C-c C-l") 'ruby-load-file)
(define-key map (kbd "C-x C-e") 'ruby-send-last-sexp)
- (define-key map (kbd "TAB") 'inf-ruby-complete)
+ (define-key map (kbd "TAB") 'completion-at-point)
(define-key map (kbd "C-x C-q") 'inf-ruby-maybe-switch-to-compilation)
(define-key map (kbd "C-c C-z") 'ruby-switch-to-last-ruby-buffer)
map)
@@ -246,6 +246,7 @@ The following commands are available:
(set (make-local-variable 'comint-prompt-read-only)
inf-ruby-prompt-read-only)
(when (eq system-type 'windows-nt)
(setq comint-process-echoes t))
+ (add-hook 'completion-at-point-functions 'inf-ruby-completion-at-point nil t)
(compilation-shell-minor-mode t)
(run-hooks 'inf-ruby-mode-hook))
@@ -509,52 +510,28 @@ Then switch to the process buffer."
(defun inf-ruby-completion-bounds-of-expr-at-point ()
"Return bounds of expression at point to complete."
- (save-excursion
- (let ((end (point)))
- (skip-chars-backward (concat "^" inf-ruby-ruby-expr-break-chars))
- (cons (point) end))))
+ (when (not (memq (char-syntax (following-char)) '(?w ?_)))
+ (save-excursion
+ (let ((end (point)))
+ (skip-chars-backward (concat "^" inf-ruby-ruby-expr-break-chars))
+ (cons (point) end)))))
(defun inf-ruby-completion-expr-at-point ()
"Return expression at point to complete."
(let ((bounds (inf-ruby-completion-bounds-of-expr-at-point)))
- (buffer-substring (car bounds) (cdr bounds))))
+ (and bounds
+ (buffer-substring (car bounds) (cdr bounds)))))
(defun inf-ruby-completion-at-point ()
"Retrieve the list of completions and prompt the user.
Returns the selected completion or nil."
- (if inf-ruby-at-top-level-prompt-p
- (let* ((expr (inf-ruby-completion-expr-at-point))
- (completions (inf-ruby-completions expr)))
- (if completions
- (if (= (length completions) 1)
- (car completions)
- (completing-read "possible completions: "
- completions nil t expr))))
- (message "Completion aborted: Not at a top-level prompt")
- nil))
-
-(defun inf-ruby-complete ()
- "Complete the Ruby code at point.
-Uses the first one available of Pry, Bond and the default IRB
-completion."
- (interactive)
- (let ((replacement (inf-ruby-completion-at-point)))
- (when replacement
- (inf-ruby-complete-replace-expr replacement))))
-
-(defun inf-ruby-complete-replace-expr (str)
- "Replace expression at point with STR."
(let ((bounds (inf-ruby-completion-bounds-of-expr-at-point)))
- (delete-region (car bounds) (cdr bounds)))
- (insert str))
-
-(defun inf-ruby-complete-or-tab ()
- "Complete the Ruby code at point or call `indent-for-tab-command'."
- (interactive)
- (let ((replacement (inf-ruby-completion-at-point)))
- (if (not replacement)
- (call-interactively 'indent-for-tab-command)
- (inf-ruby-complete-replace-expr replacement))))
+ (when bounds
+ (list (car bounds) (cdr bounds)
+ (when inf-ruby-at-top-level-prompt-p
+ (if (fboundp 'completion-table-with-cache)
+ (completion-table-with-cache #'inf-ruby-completions)
+ (completion-table-dynamic #'inf-ruby-completions)))))))
(defvar inf-ruby-orig-compilation-mode nil
"Original compilation mode before switching to `inf-ruby-mode'.")
- [nongnu] elpa/inf-ruby 281c1263f9 097/265: Fix completion in Ruby 1.8.7, (continued)
- [nongnu] elpa/inf-ruby 281c1263f9 097/265: Fix completion in Ruby 1.8.7, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 9e2c0ab255 117/265: inf-ruby-console-rails: use 'bundle exec' if Gemfile is present, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby f232f780ec 119/265: Link to the issue 51, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby d4d2451d16 111/265: Apply `defcustom` fixes, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby fd84092271 099/265: Merge pull request #43 from hrvladev/fix-readme-typo, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 14ca8ddda5 098/265: Fix code indication in the readme, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 8979f51c53 126/265: Start console.rb through bundler., ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby db0bdf3f38 107/265: Merge pull request #50 from avsej/master, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 2cebc69ecd 095/265: Remove some outdated code, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 6c00b018bf 142/265: inf-ruby-console-rails-p: Use a stricter check, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby d130ede56a 133/265: Define a proper completion function,
ELPA Syncer <=
- [nongnu] elpa/inf-ruby b31b7d3061 137/265: inf-ruby-console-patterns-alist: Detect Rails by the presence of bin/rails, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 1f69ae4baf 157/265: Automatically entering inf-ruby on pry, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 03e969c89a 146/265: Retain compilation-arguments, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 7f8f32e7d0 154/265: Use 'point-min instead of the hardcoded value, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 45af13a729 172/265: Recognize byebug prompt, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 8b198d01e9 180/265: Merge pull request #93 from sideshowcoder/zeus-console-support, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby c14a68d164 207/265: Specify environment correctly, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 5ae6149a15 211/265: Merge pull request #110 from ppiotrowicz/master, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby a986a1a8c6 260/265: Fix broken behaviour on load-current-ruby-file fn, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby dbf4386bac 264/265: Use a more uniform style, ELPA Syncer, 2022/07/09