Emacs Shell Output Buffer Height

I have the following in my .emacs file (thanks to SOer nikwin) that evaluates the current contents of the buffer 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 occupies half the emacs screen. Is there a way to set the height of the output windows to something less. I googled for 30 minutes or so and could not find anything that worked. Thanks in advance.

+3
source share
2 answers

This extends the source code buffer by 20 lines when its height is less than or equal to half the height of the frame. 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))
+1
source

I asked a very similar question: emacs programmatically resizes the window

, ( 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)
0

Source: https://habr.com/ru/post/1743601/


All Articles