在进程退出并出现错误或警告之前,不要在Emacs中显示*compilation*buffer

Rov*_*ion 7 emacs buffer elisp process compile-mode

我正在寻找一种方法来让Mx编译触发Emacs 编译缓冲区,Mx重新编译或保存脚本上的一些编译仅在编译退出时​​出现错误或警告.

请注意,如果没有[1]中描述的错误或警告,我不会寻找关闭编译缓冲区的方法.不,我希望缓冲区在编译完全完成之前永远不会出现,只有在显示错误或警告时才会出现.

原因很简单:闪烁的编译缓冲区令人不安,并重新排列屏幕上代码的位置.如果你打开保存编译,这会变得更烦人.

编译缓冲区包含许多不同类型的化妆编译过程,以pdflatex所以这将是巨大的,如果它确定缓冲区是否应显示全线工程的功能.

[1] emacs编译缓冲区自动关闭?

ass*_*sem 5

像你看起来可以实现你想要的通过暂时禁用display-buffer跨越compilation-start

这是sds所说的内容和评论@ 这里发布的内容的组合

那里的评论存在一个令人讨厌的问题,即原始源缓冲区中的点跳转,我似乎也通过阻塞set-window-point和来解决goto-char。感觉像是一个肮脏的骇客,但到目前为止,它仍在工作。YMMV!

(defun brian-compile-finish (buffer outstr)
  (unless (string-match "finished" outstr)
    (switch-to-buffer-other-window buffer))
  t)

(setq compilation-finish-functions 'brian-compile-finish)

(require 'cl)

(defadvice compilation-start
  (around inhibit-display
      (command &optional mode name-function highlight-regexp)) 
  (if (not (string-match "^\\(find\\|grep\\)" command))
      (flet ((display-buffer)
         (set-window-point)
         (goto-char)) 
    (fset 'display-buffer 'ignore)
    (fset 'goto-char 'ignore)
    (fset 'set-window-point 'ignore)
    (save-window-excursion 
      ad-do-it))
    ad-do-it))

(ad-activate 'compilation-start)
Run Code Online (Sandbox Code Playgroud)

现在您应该看到,只有在outstr未返回成功的完成状态或以“ find”或“ grep”开头的被调用命令时,才会显示所有编译缓冲区。