mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +00:00
Improve github segment.
1. Fetch notifications 1 min later after opening the page. 2. Mouse-3 to fetch notifications.
This commit is contained in:
parent
f9e021a2eb
commit
be9df01374
1 changed files with 22 additions and 11 deletions
|
@ -1561,7 +1561,7 @@ mouse-3: Describe current input method")
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(defvar doom-modeline--github-notifications-number 0)
|
(defvar doom-modeline--github-notifications-number 0)
|
||||||
(defun doom-modeline-github-fetch-notifications ()
|
(defun doom-modeline--github-fetch-notifications ()
|
||||||
"Fetch github notifications."
|
"Fetch github notifications."
|
||||||
(if (and doom-modeline-github
|
(if (and doom-modeline-github
|
||||||
(fboundp 'async-start))
|
(fboundp 'async-start))
|
||||||
|
@ -1580,12 +1580,13 @@ mouse-3: Describe current input method")
|
||||||
|
|
||||||
(run-with-timer 30
|
(run-with-timer 30
|
||||||
doom-modeline-github-interval
|
doom-modeline-github-interval
|
||||||
'doom-modeline-github-fetch-notifications)
|
#'doom-modeline--github-fetch-notifications)
|
||||||
|
|
||||||
(defun doom-modeline--github-open-notifications ()
|
(defun doom-modeline--github-open-notifications ()
|
||||||
"Open GitHub Notifications page."
|
"Open GitHub Notifications page."
|
||||||
(interactive)
|
(interactive)
|
||||||
(browse-url "https://github.com/notifications"))
|
(browse-url "https://github.com/notifications")
|
||||||
|
(run-with-timer 60 nil #'doom-modeline--github-fetch-notifications))
|
||||||
|
|
||||||
(doom-modeline-def-segment github
|
(doom-modeline-def-segment github
|
||||||
"The github notifications."
|
"The github notifications."
|
||||||
|
@ -1594,16 +1595,26 @@ mouse-3: Describe current input method")
|
||||||
(> doom-modeline--github-notifications-number 0))
|
(> doom-modeline--github-notifications-number 0))
|
||||||
(propertize
|
(propertize
|
||||||
(concat (if doom-modeline-icon " ")
|
(concat (if doom-modeline-icon " ")
|
||||||
(doom-modeline-icon-faicon "github" :v-adjust -0.0575 :face 'doom-modeline-warning)
|
(doom-modeline-icon-faicon "github"
|
||||||
|
:v-adjust -0.0575
|
||||||
|
:face 'doom-modeline-warning)
|
||||||
(if doom-modeline-icon doom-modeline-vspc " ")
|
(if doom-modeline-icon doom-modeline-vspc " ")
|
||||||
(propertize
|
(propertize (format "%s " doom-modeline--github-notifications-number)
|
||||||
(format "%s " doom-modeline--github-notifications-number)
|
'face 'doom-modeline-warning))
|
||||||
'face 'doom-modeline-warning))
|
'help-echo "Github
|
||||||
'help-echo "mouse-1: Show github notifications"
|
mouse-1: Show notifications
|
||||||
|
mouse-3: Fetch notifications"
|
||||||
'mouse-face '(:box 1)
|
'mouse-face '(:box 1)
|
||||||
'local-map (make-mode-line-mouse-map
|
'local-map (let ((map (make-sparse-keymap)))
|
||||||
'mouse-1
|
(define-key map [mode-line mouse-1]
|
||||||
#'doom-modeline--github-open-notifications))))
|
#'doom-modeline--github-open-notifications)
|
||||||
|
(define-key map [mode-line mouse-3]
|
||||||
|
(lambda ()
|
||||||
|
(interactive)
|
||||||
|
(message "Fetching github notifications...")
|
||||||
|
(doom-modeline--github-fetch-notifications)))
|
||||||
|
map))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; debug state
|
;; debug state
|
||||||
|
|
Loading…
Reference in a new issue