diff --git a/README.md b/README.md index f90042a..47cc355 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ Robe is a code assistance tool that uses a Ruby REPL subprocess with your application or gem code loaded, to provide information about loaded classes and modules, and where each method is defined. -Generally, you'll want to start with `M-x inf-ruby-console-auto`. -If there's no Ruby console running, most interactive commands provided -by Robe will offer to launch it automatically. +Generally, you'll want to start with `M-x inf-ruby-console-auto` or +with `M-x robe-start` (which will offer to call the former function as +well if there is no Ruby console running). Some interactive commands +provided by Robe will also offer to launch it first. The exceptions are code completion and eldoc, which only work if the server is already running. To launch it, type `M-x robe-start`. diff --git a/robe.el b/robe.el index 3619a88..4ca85ab 100644 --- a/robe.el +++ b/robe.el @@ -1346,7 +1346,7 @@ Only works with Rails, see e.g. `rinari-console'." (robe-complete-symbol-p (car bounds))) (buffer-substring (car bounds) (cdr bounds))))) -(defun robe--xref-backend () 'robe) +(defun robe--xref-backend () (and (robe-running-p) 'robe)) (cl-defmethod xref-backend-identifier-completion-table ((_backend (eql 'robe))) (let ((context (robe-context)) @@ -1379,8 +1379,6 @@ Only works with Rails, see e.g. `rinari-console'." (cond (at-pt (or (robe--xref-variable-definition identifier (nth 3 context)) - ;; FIXME: Probably move this check to `robe--xref-backend'. - (ignore (robe-start)) (append (robe--xref-method-definitions identifier context) (robe--xref-module-definitions identifier (nth 1 context))))) @@ -1431,6 +1429,11 @@ Only works with Rails, see e.g. `rinari-console'." (list (xref-make name var))))) +;; XXX: Search across the full LOAD_PATH as well? +(cl-defmethod xref-backend-references ((backend (eql 'robe)) identifier) + ;; FIXME: Do more filtering by scope, to remove definite non-matches. + (cl-call-next-method backend (car (last (string-split identifier "::\\|#\\|\\."))))) + (cl-defmethod xref-location-marker ((var robe--variable)) (save-excursion (save-restriction @@ -1490,8 +1493,6 @@ Only works with Rails, see e.g. `rinari-console'." (file-relative-name file dir) file))) -;; TODO: `xref-backend-references' across LOAD_PATH. - (defvar robe-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-c C-d") 'robe-doc)