branch: elpa/mastodon
commit 66111753ace076a2caa13dccec4a29e3b52febe4
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>
make alert.el optional dependency, add mastodon-notifications-alerts.
---
lisp/mastodon-notifications.el | 32 +++++++++++++++++---------------
lisp/mastodon.el | 10 ++++++++--
2 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index bca57ef959..54cee03c99 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -99,7 +99,7 @@
(defvar mastodon-notifications-updates-interval)
(defvar mastodon-notifications-check-for-updates)
(defvar mastodon-notifications-alert-style)
-
+(defvar mastodon-notifications-alerts)
;;; VARIABLES
(defvar mastodon-notifications--map
@@ -840,20 +840,22 @@ Status notifications are created when you call
(resp (mastodon-http--get-json url nil :silent)))
(alist-get 'count resp)))
-(alert-add-rule :mode 'mastodon-mode
- :status '(buried visible idle selected)
- :persistent
- #'(lambda (info)
- ;; If the buffer is buried, or the user has been idle
- ;; for `alert-reveal-idle-time' seconds, make this
- ;; alert persistent. Normally, alerts become
- ;; persistent after `alert-persist-idle-time' seconds.
- (memq (plist-get info :status) '(buried idle)))
- ;; 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)
+(when (and mastodon-notifications-alerts
+ (require 'alert nil :noerror))
+ (alert-add-rule :mode 'mastodon-mode
+ :status '(buried visible idle selected)
+ :persistent
+ #'(lambda (info)
+ ;; If the buffer is buried, or the user has been idle
+ ;; for `alert-reveal-idle-time' seconds, make this
+ ;; alert persistent. Normally, alerts become
+ ;; persistent after `alert-persist-idle-time' seconds.
+ (memq (plist-get info :status) '(buried idle)))
+ ;; 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))
;;; REVOKE QUOTED STATUS
;; POST /api/v1/statuses/:id/quotes/:quoting_status_id/revoke.
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 399ed07718..652cedd9d5 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -7,7 +7,7 @@
;; Marty Hiatt <[email protected]>
;; Maintainer: Marty Hiatt <[email protected]>
;; Version: 2.0.8
-;; Package-Requires: ((emacs "28.1") (persist "0.8") (tp "0.8") (alert "1.2"))
+;; Package-Requires: ((emacs "28.1") (persist "0.8") (tp "0.8"))
;; Homepage: https://codeberg.org/martianh/mastodon.el
;; This file is not part of GNU Emacs.
@@ -208,6 +208,10 @@ and X others...\"."
"How often to check for new notifications, in seconds."
:type '(integer))
+(defcustom mastodon-notifications-alerts nil
+ "Whether to enable alert.el alerts."
+ :type '(boolean))
+
(defcustom mastodon-notifications-alert-style alert-default-style
"The type of alert.el style to use for mastodon.el notification alerts.
Currently, if you customize this variable, you need to restart Emacs for
@@ -617,7 +621,9 @@ Calls `mastodon-tl--get-buffer-type', which see."
(append thing-at-point-provider-alist
'((url . mastodon--url-at-point))))
;; notifs timer
- (mastodon-notifications--update-with-timer))
+ (when (and mastodon-notifications-alerts
+ (require 'alert nil :noerror))
+ (mastodon-notifications--update-with-timer)))
;;;###autoload
(add-hook 'mastodon-mode-hook #'mastodon-mode-hook-fun)