Add elisp utility lib
This commit is contained in:
parent
92b74eda73
commit
70e8ba5d52
19
emacs/.emacs.d/config/init-lib.el
Normal file
19
emacs/.emacs.d/config/init-lib.el
Normal file
@ -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)
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user