Created
December 16, 2016 16:05
-
-
Save kiwanami/2265393d43d04a936c818c19eec3b4dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro define-background-function-wrapper (bg-function fn) | |
(let ((is-loading-sym (intern (concat "*" (symbol-name bg-function) "-is-loading*")))) | |
`(progn | |
(defvar ,is-loading-sym nil) | |
(defun ,bg-function () | |
(interactive) | |
(when ,is-loading-sym | |
(message ,(concat (symbol-name fn) " is already loading"))) | |
(setq ,is-loading-sym t) | |
(make-thread (lambda () | |
(unwind-protect | |
(,fn) | |
(setq ,is-loading-sym nil)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment