我的.emacs文件中有以下内容(感谢SOer nikwin),它评估当前缓冲区内容并在另一个缓冲区中显示输出。
(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)))
问题是输出窗口占用了emacs屏幕的一半。有没有办法将输出窗口的高度设置为更小的值。我用Google搜索了30分钟左右,找不到任何有用的东西。提前谢谢。
答案 0 :(得分:1)
每当源高度小于或等于帧高度的一半时,它会将源代码缓冲区扩展20行。非常粗糙,但它可能符合你的目的。
(defun shell-compile ()
(interactive)
(save-buffer)
(shell-command (concat "python " (buffer-file-name)))
(if (<= (* 2 (window-height)) (frame-height))
(enlarge-window 20)
nil))
答案 1 :(得分:0)
之前我问过非常相似的问题:emacs programmatically change window size
这是我曾经拥有的(在使用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)