Commit ac51d8149acb

Vincent Demeester <vincent@sbr.pm>
2020-01-31 14:48:03
emacs.org: add setup-compile.el
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent d76ff1f
Changed files (2)
lisp/setup-compile.el
@@ -1,6 +1,3 @@
-;;; setup-compile.el --- setup compilation modes
-;;; Commentary:
-;;; Code:
 ;;; -*- lexical-binding: t; -*-
 (use-package compile
   :defer 2
@@ -27,7 +24,7 @@
                   (derived-mode-p 'ag-mode))
         (ansi-color-apply-on-region compilation-filter-start (point))))
     (add-hook 'compilation-filter-hook #'vde/colorize-compilation-buffer)
-    
+
     (defun vde/mark-compilation-window-as-dedicated ()
       "Setup the *compilation* window with custom settings."
       (when (string-prefix-p "*compilation: " (buffer-name))
@@ -64,8 +61,3 @@
   (setq flycheck-idle-change-delay 1.2))
 
 (provide 'setup-compile)
-
-;; Local Variables:
-;; coding: utf-8
-;; indent-tabs-mode: nil
-;; End:
emacs.org
@@ -519,6 +519,77 @@
   (provide 'setup-buffers)
 #+end_src
 
+*** ~setup-compile.el~
+:PROPERTIES:
+:CUSTOM_ID: h:31c034c1-735e-4aae-affd-deb25a11a50e
+:END:
+
+#+begin_src emacs-lisp :tangle lisp/setup-compile.el
+  ;;; -*- lexical-binding: t; -*-
+  (use-package compile
+    :defer 2
+    :config
+    (progn
+      ;; http://stackoverflow.com/a/13408008/1219634
+      (setq
+       compilation-scroll-output t
+       ;; I'm not scared of saving everything.
+       compilation-ask-about-save nil
+       ;; Automatically scroll and jump to the first error
+       compilation-scroll-output 'next-error
+       ;; compilation-scroll-output 'first-error
+       ;; compilation-auto-jump-to-first-error t
+       ;; Skip over warnings and info messages in compilation
+       compilation-skip-threshold 2
+       ;; Don't freeze when process reads from stdin
+       compilation-disable-input t
+       ;; Show three lines of context around the current message
+       compilation-context-lines 3)
+      (require 'ansi-color)
+      (defun vde/colorize-compilation-buffer ()
+        (unless (or (derived-mode-p 'grep-mode) ;Don't mess up colors in Grep/Ag results buffers
+                    (derived-mode-p 'ag-mode))
+          (ansi-color-apply-on-region compilation-filter-start (point))))
+      (add-hook 'compilation-filter-hook #'vde/colorize-compilation-buffer)
+
+      (defun vde/mark-compilation-window-as-dedicated ()
+        "Setup the *compilation* window with custom settings."
+        (when (string-prefix-p "*compilation: " (buffer-name))
+          (save-selected-window
+            (save-excursion
+              (let* ((w (get-buffer-window (buffer-name))))
+                (when w
+                  (select-window w)
+                  (switch-to-buffer (buffer-name))
+                  (set-window-dedicated-p w t)))))))
+      (add-hook 'compilation-mode-hook 'vde/mark-compilation-window-as-dedicated)))
+
+  (use-package flycheck
+    :if (not (eq system-type 'windows-nt))
+    :defer 4
+    :commands (flycheck-mode
+               flycheck-next-error
+               flycheck-previous-error)
+    :init
+    (dolist (where '((emacs-lisp-mode-hook . emacs-lisp-mode-map)
+                     (haskell-mode-hook    . haskell-mode-map)
+                     (js2-mode-hook        . js2-mode-map)
+                     (go-mode-hook         . go-mode-map)
+                     (c-mode-common-hook   . c-mode-base-map)))
+      (add-hook (car where)
+                `(lambda ()
+                   (bind-key "M-n" #'flycheck-next-error ,(cdr where))
+                   (bind-key "M-p" #'flycheck-previous-error ,(cdr where)))
+                t))
+    :config
+    (add-hook 'prog-mode-hook 'flycheck-mode)
+    (defalias 'show-error-at-point-soon
+      'flycheck-show-error-at-point)
+    (setq flycheck-idle-change-delay 1.2))
+
+  (provide 'setup-compile)
+#+end_src
+
 *** ~setup-dired.el~
 :PROPERTIES:
 :CUSTOM_ID: h:66b435e6-b66c-4d39-9414-d13ce9ae5dd9