summaryrefslogtreecommitdiff
path: root/lisp/km-compile.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-02-18 18:58:03 -0500
committerKyle Meyer <kyle@kyleam.com>2017-02-18 18:58:03 -0500
commit20b21ee15c5f2745328e8d1c825aeaccf14c1fad (patch)
tree1c7fec32fef6098c0a881ce8a7e07470680029c7 /lisp/km-compile.el
parent0fb37a03805e85556fe9c777c417de42ab8eddbc (diff)
downloademacs.d-20b21ee15c5f2745328e8d1c825aeaccf14c1fad.tar.gz
Use function list for mupdf compile refresh
Diffstat (limited to 'lisp/km-compile.el')
-rw-r--r--lisp/km-compile.el39
1 files changed, 28 insertions, 11 deletions
diff --git a/lisp/km-compile.el b/lisp/km-compile.el
index f04c660..3cd5a4f 100644
--- a/lisp/km-compile.el
+++ b/lisp/km-compile.el
@@ -97,23 +97,40 @@ 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-make-pdf-target (command)
+ (and (string-match (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)
+ command)
+ (match-string 1 command)))
+
+(defun km/compile-latexmk-pdf-target (command)
+ (and (string-match (rx string-start
+ "latexmk"
+ (zero-or-more not-newline) space
+ (group (one-or-more (not space)))
+ (zero-or-one ".tex")
+ (zero-or-more space)
+ string-end)
+ command)
+ (concat (match-string 1 command) ".pdf")))
+
+(defvar km/compile-pdf-functions '(km/compile-make-pdf-target
+ km/compile-latexmk-pdf-target))
(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)
+ (let* ((cmd (car compilation-arguments))
+ (pdf-file (run-hook-with-args-until-success
+ 'km/compile-pdf-functions cmd)))
+ (when pdf-file
(call-process "xdotool" nil nil nil
"search" "--all" "--class" "--name"
- (concat "^mupdf|" (file-name-nondirectory
- (match-string 1 cmd)))
+ (concat "^mupdf|" (file-name-nondirectory pdf-file))
"key" "--window" "%@" "r"))))))
(add-to-list 'compilation-finish-functions #'km/compile-check-pdf)