summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmin Bandali <amin@gnu.org>2018-08-30 17:08:19 -0400
committerAmin Bandali <amin@gnu.org>2018-08-30 17:08:19 -0400
commitb07c1cc4dfe36f215eac01e5c69e32cdc7607015 (patch)
tree1296bec76295e718b5ab81ae43cf58a7200261fd
parenteb689aa4385a8a98336b9a8259a55ca4e294d68e (diff)
downloadconfigs-b07c1cc4dfe36f215eac01e5c69e32cdc7607015.tar.gz
configs-b07c1cc4dfe36f215eac01e5c69e32cdc7607015.tar.xz
configs-b07c1cc4dfe36f215eac01e5c69e32cdc7607015.zip
[emacs] call compile after async tangle, auto-close *compilation*
close *compilation* buffer on successful compile
-rw-r--r--init.org30
1 files changed, 23 insertions, 7 deletions
diff --git a/init.org b/init.org
index 81c652e..8bce20c 100644
--- a/init.org
+++ b/init.org
@@ -679,6 +679,9 @@ 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)
@@ -693,18 +696,31 @@ file.
(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
'safe-local-variable-values
'(eval add-hook 'after-save-hook #'amin/async-babel-tangle 'append 'local))
+
+(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
*** [[https://magit.vc/][Magit]]