Skip to content

Commit de42f75

Browse files
committed
Add auctex, and automatically hide compilation when successful.
1 parent 4e93687 commit de42f75

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lisp/init-project.el

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
;;; Code:
44

55
(use-package projectile
6+
:ensure nil
67
:diminish projectile-mode
78
:bind-keymap
89
("C-c p" . projectile-command-map)
@@ -13,6 +14,32 @@
1314
(add-hook 'prog-mode-hook #'(lambda () (projectile-mode +1)))
1415
)
1516

17+
(use-package compile
18+
:ensure nil
19+
:config
20+
;; Switch to previous buffer when compilation is successful
21+
;; https://stackoverflow.com/a/11059012/11579038
22+
(defun rb-bury-compile-buffer-if-successful (buffer string)
23+
"Bury a compilation buffer if succeeded without warnings."
24+
(when (and
25+
(buffer-live-p buffer)
26+
(string-match "compilation" (buffer-name buffer))
27+
(string-match "finished" string)
28+
)
29+
(run-with-timer 1 nil
30+
(lambda (buf)
31+
(bury-buffer buf)
32+
(switch-to-prev-buffer (get-buffer-window buf) 'kill)
33+
;; delete window if it was opened by the compilation process
34+
;; (have two windows with the same buffer)
35+
(when
36+
(and (equal 2 (length (window-list)))
37+
(eq (window-buffer (car (window-list))) (window-buffer (cadr (window-list)))))
38+
(delete-window (selected-window))
39+
)
40+
)
41+
buffer)))
42+
(add-hook 'compilation-finish-functions 'rb-bury-compile-buffer-if-successful))
1643

1744
(provide 'init-project)
1845

lisp/init-tex.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
;; maybe configure LaTeX-indent-environment-list (removed)
1111
)
1212

13+
(use-package auctex
14+
:ensure (:source "MELPA"))
15+
1316

1417
(provide 'init-tex)
1518

0 commit comments

Comments
 (0)