[emacs] assimilate unkillable-scratch
[~bandali/configs] / init.org
index 81c652e..2fa171d 100644 (file)
--- a/init.org
+++ b/init.org
@@ -577,7 +577,8 @@ variable.
 
 #+begin_src emacs-lisp
 (setq backup-by-copying t
 
 #+begin_src emacs-lisp
 (setq backup-by-copying t
-      version-control t)
+      version-control t
+      delete-old-versions t)
 #+end_src
 
 *** Auto revert
 #+end_src
 
 *** Auto revert
@@ -607,6 +608,20 @@ Enable =winner-mode=.
 (winner-mode 1)
 #+end_src
 
 (winner-mode 1)
 #+end_src
 
+*** Close =*compilation*= on success
+
+#+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)))
+#+end_src
+
 ** Bindings
 
 #+begin_src emacs-lisp
 ** Bindings
 
 #+begin_src emacs-lisp
@@ -679,6 +694,9 @@ file.
   (defvar amin-show-async-tangle-time nil
     "Show the time spent tangling the file.")
 
   (defvar amin-show-async-tangle-time nil
     "Show the time spent tangling the file.")
 
+  (defvar amin-async-tangle-post-compile "make ti"
+    "If non-nil, pass to `compile' after successful tangle.")
+
   (defun amin/async-babel-tangle ()
     "Tangle org file asynchronously."
     (interactive)
   (defun amin/async-babel-tangle ()
     "Tangle org file asynchronously."
     (interactive)
@@ -693,13 +711,16 @@ file.
        (unless amin-show-async-tangle-results
          `(lambda (result)
             (if result
        (unless amin-show-async-tangle-results
          `(lambda (result)
             (if result
-                (message "Tangled %s%s"
-                         ,file-nodir
-                         (if amin-show-async-tangle-time
-                             (format " (%.3fs)"
-                                     (float-time (time-subtract (current-time)
-                                                                ',file-tangle-start-time)))
-                           ""))
+                (progn
+                  (message "Tangled %s%s"
+                           ,file-nodir
+                           (if amin-show-async-tangle-time
+                               (format " (%.3fs)"
+                                       (float-time (time-subtract (current-time)
+                                                                  ',file-tangle-start-time)))
+                             ""))
+                  (when amin-async-tangle-post-compile
+                    (compile amin-async-tangle-post-compile)))
               (message "Tangling %s failed" ,file-nodir))))))))
 
 (add-to-list
               (message "Tangling %s failed" ,file-nodir))))))))
 
 (add-to-list
@@ -1271,6 +1292,18 @@ Emacs package that displays available keybindings in popup
   (shell-pop-shell-type '("eshell" "*eshell*" (lambda nil (eshell)))))
 #+end_src
 
   (shell-pop-shell-type '("eshell" "*eshell*" (lambda nil (eshell)))))
 #+end_src
 
+** [[https://github.com/EricCrosson/unkillable-scratch][unkillable-scratch]]
+
+Make =*scratch*= and =*Messages*= unkillable.
+
+#+begin_src emacs-lisp
+(use-package unkillable-scratch
+  :config
+  (unkillable-scratch 1)
+  :custom
+  (unkillable-buffers '("^\\*scratch\\*$" "^\\*Messages\\*$")))
+#+end_src
+
 * Email
 ** [[https://notmuchmail.org][notmuch]]
 
 * Email
 ** [[https://notmuchmail.org][notmuch]]