Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-blocking start #93

Open
dre-hh opened this issue Sep 21, 2016 · 12 comments
Open

Non-blocking start #93

dre-hh opened this issue Sep 21, 2016 · 12 comments

Comments

@dre-hh
Copy link

dre-hh commented Sep 21, 2016

hi, how hard would it be to make robe not blocking the main emacs interface on starting. rails projects with a lot of gems tend to have really bad startup times?

@dgutov
Copy link
Owner

dgutov commented Sep 21, 2016

Why? You don't have to start it right away.

@dre-hh
Copy link
Author

dre-hh commented Sep 21, 2016

as long as it starting, one cannot do anything. i am not starting it right away.

@sandric
Copy link

sandric commented Dec 5, 2016

Yes, I can approve that - robe-start hangs emacs for me for like 5 seconds, I assume its loading environment to pry console.

@dgutov
Copy link
Owner

dgutov commented Dec 5, 2016

Here's a question. Suppose we have a new command, robe-start-nonblocking.

Would you still expect it to start the REPL in the background, or would it rely on the REPL being already launched?

@vlymar
Copy link

vlymar commented Jan 29, 2017

I too am interested in this feature, but I recognize there are some tradeoffs.

Would you still expect it to start the REPL in the background, or would it rely on the REPL being already launched?

I'd prefer it to start the REPL in the background. The way I bump against this blocking behavior is usually (note: I use spacemacs):

  1. I start a new emacs session
  2. I attempt to jump to the definition of a ruby method
  3. I get a prompt No ruby console running. Launch automatically? (y or n)
  4. I hit y
  5. A list of the possible rails environments comes up, and I select one
  6. Emacs locks up while the console is loaded

I'd prefer for the editor to never be locked up, but I see that it might be jarring for a user to trigger a robe command, then get no indication that the command worked (while the console is loaded in the background), the suddenly have the effect of their command to happen several seconds later while they may have done several other things in the editor.

Perhaps theres some way to have a loading indicator somewhere in the UI?

As an alternative I may look into triggering info-ruby-console-auto automatically when I first start emacs.

@stardiviner
Copy link

Here is my personal settings for robe auto starting, hope this can help some people.

  ;; ruby-mode has keybinding [C-c C-s] for `inf-ruby'.
  ;; auto start robe `robe-start' after start `inf-ruby'.
  (defun my-robe-start ()
    (interactive)
    (unless robe-running
      (robe-start)))

  (defadvice inf-ruby-console-auto (after inf-ruby-console-auto activate)
    "Run `robe-start' after `inf-ruby-console-auto' started."
    (my-robe-start))

  (with-eval-after-load 'projectile-rails
    (define-key projectile-rails-mode-map
      [remap inf-ruby] 'inf-ruby-console-auto))

  (defadvice inf-ruby (after inf-ruby activate)
    "Run `robe-start' after `inf-ruby' started."
    (my-robe-start))

  (define-key enh-ruby-mode-map (kbd "C-c C-s") 'inf-ruby)

  ;; auto start robe process for completing
  (defun my-robe-auto-start ()
    (unless robe-running
      (call-interactively 'inf-ruby)))
  (add-hook 'enh-ruby-mode-hook #'my-robe-auto-start)

@dgutov
Copy link
Owner

dgutov commented May 21, 2017

@stardiviner Does that work in any way asynchronously?

I imagine you still have to wait for it to start when the first Ruby file in a given session is opened.

@stardiviner
Copy link

@dgutov Yes, just automate this start process for me for daily Ruby usage.
I agree your opinion of the robe REPL don't need to be async because user need a launched REPL to make sure can work. Not like big REPL like CIDER which will block Emacs for a long time if it is sync.

dgutov added a commit that referenced this issue May 22, 2017
dgutov added a commit that referenced this issue May 22, 2017
dgutov added a commit that referenced this issue May 22, 2017
dgutov added a commit that referenced this issue May 22, 2017
@dgutov
Copy link
Owner

dgutov commented May 22, 2017

@stardiviner Thanks for the clarification. Regarding your code:

  • It might not work as intended anymore, because robe-running is now a buffer-local variable since the introduction of multi-project support. On the other hand, it'll probably continue to function okay for a while because inf-ruby-console-auto does not do much if the console is already running.

  • If robe-start hanging Emacs for several seconds is the main issue, you might get away with only starting the REPL process automatically. inf-ruby and inf-ruby-console-auto both work asynchronously, so that should get you waiting less. M-x robe-start afterwards should work instantly.

@dgutov
Copy link
Owner

dgutov commented May 22, 2017

All that aside, I have implemented the asynchronous version. But it ended up being fairly convoluted.

Everybody interested, please check out the robe-start-async branch and see if it really makes your life better.

@dgutov
Copy link
Owner

dgutov commented May 22, 2017

To clarify @vlymar: robe-jump still uses the synchronous version, and will block until the server is started.

I can't imagine how it would work differently without causing weird behaviors if the user e.g. changes the window configuration.

@dgutov
Copy link
Owner

dgutov commented May 24, 2017

And if it does make your life better, please describe how.

@dre-hh A thumbs-up is appreciated, but not enough, sorry.

@dgutov dgutov changed the title non blocking start Non-blocking start Jun 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants