Emacs Shell 输出缓冲区高度
我在我的 .emacs 文件里有以下内容(感谢 SO 的用户 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 窗口的一半。有没有办法把输出窗口的高度设置得小一些呢?我搜索了大约 30 分钟,但没有找到有效的解决办法。提前谢谢大家。
2 个回答
0
我之前问过一个很相似的问题:如何在emacs中通过编程改变窗口大小
这是我之前用的代码(在使用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)
2
当源代码的显示区域高度小于或等于窗口高度的一半时,这段代码会让显示区域的高度增加20行。虽然这个方法比较简单粗暴,但可能正好满足你的需求。
(defun shell-compile ()
(interactive)
(save-buffer)
(shell-command (concat "python " (buffer-file-name)))
(if (<= (* 2 (window-height)) (frame-height))
(enlarge-window 20)
nil))