I find that pry-remote is the best way to run pry within Emacs, since then pry gets its own dedicated buffer and can attach to a ruby process from anywhere (included a non-Emacs terminal or things like pow). I use something like this:
(defun my-run-remote-pry (&rest args)
(interactive)
(let ((buffer (apply 'make-comint "pry-remote" "pry-remote" nil args)))
(switch-to-buffer buffer)
(setq-local comint-process-echoes t)))
(define-key ruby-mode-map (kbd "C-c r d") 'my-run-remote-pry) ; (or whatever keybinding)
Then, you'll put binding.remote_pry
in your code; you attach to a waiting pry
with C-c r d
(or whatever) and exit pry (continuing the process) with C-c C-d
.
You'll also probably want to disable paging in your ~/.pryrc
, since it doesn't play well with comint
:
Pry.config.pager = false