2019-02-26 10:14:57 +01:00
|
|
|
|
;;; oni-compilation.el --- Compilation configuration -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2019 Tom Willemse
|
|
|
|
|
|
|
|
|
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
|
|
|
|
;; Keywords: local
|
2021-09-20 08:07:55 +02:00
|
|
|
|
;; Version: 2021.0919.230646
|
2019-09-20 02:33:38 +02:00
|
|
|
|
;; Package-Requires: (oni-alert xterm-color)
|
2019-02-26 10:14:57 +01:00
|
|
|
|
|
|
|
|
|
;; This program 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.
|
|
|
|
|
|
|
|
|
|
;; This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; Configuration for the compilation mode.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(require 'compile)
|
|
|
|
|
(require 'subr-x)
|
2019-09-20 02:33:38 +02:00
|
|
|
|
(require 'xterm-color)
|
2019-02-26 10:14:57 +01:00
|
|
|
|
|
|
|
|
|
(setq compilation-scroll-output t)
|
|
|
|
|
|
|
|
|
|
(defun oni-compilation--maybe-dont-show-window (buffer-or-name alist plist)
|
|
|
|
|
"Don't show BUFFER-OR-NAME unless it absolutely must.
|
|
|
|
|
|
|
|
|
|
ALIST and PLIST contain extra information about the buffer."
|
|
|
|
|
(if (alist-get 'allow-no-window alist)
|
|
|
|
|
buffer-or-name
|
|
|
|
|
(funcall (plist-get plist :fallback) buffer-or-name alist
|
|
|
|
|
(plist-put (copy-sequence plist) :custom nil))))
|
|
|
|
|
|
|
|
|
|
(defun oni-compilation--maybe-display-compilation-window (buffer status)
|
|
|
|
|
"Display BUFFER if STATUS is not finished."
|
|
|
|
|
(unless (string= (string-trim status) "finished")
|
|
|
|
|
(display-buffer buffer)))
|
|
|
|
|
|
|
|
|
|
(defun oni-compilation--compilation-finish-notify-function (buffer status)
|
|
|
|
|
"Show an alert of the status of the compliation.
|
|
|
|
|
|
|
|
|
|
BUFFER is the `compilation-mode' buffer and STATUS is the exit
|
|
|
|
|
status of the process."
|
|
|
|
|
(when (string= (buffer-name buffer) "*compilation*")
|
|
|
|
|
(if (string= (string-trim status) "finished")
|
|
|
|
|
(alert "Compilation finished succesfully")
|
|
|
|
|
(alert "Compilation finished with an error"))))
|
|
|
|
|
|
2019-09-20 02:33:38 +02:00
|
|
|
|
(defun oni-compilation--filter-xterm-colors (func proc string)
|
|
|
|
|
"Call FUNC with PROC and STRING filtered through ‘xterm-color-filter’."
|
|
|
|
|
(funcall func proc (xterm-color-filter string)))
|
|
|
|
|
|
|
|
|
|
(setq compilation-environment '("TERM=xterm-256color"))
|
|
|
|
|
|
2019-09-09 02:18:12 +02:00
|
|
|
|
(add-to-list 'display-buffer-alist
|
|
|
|
|
'("\\`\\*compilation\\*\\'" display-buffer-in-side-window
|
|
|
|
|
(side . bottom)
|
|
|
|
|
(slot . 0)
|
|
|
|
|
(window-height . 0.33)))
|
2019-02-26 10:14:57 +01:00
|
|
|
|
|
|
|
|
|
(add-hook 'compilation-finish-functions
|
|
|
|
|
#'oni-compilation--maybe-display-compilation-window)
|
|
|
|
|
|
|
|
|
|
(add-hook 'compilation-finish-functions
|
|
|
|
|
#'oni-compilation--compilation-finish-notify-function)
|
|
|
|
|
|
2019-09-20 02:33:38 +02:00
|
|
|
|
(advice-add 'compilation-filter :around #'oni-compilation--filter-xterm-colors)
|
|
|
|
|
|
2019-02-26 10:14:57 +01:00
|
|
|
|
(provide 'oni-compilation)
|
|
|
|
|
;;; oni-compilation.el ends here
|