如何防止 emacs 为编译输出打开新窗口? [英] How can I prevent emacs from opening new window for compilation output?
本文介绍了如何防止 emacs 为编译输出打开新窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何防止 emacs 在调用 compile 命令时打开新窗口?我想将其绑定到特定的现有窗口.
How can I prevent emacs from opening new window when I invoke compile command? I would like to bind it to a particular existing window.
推荐答案
根据您对 Luke 的评论,我建议您检查一下我使用的这个函数.我喜欢它,因为如果没有错误,它会掩埋编译缓冲区,否则它会保留它以便您可以看到它们.
Based on your comments with Luke, I would recommend checking out this function that I use. I like it because it buries the compilation buffer if there were no errors, otherwise it leaves it up so you can see them.
您可以查看该页面的 emacs wiki,但代码如下:
You can check emacs wiki for the page, but here is the code:
;; Helper for compilation. Close the compilation window if
;; there was no error at all. (emacs wiki)
(defun compilation-exit-autoclose (status code msg)
;; If M-x compile exists with a 0
(when (and (eq status 'exit) (zerop code))
;; then bury the *compilation* buffer, so that C-x b doesn't go there
(bury-buffer)
;; and delete the *compilation* window
(delete-window (get-buffer-window (get-buffer "*compilation*"))))
;; Always return the anticipated result of compilation-exit-message-function
(cons msg code))
;; Specify my function (maybe I should have done a lambda function)
(setq compilation-exit-message-function 'compilation-exit-autoclose)
您可以随时切换回编译缓冲区以查看任何警告.
You can always switch back to the compilation buffer to view any warnings.
这篇关于如何防止 emacs 为编译输出打开新窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文