branch: elpa/mastodon
commit edea11cc69c7fc45cb3606b9bff90c89372bdea1
Merge: 23a4c2227f f75f9f2d64
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>
Merge branch 'develop'
---
lisp/mastodon-notifications.el | 80 +++++++++++++++++++++---------------------
lisp/mastodon.el | 17 ++++-----
mastodon-index.org | 5 ++-
3 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 2683ec528c..5ca14ad1e2 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -96,8 +96,7 @@
(defvar mastodon-notifications-grouped-names-count)
(defvar mastodon-tl--link-keymap)
(defvar mastodon-tl--update-point)
-(defvar mastodon-notifications-updates-interval)
-(defvar mastodon-notifications-check-for-updates)
+(defvar mastodon-notifications-alerts-interval)
(defvar mastodon-notifications-alert-style)
(defvar mastodon-notifications-alerts)
;;; VARIABLES
@@ -1057,43 +1056,44 @@ When FORCE, skip all checks and show an alert (for
debugging)."
(defun mastodon-notifications--update-with-timer ()
"Run a timer to update notifications. Added to `mastodon-mode-hook'."
- ;; if no buffers: cancel our timer and do nothing else:
- (if (and (not (mastodon-live-buffers))
- ;; if we are loading a first mastodon buffer, the previous
- ;; check fails, as `mastodon-mode-hook' necessariliy runs
- ;; before we have buf-spec, which
- ;; `mastodon-tl--get-buffer-type' depends on, and if we set
- ;; buf-spec before enabling the mode, buf-spec is lost. so
- ;; let's also check if the current buffer prefix is *mastodon-,
- ;; which it will be when first calling `mastodon' at least
- ;; (though not necessarily when loading other first mastodon.el
- ;; buffers, such as new toot):
- (not (string-prefix-p "*mastodon-" (buffer-name))))
- ;; if not masto buffers: cancel everything:
- (mastodon-notifications-cancel-timer)
- (when mastodon-notifications-check-for-updates
- ;; if a timer has already run but somehow the variable has not been
- ;; nilled, assume it is a leftover and cancel it, otherwise our
- ;; unless check below will always fail and no new timer will be
- ;; created.
- ;; NB: this gets called:
- ;; - on creating a new mastodon.el buffer,
- ;; - if an existing timer is run.
- ;; in both cases, `timerp' should fail, but sometimes we have a
- ;; zombie one somehow:
- (when (and (timerp mastodon-notifications-timer)
- (timer--triggered mastodon-notifications-timer))
- (mastodon-notifications-cancel-timer))
- ;; maybe we can remove this unless check, and just always cancel and
- ;; restart? that would have the effect of making the timer always
- ;; run mastodon-notifications-updates-interval seconds after opening
- ;; a new mastodon.el buffer, or effectively only showing an alert if
- ;; the user stops opening buffers:
- (unless mastodon-notifications-timer
- ;; set new timer if we don't have one:
- (setq mastodon-notifications-timer
- (run-at-time mastodon-notifications-updates-interval
- nil #'mastodon-notifications--update-check))))))
+ (cond
+ ;; if no buffers: cancel our timer and do nothing else:
+ ((and (not (mastodon-live-buffers))
+ ;; if we are loading a first mastodon.el buffer, the previous
+ ;; check fails, as `mastodon-mode-hook' necessariliy runs
+ ;; before we have buf-spec, which
+ ;; `mastodon-tl--get-buffer-type' relies on, and if we set
+ ;; buf-spec earlier, enabling the mode wipes it. So
+ ;; let's also check if the current buffer prefix is *mastodon-,
+ ;; which it will be when first calling `mastodon' at least
+ ;; (though not necessarily when loading other first mastodon.el
+ ;; buffers, such as new toot):
+ (not (string-prefix-p "*mastodon-" (buffer-name))))
+ ;; if not masto buffers: cancel everything:
+ (mastodon-notifications-cancel-timer))
+ ;; if a timer has already run but somehow
+ ;; `mastodon-notifications-timer' has not been nilled, assume it is a
+ ;; leftover and cancel it, otherwise our unless check below will always
+ ;; fail and no new timer will be created.
+ ;; NB: this gets called:
+ ;; - on creating a new mastodon.el buffer,
+ ;; - if an existing timer is run.
+ ;; in both cases, `timerp' should fail, but sometimes we have a
+ ;; zombie one somehow:
+ ((and (timerp mastodon-notifications-timer)
+ (timer--triggered mastodon-notifications-timer))
+ (mastodon-notifications-cancel-timer))
+ ;; maybe we can remove this unless check, and just always cancel and
+ ;; restart? that would have the effect of making the timer always
+ ;; run `mastodon-notifications-alerts-interval' seconds after opening
+ ;; a new mastodon.el buffer, or effectively only showing an alert if
+ ;; the user stops opening buffers:
+ (t
+ (unless mastodon-notifications-timer
+ ;; set new timer if we don't have one:
+ (setq mastodon-notifications-timer
+ (run-at-time mastodon-notifications-alerts-interval
+ nil #'mastodon-notifications--update-check))))))
(defun mastodon-notifications--update-check ()
"Get unread notifications count from the server, asynchronously.
@@ -1114,7 +1114,7 @@ Callback is `mastodon-notifications--update-check-cb'."
;; FIXME: unsure how to check if notifications buffer is active
;; here, as (current-buffer) returns different things if this is
;; triggered with notifs buffer active! so let's skip it for now,
- ;; and only ever notify, not update.
+ ;; and only ever notify, not update the notifs buffer.
;; (if ;;(not (mastodon-tl--buffer-type-eq 'notifications))
;; (not mastodon-notifications-update-when-unread)
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 397a121a0f..c4fce67f5a 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -6,7 +6,7 @@
;; Author: Johnson Denen <[email protected]>
;; Marty Hiatt <[email protected]>
;; Maintainer: Marty Hiatt <[email protected]>
-;; Version: 2.0.10
+;; Version: 2.0.11
;; Package-Requires: ((emacs "29.1") (persist "0.8") (tp "0.8"))
;; Homepage: https://codeberg.org/martianh/mastodon.el
@@ -200,16 +200,17 @@ A count of 2 for example means to display like so: \"Bob,
Jenny
and X others...\"."
:type '(integer))
-(defcustom mastodon-notifications-check-for-updates t
- "Whether to regularly check for new notifications."
- :type '(boolean))
-
-(defcustom mastodon-notifications-updates-interval 60
+(defcustom mastodon-notifications-alerts-interval 60
"How often to check for new notifications, in seconds."
:type '(integer))
-(defcustom mastodon-notifications-alerts nil
- "Whether to enable alert.el alerts."
+(defcustom mastodon-notifications-alerts t
+ "Whether to enable alert.el unread-notification alerts.
+If this is enabled and alert.el is installed, an alert.el notification
+will be shown using `mastodon-notifications-alert-style' as its alert
+style. If this is enabled but alert.el is not installed, alerts will be
+shown using `message'.
+Alerts are only checked for when at least 1 mastodon.el buffer is open."
:type '(boolean))
(defcustom mastodon-notifications-alert-style alert-default-style
diff --git a/mastodon-index.org b/mastodon-index.org
index 4225480ea0..164ed8bb42 100644
--- a/mastodon-index.org
+++ b/mastodon-index.org
@@ -325,10 +325,9 @@
| mastodon-media--preview-max-height | Max height of any media
attachment preview to be shown in timelines. |
| mastodon-mode-hook | Hook run when entering
Mastodon mode. |
| mastodon-notifications-alert-style | The type of alert.el
style to use for mastodon.el notification alerts. |
-| mastodon-notifications-alerts | Whether to enable
alert.el alerts. |
-| mastodon-notifications-check-for-updates | Whether to regularly
check for new notifications. |
+| mastodon-notifications-alerts | Whether to enable
alert.el unread-notification alerts. |
+| mastodon-notifications-alerts-interval | How often to check for
new notifications, in seconds. |
| mastodon-notifications-grouped-names-count | The number of
notification authors to display. |
-| mastodon-notifications-updates-interval | How often to check for
new notifications, in seconds. |
| mastodon-profile-mode-hook | Hook run after entering
or leaving `mastodon-profile-mode'. |
| mastodon-profile-note-in-foll-reqs | If non-nil, show a
user's profile note in follow request notifications. |
| mastodon-profile-note-in-foll-reqs-max-length | The max character
length for user profile note in follow requests. |