20 lines
570 B
EmacsLisp
20 lines
570 B
EmacsLisp
|
;; -*- lexical-binding: t; -*-
|
||
|
;; Elisp utilities
|
||
|
(defun make-process-sentinel (success err)
|
||
|
"Makes a process sentinel that calls `success` on success and `err` on error"
|
||
|
(lambda (proc event)
|
||
|
(cond ((string-match-p "finished" event) (funcall success))
|
||
|
(t (funcall err)))))
|
||
|
|
||
|
(defun make-success-err-msg-sentinel (buf success-msg err-msg &optional kill-on-err)
|
||
|
(make-process-sentinel
|
||
|
(lambda ()
|
||
|
(message success-msg)
|
||
|
(kill-buffer buf))
|
||
|
(lambda ()
|
||
|
(message err-msg)
|
||
|
(when kill-on-err
|
||
|
(kill-buffer buf)))))
|
||
|
|
||
|
(provide 'init-lib)
|