From 7439d7b9271ccef958e30cf2f800e0bbdc522778 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Wed, 2 Jan 2019 18:27:13 +0800 Subject: [PATCH] Fix #82: load `async` if it exists but is not loaded. --- doom-modeline.el | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/doom-modeline.el b/doom-modeline.el index 5674a9a..01224b9 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -1573,21 +1573,24 @@ mouse-3: Describe current input method") (defvar doom-modeline--github-notifications-number 0) (defun doom-modeline--github-fetch-notifications () "Fetch github notifications." - (if (and doom-modeline-github - (fboundp 'async-start)) - (async-start - `(lambda () - ,(async-inject-variables "\\`load-path\\'") - (require 'ghub nil t) - (when (fboundp 'ghub-get) - (with-timeout (10) - (ghub-get "/notifications" - nil - :query '((notifications . "true")) - :noerror t)))) - (lambda (result) - (setq doom-modeline--github-notifications-number - (length result)))))) + (when (and doom-modeline-github + (fboundp 'async-start)) + ;; load `async' if it's not loaded + (unless (fboundp 'async-inject-variables) + (require 'async nil t)) + (async-start + `(lambda () + ,(async-inject-variables "\\`load-path\\'") + (require 'ghub nil t) + (when (fboundp 'ghub-get) + (with-timeout (10) + (ghub-get "/notifications" + nil + :query '((notifications . "true")) + :noerror t)))) + (lambda (result) + (setq doom-modeline--github-notifications-number + (length result)))))) (run-with-timer 30 doom-modeline-github-interval