summaryrefslogtreecommitdiff
path: root/lisp/km-compile.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-06-06 22:17:14 -0400
committerKyle Meyer <kyle@kyleam.com>2016-06-06 22:17:14 -0400
commite5779161bb96f6cefa6dffe62ba209205c6bba36 (patch)
treefdf3e04f47a0af949591fa3ab376ae18e09fbcf5 /lisp/km-compile.el
parentbc4a0af867e24be981dd04ec2f832f61f953ab6b (diff)
downloademacs.d-e5779161bb96f6cefa6dffe62ba209205c6bba36.tar.gz
compile: Add function to update mupdf
Diffstat (limited to 'lisp/km-compile.el')
-rw-r--r--lisp/km-compile.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/km-compile.el b/lisp/km-compile.el
index 4812afd..2e179ca 100644
--- a/lisp/km-compile.el
+++ b/lisp/km-compile.el
@@ -90,5 +90,26 @@ Otherwise, if ARG is non-nil, prompt with buffers from
(defun km/compilation-buffer-list ()
(-filter #'km/compilation-buffer-p (buffer-list)))
+(defvar km/compile-pdf-re
+ (rx string-start
+ (zero-or-one "snake") "make"
+ (zero-or-more not-newline) space
+ (group (one-or-more (not space)) ".pdf")
+ (zero-or-more space)
+ string-end))
+
+(defun km/compile-check-pdf (buf exit)
+ (when (equal exit "finished\n")
+ (with-current-buffer buf
+ (let ((cmd (car compilation-arguments)))
+ (when (string-match km/compile-pdf-re cmd)
+ (call-process "xdotool" nil nil nil
+ "search" "--all" "--class" "--name"
+ (concat "^mupdf|" (file-name-nondirectory
+ (match-string 1 cmd)))
+ "key" "--window" "%@" "r"))))))
+
+(add-to-list 'compilation-finish-functions #'km/compile-check-pdf)
+
(provide 'km-compile)
;;; km-compile.el ends here