From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Amin Bandali Newsgroups: gmane.emacs.help Subject: Show *compilation* only if build did not succeed Date: Sat, 22 Dec 2018 10:12:35 -0500 Message-ID: <87h8f5fvdo.fsf@aminb.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1545491472 16574 195.159.176.226 (22 Dec 2018 15:11:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 22 Dec 2018 15:11:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 22 16:11:07 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gaivj-0004Dm-Bp for geh-help-gnu-emacs@m.gmane.org; Sat, 22 Dec 2018 16:11:07 +0100 Original-Received: from localhost ([::1]:43578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaixq-0000GA-49 for geh-help-gnu-emacs@m.gmane.org; Sat, 22 Dec 2018 10:13:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaixC-0000FF-2v for help-gnu-emacs@gnu.org; Sat, 22 Dec 2018 10:12:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaixB-0002uC-6A for help-gnu-emacs@gnu.org; Sat, 22 Dec 2018 10:12:38 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaixB-0002tu-2q for help-gnu-emacs@gnu.org; Sat, 22 Dec 2018 10:12:37 -0500 Original-Received: from [2607:fea8:3ba0:f85::5] (port=49286 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gaixA-0001nr-Pg for help-gnu-emacs@gnu.org; Sat, 22 Dec 2018 10:12:36 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:119019 Archived-At: Hello, I use a literate init.org configuration for my GNU Emacs, which I automatically tangle into init.el on each save and then call =E2=80=98make= =E2=80=99 using something like (compile "make ti"). Here=E2=80=99s my problem: invoking compile creates a new window, and that annoys me to no end, esp. since I save my init.org frequently while editing. So I=E2=80=99ve wrapped the call to compile in a call to save-window-excursion which causes compile to not create a window. But ideally the window would be created if compilation did not succeed. Recently I found the following snippet=C2=B9 on Stack Overflow: #+begin_src emacs-lisp (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))=20 (if (not (string-match "^\\(find\\|grep\\)" command)) (flet ((display-buffer) (set-window-point) (goto-char))=20 (fset 'display-buffer 'ignore) (fset 'goto-char 'ignore) (fset 'set-window-point 'ignore) (save-window-excursion=20 ad-do-it)) ad-do-it)) (ad-activate 'compilation-start) #+end_src But the problem with the above is that, if you look at the defadvice, it uses flet, which has been obsolete since 24.3, and so I get an annoying warning on every startup (I byte-compile my init.el). Are there any =E2=80=9Cmodern=E2=80=9D solutions for achieving this? If no= t, it would be great if one could customize the behaviour of when compile would create a window, depending on the build result or if the build takes longer than a certain time threshold. Thanks, amin Footnotes: =C2=B9 https://stackoverflow.com/a/17788551