Giter Site home page Giter Site logo

robe's Introduction

Robe Build Status MELPA

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 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.

As you change the code in your project, you'll want to update the running process. To load the current file, type C-c C-l (ruby-load-file), see inf-ruby for more commands. When you're working on a Rails project, you can type C-c C-k instead to reload the whole environment at once.

Features

  • Jump to method definition
  • Jump to super or a constructor called at point
  • Jump to a module/class/constant definition
  • Display method documentation
  • Display information about method called at point using ElDoc
  • Method and constant name completion
  • Jumping and completion for instance and local variable names, using simple regexp search in the current file

To see the available commands, type M-x describe-package RET robe RET.

Details

When performing one of the commands defined here, we either need to narrow the method name at point down to a specific method in a specific module, or enumerate the possible method names or constants allowed at point (for code completion).

To do that, we look at the contents of the buffer, and the context at point: in which method it is, of which class, and if it's in singleton class context. Then we look at the method call at point.

If the method call target is implicit (there's no target or the method is super), or the call target is obvious (Foo.new, self.foo), then we first try to look for the definition in the inheritance hierarchy of the target class. Otherwise, or if the initial search yields no result, scan all defined classes and modules.

Depending on the command, if the result is ambiguous, you're either prompted to resolve the ambiguity manually, or the results are merged together.

Install

Set up MELPA if you haven't already, then type M-x package-install RET robe RET.

In the init file:

(add-hook 'ruby-mode-hook 'robe-mode)
(add-hook 'ruby-ts-mode-hook 'robe-mode)

or

(global-robe-mode)

Dependencies

  • pry >= 0.10
  • pry-doc >= 0.6.0 (for stdlib docs on MRI; optional)
  • Ruby must be compiled with Readline support (how to check).
  • With Ruby 3.3, the gem readline-ext is also needed.

The alternative to the last two items is to configure the app not to use the Pry shell (at least when inside Emacs) while still keeping pry available for loading.

Note that if your project is using Bundler, all dependencies have to be in the Gemfile.

Completion

(eval-after-load 'company
  '(push 'company-robe company-backends))

Built-in completion (triggered with C-M-i) is also supported, no extra setup required.

Both of the above work only when the connection to the Ruby subprocess has been established. To do that, either use one of the core Robe commands, or type M-x robe-start.

Integration with rvm.el

rvm.el may not have activated the correct project Ruby before robe-start runs.

Either manually run M-x rvm-activate-corresponding-ruby before starting Robe, or advise inf-ruby-console-auto to activate rvm automatically.

(advice-add 'inf-ruby-console-auto :before #'rvm-activate-corresponding-ruby)

Compatibility

  • Tested in Emacs 24.4+, with Ruby 2.3-3.3, on GNU/Linux.
  • But see the section Dependencies above.
  • Essential features work with JRuby, though the startup is longer.
  • Mostly works on MS Windows, with minor glitches.
  • Built-in ruby-mode or ruby-ts-mode (Emacs 29+) work best, enh-ruby-mode is not recommended (it breaks the detection of the current context, see #47 and enhanced-ruby-mode#96).

Notes

  • We can't jump to methods defined in C (such as most of the core classes). To read their docs, install pry-doc or add it to your Gemfile.
  • We can't jump to lazily defined methods, such as model.column or find_by_ ActiveRecord methods, before they've been called. This is treatable, but low priority.
  • Jumping to methods defined with Module#delegate just brings us to the place where delegate is called, which is accurate, but often less than useful.
  • To work on several projects in the same Emacs session, you'll have to create the Ruby console for each project after the first one manually with M-x inf-ruby-console-auto. Otherwise, the first one will be used for all Ruby files, with suboptimal results.
  • We may get the context wrong for code inside a block if the method it's passed to uses instance_eval or instance_exec.

TODO

  • Handle delegate and send, Class.new.method and self.class.method.
  • For methods defined through macros, optionally jump to where the macro was called, instead of its definition?
  • Apropos search for classes and methods.
  • Better type inference.

Copying

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 the Free Software Foundation; either version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

robe's People

Contributors

alexpetrov avatar asok avatar bjpbakker avatar connorbey13 avatar dgtized avatar dgutov avatar dunn avatar edipofederle avatar edslocomb avatar kakakikikeke-fork avatar ovy avatar purcell avatar syohex avatar technomancy avatar yourpalal avatar zerodivisible avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robe's Issues

Could you add complete-on-dot feature to robe?

robe is an excellent package but I really want complete-on-dot feature.

The similar package, it's for python though, jedi is supporting that feature and I find that is very useful completion method.
I would send a pull request if I could, but unfortunately I don't know elisp for the moment.

Thanks in advance.

FYI
https://github.com/tkf/emacs-jedi

add ac-robe face for auto-complete.

I found Robe has not defined a face for ac-robe. (which has suffix r)
Here is what I got in auto-complete candidates. It looks ugly.
Please add ac-robe face definition.

robe-face-invalid

cannot run robe-rails-refresh

Hi,

I'm starting to use robe for rails development (read: I'm a newb) and now, all of a sudden, it doesn't work. When I run 'robe-rails-refresh' I get:

