branch: elpa/mastodon
commit 959b2731a5b67f90455df05da21509a465b5fbd5
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>
add an alert.el rule
---
lisp/mastodon-notifications.el | 34 ++++++++++++++++++++--------------
lisp/mastodon.el | 7 ++++---
2 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 8d685334f6..540d58b47f 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -839,11 +839,18 @@ Status notifications are created when you call
(resp (mastodon-http--get-json url)))
(alist-get 'count resp)))
+(alert-add-rule :mode 'mastodon-mode
+ :status '(buried visible idle selected)
+ ;; FIXME: if user configures this variable, we need to
+ ;; remove this rule and re-add it! or they need to restart
+ ;; emacs?:
+ :style mastodon-notifications-alert-style
+ :continue t)
+
(defun mastodon-notifications-notify ()
"Send a desktop notification when we have unread notifications.
Uses `notifications-notify'."
- (let ((count (mastodon-notifications--get-unread-count))
- (alert-default-style mastodon-notifications-alert-style))
+ (let ((count (mastodon-notifications--get-unread-count)))
(when (> 0 count)
(alert (format "New notifications: <b>%s</b>" count)
:title "mastodon.el"))))
@@ -1041,18 +1048,17 @@ Calls `mastodon-tl--update'."
(defun mastodon-notifications--update-check-cb (resp)
"Callback functions for handling unread notifs count response RESP."
(let ((count (alist-get 'count resp)))
- (if (> count 0)
- (if (not (mastodon-tl--buffer-type-eq 'notifications))
- (progn
- (mastodon-notifications-notify)
- (message "New mastodon.el notification(s): %s" count))
- ;; run updates if in notifs buffer:
- (message "Updating mastodon.el notifications...")
- (undo-boundary)
- (mastodon-tl--update)
- (undo-boundary)
- (message "Updating mastodon.el notifications... Done."))
- (message "No new mastodon.el notifications")) ;; just to show we ran
+ (when (> count 0)
+ (if (not (mastodon-tl--buffer-type-eq 'notifications))
+ (progn
+ (mastodon-notifications-notify)
+ (message "New mastodon.el notification(s): %s" count))
+ ;; run updates if in notifs buffer:
+ (message "Updating mastodon.el notifications...")
+ (undo-boundary)
+ (mastodon-tl--update)
+ (undo-boundary)
+ (message "Updating mastodon.el notifications... Done.")))
;; cancel and set new timer:
(mastodon-notifications-cancel-timer)
(mastodon-notifications--update-with-timer)))
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index b893c37ec9..c57ebafee7 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -205,10 +205,11 @@ and X others...\"."
"How often to check for new notifications, in seconds."
:type '(integer))
-(defcustom mastodon-notifications-alert-style 'alert-default-style
+(defcustom mastodon-notifications-alert-style alert-default-style
"The type of alert.el style to use for mastodon.el notification alerts.
-If you have alert.el configured elsewhere, this will not override your
-configuration, it merely sets the `alert-default-style' variable temporarily."
+Currently, if you customize this variable, you need to restart emacs for
+it to take effect, or if you don't have any other alert.el rules set up,
+you can nil `alert-internal-configuration' and reload mastodon.el"
:type
`(choice
,@(append