-
Notifications
You must be signed in to change notification settings - Fork 26
/
sauron-compilation.el
66 lines (50 loc) · 2.24 KB
/
sauron-compilation.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
;;; sauron-compilation.el --- a compilation tracking module, part of sauron
;;
;; Copyright (C) 2012 Dirk-Jan C. Binnema, Joel McCracken
;; This file is not part of GNU Emacs.
;;
;; Sauron is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; Sauron is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; For documentation, please see:
;; https://github.com/djcb/sauron/blob/master/README.org
;;; Code:
(require 'compile nil 'noerror)
(defvar sauron-prio-compilation 3
"Compilation event priority.")
(defvar sauron-compilation-running nil
"when non-nil, sauron-compilation is running")
(defun sauron-compilation-start ()
"Starts sauron-compilation."
(when sauron-compilation-running
(error "sauron-compilation is already running. Call
sauron-compilation-stop first."))
(add-to-list 'compilation-finish-functions #'sauron-compilation-complete-func)
(setq sauron-compilation-running t))
(defun sauron-compilation-stop ()
"Stops and cleans up sauron-compilation."
(when sauron-compilation-running
(setq compilation-finish-functions
(remove 'sauron-compilation-complete-func
compilation-finish-functions))
(setq sauron-compilation-running nil)))
(defun sauron-compilation-complete-func (buffer msg)
"Hook which handles the compilation completion. Main entry
point and interface to compilation.
`compilation-finish-functions' passes in the compilation buffer
name and message to this function."
(sauron-add-event 'compilation
sauron-prio-compilation
(format "[%s]: %s" buffer msg)
'(lambda () (switch-to-buffer-other-window "*compilation*"))
nil))
(provide 'sauron-compilation)
;; End of sauron-compilation.el