irb(main):002:0> E, [2014-06-06T19:59:35.875500 #31185] ERROR -- : Request failed: /rails_refresh/. Please file an issue.
E, [2014-06-06T19:59:35.875573 #31185] ERROR -- : uninitialized constant Robe::Sash::ActionDispatch
/home/renanranelli/.emacs.d/elpa/robe-20140401.1339/lib/robe/sash.rb:171:in `rails_refresh'
/home/renanranelli/.emacs.d/elpa/robe-20140401.1339/lib/robe/sash.rb:182:in `public_send'
/home/renanranelli/.emacs.d/elpa/robe-20140401.1339/lib/robe/sash.rb:182:in `call'
/home/renanranelli/.emacs.d/elpa/robe-20140401.1339/lib/robe/server.rb:40:in `block in start'
/home/renanranelli/.emacs.d/elpa/robe-20140401.1339/lib/robe/server.rb:28:in `loop'
/home/renanranelli/.emacs.d/elpa/robe-20140401.1339/lib/robe/server.rb:28:in `start'
/home/renanranelli/.emacs.d/elpa/robe-20140401.1339/lib/robe.rb:18:in `block in start'

I'm using rbenv and everything seens to work fine on emacs (e.g. rspec-mode) so I don't think it's an issue with that.

Also, when I open emacs shell and type bundle exec rails console and then `MyModel.new`` I receive:

WARNING: terminal is not fully functional
-  (press RETURN)

I have read issue #9 but since my inf-ruby shows => "robe on" I think that's not the same issue.

Any ideas ?

Robe launch failed

M-x robe-start (selected "development" environment) returns : "Robe launch failed"

but this isn't true, the console output is:

W, [2015-09-09T10:41:32.037870 #22292]  WARN -- : [SKYLIGHT] [0.8.0] Running Skylight in development mode. No data will be reported until you deploy your app.
(To disable this message, set `alert_log_file` in your config.)
I, [2015-09-09T10:41:32.217297 #22292]  INFO -- : ** [Raven] Raven 0.14.0 configured not to send errors.
Loading development environment (Rails 4.2.3)
�[0G[1] pry(main)> => "robe on 32932"
[2] pry(main)> 

Seems robe is turned on, but because the Raven message contains "errors", robe reports launch failed error:

(defun robe-start (&optional force)
...
    ((string-match-p "Error" s)
                               (setq failed t))
...
)

robe version: 20150829.205

robe-mode return lots of incorrect methods.

Hi. I'm using robe-mode + rvm.el.
When I using it for completing it always all methods for all objects.
Just like the following picture:
selection_012
However if I complete via C-M-i it will show "[No matches]".
Did I do something wrong? I'm using the latest version robe in list-package. The only ruby related configures are:

(add-hook 'ruby-mode-hook 'robe-mode)
(require 'rvm)  
(rvm-use-default)

robe-doc/eldoc for all methods?

First of all, robe is AWESOME 👍

Now, I noticed that eldoc shows informations for stuffs like belongs_to and that robe-doc works for it. However, it doens't work for File.exists? and other basic methods, while the package yari has no problem accessing it.

Any idea?

[EDIT] ha, actually yari doesn't work for belongs_to... basically it seems one works where the other doesn't

Error robe server doesn't respond

I have configuration:

(require 'robe)

(setq robe-turn-on-eldoc t
      robe-highlight-capf-candidates t
      )

;; start Robe server.
(eval-after-load 'robe
  '(progn
     (inf-ruby)
     (robe-start)))

(dolist (hook '(ruby-mode-hook
                enh-ruby-mode-hook
                inf-ruby-mode-hook ; FIXME: robe-mode is not enabled in inf-ruby-mode. seems this hook is not valid.
                ))
  (add-hook hook 'robe-mode))

(add-hook 'robe-mode-hook
          (lambda ()
            (ac-robe-setup)
            ))

And I tried to debug with emacs option -Q and -q, both will appear this error when I load robe.

And I checked out robe server port 24969 with command $ lsof -i :24969, get this result:

COMMAND   PID        USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
ruby    22179 stardiviner    7u  IPv4 152012      0t0  TCP localhost:24969 (LISTEN)
ruby    22179 stardiviner    8u  IPv4 152676      0t0  TCP localhost:24969->localhost:45101 (CLOSE_WAIT)

And I checked out the state flag CLOSE_WAIT, seems it means still has stream in the server or something else.
And I did google on this, but I can't understand more and dig more.

Can you help me out?

$stdout window size is [0,0] when using pry

When I enter ls -l into the inf-ruby buffer I get back a ZeroDivisonError coming from line 210 in pager.rb (pry)

I tried entering $stdout.winsize which returned [0,0]

I can set the window size manually with $stdout.winsize= and that fixes the error but this has to be entered each session.

Pry works normally in the gnome terminal.

Pry 0.10.0
Ruby 1.9.3
Emacs 24.3.1 (GTK)
Linux Mint 17

'Method not found' and 'Cannot locate this method' ...

I'm having some trouble getting robe to work properly ... I've got the necessary gems installed, and I'm starting robe in a gem with standard layout. The inf-ruby process appears to start (with buffer name *gem*), but hitting M-. just prints the message 'Method not found', whatever method point is at.

Similarly, only some documentation appears: mostly, I just get the message 'Cannot locate this method: [method]. Try 'gem install pry-doc ...`' etc. (I do have pry-doc installed).

Do you have any tips, or a step-by-step to get things working correctly?

An update and clarification on this: the second problem is solved by including pry and pry-doc as development dependencies in the gemspec (the project in question is a gem). Still no method-at-point navigation though.

problem installing robe from melpa

Hi,

I'm trying to install robe using melpa but I am getting the following error:

error: Error during download request: Not found.

Is there some problem with the robe package in melpa or am I doing something wrong??

ty

Calling robe-doc-for from elsewhere

Hey Dmitry! I'm writing an auto-complete source for inf-ruby-mode, and I'd like to hook the pop-up documentation into robe when it's available. robe-doc-for is the obvious entry point for this, but it expects a spec rather than just a symbol name. Is there an easy way to get the former from the latter? I didn't see anything in inf-ruby itself for querying documentation.

Robe may throw exception if a gem overrides `Class#instance_methods`

I got errors like below when using robe as a company backend. I looked into this case and it seems that it's because exifr overrides Class#instance_methods to include additional entries in the return of instance_methods but didn't include that in instance_method. https://github.com/remvee/exifr/blob/90f7734233f2a37cdc101bcc347265714fd0f02e/lib/exifr/tiff.rb#L429-L431

My proposed solution to this is to rescue NameError for the candidates << mod.instance_method(sym). But I still have a question about why EXIFR::JPEG is scanned when scanning candidates for an instance of a totally unrelated class.

Request failed: /complete_method/refer/rop/ReferralsController/-. Please file an issue.
undefined method `reference_black_white' for class `EXIFR::JPEG'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/scanners.rb:43:in `instance_method'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/scanners.rb:43:in `block in scan_methods'
/usr/local/opt/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/awesome_print-1.0.2/lib/awesome_print/core_ext/array.rb:62:in `block in grep'
/usr/local/opt/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/awesome_print-1.0.2/lib/awesome_print/core_ext/array.rb:60:in `each'
/usr/local/opt/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/awesome_print-1.0.2/lib/awesome_print/core_ext/array.rb:60:in `grep'
/usr/local/opt/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/awesome_print-1.0.2/lib/awesome_print/core_ext/array.rb:60:in `grep'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/scanners.rb:42:in `scan_methods'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/scanners.rb:20:in `block in scan'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/scanners.rb:13:in `each_object'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/scanners.rb:13:in `each'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/scanners.rb:13:in `scan'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/sash.rb:132:in `complete_method'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/sash.rb:176:in `public_send'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/sash.rb:176:in `call'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/server.rb:40:in `block in start'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/server.rb:28:in `loop'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe/server.rb:28:in `start'
/Users/song_xie/.emacs.d/.cask/24.5.1/elpa/robe-20150222.1644/lib/robe.rb:18:in `block in start'

Restarting inf-ruby confuses robe

If I start robe, then quit the inf-ruby buffer and re-start it, a second M-x robe-start has no effect: robe-running is still t, even though the buffer has disappeared. Perhaps it would be worth tracking the buffer in which robe was loaded, so that its disappearance can be handled.

Just a minor nit. :-)

Is this meant for public consumption yet?

Hi,
I gave robe a try but I cannot get it to work. Here is the stracktrace after starting inf-ruby and loading in the project code:

 [2013-03-04 23:33:05] INFO  WEBrick 1.3.1
[2013-03-04 23:33:05] INFO  ruby 1.9.3 (yyyy-mm-dd) [x86_64-unknown-linux-gnu]
[2013-03-04 23:33:05] WARN  TCPServer Error: Address already in use - bind(2)
[2013-03-04 23:33:05] WARN  TCPServer Error: Address already in use - bind(2)
Errno::EADDRINUSE: Address already in use - bind(2)
    from kernel/common/errno.rb:19:in `handle'
    from /home/expez/.rvm/rubies/rbx-head/lib/19/socket.rb:1251:in `tcp_setup'
    from /home/expez/.rvm/rubies/rbx-head/lib/19/socket.rb:1300:in `initialize'
    from /home/expez/.rvm/rubies/rbx-head/lib/19/webrick/utils.rb:85:in `create_listeners'
    from kernel/bootstrap/array.rb:68:in `each'
    from /home/expez/.rvm/rubies/rbx-head/lib/19/webrick/utils.rb:82:in `create_listeners'
    from /home/expez/.rvm/rubies/rbx-head/lib/19/webrick/server.rb:82:in `listen'
    from /home/expez/.rvm/rubies/rbx-head/lib/19/webrick/server.rb:70:in `initialize'
    from /home/expez/.rvm/rubies/rbx-head/lib/19/webrick/httpserver.rb:45:in `initialize'
    from /home/expez/.emacs.d/elpa/robe-20130111.859/lib/robe/server.rb:11:in `initialize'
    from /home/expez/.emacs.d/elpa/robe-20130111.859/lib/robe.rb:10:in `start'
    from (irb):3
    from kernel/common/block_environment.rb:75:in `call_on_instance'
    from kernel/common/eval.rb:75:in `eval'
    from kernel/common/kernel19.rb:42:in `loop'
    from kernel/common/throw_catch19.rb:8:in `catch'
    from kernel/common/throw_catch.rb:10:in `register'
    from kernel/common/throw_catch19.rb:7:in `catch'
    from kernel/common/throw_catch19.rb:8:in `catch'
    from kernel/common/throw_catch.rb:10:in `register'
    from kernel/common/throw_catch19.rb:7:in `catch'
    from kernel/common/codeloader.rb:212:in `require'
    from kernel/common/kernel.rb:649:in `gem_original_require (require)'
    from /home/expez/.rvm/rubies/rbx-head/lib/rubygems/custom_require.rb:36:in `require'
    from kernel/loader.rb:681:in `irb'

I figured the issue might be my use of Rubinius and ruby 2.0, but I couldn't get it to work with MRI and 1.9.3 either.

I grabbed your source and ran the spec and got quite a few failures running on Rubinius. One of the great things about Rubinius is that the stdlib itself is implemented in Ruby, so it is knowable. Of course, this meant that the specs which were meant to test the use of pry-doc as fallback failed, but there were other failures as well. These seem more serious:

rspec ./spec/robe/sash_spec.rb:53 # Robe::Sash#targets value is a module
rspec ./spec/robe/sash_spec.rb:80 # Robe::Sash#method_spec works on String#gsub
rspec ./spec/robe/sash_spec.rb:151 # Robe::Sash#method_targets examples returns the method on Class
rspec ./spec/robe/sash_spec.rb:167 # Robe::Sash#method_targets examples unknown target returns String method candidate
rspec ./spec/robe/sash_spec.rb:172 # Robe::Sash#method_targets examples unknown target does not return wrong candidates
rspec ./spec/robe/sash_spec.rb:222 # Robe::Sash#complete_method completes instance methods
rspec ./spec/robe/sash_spec.rb:302 # Robe::Sash#complete_const keeps the global

I noticed there was no .rvmrc in your robe folder, so I suppose another source of issues lies in the interaction between robe, inf-ruby and rvm.el.

As an aside how do you manage the load path for inf-ruby to add the current project? Do you manually $:.unshift "/path/to/lib"? I wrote a small helper function do this, but it felt pretty backwards.

If you think it's possible to get Robe to work with Rubinius, I'd be interested in helping with that.

Completing or showing the class intialization parameters

So I recently started using robe and I am pretty much liking it.
I noticed that currently it doesn't complete the class constructor-parameters which it is initialized with.

For instance, I have a class Foo that is initialized with parameters name and address. When creating instances with Foo.new(), the autocomplete doesn't list the method info or accepted parameters in the mini buffer.

Just saying cause I use Jedi.el for Python and it shows the function attributes no matter how and where exactly a particular Class is defined, when creating new instances!

So the question is, is it possible in robe?
I hope that helps improve robe :)

auto-complete does not start

I have inf-ruby console running and C-M-i brings up list of methods in second buffer but I cannot manage to show auto-complete-mode's popup with list of available completions.

I already have (push 'ac-source-robe ac-sources) in .emacs.

Is this a bug?

Buffer support

Hi i have write a simple ruby file, before i run M-x inf-ruby, M-x robe-start, then it can complete the stdlib in ruby very well, but it can't complete the class i define in the file,
Example,
class A
def foo_a
puts 'a'
end
def foo_b
puts 'b'
end
end

when i type a = A.new, a.foo, it don't list the foo_a and foo_b. But when i require './filename.rb' in inf-ruby console, it can list, why? Must i load the file i edit or needed in inf-ruby manually? Thanks!!!

Running robe-start produces error

When running robe-start, I get first Wrong type argument: stringp, nil from (get-buffer inf-ruby-buffer). This is apparently because inf-ruby-buffer returns nil. If I run inf-ruby-console-auto manually before robe-start I get forwards but receive the following stacktrace:

[1] pry(main)> => "robe on"
[2] pry(main)> E, [2015-02-18T11:19:06.784630 #14917] ERROR -- : Request failed: /rails_refresh/. Please file an issue.
E, [2015-02-18T11:19:06.784707 #14917] ERROR -- : uninitialized constant Robe::Sash::ActionDispatch
/.emacs.d/elpa/robe-20150216.1624/lib/robe/sash.rb:165:in `rails_refresh'
/.emacs.d/elpa/robe-20150216.1624/lib/robe/sash.rb:176:in `public_send'
/.emacs.d/elpa/robe-20150216.1624/lib/robe/sash.rb:176:in `call'
/.emacs.d/elpa/robe-20150216.1624/lib/robe/server.rb:40:in `block in start'
/.emacs.d/elpa/robe-20150216.1624/lib/robe/server.rb:28:in `loop'
/.emacs.d/elpa/robe-20150216.1624/lib/robe/server.rb:28:in `start'
/.emacs.d/elpa/robe-20150216.1624/lib/robe.rb:18:in `block in start'

Still getting errors when unconnected

This is the result of in-buffer tab-completion with robe mode enabled but no inf-ruby started:

Debugger entered--Lisp error: (error "No current process. See variable inf-ruby-buffer")
  signal(error ("No current process. See variable inf-ruby-buffer"))
  completion--some(#[257 "ELIDED" [1 ("") (#[771 "ELIDED" [robe-complete-thing boundaries metadata minibuffer-selected-window window-live-p window-buffer complete-with-action] 8 "\n\n(fn STRING PRED ACTION)"]) nil (0) completion-styles-alist] 6 "\n\n(fn STYLE)"] (basic partial-completion emacs22 initials))
  completion--nth-completion(1 "" #[771 "ELIDED" [robe-complete-thing boundaries metadata minibuffer-selected-window window-live-p window-buffer complete-with-action] 8 "\n\n(fn STRING PRED ACTION)"] nil 0 (metadata))
  completion-try-completion("" #[771 "ELIDED" [robe-complete-thing boundaries metadata minibuffer-selected-window window-live-p window-buffer complete-with-action] 8 "\n\n(fn STRING PRED ACTION)"] nil 0 (metadata))
  completion--do-completion()
  minibuffer-complete()
  call-interactively(minibuffer-complete)
  #[1028 "ELIDED" [minibuffer-completion-predicate minibuffer-completion-table completion-in-region-mode-predicate completion-in-region--data make-overlay nil t overlay-put field completion priority 100 completion-in-region-mode 1 markerp copy-marker funcall make-byte-code 0 "ELIDED" vconcat vector [delete-overlay] 2 "\n\n(fn)" call-interactively minibuffer-complete] 14 "\n\n(fn START END COLLECTION PREDICATE)"](#<marker at 166 in asset_magic.rb> 166 #[771 "ELIDED" [robe-complete-thing boundaries metadata minibuffer-selected-window window-live-p window-buffer complete-with-action] 8 "\n\n(fn STRING PRED ACTION)"] nil)
  apply(#[1028 "��ELIDED" [minibuffer-completion-predicate minibuffer-completion-table completion-in-region-mode-predicate completion-in-region--data make-overlay nil t overlay-put field completion priority 100 completion-in-region-mode 1 markerp copy-marker funcall make-byte-code 0 "\301\300!\207" vconcat vector [delete-overlay] 2 "\n\n(fn)" call-interactively minibuffer-complete] 14 "\n\n(fn START END COLLECTION PREDICATE)"] (#<marker at 166 in asset_magic.rb> 166 #[771 "ELIDED" [robe-complete-thing boundaries metadata minibuffer-selected-window window-live-p window-buffer complete-with-action] 8 "\n\n(fn STRING PRED ACTION)"] nil))
  #[771 "ELIDED" [(#0) t append nil apply apply-partially make-byte-code 642 "\300@���#\207" vconcat vector [] 7 "\n\n(fn FUNS GLOBAL &rest ARGS)" #[1028 "��ELIDED" [minibuffer-completion-predicate minibuffer-completion-table completion-in-region-mode-predicate completion-in-region--data make-overlay nil t overlay-put field completion priority 100 completion-in-region-mode 1 markerp copy-marker funcall make-byte-code 0 "ELIDED" vconcat vector [delete-overlay] 2 "\n\n(fn)" call-interactively minibuffer-complete] 14 "\n\n(fn START END COLLECTION PREDICATE)"]] 12 "\n\n(fn FUNS GLOBAL ARGS)"](nil nil (#<marker at 166 in asset_magic.rb> 166 #[771 "ELIDED" [robe-complete-thing boundaries metadata minibuffer-selected-window window-live-p window-buffer complete-with-action] 8 "\n\n(fn STRING PRED ACTION)"] nil))
  completion--in-region(#<marker at 166 in asset_magic.rb> 166 #[771 "ELIDED" [robe-complete-thing boundaries metadata minibuffer-selected-window window-live-p window-buffer complete-with-action] 8 "\n\n(fn STRING PRED ACTION)"] nil)
  completion-in-region(#<marker at 166 in asset_magic.rb> 166 #[771 "ELIDED" [robe-complete-thing boundaries metadata minibuffer-selected-window window-live-p window-buffer complete-with-action] 8 "\n\n(fn STRING PRED ACTION)"] nil)
  completion-at-point()
  indent-for-tab-command(nil)
  call-interactively(indent-for-tab-command nil nil)
  command-execute(indent-for-tab-command)

It'd be nice if robe-complete-at-point were a no-op in this situation.

Doesn't work without Gemfile

Hello,

I installed the gems in some gemset then I did M-x rvm-use and picked the gemset, yet robe refuses to work:

inf-ruby-console-auto: No matching directory found

Is this intentional? When I add a Gemfile everything works.

robe-show-doc exception

I get this error when trying to look up any docs.

call-interactively: Wrong number of arguments: #[(spec) "Æ�!�ÇÈ!�É�ÊÄ \"A�ÊÅ    \"A�ÊË    \"A��ÊÌ   \"A�Í�8�.�/Î���Î�0Ï�1B�1�2�3rÇ
!q�pÐ ��3�2Î��4�5É��6É�7�Ñ �ÒÓ!�+��8�9ÔG!�tÕÖ!�Õ!�×�8!�+Ø�0!�*r
q�Ù �
�¸Úc�ÛÜÝÞ#�:Öc��.�­`�;
c�ß�;`\"�)�²à
!c�Þ�:!�)eb��á�!c��.�Öâc�Ûã�.!Ýäå�ÉD%��æ��àÎ����ê��íÚc����üçèé��ê#±������ë�±��)ìí!. �" [spec doc buffer inhibit-read-only docstring source robe-doc-for get-buffer-create "*robe-doc*" t ...] 8 nil nil], 0

And here's a bit more info:

Debugger entered--Lisp error: (wrong-number-of-arguments #[(spec) "\306�!�\307\310!�\311�\312\304   \"A�\312\305    \"A�\312\313    \"A��\312\314   \"A�\315�8�.�/\316\211\223\210\316�0\317�1B�1�2�3r\307
!q\210p\320 \210�3�2\316\211�4�5\311\211�6\311�7�\321 \210\322\323!\210+\211�8�9\324G!\204t�\325\326!\210\325!\210\327�8!\210+\330�0!\210*r
q\210\331 \210
\203\270�\332c\210\333\334\335\336#�:\326c\210�.\203\255�`�;
c\210\337�;`\"\210)\202\262�\340
!c\210\336�:!\210)eb\210\212\341�!c\210�.\203\326�\342c\210\333\343�.!\335\344\345�\311D%\210�\346\232\203\340�\316���\204\352��\203\355�\332c\210��\203\374�\347\350\351��\352#\261�\210�\203��\353�\261�\210)\354\355!.  \207" [spec doc buffer inhibit-read-only docstring source robe-doc-for get-buffer-create "*robe-doc*" t assoc aliases visibility 4 nil #[nil "\301 \211�\207" [help-window selected-window] 2] kill-all-local-variables erase-buffer run-hooks temp-buffer-setup-hook zerop princ "

" internal-temp-output-buffer-show help-window-setup robe-doc-fontify-regions "
" insert-text-button "Source" type robe-toggle-source robe-doc-fontify-ruby robe-doc-fontify-c-string robe-signature " is defined in " file-name-nondirectory robe-method-def help-args "public" "
Aliases: " mapconcat identity ", " "
Visibility: " visual-line-mode 1 file help-window-point-marker help-window temp-buffer-show-hook default-directory old-dir buffer-read-only buffer-file-name buffer-undo-list inhibit-modification-hooks buf standard-output button beg] 8 nil nil] 0)
  robe-show-doc()
  call-interactively(robe-show-doc record nil)
  command-execute(robe-show-doc record)
  execute-extended-command(nil "robe-show-doc")
  call-interactively(execute-extended-command nil nil)

wrong completion candidates after require

I try with the following code:

require 'sqlite3'

database_file = "test.sqlite"
db = SQLite3::Da

The company-mode only completed candidates:

  • SQLite3::Data
  • SQLite3::Date
  • SQLite3::DateTime

There is no SQLite3::Database, And I tried it in Pry, the SQLite3::Database is the only candidate after SQLite3::Da. I don't know what's wrong here.

feature request: simplify changing project

If I change project, I'd like to be able to restart (or at least stop, and then start) robe in the context of the new buffer. I can do this right now by killing the inf-ruby buffer, but it seems like it could be more elegant.

PS: I have close to no idea what I'm doing in elisp, but if you judge that it's a task that can't be screwed up too badly by a beginner, I can give it a shot.

robe-start fails to load pry

after installing robe and doing bundle init, added pry and pry-doc to dev dependency and bundle install I get
LoadError: cannot load such file -- pry
from /home/gozes/.emacs.d/elpa/robe-20150126.808/lib/robe/sash/doc_for.rb:1:in require' from /home/gozes/.emacs.d/elpa/robe-20150126.808/lib/robe/sash/doc_for.rb:1:in<top (required)>'
from /home/gozes/.emacs.d/elpa/robe-20150126.808/lib/robe/sash.rb:1:in require' from /home/gozes/.emacs.d/elpa/robe-20150126.808/lib/robe/sash.rb:1:in<top (required)>'
from /home/gozes/.emacs.d/elpa/robe-20150126.808/lib/robe.rb:1:in require' from /home/gozes/.emacs.d/elpa/robe-20150126.808/lib/robe.rb:1:in<top (required)>'

OS: Linux
Ruby Version: 2.1
RVM: NO

Company robe hangs before presenting completions

I've been encountering a problem where completion frequently hangs. I enter 3 characters pause for a second, completion kicks in, and just hangs with the message "Contacting host: 127.0.0.1:24969". I've waited at least 30s and had no response. After using C-g to abort, it immediately presents a list of completions.

I benchmarked the robe server by adding request time information to the requests, and all completion lists were handled in < 0.25s, so it's not hanging on the server. I also benchmarked calling robe-request and that responded quickly, so it does not appear to be anything on the parsing edge of emacs.

(benchmark-run 10
  (robe-request "complete_method" "after" nil "ApplicationController" nil))

;; => (0.22050937399999998 0 0.0)

I then tried edebug on company-abort and found that C-g was not triggering that. So I used (setq debug-on-quit t) to diagnose what was blocking. Sometimes this resulted in the completion working without blocking, but when it did, the abort backtrace was:

Debugger entered--Lisp error: (quit)
  redisplay_internal\ \(C\ function\)()

So as soon as that is aborted it jumps back into company and displays the options.

I tried mucking around with company-echo-delay, and have a hunch this is related to eldoc making timer requests at the same time as robe. I haven't had much luck disabling eldoc. It's also tricky to test because occasionally completion just works, so it's tricky to tell if fiddling with something improved it, or I just randomly got a couple of completions to work.

I'm happy to try and work on a test case, but wanted to document what I have thus far, and see if anyone else had ideas.

VirtualBox support

Hey, i install ruby and rails in virtualbox and run rails in virtualbox through ssh. But i write code in local with emacs. Can i use robe with virtualbox?

Using robe-ac-setup loads robe-mode in all buffers

If I add the following to enable auto-complete with robe, then robe-mode is enabled in every open buffer and any that open after that.

(add-hook 'robe-mode 'robe-ac-setup)

I'm using emacs 24.3.50.1 with latest MELPA packages for quite a list of modes, so not sure if this is just interacting poorly with something else. I also tried adding ac-source-robe to ac-sources manually and that triggered the same behavior. Just using robe-mode as a hook for ruby-mode appears to keep it limited to buffers using ruby-mode. I can certainly live without auto-complete integration, but wondered if anyone else was having this issue.

Any ideas?

Company-robe slow to the point of being unsable

Hi,
As the title says, working with company-robe is impossible, it freezes emacs for a couple of minutes everytime I type an additional character. That's working with a file part of a small Rails app. The completion is correct, it just takes ages to come up.

Is this just me?
I'm running:
Emacs 24.3.1
company 20140518.538
robe 20140401.1339

Doc change?: mention inf-ruby instead of inf-ruby-console-auto for non rails applications

Hi,
I have opened a Sinatra app in Emacs. When I run inf-ruby-console-auto, I get the error:

inf-ruby-console-rails-envs: No files in my_sinatra_app/config/environments/

I tried inf-ruby instead and robe started working. I don't know if this an error on my part (emacs newbie) or something which should be mentioned in the robe docs.

On a separate note, I would like to thank you for the fine work that you have been doing in contributing to the emacs community.

"Private method singleton_method? called for" when jumping to a definition of function inside a module

When a module function is defined under module_function and called with module as receiver robe-mode's jump-to-definition fails. This outputs "End of file during parsing" to minibuffer and inf-ruby console has an error of

private method `singleton_class?' called for #<Class:0x007fa413878408>
.emacs.d/elpa/robe-20141120.1919/lib/robe/type_space.rb:41:in `reject!'
.emacs.d/elpa/robe-20141120.1919/lib/robe/type_space.rb:41:in `scan_with'
.emacs.d/elpa/robe-20141120.1919/lib/robe/sash.rb:102:in `method_targets'
.emacs.d/elpa/robe-20141120.1919/lib/robe/sash.rb:176:in `public_send'
.emacs.d/elpa/robe-20141120.1919/lib/robe/sash.rb:176:in `call'
.emacs.d/elpa/robe-20141120.1919/lib/robe/server.rb:40:in `block in start'
.emacs.d/elpa/robe-20141120.1919/lib/robe/server.rb:28:in `loop'
.emacs.d/elpa/robe-20141120.1919/lib/robe/server.rb:28:in `start'

Changes global value of 'completion-at-point-functions

Having loaded robe and opened a ruby buffer such that robe-mode has run, the global value of completion-at-point-functions contains robe-complete-at-point.

As a result, if I tab-complete symbols from the minibuffer for the eval-expression command, I get:

completion--some: No current process. See variable inf-ruby-buffer [4 times]

Should robe either

  1. make a buffer-local copy of completion-at-point-functions or
  2. make robe-complete-at-point a no-op when robe is inactive in the current buffer

?

-Steve

TRAMP support

Hello,

Is there any ways to have this work over TRAMP? I guess not but asking never hurts :)

Vim integration

Do you intend to integrate with Vim or has anyone managed to get this working with Vim?

'Method not found' for files in Sinatra app when I do robe-jump

Hi,
I am trying to do robe-jump in a Sinatra app. I open the file application.rb in the Sinatra app. I then do

  • M-x rvm-activate-corresponding-ruby ( No visible sign that it works though in the mini-buffer)
  • M-x inf-ruby( M-x inf-ruby-console-auto did not work for me. I guess this may be the offending part. I have documented the issue here at #45)
  • M-x robe-start
  • My application.rb calls a file within the same directory (e.g MyClass) as MyClass.new(a,b). When I do robe-jump on the word new, I get 'Method not found' error in the mini-buffer

Things I have tried.

  • When I type MyClass in my irb session started by inf-ruby, it raises an uninitialized constant error
  • When I do robe-jump on a method which is in the same file as application.rb, it does not recognize it and instead offers to show the method in the third-party gems(i.e. the mini-buffer shows Module: followed by a list of third party modules which have the method). robe-jump and returning back to the original file(application.rb) works when I go to the shown third-party file.

My system info:
Ruby version: 2.2
Emacs Version:24.4.1
OS: Mac Yosemite

Thanks,
Rajiv

very slow for single-letter completions

Hello,

I have (setq company-minimum-prefix-length 1) in my config.

Whenever I type [].pus then wait a little, the completion comes quickly (with push, push_bulk, push_inspect_key, etc). Then I press backspace twice and I have to wait around 10 seconds to get the [].p completions.

Same happens if I type [].p and then wait a little.

I guess this problem cannot be really solved, so my suggestion is to maybe turn the completion into something like "here is the list I have so far", which would be updated whenever new results come in.

At least make it asynchronous if you can :)

[EDIT] or... maybe just ignore it because minimum prefix length to 1 is probably a bit silly anyway? I'll set it to 2 and test the speed.

add support for company-mode jump to location in robe-complete-at-point

company-mode has a keybinding to jump to candidate location, and company-mode use company-capf for completion-at-point-functions and robe-complete-at-point.
robe-complete-at-point has annotation support already. I hope robe can add robe-jump to in completion function as support.

Thanks in advance.

End of file during parsing on typing "ex"

Hi,
I got frozen connection and error Company: back-end company-robe error "End of file during parsing" with args (candidates ex)
Steps to reproduce:

def my_method
  a = {a: 1, b: 2}
  a.sample
  # Cool! It works

  a.ex
  # Oooops! It seems to be frozen for some time
  # Company: back-end company-robe error "End of file during parsing" with args (candidates ex)
  # And of course no result
end

My config of robe (I'm requring it as prelude module)

(prelude-require-packages '(robe))
(add-hook 'ruby-mode-hook 'robe-mode)
(add-hook 'ruby-mode-hook
      (lambda ()
        (set (make-local-variable 'company-backends)
             (remq 'company-capf company-backends))))
(defadvice inf-ruby-console-auto (before activate-rvm-for-robe activate)
(rvm-activate-corresponding-ruby))
(global-company-mode t)
(push 'company-robe company-backends)
(provide 'prelude-robe)

Support vagrant box

Hi,

I have a few vagrant boxes running on Debian, each of these vagrant boxes contains a Rails project. I edit source code files in the shared folders from the host (aka Debian).

It seems to me that robe sever runs locally and therefore can't provide completion and doc lookup in my case. Any workaround?

Regards,
Wenshan

Problems with autocomplete from words in current buffer

Hi I have this configuration for ruby development

;; Files with the following extensions should open in ruby-mode
(add-to-list 'auto-mode-alist '(".rb$" . ruby-mode))
(add-to-list 'auto-mode-alist '(".rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
(add-to-list 'auto-mode-alist '(".gemspec$" . ruby-mode))
(add-to-list 'auto-mode-alist '(".ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))

(require 'ruby-mode)
(require 'inf-ruby)

;; When folding, take these delimiters into consideration
(add-to-list 'hs-special-modes-alist
'(ruby-mode
"(class|def|do|if)" "(end)" "#"
(lambda (arg) (ruby-end-of-block)) nil))

;; RVM support
(require 'rvm)
(rvm-use-default)

;; Cucumber
(require 'feature-mode)
(setq feature-use-rvm t) ;; Tell cucumber to use RVM
(setq feature-cucumber-command "cucumber {options} {feature}")
;; .feature files should open in feature-mode
(add-to-list 'auto-mode-alist '(".feature$" . feature-mode))

;; Rspec
(require 'rspec-mode)
;; I want rspec instead of rake spec
(setq rspec-use-rake-when-possible nil)
;; Scroll to the first test failure
(setq compilation-scroll-output 'first-error)

;; Projectile mode
(require 'projectile)
(projectile-global-mode)
(setq projectile-completion-system 'grizzl)

;; Prevent emacs from adding the encoding line at the top of the file
(setq ruby-insert-encoding-magic-comment nil)

;; Functions to help with refactoring
(require 'ruby-refactor)
(add-hook 'ruby-mode-hook 'ruby-refactor-mode-launch)
;; Easily toggle ruby's hash syntax
(require 'ruby-hash-syntax)
;; Ruby rdoc helpers mostly
(require 'ruby-additional)
;; Helpers to deal with strings and symbols
(require 'ruby-tools)
;; Support for YARD
(require 'yard-mode)
(add-hook 'ruby-mode-hook 'yard-mode)
;; Support for running rspec tests
(require 'rspec-mode)

;; Turn on eldoc in ruby files to display info about the
;; method or variable at point
(add-hook 'ruby-mode-hook 'eldoc-mode)
;; Switch the compilation buffer mode with C-x C-q (useful
;; when interacting with a debugger)
(add-hook 'after-init-hook 'inf-ruby-switch-setup)

(add-hook 'ruby-mode-hook
(lambda ()
(hs-minor-mode 1) ;; Enables folding
(modify-syntax-entry ?: "."))) ;; Adds ":" to the word definition

;; Start projectile-rails
(add-hook 'projectile-mode-hook 'projectile-rails-on)

;; robe autocompletion
(add-hook 'ruby-mode-hook 'robe-mode)
(global-company-mode t)
;;(push 'company-robe company-backends)
(eval-after-load 'company
'(progn
(push 'company-robe company-backends)
(push 'company-inf-ruby company-backends)))

;;(add-hook 'robe-mode-hook 'ac-robe-setup)
;;(add-hook 'robe-mode-hook
;; (lambda ()
;; (add-to-list 'ac-sources 'ac-source-robe)
;; (setq completion-at-point-functions '(auto-complete))))

(defadvice inf-ruby-console-auto (before activate-rvm-for-robe activate)
(rvm-activate-corresponding-ruby))

things works well but for example, company completes well the method say_hello...

captura de pantalla de 2015-07-15 13 23 28

then I can see the methods in inf-ruby

captura de pantalla de 2015-07-15 13 23 52

but when I make robe-start I can see ruby methods but not say_hello..

captura de pantalla de 2015-07-15 13 24 04

so here the problem after robe-start

captura de pantalla de 2015-07-15 13 24 23

If some body can help me, it will be good, thanks

captura0
captura1
captura2
captura3

rspec docs

Hi, I've recently found robe and I'm trying to get the doc or source code for methods like describe or expect (from rspec) and I get Method not found or some unrelated classes. Am I missing something ? Do I need to configure it somehow ?

Thanks

json-read: JSON readtable error

I'm running robe-jump on a method in a rails controller and I get this:

Contacting host: 127.0.0.1:24959
*beep*
json-read: JSON readtable error

robe auto launch does not work with latest version of pry

Robe doesn't seem to be working with latest version of pry because:

Loading development environment (Rails 3.2.13)
�[0G[1] pry(main)> �[1A�[0G[1] pry(main)> unless defined? Robe;  $:.unshift '/Users/gnufied/new_emacs/robe/lib';  require 'robe';end;Robe.start(24969)�[1B�[0GWARNING: terminal is not fully functional
                              -  (press RETURN)
                              => "robe on"

It could be basically because recent versions of pry has become almost non-functional in comint mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.