【发布时间】:2012-06-18 01:42:08
【问题描述】:
我想在没有错误和警告时自动关闭编译缓冲区,但我想在有警告时显示它。任何人都可以帮助我吗?来自emacswiki 的这段代码只满足第一个要求。怎么改?
;; Helper for compilation. Close the compilation window if
;; there was no error at all.
(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)
【问题讨论】:
-
@Thomas 这不是关键问题
-
了解您正在运行的编译器可能很有用,因为您可以使用
msg参数来检查是否有错误或警告。 -
您可以尝试在 and 子句中添加另一个条件以在 compilation 缓冲区中查找字符串 'warning'。或者您的编译器用来指示警告的任何其他字符串。
-
@vpit3833 我刚试过了,但是没用。
标签: emacs buffer compile-mode