Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs shell output buffer height

Tags:

python

emacs

i have the following in my .emacs file(thanks to SOer nikwin), which evaluates the current buffer content and displays the output in another buffer.

 (defun shell-compile ()
  (interactive)
(save-buffer)
   (shell-command (concat "python " (buffer-file-name))))

 (add-hook 'python-mode-hook
           (lambda () (local-set-key (kbd "\C-c\C-c") 'shell-compile)))

The problem is that the output window takes half the emacs screen. Is there any way to set the output windows's height to something smaller. I googled for 30mins or so and could not find anything that worked. Thanks in advance.

like image 775
jimbo Avatar asked Jul 05 '26 02:07

jimbo


1 Answers

This expands the source code buffer by 20 lines whenever its height is less than or equal to half the frame's height. Pretty crude, but it may serve your purpose.

(defun shell-compile ()
  (interactive)
  (save-buffer)
  (shell-command (concat "python " (buffer-file-name)))
  (if (<= (* 2 (window-height)) (frame-height))
      (enlarge-window 20)
    nil))
like image 92
unutbu Avatar answered Jul 06 '26 16:07

unutbu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!