From 834f59c2eff02fedf9bff66d1306515275bb58c7 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Sun, 30 Dec 2018 20:57:42 +0800 Subject: [PATCH] Optimize: inject load-path var and add timeout for async process. --- doom-modeline.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/doom-modeline.el b/doom-modeline.el index 152532c..94bedd7 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -186,6 +186,7 @@ It returns a file name which can be used directly as argument of (declare-function anzu--reset-status 'anzu) (declare-function anzu--where-is-here 'anzu) +(declare-function async-inject-variables 'async) (declare-function avy-traverse 'avy) (declare-function avy-tree 'avy) (declare-function aw-update 'ace-window) @@ -1565,14 +1566,15 @@ mouse-3: Describe current input method") (if (and doom-modeline-github (fboundp 'async-start)) (async-start - (lambda () - (package-initialize) - (require 'ghub nil t) - (when (fboundp 'ghub-get) - (ghub-get "/notifications" - nil - :query '((notifications . "true")) - :noerror t))) + `(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))))))