unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Show *compilation* only if build did not succeed
@ 2018-12-22 15:12 Amin Bandali
  2018-12-22 16:49 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Amin Bandali @ 2018-12-22 15:12 UTC (permalink / raw)
  To: help-gnu-emacs

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 ‘make’
using something like (compile "make ti").

Here’s 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’ve 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¹ 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)) 
  (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)
#+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 “modern” solutions for achieving this?  If not, 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:
¹  https://stackoverflow.com/a/17788551




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-12-23 14:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-22 15:12 Show *compilation* only if build did not succeed Amin Bandali
2018-12-22 16:49 ` Stefan Monnier
2018-12-22 17:52   ` Amin Bandali
2018-12-22 18:21     ` Stefan Monnier
2018-12-22 19:09       ` Amin Bandali
2018-12-23 14:29         ` Stefan Monnier
2018-12-23 14:59           ` Amin Bandali

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).