From 0e75fc74eebd142601d725cb814d7fe18b87c25e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 29 Oct 2024 12:02:23 +0100 Subject: group-notifs custom (for servers without). #608. WIP. --- lisp/mastodon.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index deee0c1..86810b7 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -372,7 +372,10 @@ MAX-ID is a request parameter for pagination." type (when max-id `(("max_id" . ,(mastodon-tl--buffer-property 'max-id)))) - nil nil nil "v2") + nil nil nil + (if (not mastodon-notifications--group-notifications) + "v1" + "v2")) (with-current-buffer (get-buffer-create buffer) (use-local-map mastodon-notifications--map)))) -- cgit v1.2.3 From 639745a8850dd01713437c2327610bdef9bd525c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 29 Oct 2024 17:16:21 +0100 Subject: move notifs customizes into mastodon.el --- lisp/mastodon-notifications.el | 40 +++++++++------------------------------- lisp/mastodon-tl.el | 4 ++-- lisp/mastodon.el | 26 +++++++++++++++++++++++++- mastodon-index.org | 6 +++--- 4 files changed, 39 insertions(+), 37 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index fde57f5..f0657fb 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -64,30 +64,8 @@ (autoload 'mastodon-tl--symbol "mastodon-tl") (autoload 'mastodon-tl--display-or-uname "mastodon-tl") -(defgroup mastodon-notifications nil - "Nofications in mastodon.el." - :prefix "mastodon-notifications-" - :group 'mastodon) - -(defcustom mastodon-notifications--profile-note-in-foll-reqs t - "If non-nil, show a user's profile note in follow request notifications." - :type '(boolean)) - -(defcustom mastodon-notifications--profile-note-in-foll-reqs-max-length nil - "The max character length for user profile note in follow requests. -Profile notes are only displayed if -`mastodon-notifications--profile-note-in-foll-reqs' is non-nil. -If unset, profile notes of any size will be displayed, which may -make them unweildy." - :type '(integer)) - -(defcustom mastodon-notifications--images-in-notifs nil - "Whether to display attached images in notifications." - :type '(boolean)) - -(defcustom mastodon-notifications--group-notifications t - "Whether to use grouped notifications." - :type '(boolean)) +;; notifications defcustoms moved into mastodon.el +;; as some need to be available without loading this file (defvar mastodon-tl--buffer-spec) (defvar mastodon-tl--display-media-p) @@ -244,8 +222,8 @@ JSON is a list of alists." (let ((str (mastodon-tl--field 'note (mastodon-tl--field 'account note)))) - (if mastodon-notifications--profile-note-in-foll-reqs-max-length - (string-limit str mastodon-notifications--profile-note-in-foll-reqs-max-length) + (if mastodon-profile-note-in-foll-reqs-max-length + (string-limit str mastodon-profile-note-in-foll-reqs-max-length) str)))) (status (mastodon-tl--field 'status note)) (follower (alist-get 'account note)) @@ -279,7 +257,7 @@ JSON is a list of alists." (propertize (format "You have a follow request from %s" follower-name) 'face 'default) - (when mastodon-notifications--profile-note-in-foll-reqs + (when mastodon-profile-note-in-foll-reqs (concat ":\n" (mastodon-notifications--comment-note-text body))))) @@ -323,8 +301,8 @@ ACCOUNTS is data of the accounts that have reacted to the notification." (profile-note (when (member type-sym '(follow_request)) (let ((str (mastodon-tl--field 'note (car accounts)))) - (if mastodon-notifications--profile-note-in-foll-reqs-max-length - (string-limit str mastodon-notifications--profile-note-in-foll-reqs-max-length) + (if mastodon-profile-note-in-foll-reqs-max-length + (string-limit str mastodon-profile-note-in-foll-reqs-max-length) str)))) (follower (when (member type-sym '(follow follow_request)) (car accounts))) @@ -356,7 +334,7 @@ ACCOUNTS is data of the accounts that have reacted to the notification." (propertize (format "You have a follow request from %s" follower-name) 'face 'default) - (when mastodon-notifications--profile-note-in-foll-reqs + (when mastodon-profile-note-in-foll-reqs (concat ":\n" (mastodon-notifications--comment-note-text body))))) @@ -530,7 +508,7 @@ When DOMAIN, force inclusion of user's domain in their handle." "Format JSON in Emacs buffer." (if (seq-empty-p json) (user-error "Looks like you have no (more) notifications for now") - (mastodon-notifications--render json (not mastodon-notifications--group-notifications)) + (mastodon-notifications--render json (not mastodon-group-notifications)) (goto-char (point-min)))) (defun mastodon-notifications--get-mentions () diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index ab6951e..4f77f92 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -97,7 +97,7 @@ (defvar mastodon-toot--visibility) (defvar mastodon-toot-mode) (defvar mastodon-active-user) -(defvar mastodon-notifications--images-in-notifs) +(defvar mastodon-images-in-notifs) (when (require 'mpv nil :no-error) (declare-function mpv-start "mpv")) @@ -1326,7 +1326,7 @@ SENSITIVE is a flag from the item's JSON data." ;; if in notifs, also check notifs images custom: (if (or (mastodon-tl--buffer-type-eq 'notifications) (mastodon-tl--buffer-type-eq 'mentions)) - mastodon-notifications--images-in-notifs + mastodon-images-in-notifs t)) (mastodon-media--get-media-link-rendering ; placeholder: "[img]" .preview_url remote-url ; for shr-browse-url diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 86810b7..211a9bc 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -153,6 +153,30 @@ currently, it doesn't seem to have a way to handle custom emoji, while emojify,el has this feature and mastodon.el implements it." :type 'boolean) +;; notifications customizes +;; moved here because we can load notifs without first loading mastodon.el +;; or mastodon-notifications.el + +(defcustom mastodon-profile-note-in-foll-reqs t + "If non-nil, show a user's profile note in follow request notifications." + :type '(boolean)) + +(defcustom mastodon-profile-note-in-foll-reqs-max-length nil + "The max character length for user profile note in follow requests. +Profile notes are only displayed if +`mastodon-profile-note-in-foll-reqs' is non-nil. +If unset, profile notes of any size will be displayed, which may +make them unweildy." + :type '(integer)) + +(defcustom mastodon-images-in-notifs nil + "Whether to display attached images in notifications." + :type '(boolean)) + +(defcustom mastodon-group-notifications t + "Whether to use grouped notifications." + :type '(boolean)) + (defun mastodon-kill-window () "Quit window and delete helper." (interactive) @@ -373,7 +397,7 @@ MAX-ID is a request parameter for pagination." (when max-id `(("max_id" . ,(mastodon-tl--buffer-property 'max-id)))) nil nil nil - (if (not mastodon-notifications--group-notifications) + (if (not mastodon-group-notifications) "v1" "v2")) (with-current-buffer (get-buffer-create buffer) diff --git a/mastodon-index.org b/mastodon-index.org index b3d6af7..858c322 100644 --- a/mastodon-index.org +++ b/mastodon-index.org @@ -269,9 +269,9 @@ | mastodon-media--hide-sensitive-media | Whether media marked as sensitive should be hidden. | | 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--images-in-notifs | Whether to display attached images in notifications. | -| mastodon-notifications--profile-note-in-foll-reqs | If non-nil, show a user's profile note in follow request notifications. | -| mastodon-notifications--profile-note-in-foll-reqs-max-length | The max character length for user profile note in follow requests. | +| mastodon-images-in-notifs | Whether to display attached images in notifications. | +| 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. | | mastodon-profile-mode-hook | Hook run after entering or leaving `mastodon-profile-mode'. | | mastodon-profile-update-mode-hook | Hook run after entering or leaving `mastodon-profile-update-mode'. | | mastodon-search-mode-hook | Hook run after entering or leaving `mastodon-search-mode'. | -- cgit v1.2.3 From 198c7ae8c71bd6460122b34549c4e6c4b5393bc4 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 31 Oct 2024 08:36:05 +0100 Subject: bump tp version, bump version --- lisp/mastodon.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index b544d5b..32cc671 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -6,8 +6,8 @@ ;; Author: Johnson Denen ;; Marty Hiatt ;; Maintainer: Marty Hiatt -;; Version: 1.1.3 -;; Package-Requires: ((emacs "28.1") (request "0.3.0") (persist "0.4") (tp "0.5")) +;; Version: 1.1.4 +;; Package-Requires: ((emacs "28.1") (request "0.3.0") (persist "0.4") (tp "0.6")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. -- cgit v1.2.3 From 6242db6028ef5646ead41e915dec6b8f014e33f8 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 2 Nov 2024 17:33:58 +0100 Subject: bump --- lisp/mastodon.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 32cc671..c13c3ba 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -6,7 +6,7 @@ ;; Author: Johnson Denen ;; Marty Hiatt ;; Maintainer: Marty Hiatt -;; Version: 1.1.4 +;; Version: 1.1.5 ;; Package-Requires: ((emacs "28.1") (request "0.3.0") (persist "0.4") (tp "0.6")) ;; Homepage: https://codeberg.org/martianh/mastodon.el -- cgit v1.2.3