Optimize: inject load-path var and add timeout for async process.

This commit is contained in:
Vincent Zhang 2018-12-30 20:57:42 +08:00
parent e116b3e840
commit 834f59c2ef

View file

@ -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--reset-status 'anzu)
(declare-function anzu--where-is-here 'anzu) (declare-function anzu--where-is-here 'anzu)
(declare-function async-inject-variables 'async)
(declare-function avy-traverse 'avy) (declare-function avy-traverse 'avy)
(declare-function avy-tree 'avy) (declare-function avy-tree 'avy)
(declare-function aw-update 'ace-window) (declare-function aw-update 'ace-window)
@ -1565,14 +1566,15 @@ mouse-3: Describe current input method")
(if (and doom-modeline-github (if (and doom-modeline-github
(fboundp 'async-start)) (fboundp 'async-start))
(async-start (async-start
(lambda () `(lambda ()
(package-initialize) ,(async-inject-variables "\\`load-path\\'")
(require 'ghub nil t) (require 'ghub nil t)
(when (fboundp 'ghub-get) (when (fboundp 'ghub-get)
(ghub-get "/notifications" (with-timeout (10)
nil (ghub-get "/notifications"
:query '((notifications . "true")) nil
:noerror t))) :query '((notifications . "true"))
:noerror t))))
(lambda (result) (lambda (result)
(setq doom-modeline--github-notifications-number (setq doom-modeline--github-notifications-number
(length result)))))) (length result))))))