emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/mastodon cf64163130 18/18: Merge branch 'develop'


From: ELPA Syncer
Subject: [nongnu] elpa/mastodon cf64163130 18/18: Merge branch 'develop'
Date: Thu, 21 Nov 2024 13:00:20 -0500 (EST)

branch: elpa/mastodon
commit cf6416313084a04e5028f46274e88284e2d120ee
Merge: 6112232a7a de40a8d6cc
Author: marty hiatt <martianhiatus@disroot.org>
Commit: marty hiatt <martianhiatus@disroot.org>

    Merge branch 'develop'
---
 README.org                     |  2 +-
 lisp/mastodon-notifications.el |  9 +++--
 lisp/mastodon-profile.el       |  8 ++--
 lisp/mastodon-tl.el            | 88 +++++++++++++++++++++++++++++-------------
 lisp/mastodon-toot.el          |  2 +-
 lisp/mastodon.el               | 17 ++++++--
 6 files changed, 87 insertions(+), 39 deletions(-)

diff --git a/README.org b/README.org
index b2f4964300..968493cdcf 100644
--- a/README.org
+++ b/README.org
@@ -12,7 +12,7 @@
 
 * README
 
-=mastodon.el= is an Emacs client for the AcitivityPub social networks that
+=mastodon.el= is an Emacs client for the ActivityPub social networks that
 implement the Mastodon API. For info see 
[[https://joinmastodon.org/][joinmastodon.org]].
 
 NB: =mastodon.el= now ships this readme as an .info file, so if you have it 
installed you should be able to browse this readme inside emacs. =C-h i= for 
info, then =m masto RET= should load it for you.
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 238feacc1b..bd6cb777b1 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -30,7 +30,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'subr-x))
+(require 'subr-x)
 (require 'cl-lib)
 
 (autoload 'mastodon-http--api "mastodon-http")
@@ -74,7 +74,7 @@
 (defvar mastodon-profile-note-in-foll-reqs)
 (defvar mastodon-profile-note-in-foll-reqs-max-length)
 (defvar mastodon-group-notifications)
-
+(defvar mastodon-notifications-grouped-names-count)
 (defvar mastodon-notifications--types
   '("favourite" "reblog" "mention" "poll"
     "follow_request" "follow" "status" "update"
@@ -266,7 +266,8 @@ ACCOUNTS is data of the accounts that have reacted to the 
notification."
                     str))))
              (follower (when (member type '(follow follow_request))
                          (car accounts)))
-             (follower-name (mastodon-tl--field 'username follower))
+             (follower-name (or (alist-get 'display_name follower)
+                                (alist-get 'username follower)))
              (filtered (mastodon-tl--field 'filtered status))
              (filters (when filtered
                         (mastodon-tl--current-filters filtered))))
@@ -416,7 +417,7 @@ GROUP is the group notification data.
 When AVATAR, include the account's avatar image.
 When DOMAIN, force inclusion of user's domain in their handle."
   (let ((total (alist-get 'notifications_count group))
-        (accts 2))
+        (accts mastodon-notifications-grouped-names-count))
     (concat
      (string-trim ;; remove trailing newline
       (cl-loop
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 1ce87479e8..a94fd16423 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -84,6 +84,7 @@
 (autoload 'mastodon-tl--buffer-property "mastodon-tl")
 (autoload 'mastodon-search--query "mastodon-search")
 (autoload 'mastodon-tl--field-status "mastodon-tl")
+(autoload 'mastodon-toot--with-toot-item "mastodon-toot" nil nil 'macro)
 
 (defvar mastodon-active-user)
 (defvar mastodon-tl--horiz-bar)
@@ -797,9 +798,10 @@ the format \"2000-01-31T00:00:00.000Z\"."
 If toot is a boost, opens the profile of the booster.
 MAX-ID is a flag to include the max_id pagination parameter."
   (interactive)
-  (mastodon-profile--make-author-buffer
-   (alist-get 'account (mastodon-profile--item-json))
-   nil nil nil nil max-id))
+  (mastodon-toot--with-toot-item
+   (mastodon-profile--make-author-buffer
+    (alist-get 'account (mastodon-profile--item-json))
+    nil nil nil nil max-id)))
 
 (defun mastodon-profile--image-from-account (account img-type)
   "Return a avatar image from ACCOUNT.
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 51abb6eb40..4a46cc27f8 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -89,7 +89,6 @@
 (autoload 'mastodon-media--process-full-sized-image-response "mastodon-media")
 (autoload 'mastodon-search--trending-statuses "mastodon-search")
 (autoload 'mastodon-search--format-heading "mastodon-search")
-(autoload 'mastodon-toot--with-toot-item "mastodon-toot")
 (autoload 'mastodon-media--image-or-cached "mastodon-media")
 (autoload 'mastodon-toot--base-toot-or-item-json "mastodon-toot")
 (autoload 'mastodon-search--load-link-posts "mastodon-search")
@@ -1211,15 +1210,16 @@ content should be hidden."
 
 (defun mastodon-tl--toggle-spoiler-text (position)
   "Toggle the visibility of the spoiler text at/after POSITION."
-  (let ((inhibit-read-only t)
-        (spoiler-region (mastodon-tl--find-property-range
-                         'mastodon-content-warning-body position nil)))
+  (let* ((inhibit-read-only t)
+         (spoiler-region (mastodon-tl--find-property-range
+                          'mastodon-content-warning-body position nil))
+         (new-state (not (get-text-property (car spoiler-region)
+                                            'invisible))))
     (if (not spoiler-region)
         (user-error "No spoiler text here")
       (add-text-properties (car spoiler-region) (cdr spoiler-region)
-                           (list 'invisible
-                                 (not (get-text-property (car spoiler-region)
-                                                         'invisible)))))))
+                           (list 'invisible new-state))
+      new-state))) ;; return what we set invisibility to
 
 (defun mastodon-tl--toggle-spoiler-text-in-toot ()
   "Toggle the visibility of the spoiler text in the current toot."
@@ -1254,7 +1254,13 @@ content should be hidden."
           (let* ((json (mastodon-tl--property 'item-json :no-move))
                  (cw (alist-get 'spoiler_text json)))
             (when (not (string= "" cw))
-              (mastodon-tl--toggle-spoiler-text-in-toot))))))))
+              (let ((new-state
+                     (pcase
+                         (mastodon-tl--toggle-spoiler-text-in-toot)
+                       ('t 'folded)
+                       ('nil 'unfolded))))
+                (plist-put mastodon-tl--buffer-spec
+                           'thread-unfolded new-state)))))))))
 
 (defun mastodon-tl--spoiler (toot &optional filter)
   "Render TOOT with spoiler message.
@@ -1287,13 +1293,15 @@ FILTER is a string to use as a filter warning spoiler 
instead."
             (if (not (eq 'server cust))
                 (not cust) ;; opp to setting
               ;; respect server setting:
-              (not
-               ;; If something goes wrong reading prefs,
-               ;; just return nil so CWs show by default.
-               (condition-case nil
-                   (mastodon-profile--get-preferences-pref
-                    'reading:expand:spoilers)
-                 (error nil))))))
+              ;; If something goes wrong reading prefs,
+              ;; just return t so CWs fold by default.
+              (condition-case nil
+                  (if (eq :json-false
+                          (mastodon-profile--get-preferences-pref
+                           'reading:expand:spoilers))
+                      t
+                    nil)
+                (error t)))))
       'mastodon-content-warning-body t))))
 
 
@@ -1665,7 +1673,8 @@ this just means displaying toot client.
 THREAD means the status will be displayed in a thread view.
 When DOMAIN, force inclusion of user's domain in their handle.
 UNFOLDED is a boolean meaning whether to unfold or fold item if foldable.
-NO-BYLINE means just insert toot body, used for folding."
+NO-BYLINE means just insert toot body, used for folding.
+CW-EXPANDED means treat content warnings as unfolded."
   (let* ((reply-to-id (alist-get 'in_reply_to_id toot))
          (after-reply-status-p
           (when (and thread reply-to-id)
@@ -1770,7 +1779,7 @@ THREAD means the status will be displayed in a thread 
view.
 When DOMAIN, force inclusion of user's domain in their handle.
 UNFOLDED is a boolean meaning whether to unfold or fold item if foldable.
 NO-BYLINE means just insert toot body, used for folding.
-NO-CW means treat content warnings as unfolded."
+CW-EXPANDED means treat content warnings as unfolded."
   (let* ((mastodon-tl--expand-content-warnings
           (or cw-expanded mastodon-tl--expand-content-warnings))
          (filtered (mastodon-tl--field 'filtered toot))
@@ -1816,6 +1825,7 @@ NO-BYLINE means just insert toot body, used for folding."
 
 (defun mastodon-tl--read-more-or-less (str cw invis)
   "Return a read more or read less heading.
+STR is an uppercase string, either MORE or LESS.
 The heading is a link to toggle the fold status of the toot.
 CW and INVIS are boolean values for the properties invisible and
 mastodon-content-warning-body."
@@ -1856,7 +1866,8 @@ FOLD means to fold it instead."
              (cw-range (mastodon-tl--find-property-range
                         'mastodon-content-warning-body
                         (point) :backward))
-             (cw-invis (get-text-property (car cw-range) 'invisible))
+             (cw-invis (when cw-range
+                         (get-text-property (car cw-range) 'invisible)))
              (toot (mastodon-tl--property 'item-json :no-move))
              ;; `replace-region-contents' is much too slow, our hack from
              ;; fedi.el is much simpler and much faster:
@@ -2323,15 +2334,37 @@ view all branches of a thread."
       (mastodon-tl--thread id))))
 
 (defun mastodon-tl--thread (&optional thread-id)
-  "Open thread buffer for toot at point or with THREAD-ID."
+  "Open thread buffer for toot at point or with THREAD-ID.
+UNFOLDED STATE is a boolean of whether the thread (that we are
+reloading) is fully unfolded or folded, i.e. via
+`mastodon-tl--toggle-spoiler-in-thread'."
   (interactive)
-  ;; no toot-at-point macro here as we can call this programmatically, eg from
-  ;; `mastodon-url-lookup'
+  (if (not (eq 'toot (mastodon-tl--property 'item-type :no-move)))
+      (user-error "Looks like there's no toot at point?")
+    (mastodon-tl--thread-do thread-id)))
+
+(defun mastodon-tl--thread-do (&optional thread-id)
+  "Open thread buffer for toot at point or with THREAD-ID.
+UNFOLDED STATE is a boolean of whether the thread (that we are
+reloading) is fully unfolded or folded, i.e. via
+`mastodon-tl--toggle-spoiler-in-thread'.
+This is the non-interactive version, so we can call it
+programmatically and not crash into
+`mastodon-toot--with-toot-item'."
   ;; this function's var must not be id as the above macro binds id and even
   ;; if we provide the arg (e.g. url-lookup), the macro definition overrides
   ;; it, making the optional arg unusable!
   (let* ((id (or thread-id (mastodon-tl--property 'base-item-id :no-move)))
-         (type (mastodon-tl--field 'type (mastodon-tl--property 'item-json 
:no-move))))
+         (type (mastodon-tl--field 'type
+                                   (mastodon-tl--property 'item-json 
:no-move)))
+         (unfolded-state (mastodon-tl--buffer-property 'thread-unfolded
+                                                       (current-buffer) 
:noerror))
+         (mastodon-tl--expand-content-warnings
+          ;; if reloading and thread was explicitly (un)folded, respect it:
+          (or (pcase unfolded-state
+                ('folded nil)
+                ('unfolded t)
+                (_ mastodon-tl--expand-content-warnings)))))
     (if (or (string= type "follow_request")
             (string= type "follow")) ; no can thread these
         (user-error "No thread")
@@ -2356,6 +2389,9 @@ view all branches of a thread."
                 (mastodon-tl--set-buffer-spec buffer endpoint
                                               #'mastodon-tl--thread
                                               nil nil nil nil id)
+                (when unfolded-state
+                  (plist-put mastodon-tl--buffer-spec
+                             'thread-unfolded unfolded-state))
                 (mastodon-tl--timeline (alist-get 'ancestors context) :thread)
                 (goto-char (point-max))
                 (move-marker marker (point))
@@ -3045,10 +3081,11 @@ MAX-ID is the pagination parameter, a string."
               (mastodon-tl--get-link-header-from-response headers)))
         (goto-char (point-max))
         (if (eq 'thread (mastodon-tl--get-buffer-type))
+            ;; if thread fully unfolded, respect it:
             ;; if thread view, call --thread with parent ID
             (progn (goto-char (point-min))
                    (mastodon-tl--goto-next-item)
-                   (funcall (mastodon-tl--update-function))
+                   (mastodon-tl--thread)
                    (goto-char point-before)
                    (message "Loaded full thread."))
           (if (not json)
@@ -3245,9 +3282,8 @@ This location is defined by a non-nil value of
       ;; update a thread, without calling `mastodon-tl--updated-json':
       (if (mastodon-tl--buffer-type-eq 'thread)
           ;; load whole thread:
-          (let ((thread-id (mastodon-tl--thread-parent-id)))
-            (funcall update-function thread-id)
-            (message "Loaded full thread."))
+          (progn (mastodon-tl--thread)
+                 (message "Loaded full thread."))
         ;; update other timelines:
         (let* ((id (mastodon-tl--newest-id))
                (params (mastodon-tl--update-params))
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 4ba5e5d342..1bc48c8cf9 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -301,7 +301,7 @@ Includes boosts, and notifications that display toots.
 This macro makes the local variable ID available."
   (declare (debug t))
   `(if (or (not (eq 'toot (mastodon-tl--property 'item-type :no-move)))
-           (member (mastodon-tl--property 'notification-type)
+           (member (mastodon-tl--property 'notification-type :no-move)
                    '("follow" "follow_request")))
        (user-error "Looks like there's no toot at point?")
      (mastodon-tl--with-toot-helper
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index d578ab1a80..b1147dc9ce 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -102,6 +102,7 @@
 (autoload 'mastodon-tl--dm-user "mastodon-tl")
 (autoload 'mastodon-tl--scroll-up-command "mastodon-tl")
 (autoload 'special-mode "simple")
+(autoload 'mastodon-tl--thread-do "mastodon-tl")
 
 (defvar mastodon-tl--highlight-current-toot)
 (defvar mastodon-notifications--map)
@@ -173,10 +174,18 @@ make them unweildy."
   "Whether to display attached images in notifications."
   :type '(boolean))
 
-(defcustom mastodon-group-notifications t
-  "Whether to use grouped notifications."
+(defcustom mastodon-group-notifications nil
+  "Whether to use grouped notifications.
+Requires that your instance actually implements grouped notifications.
+Mastodon implemented them in 4.3."
   :type '(boolean))
 
+(defcustom mastodon-notifications-grouped-names-count 2
+  "The number of notification authors to display.
+A count of 2 for example means to display like so: \"Bob, Jenny
+and X others...\"."
+  :type '(integer))
+
 (defun mastodon-kill-window ()
   "Quit window and delete helper."
   (interactive)
@@ -403,7 +412,7 @@ MAX-ID is a request parameter for pagination."
      nil nil nil
      (if (or (not mastodon-group-notifications)
              ;; if version less than 1st grouped notifs release:
-             (< 4.3 (string-to-number
+             (> 4.3 (string-to-number
                      (mastodon-instance-version))))
          "v1"
        "v2"))
@@ -439,7 +448,7 @@ If FORCE, do a lookup regardless of the result of 
`mastodon--fedi-url-p'."
                (let* ((statuses (assoc 'statuses response))
                       (status (seq-first (cdr statuses)))
                       (status-id (alist-get 'id status)))
-                 (mastodon-tl--thread status-id)))
+                 (mastodon-tl--thread-do status-id)))
               ((not (seq-empty-p (alist-get 'accounts response)))
                (let* ((accounts (assoc 'accounts response))
                       (account (seq-first (cdr accounts))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]