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

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

Closed
bawalsh3000 opened this issue Jul 29, 2014 · 5 comments
Closed

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

bawalsh3000 opened this issue Jul 29, 2014 · 5 comments

Comments

@bawalsh3000
Copy link

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

@dgutov
Copy link
Owner

dgutov commented Jul 29, 2014

Yep, I've also seen the pry hooks error, but didn't have time to look into it.

Any suggestions how to fix it?

@bawalsh3000
Copy link
Author

Sorry, I'm just starting out with emacs/elisp , so no suggestions off the top my head :)
I'll try more fiddling

@dgutov
Copy link
Owner

dgutov commented Jul 30, 2014

This seems to help:

diff --git a/inf-ruby.el b/inf-ruby.el
index e6b55be..61cea16 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -229,8 +229,17 @@ The following commands are available:
   (when (eq system-type 'windows-nt)
     (setq comint-process-echoes t))
   (compilation-shell-minor-mode t)
+  (inf-ruby-set-window-size)
+  (add-hook 'window-configuration-change-hook 'inf-ruby-set-window-size nil t)
   (run-hooks 'inf-ruby-mode-hook))

+(defun inf-ruby-set-window-size ()
+  (let ((proc (get-buffer-process (current-buffer))))
+    (when proc
+      (set-process-window-size
+       proc (window-text-height) (1- (window-body-width))))))
+
 (defun inf-ruby-output-filter (output)
   "Check if the current prompt is a top-level prompt."
   (unless (zerop (length output))

Although I do wonder if that's something Pry should handle itself. It's not like it ends up using the returned values in any meaningful way, AFAICS.

@dgutov
Copy link
Owner

dgutov commented Jul 31, 2014

I've reverted the workaround, but see the update in the inf-ruby README now.

@bawalsh3000
Copy link
Author

Ya, I finally wound up turning off pager too. It's shame that Pry just
checks for nil window size before triggering the default.

On Wed, Jul 30, 2014 at 10:02 PM, Dmitry Gutov notifications@github.com
wrote:

I've reverted the workaround, but see the update in the inf-ruby README
now.


Reply to this email directly or view it on GitHub
#37 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants