From 70e8ba5d52f9cf3e9612b3dd90cf854f69b37bff Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Sat, 20 Feb 2021 22:00:23 -0500 Subject: [PATCH] Add elisp utility lib --- emacs/.emacs.d/config/init-lib.el | 19 +++++++++++++++++++ emacs/.emacs.d/init.el | 1 + 2 files changed, 20 insertions(+) create mode 100644 emacs/.emacs.d/config/init-lib.el diff --git a/emacs/.emacs.d/config/init-lib.el b/emacs/.emacs.d/config/init-lib.el new file mode 100644 index 0000000..9da8d0d --- /dev/null +++ b/emacs/.emacs.d/config/init-lib.el @@ -0,0 +1,19 @@ +;; -*- 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) diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index c92cd45..2db95c7 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -53,6 +53,7 @@ (require 'init-evil) (require 'init-keybindings) (require 'init-auth) +(require 'init-lib) (require 'init-profiler) (require 'init-built-ins) (require 'init-dashboard)