vermiculus / sx.el

Stack Exchange for Emacs
http://stackapps.com/q/3950
709 stars 40 forks source link

How to get sx.el inbox new message count in mode-line? #351

Open stardiviner opened 6 years ago

stardiviner commented 6 years ago

I have a config as following:

;;; GitHub Notifications (Participating)
(use-package ghub+
  :ensure t
  :config
  (defvar github-notifications-number nil)
  (defun github-notifications ()
    (setq github-notifications-number
          (length
           ;; check out documentation of `ghubp-get-notifications'.
           (ghubp-get-notifications :participating "true") ; from package `ghub+'.
           ;; (ghub-get "/notifications" '((:participating . "true")))
           ;; (ghub-get "/notifications")
           )))
  (run-with-timer 10 600 'github-notifications)
  (defun *github-notifications ()
    (if (and (active) (> github-notifications-number 0))
        (propertize
         (concat
          (all-the-icons-faicon "github" :v-adjust 0.05)
          (format " %s " github-notifications-number))
         'face 'mode-line-data-face)))
  (defun github-open-notifications-participating ()
    "Open GitHub Notifications/Participating page."
    (interactive)
    (browse-url "https://github.com/notifications/participating"))
  (unless (boundp 'prog-vcs-prefix)
    (define-prefix-command 'prog-vcs-prefix))
  (define-key prog-vcs-prefix (kbd "N") 'github-open-notifications-participating)
  )

I use function *github-notifications in my custom mode-line-format to show GitHub notifications. How can I do this for sx.el?

stardiviner commented 6 years ago

I check out sx-inbox.el source code, but hardly to implement one function by myself (I'm not good enough on Elisp). Only know related functions sx-inbox--print-info and sx-inbox-item-type-unread etc.