dotfiles/emacs/.emacs.d/config/init-lib.el

20 lines
570 B
EmacsLisp
Raw Normal View History

2021-02-21 03:00:23 +00:00
;; -*- 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)