[emacs] don’t display *compilation* on successful builds
[~bandali/configs] / init.org
index b06abe7..d7af98c 100644 (file)
--- a/init.org
+++ b/init.org
@@ -65,7 +65,7 @@ make build
 ** First line
 
 #+begin_src emacs-lisp :comments none
-;;; init.el --- Amin Bandali's Emacs config -*- lexical-binding: t ; eval: (view-mode 1)-*-
+;;; init.el --- Amin Bandali's Emacs config -*- lexical-binding: t; eval: (view-mode 1) -*-
 #+end_src
 
 Enable =view-mode=, which both makes the file read-only (as a reminder
@@ -113,7 +113,6 @@ The conventions below were inspired by [[https://github.com/hlissner/doom-emacs]
 ;;   amin-...   public variables or non-interactive functions
 ;;   amin--...  private anything (non-interactive), not safe for direct use
 ;;   amin/...   an interactive function; safe for M-x or keybinding
-;;   amin:...   an evil operator, motion, or command
 ;;   amin|...   a hook function
 ;;   amin*...   an advising function
 ;;   amin@...   a hydra command
@@ -125,10 +124,6 @@ The conventions below were inspired by [[https://github.com/hlissner/doom-emacs]
 :CUSTOM_ID: initial-setup
 :END:
 
-#+begin_src emacs-lisp :comments none
-;;; Code:
-#+end_src
-
 ** Emacs initialization
 
 I'd like to do a couple of measurements of Emacs' startup time. First,
@@ -655,18 +650,35 @@ Enable =winner-mode=.
 (winner-mode 1)
 #+end_src
 
-*** Close =*compilation*= on success
+*** Don’t display =*compilation*= on success
+
+From https://stackoverflow.com/a/17788551.
 
 #+begin_src emacs-lisp
-(setq compilation-exit-message-function
-      (lambda (status code msg)
-        "Close the compilation window if successful."
-        ;; if M-x compile exits with 0
-         (when (and (eq status 'exit) (zerop code))
-           (bury-buffer)
-           (delete-window (get-buffer-window (get-buffer "*compilation*"))))
-         ;; return the result of compilation-exit-message-function
-         (cons msg code)))
+(defun amin--compilation-finish-function (buffer outstr)
+  (unless (string-match "finished" outstr)
+    (switch-to-buffer-other-window buffer))
+  t)
+
+(setq compilation-finish-functions #'amin--compilation-finish-function)
+
+(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
 
 *** Search for non-ASCII characters
@@ -1127,15 +1139,6 @@ TODO: break this giant source block down into individual org sections.
   (add-to-list 'tramp-default-proxies-alist
                (list (regexp-quote (system-name)) nil nil)))
 
-(use-package undo-tree
-  :config
-  (global-undo-tree-mode -1))
-  ;; :bind (("C-?" . undo-tree-undo)
-  ;;        ("M-_" . undo-tree-redo))
-  ;; :config
-  ;; (global-undo-tree-mode)
-  ;; (setq undo-tree-mode-lighter ""
-  ;;       undo-tree-auto-save-history t))
 #+end_src
 
 * Editing
@@ -1160,6 +1163,7 @@ TODO: break this giant source block down into individual org sections.
 #+end_src
 
 * Syntax and spell checking
+
 #+begin_src emacs-lisp
 (use-package flycheck
   :defer 3
@@ -1948,9 +1952,9 @@ Hopefully temporary.
 #+begin_src emacs-lisp
 (use-package multi-term
   :defer 1
-  :bind (("C-c C-j" . term-line-mode)
-         ("C-c m m" . multi-term)
-         ("C-c m p" . multi-term-dedicated-toggle))
+  :bind (("C-c C-j"     . term-line-mode)
+         ("C-c a s m m" . multi-term)
+         ("C-c a s m p" . multi-term-dedicated-toggle))
   :config
   (setq multi-term-program "/bin/screen"
         ;; TODO: add separate bindings for connecting to existing
@@ -1976,6 +1980,14 @@ Hopefully temporary.
         '("C-z" "C-x" "C-c" "C-h" "C-y" "<ESC>")))
 #+end_src
 
+** page-break-lines
+
+#+begin_src emacs-lisp
+(use-package page-break-lines
+  :config
+  (global-page-break-lines-mode))
+#+end_src
+
 * Email
 
 #+begin_src emacs-lisp
@@ -2244,6 +2256,7 @@ I tried using =borg-elpa= instead of doing it like this, but it added
 #+end_src
 
 * Blogging
+
 ** [[https://ox-hugo.scripter.co][ox-hugo]]
 
 #+begin_src emacs-lisp