1

In haskell-mode, C-c C-b opens a GHC REPL for testing and whatnot. However, it invariably opens in a frame equal in size to the one in which I am coding. There is a mode hook, inferior-haskell-mode-hook, but my attempts to add something along the lines of

(add-hook 'inferior-haskell-mode-hook 
    (lambda () (shrink-window 4)))

have resulted in either no effect, or the error message Cannot resize the root window of a frame. Any suggestions would be greatly appreciated.

Edit: The newest update to haskell-mode has borked the REPL functionality entirely, so this question is moot, or at least I can't test the answers until I fix it...

asg0451
  • 493
  • 4
  • 13

2 Answers2

1

Your error says it all, you cannot resize a window if it is the only window in a frame, it doesn't make sense to do so.

If what you want is to actually change the frame height, just use set-frame-height, you could use it in conjunction with frame-height to shrink the frame by 4 lines.

(set-frame-height (current-frame) (- (frame-height (current-frame)) 4)

It could be the case you are not always creating a new frame, in which case you could check if you should actually shrink the window by checking if (window-size-fixed-p (current-window) nil) is 1. Then do shrink-window else shrink the frame.

Jordon Biondo
  • 3,974
  • 1
  • 27
  • 37
1

As @Jordan said, you can explicitly specify the size of the frame that is created.

In addition, to fit a frame to the buffer shown in its (typically sole) window, you can use library fit-frame.el. I bind it to C-x C-_. And if you also use library autofit-frame.el then you can have frames automatically fit to their buffers.

For example, if C-c C-b creates a frame that shows a buffer that is already filled with text (I have no idea whether that is the case), then autofit-frame.el can be used to have the new frame automatically shrink-fit the buffer.

Of if not - if the new frame essentially shows an empty buffer (e.g. for testing) and you want a larger frame for what you will type into it, you can forego automatic fitting and fit the frame manually whenever you like.

Or you can put command fit-frame on a hook, to fit the frame to its buffer according to some state or event.

More info.

Drew
  • 29,895
  • 7
  • 74
  • 104