42 lines
1.5 KiB
EmacsLisp
42 lines
1.5 KiB
EmacsLisp
;;; build.el --- Project build, set up for Evil -*- lexical-binding: t; -*-
|
|
;;; Commentary:
|
|
;; Loaded from init.el after Evil.
|
|
;;
|
|
;; :build Run ./build.sh from the project root.
|
|
;; :build ARGS Run ./build.sh ARGS, e.g. :build release -v
|
|
;;
|
|
;; The compilation buffer opens at the bottom (45% height, full width) and
|
|
;; takes focus when the build starts. ANSI colours are rendered.
|
|
;; Kill a running build with M-x kill-compilation.
|
|
;;; Code:
|
|
|
|
(setq compile-command "./build.sh"
|
|
compilation-read-command nil ; run without prompting
|
|
compilation-ask-about-save nil
|
|
compilation-scroll-output t)
|
|
|
|
(add-hook 'compilation-filter-hook #'ansi-color-compilation-filter)
|
|
|
|
;; Compilation buffer at the bottom, full frame width.
|
|
(add-to-list 'display-buffer-alist
|
|
'((derived-mode . compilation-mode)
|
|
(display-buffer-reuse-window display-buffer-at-bottom)
|
|
(window-height . 0.45)))
|
|
|
|
;; Focus the compilation window when a build starts.
|
|
(add-hook 'compilation-start-hook
|
|
(lambda (proc)
|
|
(when-let* ((win (get-buffer-window (process-buffer proc))))
|
|
(select-window win))))
|
|
|
|
;; :build runs ./build.sh; :build ARGS appends ARGS.
|
|
(evil-define-command my/ex-build (args)
|
|
"Run `./build.sh ARGS' from the project root."
|
|
(interactive "<a>")
|
|
(let ((compile-command (concat "./build.sh " args))) ; nil args -> ""
|
|
(project-compile)))
|
|
|
|
(evil-ex-define-cmd "build" #'my/ex-build)
|
|
|
|
;;; build.el ends here
|