From e5779161bb96f6cefa6dffe62ba209205c6bba36 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Mon, 6 Jun 2016 22:17:14 -0400 Subject: compile: Add function to update mupdf --- lisp/km-compile.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lisp') 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 -- cgit v1.2.3