jimbo
jimbo

Reputation: 379

Emacs shell output buffer height

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.

Upvotes: 3

Views: 879

Answers (2)

unutbu
unutbu

Reputation: 879869

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))

Upvotes: 2

Anycorn
Anycorn

Reputation: 51485

I asked very similar question before: emacs programmatically change window size

this is what I used to have (before using ecb)

(defun collapse-compilation-window (buffer)
  "Shrink the window if the process finished successfully."
  (let ((compilation-window-height 5))
    (compilation-set-window-height (get-buffer-window buffer 0))))

(add-hook 'compilation-finish-functions
          (lambda (buf str)
            (if (string-match "exited abnormally" str)
;               (next-error)
              ;;no errors, make the compilation window go away in a few seconds
              ;(run-at-time "2 sec" nil 'delete-windows-on (get-buffer-create "*compilation*"))
              (collapse-compilation-window buf)
              (message "No Compilation Errors!")
              )
            ))

;(add-hook 'compilation-finish-functions 'my-compilation-finish-function)

Upvotes: 0

Related Questions