nonsequitur / inf-ruby

218 stars 69 forks source link

Switching back to Ruby source from inf #44

Closed shakthimaan closed 10 years ago

shakthimaan commented 10 years ago

1 How do I switch from the inf buffer back to the Ruby source buffer?

2 I have the following in ~/.emacs:

;; inf-ruby (autoload 'inf-ruby "inf-ruby" "Run an inferior Ruby process" t) (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)

Including the following: (add-hook 'after-init-hook 'inf-ruby-switch-setup)

produces the message:

"symbol's value as variable is void ruby-compilation-mode-map"

Using Emacs 24.3-13 on Fedora 20 (x86_64).

dgutov commented 10 years ago
  1. With winner-mode? I can add a dedicated command for this, if you like.
  2. You might be using an old version of ruby-compilation from somewhere. AFAICS, the ones from MELPA and Marmalade have this line:
(define-compilation-mode ruby-compilation-mode "RubyComp"

It defines a new major mode, and a related keymap with it.

shakthimaan commented 10 years ago

Can you please provide the dedicated command or code snippet I should use for the same? Thanks for the prompt response.

dgutov commented 10 years ago

Here you go. New command, bound to C-c C-z in repl buffers.

shakthimaan commented 10 years ago

When I type C-c C-z in the REPL buffer, it simply displays the same in the irb> prompt. I checked what it is assigned to using C-h k, and it returns:

C-c C-z runs the command comint-stop-subjob, which is an interactive compiled Lisp function.

It is bound to C-c C-z, .

(comint-stop-subjob)

Stop the current subjob. This command also kills the pending input between the process mark and point.

WARNING: if there is no current subjob, you can end up suspending the top-level process running in the buffer. If you accidentally do this, use M-x comint-continue-subjob to resume the process. (This is not a problem with most shells, since they ignore this signal.)

What could I be missing?

dgutov commented 10 years ago

Are you using the current inf-ruby master?

shakthimaan commented 10 years ago

Yes!

$ md5sum ~/.emacs.d/lib/inf-ruby.el bc4fd3f16126d03c8b31b42becaf03b4 /home/foo/.emacs.d/lib/inf-ruby.el

dgutov commented 10 years ago

What's the major mode you have in that REPL? Press M-:, type major-mode, press Return.

If you type M-x find-function, Return, inf-ruby, does it open the file you listed above?

What command do you use to open the REPL?

shakthimaan commented 10 years ago

"M-:" and "major-mode" returns "inf-ruby-mode".

"M-x find-function" and "inf-ruby" opens the ~/.emacs.d/lib/inf-ruby.el file in a buffer.

dgutov commented 10 years ago

Sorry, I've no idea what could be wrong. It works for me.

inf-ruby-mode should use inf-ruby-mode-map, and it has a new C-c C-z binding.

Do you use a reasonably recent version of Emacs?

shakthimaan commented 10 years ago

Using Emacs 24.3-13 on Fedora 20 (x86_64).

dgutov commented 10 years ago

Tried it in 24.3: works fine, too.

shakthimaan commented 10 years ago

Can you please share your minimial .emacs configuration that works with this commit?

dgutov commented 10 years ago

There's not much to do, aside from installing inf-ruby. If you're running in a terminal, that could be a reason (some key sequences work differently there), but it works fine on my system, too.

Here's a recording of installing it via package.el and using it: https://asciinema.org/a/7997

If you're running from a Git checkout, adding the dir to the load path plus your config from the first message in this thread should do it just as well. But if you have problems getting things working with a custom setup, better stick to the streamlined package.el installation.

shakthimaan commented 10 years ago

Thanks for the nice asciinema video. I removed ~/.emacs.d and used only the following in ~/.emacs.

(load "/tmp/inf-ruby.el")

I was able to switch to the irb prompt using "M-x inf-ruby", "C-c C-s" or "C-c C-z". But, switching back prints "C-c C-z" in the output, as shown.

Which distribution do you use? inf-output

dgutov commented 10 years ago

(load "/tmp/inf-ruby.el")

This setup works fine for me, too.

Which distribution do you use?

Ubuntu 13.10, but that's probably irrelevant. I compile Emacs myself (you can see the path to 24.3 in the recording, it's a tarball extracted into ~/Downloads).

At this point I can only recommend you to write to help-gnu-emacs or maybe report a bug.

The binding is in inf-ruby-mode-map, it's used in inf-ruby-mode (see the use-local-map call), and that's the major mode used in the REPL buffer, as you've checked.