From 8404082b696b730b3ee625474ece49f4011e02f2 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 15:39:02 +0200
Subject: move scroll up cmd
---
lisp/mastodon-tl.el | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 68147d9..62d3d67 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -311,6 +311,15 @@ than `switch-to-buffer'."
;;; NAV
+(defun mastodon-tl--scroll-up-command ()
+ "Call `scroll-up-command', loading more toots if necessary.
+If we hit `point-max', call `mastodon-tl--more' then `scroll-up-command'."
+ (interactive)
+ (if (not (equal (point) (point-max)))
+ (scroll-up-command)
+ (mastodon-tl--more)
+ (scroll-up-command)))
+
(defun mastodon-tl--next-tab-item (&optional previous)
"Move to the next interesting item.
This could be the next toot, link, or image; whichever comes first.
@@ -359,15 +368,6 @@ Optionally start from POS."
(mastodon-tl--message-help-echo))
(funcall refresh))))
-(defun mastodon-tl--scroll-up-command ()
- "Call `scroll-up-command', loading more toots if necessary.
-If we hit `point-max', call `mastodon-tl--more' then `scroll-up-command'."
- (interactive)
- (if (not (equal (point) (point-max)))
- (scroll-up-command)
- (mastodon-tl--more)
- (scroll-up-command)))
-
(defun mastodon-tl--goto-next-toot ()
"Jump to next toot header."
(interactive)
--
cgit v1.2.3
From 45fd842fe2f2cb1210d44c869140d4ca542e088e Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 15:39:12 +0200
Subject: goto-too-pos: add masto-tab-stop second prop
---
lisp/mastodon-tl.el | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 62d3d67..4d07a4a 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -356,12 +356,19 @@ text, i.e. hidden spoiler text."
"Search for toot with FIND-POS.
If search returns nil, execute REFRESH function.
Optionally start from POS."
- (let* ((npos (funcall find-pos
- (or pos (point))
- 'byline
- (current-buffer))))
+ (let* ((npos (or ; toot/user items have byline:
+ (funcall find-pos
+ (or pos (point))
+ 'byline
+ (current-buffer))
+ ;; some other things don't, so just tab-stop:
+ (funcall find-pos
+ (or pos (point))
+ 'mastodon-tab-stop
+ (current-buffer)))))
(if npos
- (if (not (get-text-property npos 'toot-id))
+ (if (not (or (get-text-property npos 'toot-id) ; toots, etc.
+ (get-text-property npos 'mastodon-tab-stop))) ; generic
(mastodon-tl--goto-toot-pos find-pos refresh npos)
(goto-char npos)
;; force display of help-echo on moving to a toot byline:
--
cgit v1.2.3
From 267b8f9fff61c44cc817c662ce9dfb5b40d9a42f Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 15:56:01 +0200
Subject: refactor/rename mastodon-search--insert-heading
---
lisp/mastodon-search.el | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 41e4f23..3fd552d 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -122,22 +122,20 @@ PRINT-FUN is the function used to print the data from the response."
(format "trends/%s" type)
print-fun nil
params)
- (insert (mastodon-tl--set-face
- (concat "\n " mastodon-tl--horiz-bar "\n"
- (upcase (format " TRENDING %s\n" type))
- " " mastodon-tl--horiz-bar "\n\n")
- 'success))
+ (mastodon-search--insert-heading "trending" type)
(funcall print-fun data)
(unless (equal type "statuses")
(goto-char (point-min))))))
;; functions for mastodon search
-(defun mastodon-search--format-heading (heading)
- "Format HEADING as a heading."
+(defun mastodon-search--insert-heading (heading &optional type)
+ "Format HEADING as a heading.
+Optionally add string TYPE after HEADING."
(insert
(mastodon-tl--set-face (concat "\n " mastodon-tl--horiz-bar "\n "
- heading "\n"
+ (upcase heading) " "
+ (if type (upcase type) "") "\n"
" " mastodon-tl--horiz-bar "\n")
'success)))
@@ -186,7 +184,7 @@ is used for pagination."
(alist-get 'statuses response))))
(with-mastodon-buffer buffer #'mastodon-mode nil
(mastodon-search-mode)
- (mastodon-search--format-heading (upcase type))
+ (mastodon-search--insert-heading type)
;; user results:
(cond ((equal type "accounts")
(mastodon-search--render-response accts type buffer params
--
cgit v1.2.3
From 50e9fc677fd405a4e957c617f4dc31306321b9fc Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 18:17:45 +0200
Subject: fix pagination for trending tags
---
lisp/mastodon-search.el | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 3fd552d..9b4bb68 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -89,7 +89,7 @@ QUERY is the string to search."
"Display a list of tags trending on your instance."
(interactive)
(mastodon-search--view-trending "tags"
- #'mastodon-search--print-tags-list))
+ #'mastodon-search--print-tags))
(defun mastodon-search--trending-statuses ()
"Display a list of statuses trending on your instance."
@@ -109,13 +109,7 @@ PRINT-FUN is the function used to print the data from the response."
'("limit" . "20")))
(offset '(("offset" . "0")))
(params (push limit offset))
- (response (mastodon-http--get-json url params))
- (data (cond ((equal type "tags")
- (mapcar #'mastodon-search--get-hashtag-info response))
- ((equal type "statuses")
- response) ; no longer needs further processing
- ((equal type "links")
- (message "todo"))))
+ (data (mastodon-http--get-json url params))
(buffer (get-buffer-create (format "*mastodon-trending-%s*" type))))
(with-mastodon-buffer buffer #'mastodon-mode nil
(mastodon-tl--set-buffer-spec (buffer-name buffer)
--
cgit v1.2.3
From 153b1682d015624f3fe0fc716f8cfd5e8b6161a5 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 18:39:35 +0200
Subject: more*: msg when response is nil
---
lisp/mastodon-tl.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 4d07a4a..ddf3d0e 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2390,7 +2390,8 @@ Runs the timeline's update function on RESPONSE, in BUFFER.
When done, places point at POINT-BEFORE.
HEADERS is the http headers returned in the response, if any."
(with-current-buffer buffer
- (when response
+ (if (not response)
+ (message "No more results")
(let* ((inhibit-read-only t)
(json (if headers (car response) response))
;; FIXME: max-id pagination works for statuses only, not other
--
cgit v1.2.3
From f8ab918cf298a5719f1df044669436137b172484 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 19:06:00 +0200
Subject: partly refactor views function.
---
lisp/mastodon-views.el | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 24fe6d7..8110e50 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -164,16 +164,12 @@ request.
This function is used as the update-function to
`mastodon-tl--init-sync', which initializes a buffer for us and
provides the JSON data."
+ ;; FIXME: this breaks pagination, duh!
(erase-buffer)
- (insert (mastodon-tl--set-face
- (concat "\n " mastodon-tl--horiz-bar "\n "
- (upcase view-name)
- "\n " mastodon-tl--horiz-bar "\n\n")
- 'success)
- (if bindings-string
- (mastodon-tl--set-face (concat "[" bindings-string "]\n\n")
- 'font-lock-comment-face)
- ""))
+ (mastodon-search--insert-heading view-name) ; this cd go in init-sync
+ (when bindings-string
+ (insert (mastodon-tl--set-face (concat "[" bindings-string "]\n\n")
+ 'font-lock-comment-face)))
(if (seq-empty-p data)
(insert (propertize
(format "Looks like you have no %s for now." view-name)
--
cgit v1.2.3
From f5094f4cb0bc527524b90fdb1cc2dd700c4b4851 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 19:06:57 +0200
Subject: add params arg to init-sync, use limit param for foll_reqs/sugests
---
lisp/mastodon-tl.el | 13 ++++++++-----
lisp/mastodon-views.el | 10 ++++++++--
2 files changed, 16 insertions(+), 7 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index ddf3d0e..d2edd85 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2654,20 +2654,23 @@ JSON and http headers, without it just the JSON."
(mastodon-tl--do-init json update-function))))))
(defun mastodon-tl--init-sync (buffer-name endpoint update-function
- &optional note-type)
+ &optional note-type params)
"Initialize BUFFER-NAME with timeline targeted by ENDPOINT.
UPDATE-FUNCTION is used to receive more toots.
Runs synchronously.
Optional arg NOTE-TYPE means only get that type of note."
+ ;; Used by `mastodon-notifications-get' and in views.el
(let* ((exclude-types (when note-type
(mastodon-notifications--filter-types-list note-type)))
- (args (when note-type (mastodon-http--build-array-params-alist
- "exclude_types[]" exclude-types)))
+ (notes-params (when note-type
+ (mastodon-http--build-array-params-alist
+ "exclude_types[]" exclude-types)))
+ (params (append notes-params params))
(url (mastodon-http--api endpoint))
(buffer (concat "*mastodon-" buffer-name "*"))
- (json (mastodon-http--get-json url args)))
+ (json (mastodon-http--get-json url params)))
(with-mastodon-buffer buffer #'mastodon-mode nil
- (mastodon-tl--set-buffer-spec buffer endpoint update-function nil args)
+ (mastodon-tl--set-buffer-spec buffer endpoint update-function nil params)
(mastodon-tl--do-init json update-function)
buffer)))
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 8110e50..dd46b59 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -443,6 +443,7 @@ If ID is provided, use that list."
;;; FOLLOW REQUESTS
+;; TODO: paginates by link header
(defun mastodon-views--insert-follow-requests (json)
"Insert the user's current follow requests.
@@ -458,7 +459,9 @@ JSON is the data returned by the server."
(interactive)
(mastodon-tl--init-sync "follow-requests"
"follow_requests"
- 'mastodon-views--insert-follow-requests)
+ 'mastodon-views--insert-follow-requests
+ nil
+ '(("limit" . "80"))) ; server max
(mastodon-tl--goto-first-item)
(with-current-buffer "*mastodon-follow-requests*"
(use-local-map mastodon-views--view-follow-requests-keymap)))
@@ -650,13 +653,16 @@ Prompt for a context, must be a list containting at least one of \"home\",
;;; FOLLOW SUGGESTIONS
+;; No pagination: max 80 results
(defun mastodon-views--view-follow-suggestions ()
"Display a buffer of suggested accounts to follow."
(interactive)
(mastodon-tl--init-sync "follow-suggestions"
"suggestions"
- 'mastodon-views--insert-follow-suggestions)
+ 'mastodon-views--insert-follow-suggestions
+ nil
+ '(("limit" . "80"))) ; server max
(with-current-buffer "*mastodon-follow-suggestions*"
(use-local-map mastodon-views--follow-suggestions-map)))
--
cgit v1.2.3
From 312573f7ef4c0ebca511d2b8e44f50b090d44d37 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 19:17:30 +0200
Subject: cond for more* pagination woes
---
lisp/mastodon-tl.el | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index d2edd85..02c2dd7 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2357,7 +2357,8 @@ when showing followers or accounts followed."
"Append older toots to timeline, asynchronously."
(message "Loading older toots...")
(if (mastodon-tl--use-link-header-p)
- ;; link-header: can't build a URL with --more-json-async, endpoint/id:
+ ;; link-header paginate:
+ ;; can't build a URL with --more-json-async, endpoint/id:
;; ensure we have a "next" type here, otherwise the CAR will be the
;; "prev" type!
(let ((link-header (mastodon-tl--link-header)))
@@ -2368,21 +2369,22 @@ when showing followers or accounts followed."
(url (mastodon-tl--build-link-header-url next)))
(mastodon-http--get-response-async url nil 'mastodon-tl--more* (current-buffer)
(point) :headers))))
- ;; offset (search, trending, user lists, ...?):
- (if (or (string-prefix-p "*mastodon-trending-" (buffer-name))
- (mastodon-tl--search-buffer-p))
- ;; Endpoints that do not implement: follow-suggestions,
- ;; follow-requests
- (mastodon-tl--more-json-async-offset
- (mastodon-tl--endpoint)
- (mastodon-tl--update-params)
- 'mastodon-tl--more* (current-buffer) (point))
- ;; max_id (timelines, items with ids/timestamps):
- (mastodon-tl--more-json-async
- (mastodon-tl--endpoint)
- (mastodon-tl--oldest-id)
- (mastodon-tl--update-params)
- 'mastodon-tl--more* (current-buffer) (point)))))
+ (cond ( ; no paginate
+ (mastodon-tl--buffer-type-eq 'follow-suggestions)
+ (message "No more results"))
+ ;; offset paginate (search, trending, user lists, ...?):
+ ((or (string-prefix-p "*mastodon-trending-" (buffer-name))
+ (mastodon-tl--search-buffer-p))
+ (mastodon-tl--more-json-async-offset
+ (mastodon-tl--endpoint)
+ (mastodon-tl--update-params)
+ 'mastodon-tl--more* (current-buffer) (point)))
+ (t;; max_id paginate (timelines, items with ids/timestamps):
+ (mastodon-tl--more-json-async
+ (mastodon-tl--endpoint)
+ (mastodon-tl--oldest-id)
+ (mastodon-tl--update-params)
+ 'mastodon-tl--more* (current-buffer) (point))))))
(defun mastodon-tl--more* (response buffer point-before &optional headers)
"Append older toots to timeline, asynchronously.
--
cgit v1.2.3
From b078849b534ddaaebdaf45ebee89d2fe59f3f696 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 19:36:36 +0200
Subject: implement link-header pagination for foll-reqs
---
lisp/mastodon-tl.el | 18 +++++++++++-------
lisp/mastodon-views.el | 3 ++-
2 files changed, 13 insertions(+), 8 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 02c2dd7..d5d127d 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2340,12 +2340,13 @@ POS is a number, where point will be placed."
(defun mastodon-tl--use-link-header-p ()
"Return t if we are in a view needing Link header pagination.
-Currently this includes favourites, bookmarks, and profile pages
-when showing followers or accounts followed."
+Currently this includes favourites, bookmarks, follow requests,
+and profile pages when showing followers or accounts followed."
(or (mastodon-tl--buffer-type-eq 'favourites)
(mastodon-tl--buffer-type-eq 'bookmarks)
(mastodon-tl--buffer-type-eq 'profile-followers)
- (mastodon-tl--buffer-type-eq 'profile-following)))
+ (mastodon-tl--buffer-type-eq 'profile-following)
+ (mastodon-tl--buffer-type-eq 'follow-requests)))
(defun mastodon-tl--get-link-header-from-response (headers)
"Get http Link header from list of http HEADERS."
@@ -2363,7 +2364,7 @@ when showing followers or accounts followed."
;; "prev" type!
(let ((link-header (mastodon-tl--link-header)))
(if (> 2 (length link-header))
- (error "No next page")
+ (message "No next page")
(let* ((next (car link-header))
;;(prev (cadr (mastodon-tl--link-header)))
(url (mastodon-tl--build-link-header-url next)))
@@ -2656,7 +2657,7 @@ JSON and http headers, without it just the JSON."
(mastodon-tl--do-init json update-function))))))
(defun mastodon-tl--init-sync (buffer-name endpoint update-function
- &optional note-type params)
+ &optional note-type params headers)
"Initialize BUFFER-NAME with timeline targeted by ENDPOINT.
UPDATE-FUNCTION is used to receive more toots.
Runs synchronously.
@@ -2670,9 +2671,12 @@ Optional arg NOTE-TYPE means only get that type of note."
(params (append notes-params params))
(url (mastodon-http--api endpoint))
(buffer (concat "*mastodon-" buffer-name "*"))
- (json (mastodon-http--get-json url params)))
+ (response (mastodon-http--get-response url params))
+ (json (if headers (car response) response))
+ (headers (if headers (cdr response) nil))
+ (link-header (mastodon-tl--get-link-header-from-response headers)))
(with-mastodon-buffer buffer #'mastodon-mode nil
- (mastodon-tl--set-buffer-spec buffer endpoint update-function nil params)
+ (mastodon-tl--set-buffer-spec buffer endpoint update-function link-header params)
(mastodon-tl--do-init json update-function)
buffer)))
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index dd46b59..20734ae 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -461,7 +461,8 @@ JSON is the data returned by the server."
"follow_requests"
'mastodon-views--insert-follow-requests
nil
- '(("limit" . "80"))) ; server max
+ '(("limit" . "40")) ; server max is 80
+ :headers)
(mastodon-tl--goto-first-item)
(with-current-buffer "*mastodon-follow-requests*"
(use-local-map mastodon-views--view-follow-requests-keymap)))
--
cgit v1.2.3
From 6d80f5b2d2dd71a0e28a7bcb700e8fb1757ac8d6 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 19:46:41 +0200
Subject: minor-view fixme
---
lisp/mastodon-views.el | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 20734ae..d7fedb6 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -164,9 +164,12 @@ request.
This function is used as the update-function to
`mastodon-tl--init-sync', which initializes a buffer for us and
provides the JSON data."
- ;; FIXME: this breaks pagination, duh!
- (erase-buffer)
- (mastodon-search--insert-heading view-name) ; this cd go in init-sync
+ ;; FIXME: this is not an update function as it inserts a heading and
+ ;; possible bindings string
+ ;; either it should go in init-sync, or possibly in each view function
+ ;; but either way, this function does almost nothing for us.
+ ;; could we call init-sync in here pehaps?
+ (mastodon-search--insert-heading view-name)
(when bindings-string
(insert (mastodon-tl--set-face (concat "[" bindings-string "]\n\n")
'font-lock-comment-face)))
--
cgit v1.2.3
From 0fc64df90d9cb8ccb6b1968e0dc36ece6c9b639c Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 20:18:38 +0200
Subject: fix minor-view disaster disastrously: put it all init-sync
---
lisp/mastodon-tl.el | 15 ++++++++++++---
lisp/mastodon-views.el | 52 ++++++++++++++++++++++++++++++--------------------
2 files changed, 43 insertions(+), 24 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index d5d127d..47824c0 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2656,8 +2656,9 @@ JSON and http headers, without it just the JSON."
link-header update-params hide-replies)
(mastodon-tl--do-init json update-function))))))
-(defun mastodon-tl--init-sync (buffer-name endpoint update-function
- &optional note-type params headers)
+(defun mastodon-tl--init-sync
+ (buffer-name endpoint update-function
+ &optional note-type params headers view-name binding-str)
"Initialize BUFFER-NAME with timeline targeted by ENDPOINT.
UPDATE-FUNCTION is used to receive more toots.
Runs synchronously.
@@ -2676,7 +2677,15 @@ Optional arg NOTE-TYPE means only get that type of note."
(headers (if headers (cdr response) nil))
(link-header (mastodon-tl--get-link-header-from-response headers)))
(with-mastodon-buffer buffer #'mastodon-mode nil
- (mastodon-tl--set-buffer-spec buffer endpoint update-function link-header params)
+ ;; insert view-name/ heading-str
+ (when view-name
+ (mastodon-search--insert-heading view-name))
+ (when binding-str
+ (insert (mastodon-tl--set-face (concat "[" binding-str "]\n\n")
+ 'font-lock-comment-face)))
+
+ (mastodon-tl--set-buffer-spec buffer endpoint update-function
+ link-header params)
(mastodon-tl--do-init json update-function)
buffer)))
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index d7fedb6..6e46eb9 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -155,7 +155,7 @@
;;; GENERAL FUNCTION
-(defun mastodon-views--minor-view (view-name bindings-string insert-fun data)
+(defun mastodon-views--minor-view (view-name insert-fun data)
"Load a minor view named VIEW-NAME.
BINDINGS-STRING is a string explaining the view's local bindings.
INSERT-FUN is the function to call to insert the view's elements.
@@ -169,10 +169,10 @@ provides the JSON data."
;; either it should go in init-sync, or possibly in each view function
;; but either way, this function does almost nothing for us.
;; could we call init-sync in here pehaps?
- (mastodon-search--insert-heading view-name)
- (when bindings-string
- (insert (mastodon-tl--set-face (concat "[" bindings-string "]\n\n")
- 'font-lock-comment-face)))
+ ;; (mastodon-search--insert-heading view-name)
+ ;; (when bindings-string
+ ;; (insert (mastodon-tl--set-face (concat "[" bindings-string "]\n\n")
+ ;; 'font-lock-comment-face)))
(if (seq-empty-p data)
(insert (propertize
(format "Looks like you have no %s for now." view-name)
@@ -193,17 +193,19 @@ provides the JSON data."
"Show the user's lists in a new buffer."
(interactive)
(mastodon-tl--init-sync "lists" "lists"
- 'mastodon-views--insert-lists)
+ 'mastodon-views--insert-lists
+ nil nil nil
+ "your lists"
+ "C - create a list\n D - delete a list\
+ \n A/R - add/remove account from a list\
+ \n E - edit a list\n n/p - go to next/prev item")
(with-current-buffer "*mastodon-lists*"
(use-local-map mastodon-views--view-lists-keymap)))
(defun mastodon-views--insert-lists (json)
"Insert the user's lists from JSON."
(mastodon-views--minor-view
- "your lists"
- "C - create a list\n D - delete a list\
- \n A/R - add/remove account from a list\
- \n E - edit a list\n n/p - go to next/prev item"
+ "lists"
#'mastodon-views--print-list-set
json))
@@ -446,14 +448,12 @@ If ID is provided, use that list."
;;; FOLLOW REQUESTS
-;; TODO: paginates by link header
(defun mastodon-views--insert-follow-requests (json)
"Insert the user's current follow requests.
JSON is the data returned by the server."
(mastodon-views--minor-view
"follow requests"
- "a/j - accept/reject request at point\n n/p - go to next/prev request"
#'mastodon-views--insert-users-propertized-note
json))
@@ -465,7 +465,10 @@ JSON is the data returned by the server."
'mastodon-views--insert-follow-requests
nil
'(("limit" . "40")) ; server max is 80
- :headers)
+ :headers
+ "follow requests"
+ "a/j - accept/reject request at point\n\
+ n/p - go to next/prev request")
(mastodon-tl--goto-first-item)
(with-current-buffer "*mastodon-follow-requests*"
(use-local-map mastodon-views--view-follow-requests-keymap)))
@@ -478,15 +481,18 @@ JSON is the data returned by the server."
(interactive)
(mastodon-tl--init-sync "scheduled-toots"
"scheduled_statuses"
- 'mastodon-views--insert-scheduled-toots)
+ 'mastodon-views--insert-scheduled-toots
+ nil nil nil
+ "your scheduled toots"
+ "n/p - prev/next\n r - reschedule\n\
+ e/RET - edit toot\n c - cancel")
(with-current-buffer "*mastodon-scheduled-toots*"
(use-local-map mastodon-views--scheduled-map)))
(defun mastodon-views--insert-scheduled-toots (json)
"Insert the user's scheduled toots, from JSON."
(mastodon-views--minor-view
- "your scheduled toots"
- "n/p - prev/next\n r - reschedule\n e/RET - edit toot\n c - cancel"
+ "scheduled toots"
#'mastodon-views--insert-scheduled-toots-list
json))
@@ -577,7 +583,11 @@ NO-CONFIRM means there is no ask or message, there is only do."
"View the user's filters in a new buffer."
(interactive)
(mastodon-tl--init-sync "filters" "filters"
- 'mastodon-views--insert-filters)
+ 'mastodon-views--insert-filters
+ nil nil nil
+ "current filters"
+ "c - create filter\n d - delete filter at point\n\
+ n/p - go to next/prev filter")
(with-current-buffer "*mastodon-filters*"
(use-local-map mastodon-views--view-filters-keymap)))
@@ -585,8 +595,7 @@ NO-CONFIRM means there is no ask or message, there is only do."
"Insert the user's current filters.
JSON is what is returned by by the server."
(mastodon-views--minor-view
- "current filters"
- "c - create filter\n d - delete filter at point\n n/p - go to next/prev filter"
+ "filters"
#'mastodon-views--insert-filter-string-set
json))
@@ -666,7 +675,9 @@ Prompt for a context, must be a list containting at least one of \"home\",
"suggestions"
'mastodon-views--insert-follow-suggestions
nil
- '(("limit" . "80"))) ; server max
+ '(("limit" . "80")) ; server max
+ nil
+ "suggested accounts")
(with-current-buffer "*mastodon-follow-suggestions*"
(use-local-map mastodon-views--follow-suggestions-map)))
@@ -675,7 +686,6 @@ Prompt for a context, must be a list containting at least one of \"home\",
JSON is the data returned by the server."
(mastodon-views--minor-view
"suggested accounts"
- nil
#'mastodon-views--insert-users-propertized-note
json))
--
cgit v1.2.3
From a672c056a8dfb17f9513933189e2786c42542398 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 19:55:22 +0200
Subject: fix init-sync for notifs-get compat with link-header/get-response
---
lisp/mastodon-tl.el | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 47824c0..0c4f8af 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2673,9 +2673,10 @@ Optional arg NOTE-TYPE means only get that type of note."
(url (mastodon-http--api endpoint))
(buffer (concat "*mastodon-" buffer-name "*"))
(response (mastodon-http--get-response url params))
- (json (if headers (car response) response))
- (headers (if headers (cdr response) nil))
- (link-header (mastodon-tl--get-link-header-from-response headers)))
+ (json (car response))
+ (headers (when headers (cdr response)))
+ (link-header (when headers
+ (mastodon-tl--get-link-header-from-response headers))))
(with-mastodon-buffer buffer #'mastodon-mode nil
;; insert view-name/ heading-str
(when view-name
@@ -2683,7 +2684,6 @@ Optional arg NOTE-TYPE means only get that type of note."
(when binding-str
(insert (mastodon-tl--set-face (concat "[" binding-str "]\n\n")
'font-lock-comment-face)))
-
(mastodon-tl--set-buffer-spec buffer endpoint update-function
link-header params)
(mastodon-tl--do-init json update-function)
--
cgit v1.2.3
From 1e40c8d19faa529efe54ee63e5b2a0f1df103717 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 14 Oct 2023 21:37:40 +0200
Subject: docstrings, autoloads
---
lisp/mastodon-tl.el | 8 +++++++-
lisp/mastodon-views.el | 13 ++++++++-----
2 files changed, 15 insertions(+), 6 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 0c4f8af..d1f6149 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -85,6 +85,8 @@
(autoload 'mastodon-search--buf-type "mastodon-search")
(autoload 'mastodon-http--api-search "mastodon-http")
(autoload 'mastodon-views--insert-users-propertized-note "mastodon-views") ; for search pagination
+(autoload 'mastodon-http--get-response "mastodon-http")
+(autoload 'mastodon-search--insert-heading "mastodon-search")
(defvar mastodon-toot--visibility)
(defvar mastodon-toot-mode)
@@ -2662,7 +2664,11 @@ JSON and http headers, without it just the JSON."
"Initialize BUFFER-NAME with timeline targeted by ENDPOINT.
UPDATE-FUNCTION is used to receive more toots.
Runs synchronously.
-Optional arg NOTE-TYPE means only get that type of note."
+Optional arg NOTE-TYPE means only get that type of note.
+PARAMS is an alist of any params to include in the request.
+HEADERS are any headers to send in the request.
+VIEW-NAME is a string, to be used as a heading for the view.
+BINDING-STR is a string explaining any bindins in the view."
;; Used by `mastodon-notifications-get' and in views.el
(let* ((exclude-types (when note-type
(mastodon-notifications--filter-types-list note-type)))
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 6e46eb9..e348cae 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -732,11 +732,13 @@ If INSTANCE is given, use that."
(string-remove-suffix (concat "/@" username)
url))))
-(defun mastodon-views--view-instance-description (&optional user brief instance misskey)
+(defun mastodon-views--view-instance-description
+ (&optional user brief instance misskey)
"View the details of the instance the current post's author is on.
USER means to show the instance details for the logged in user.
BRIEF means to show fewer details.
-INSTANCE is an instance domain name."
+INSTANCE is an instance domain name.
+MISSKEY means the instance is a Misskey or derived server."
(interactive)
(if user
(let ((response (mastodon-http--get-json
@@ -794,15 +796,16 @@ USER, BRIEF, and INSTANCE are all for
&optional misskey)
"Display instance description RESPONSE in a new buffer.
BRIEF means to show fewer details.
-INSTANCE is the instance were are working with."
+INSTANCE is the instance were are working with.
+MISSKEY means the instance is a Misskey or derived server."
(when response
(let* ((domain (url-file-nondirectory instance))
(buf (get-buffer-create
(format "*mastodon-instance-%s*" domain))))
(with-mastodon-buffer buf #'special-mode :other-window
(if misskey
- (mastodon-view--insert-json response)
- (condition-case err
+ (mastodon-views--insert-json response)
+ (condition-case nil
(progn
(when brief
(setq response
--
cgit v1.2.3
From dd5a34bb8db2f544b53811fb89dfa649ecca198c Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sun, 15 Oct 2023 10:48:12 +0200
Subject: remove "toots" from more msging, as its now (more) generic
---
lisp/mastodon-tl.el | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index d1f6149..03d5ef8 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2358,7 +2358,7 @@ and profile pages when showing followers or accounts followed."
(defun mastodon-tl--more ()
"Append older toots to timeline, asynchronously."
- (message "Loading older toots...")
+ (message "Loading...")
(if (mastodon-tl--use-link-header-p)
;; link-header paginate:
;; can't build a URL with --more-json-async, endpoint/id:
@@ -2431,7 +2431,7 @@ HEADERS is the http headers returned in the response, if any."
(mastodon-tl--endpoint)
(mastodon-tl--update-function)
link-header))
- (message "Loading older toots... done.")))))))
+ (message "Loading... done.")))))))
(defun mastodon-tl--find-property-range (property start-point
&optional search-backwards)
--
cgit v1.2.3
From a53d9824fe19c7ddeea665878fd963a5b11695f5 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sun, 15 Oct 2023 10:49:13 +0200
Subject: change some error calls to user-error calls
---
lisp/mastodon-profile.el | 6 +++---
lisp/mastodon-tl.el | 13 +++++++------
lisp/mastodon-toot.el | 12 ++++++------
lisp/mastodon-views.el | 6 +++---
4 files changed, 19 insertions(+), 18 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 3d27bb4..365e352 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -165,7 +165,7 @@ NO-REBLOGS means do not display boosts in statuses."
(interactive)
(if mastodon-profile--account
(mastodon-profile--make-author-buffer mastodon-profile--account :no-reblogs)
- (error "Not in a mastodon profile")))
+ (user-error "Not in a mastodon profile")))
(defun mastodon-profile--open-following ()
"Open a profile buffer showing the accounts that current profile follows."
@@ -177,7 +177,7 @@ NO-REBLOGS means do not display boosts in statuses."
#'mastodon-profile--format-user
nil
:headers)
- (error "Not in a mastodon profile")))
+ (user-error "Not in a mastodon profile")))
(defun mastodon-profile--open-followers ()
"Open a profile buffer showing the accounts following the current profile."
@@ -189,7 +189,7 @@ NO-REBLOGS means do not display boosts in statuses."
#'mastodon-profile--format-user
nil
:headers)
- (error "Not in a mastodon profile")))
+ (user-error "Not in a mastodon profile")))
(defun mastodon-profile--view-favourites ()
"Open a new buffer displaying the user's favourites."
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 03d5ef8..b0c121a 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1496,8 +1496,9 @@ If NO-ERROR is non-nil, do not error when property is empty."
(if no-error
(plist-get mastodon-tl--buffer-spec property)
(or (plist-get mastodon-tl--buffer-spec property)
- (error "Mastodon-tl--buffer-spec is not defined for buffer %s"
- (or buffer (current-buffer)))))))
+ (error "Mastodon-tl--buffer-spec not defined for buffer %s, prop %s"
+ (or buffer (current-buffer))
+ property)))))
(defun mastodon-tl--set-buffer-spec
(buffer endpoint update-fun &optional link-header update-params hide-replies)
@@ -1752,7 +1753,7 @@ ID is that of the toot to view."
(toot (mastodon-http--get-json
(mastodon-http--api (concat "statuses/" id)))))
(if (equal (caar toot) 'error)
- (message "Error: %s" (cdar toot))
+ (user-error "Error: %s" (cdar toot))
(with-mastodon-buffer buffer #'mastodon-mode nil
(mastodon-tl--set-buffer-spec buffer (format "statuses/%s" id)
#'mastodon-tl--update-toot)
@@ -1772,7 +1773,7 @@ are displayed by default. Call this if you subsequently want to
view all branches of a thread."
(interactive)
(if (not (eq (mastodon-tl--get-buffer-type) 'thread))
- (error "You need to be viewing a thread to call this")
+ (user-error "You need to be viewing a thread to call this")
(goto-char (point-min))
(let ((id (mastodon-tl--property 'base-toot-id)))
(mastodon-tl--thread id))))
@@ -1784,7 +1785,7 @@ view all branches of a thread."
(type (mastodon-tl--field 'type (mastodon-tl--property 'toot-json :no-move))))
(if (or (string= type "follow_request")
(string= type "follow")) ; no can thread these
- (error "No thread")
+ (user-error "No thread")
(let* ((endpoint (format "statuses/%s/context" id))
(url (mastodon-http--api endpoint))
(buffer (format "*mastodon-thread-%s*" id))
@@ -1793,7 +1794,7 @@ view all branches of a thread."
nil :silent))
(context (mastodon-http--get-json url nil :silent)))
(if (equal (caar toot) 'error)
- (message "Error: %s" (cdar toot))
+ (user-error "Error: %s" (cdar toot))
(when (member (alist-get 'type toot) '("reblog" "favourite"))
(setq toot (alist-get 'status toot)))
(if (> (+ (length (alist-get 'ancestors context))
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index acedcfe..51e0458 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -376,13 +376,13 @@ TYPE is a symbol, either `favourite' or `boost.'"
;; this boosts/faves the base toot, not the notif status
((and (equal "reblog" toot-type)
(not (mastodon-tl--buffer-type-eq 'notifications)))
- (error "You can't %s boosts" action-string))
+ (user-error "You can't %s boosts" action-string))
((and (equal "favourite" toot-type)
(not (mastodon-tl--buffer-type-eq 'notifications)))
- (error "You can't %s favourites" action-string))
+ (user-error "You can't %s favourites" action-string))
((and (equal "private" visibility)
(equal type 'boost))
- (error "You can't boost private toots"))
+ (user-error "You can't boost private toots"))
(t
(mastodon-toot--action
action
@@ -491,11 +491,11 @@ With FAVOURITE, list favouriters, else list boosters."
(params '(("limit" . "80")))
(json (mastodon-http--get-json url params)))
(if (eq (caar json) 'error)
- (error "%s (Status does not exist or is private)" (alist-get 'error json))
+ (user-error "%s (Status does not exist or is private)" (alist-get 'error json))
(let ((handles (mastodon-tl--map-alist 'acct json))
(type-string (if favourite "Favouriters" "Boosters")))
(if (not handles)
- (error "Looks like this toot has no %s" type-string)
+ (user-error "Looks like this toot has no %s" type-string)
(let ((choice (completing-read
(format "%s (enter to view profile): " type-string)
handles
@@ -1251,7 +1251,7 @@ INSTANCE is JSON."
MAX is the maximum number set by their instance."
(let ((number (read-number (format "Number of options [2-%s]: " max) 2)))
(if (> number max)
- (error "You need to choose a number between 2 and %s" max)
+ (user-error "You need to choose a number between 2 and %s" max)
number)))
(defun mastodon-toot--create-poll ()
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index e348cae..fc2e2d1 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -629,14 +629,14 @@ Prompt for a context, must be a list containting at least one of \"home\",
nil nil (or (current-word) "")))
(contexts
(if (string-empty-p word)
- (error "You must select at least one word for a filter")
+ (user-error "You must select at least one word for a filter")
(completing-read-multiple
"Contexts to filter [TAB for options]: "
'("home" "notifications" "public" "thread")
nil t)))
(contexts-processed
(if (equal nil contexts)
- (error "You must select at least one context for a filter")
+ (user-error "You must select at least one context for a filter")
(mapcar (lambda (x)
(cons "context[]" x))
contexts)))
@@ -656,7 +656,7 @@ Prompt for a context, must be a list containting at least one of \"home\",
(phrase (mastodon-tl--property 'phrase :no-move))
(url (mastodon-http--api (format "filters/%s" filter-id))))
(if (null phrase)
- (error "No filter at point?")
+ (user-error "No filter at point?")
(when (y-or-n-p (format "Delete filter %s? " phrase))
(let ((response (mastodon-http--delete url)))
(mastodon-http--triage
--
cgit v1.2.3
From 9aac053495a08482d04f36c258a4e11d7ec92ea4 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sun, 15 Oct 2023 10:50:38 +0200
Subject: masto views map: use prev/next-toot, not item for n/p
---
lisp/mastodon-views.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index fc2e2d1..7a65b30 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -51,8 +51,9 @@
(autoload 'mastodon-tl--set-face "mastodon-tl")
(autoload 'mastodon-tl--buffer-type-eq "mastodon-tl")
(autoload 'mastodon-tl--profile-buffer-p "mastodon-tl")
+(autoload 'mastodon-tl--goto-next-toot "mastodon-tl")
+(autoload 'mastodon-tl--goto-prev-toot "mastodon-tl")
(autoload 'mastodon-tl--goto-next-item "mastodon-tl")
-(autoload 'mastodon-tl--goto-prev-item "mastodon-tl")
(autoload 'mastodon-tl--goto-first-item "mastodon-tl")
(autoload 'mastodon-tl--do-if-toot "mastodon-tl")
(autoload 'mastodon-tl--set-buffer-spec "mastodon-tl")
@@ -86,8 +87,8 @@
(defvar mastodon-views-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map mastodon-mode-map)
- (define-key map (kbd "n") #'mastodon-tl--goto-next-item)
- (define-key map (kbd "p") #'mastodon-tl--goto-prev-item)
+ (define-key map (kbd "n") #'mastodon-tl--goto-next-toot)
+ (define-key map (kbd "p") #'mastodon-tl--goto-prev-toot)
map)
"Base keymap for minor mastodon views.")
--
cgit v1.2.3
From 574c17c4bdfe43a3081ddcbde4452dd477929c02 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sun, 15 Oct 2023 11:54:28 +0200
Subject: toot-id>item-id, toot-json>item-json, item-type for nav, byline still
needed
---
README.org | 2 +-
lisp/mastodon-inspect.el | 26 ++++----
lisp/mastodon-notifications.el | 16 ++---
lisp/mastodon-profile.el | 34 +++++-----
lisp/mastodon-search.el | 7 ++-
lisp/mastodon-tl.el | 138 ++++++++++++++++++++---------------------
lisp/mastodon-toot.el | 58 ++++++++---------
lisp/mastodon-views.el | 22 ++++---
mastodon.info | 24 +++----
mastodon.texi | 4 +-
test/mastodon-profile-tests.el | 4 +-
test/mastodon-tl-tests.el | 66 ++++++++++----------
test/mastodon-toot-tests.el | 10 +--
13 files changed, 208 insertions(+), 203 deletions(-)
(limited to 'lisp')
diff --git a/README.org b/README.org
index 237935a..680e94b 100644
--- a/README.org
+++ b/README.org
@@ -390,7 +390,7 @@ to your translator function as its text argument. Here's what
"Translate text of toot at point.
Uses `lingva.el'."
(interactive)
- (let* ((toot (mastodon-tl--property 'toot-json)))
+ (let* ((toot (mastodon-tl--property 'item-json)))
(if toot
(lingva-translate nil (mastodon-tl--content toot))
(message "No toot to translate?"))))
diff --git a/lisp/mastodon-inspect.el b/lisp/mastodon-inspect.el
index c332dde..0a278ab 100644
--- a/lisp/mastodon-inspect.el
+++ b/lisp/mastodon-inspect.el
@@ -62,21 +62,21 @@
(interactive)
(mastodon-inspect--dump-json-in-buffer
(concat "*mastodon-inspect-toot-"
- (mastodon-tl--as-string (mastodon-tl--property 'toot-id))
+ (mastodon-tl--as-string (mastodon-tl--property 'item-id))
"*")
- (mastodon-tl--property 'toot-json)))
+ (mastodon-tl--property 'item-json)))
-(defun mastodon-inspect--download-single-toot (toot-id)
- "Download the toot/status represented by TOOT-ID."
+(defun mastodon-inspect--download-single-toot (item-id)
+ "Download the toot/status represented by ITEM-ID."
(mastodon-http--get-json
- (mastodon-http--api (concat "statuses/" toot-id))))
+ (mastodon-http--api (concat "statuses/" item-id))))
-(defun mastodon-inspect--view-single-toot (toot-id)
- "View the toot/status represented by TOOT-ID."
+(defun mastodon-inspect--view-single-toot (item-id)
+ "View the toot/status represented by ITEM-ID."
(interactive "s Toot ID: ")
- (let ((buffer (get-buffer-create (concat "*mastodon-status-" toot-id "*"))))
+ (let ((buffer (get-buffer-create (concat "*mastodon-status-" item-id "*"))))
(with-current-buffer buffer
- (let ((toot (mastodon-inspect--download-single-toot toot-id )))
+ (let ((toot (mastodon-inspect--download-single-toot item-id )))
(mastodon-tl--toot toot)
(goto-char (point-min))
(while (search-forward "\n\n\n | " nil t)
@@ -85,12 +85,12 @@
(switch-to-buffer-other-window buffer)
(mastodon-mode)))
-(defun mastodon-inspect--view-single-toot-source (toot-id)
- "View the ess source of a toot/status represented by TOOT-ID."
+(defun mastodon-inspect--view-single-toot-source (item-id)
+ "View the ess source of a toot/status represented by ITEM-ID."
(interactive "s Toot ID: ")
(mastodon-inspect--dump-json-in-buffer
- (concat "*mastodon-status-raw-" toot-id "*")
- (mastodon-inspect--download-single-toot toot-id)))
+ (concat "*mastodon-status-raw-" item-id "*")
+ (mastodon-inspect--download-single-toot item-id)))
(defvar mastodon-inspect--search-query-accounts-result)
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 5f6d1ba..cce5810 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -50,7 +50,7 @@
(autoload 'mastodon-tl--property "mastodon-tl")
(autoload 'mastodon-tl--reload-timeline-or-profile "mastodon-tl")
(autoload 'mastodon-tl--spoiler "mastodon-tl")
-(autoload 'mastodon-tl--toot-id "mastodon-tl")
+(autoload 'mastodon-tl--item-id "mastodon-tl")
(autoload 'mastodon-tl--update "mastodon-tl")
(autoload 'mastodon-views--view-follow-requests "mastodon-views")
@@ -98,17 +98,17 @@
With no argument, the request is accepted. Argument REJECT means
reject the request. Can be called in notifications view or in
follow-requests view."
- (if (not (mastodon-tl--find-property-range 'toot-json (point)))
+ (if (not (mastodon-tl--find-property-range 'item-json (point)))
(message "No follow request at point?")
- (let* ((toot-json (mastodon-tl--property 'toot-json))
+ (let* ((item-json (mastodon-tl--property 'item-json))
(f-reqs-view-p (string= "follow_requests"
(plist-get mastodon-tl--buffer-spec 'endpoint)))
- (f-req-p (or (string= "follow_request" (alist-get 'type toot-json)) ;notifs
+ (f-req-p (or (string= "follow_request" (alist-get 'type item-json)) ;notifs
f-reqs-view-p)))
(if (not f-req-p)
(message "No follow request at point?")
- (let-alist (or (alist-get 'account toot-json) ;notifs
- toot-json) ;f-reqs
+ (let-alist (or (alist-get 'account item-json) ;notifs
+ item-json) ;f-reqs
(if .id
(let ((response
(mastodon-http--post
@@ -319,9 +319,9 @@ Status notifications are created when you call
(defun mastodon-notifications--clear-current ()
"Dismiss the notification at point."
(interactive)
- (let* ((id (or (mastodon-tl--property 'toot-id)
+ (let* ((id (or (mastodon-tl--property 'item-id)
(mastodon-tl--field 'id
- (mastodon-tl--property 'toot-json))))
+ (mastodon-tl--property 'item-json))))
(response
(mastodon-http--post (mastodon-http--api
(format "notifications/%s/dismiss" id)))))
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 365e352..9850b81 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -74,7 +74,7 @@
(autoload 'mastodon-tl--symbol "mastodon-tl")
(autoload 'mastodon-tl--timeline "mastodon-tl.el")
(autoload 'mastodon-tl--toot "mastodon-tl")
-(autoload 'mastodon-tl--toot-id "mastodon-tl")
+(autoload 'mastodon-tl--item-id "mastodon-tl")
(autoload 'mastodon-toot--count-toot-chars "mastodon-toot")
(autoload 'mastodon-toot--get-max-toot-chars "mastodon-toot")
(autoload 'mastodon-views--add-account-to-list "mastodon-views")
@@ -136,10 +136,10 @@ contains")
:keymap mastodon-profile-update-mode-map
:global nil)
-(defun mastodon-profile--toot-json ()
- "Get the next toot-json."
+(defun mastodon-profile--item-json ()
+ "Get the next item-json."
(interactive)
- (mastodon-tl--property 'toot-json))
+ (mastodon-tl--property 'item-json))
(defun mastodon-profile--make-author-buffer (account &optional no-reblogs)
"Take an ACCOUNT json and insert a user account into a new buffer.
@@ -679,7 +679,7 @@ the format \"2000-01-31T00:00:00.000Z\"."
If toot is a boost, opens the profile of the booster."
(interactive)
(mastodon-profile--make-author-buffer
- (alist-get 'account (mastodon-profile--toot-json))))
+ (alist-get 'account (mastodon-profile--item-json))))
(defun mastodon-profile--image-from-account (account img-type)
"Return a avatar image from ACCOUNT.
@@ -693,21 +693,21 @@ IMG-TYPE is the JSON key from the account data."
(interactive
(list
(if (and (not (mastodon-tl--profile-buffer-p))
- (not (mastodon-tl--property 'toot-json :no-move)))
+ (not (mastodon-tl--property 'item-json :no-move)))
(message "Looks like there's no toot or user at point?")
(let ((user-handles (mastodon-profile--extract-users-handles
- (mastodon-profile--toot-json))))
+ (mastodon-profile--item-json))))
(completing-read "View profile of user [choose or enter any handle]: "
user-handles
nil ; predicate
'confirm)))))
- (if (not (or ; own profile has no need for toot-json test:
+ (if (not (or ; own profile has no need for item-json test:
(equal user-handle (mastodon-auth--get-account-name))
(mastodon-tl--profile-buffer-p)
- (mastodon-tl--property 'toot-json :no-move)))
+ (mastodon-tl--property 'item-json :no-move)))
(message "Looks like there's no toot or user at point?")
(let ((account (mastodon-profile--lookup-account-in-status
- user-handle (mastodon-profile--toot-json))))
+ user-handle (mastodon-profile--item-json))))
(if account
(progn
(message "Loading profile of user %s..." user-handle)
@@ -733,14 +733,14 @@ Used to view a user's followers and those they're following."
(propertize
(mastodon-tl--byline-author `((account . ,toot)) :avatar)
'byline 't
- 'toot-id (alist-get 'id toot)
- 'base-toot-id (mastodon-tl--toot-id toot)
- 'toot-json toot))
+ 'item-id (alist-get 'id toot)
+ 'base-item-id (mastodon-tl--item-id toot)
+ 'item-json toot))
(mastodon-media--inline-images start-pos (point))
(insert "\n"
(propertize
(mastodon-tl--render-text (alist-get 'note toot) nil)
- 'toot-json toot)
+ 'item-json toot)
"\n")))
tootv))))
@@ -805,7 +805,7 @@ These include the author, author of reblogged entries and any user mentioned."
"Remove a user from your followers.
Optionally provide the ID of the account to remove."
(interactive)
- (let* ((account (unless id (mastodon-tl--property 'toot-json :no-move)))
+ (let* ((account (unless id (mastodon-tl--property 'item-json :no-move)))
(id (or id (alist-get 'id account)))
(handle (if account
(alist-get 'acct account)
@@ -823,10 +823,10 @@ Optionally provide the ID of the account to remove."
"Prompt for a user in the item at point and remove from followers."
(interactive)
(let* ((handles (mastodon-profile--extract-users-handles
- (mastodon-profile--toot-json)))
+ (mastodon-profile--item-json)))
(handle (completing-read "Remove from followers: " handles nil))
(account (mastodon-profile--lookup-account-in-status
- handle (mastodon-profile--toot-json)))
+ handle (mastodon-profile--item-json)))
(id (alist-get 'id account)))
(mastodon-profile--remove-user-from-followers id)))
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 9b4bb68..1f39088 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -261,7 +261,8 @@ If NOTE is non-nil, include user's profile note. This is also
(propertize (car user)
'face 'mastodon-display-name-face
'byline t
- 'toot-id id) ; for prev/next nav
+ 'item-type 'user
+ 'item-id id) ; for prev/next nav
" : \n : "
(propertize (concat "@" (cadr user))
'face 'mastodon-handle-face
@@ -275,7 +276,7 @@ If NOTE is non-nil, include user's profile note. This is also
(mastodon-tl--render-text (cadddr user) acct)
"")
"\n")
- 'toot-json acct))) ; for compat w other processing functions
+ 'item-json acct))) ; for compat w other processing functions
(defun mastodon-search--print-tags (tags)
"Print TAGS data as returned from a \"hashtags\" search query."
@@ -292,6 +293,8 @@ If NOTE is non-nil, include user's profile note. This is also
'mouse-face 'highlight
'mastodon-tag (car el)
'mastodon-tab-stop 'hashtag
+ 'item-type 'tag ; for next/prev nav
+ 'byline t ; for next/prev nav
'help-echo (concat "Browse tag #" (car el))
'keymap mastodon-tl--link-keymap)
" : \n\n"))
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index b0c121a..1600b49 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -69,7 +69,7 @@
(autoload 'mastodon-profile--open-statuses-no-reblogs "mastodon-profile")
(autoload 'mastodon-profile--profile-json "mastodon-profile")
(autoload 'mastodon-profile--search-account-by-handle "mastodon-profile")
-(autoload 'mastodon-profile--toot-json "mastodon-profile")
+(autoload 'mastodon-profile--item-json "mastodon-profile")
(autoload 'mastodon-profile--view-author-profile "mastodon-profile")
(autoload 'mastodon-profile-mode "mastodon-profile")
(autoload 'mastodon-search--get-user-info "mastodon-search")
@@ -295,18 +295,19 @@ than `switch-to-buffer'."
(switch-to-buffer ,buffer))
,@body)))
-(defmacro mastodon-tl--do-if-toot (&rest body)
- "Execute BODY if we have a toot or user at point."
+(defmacro mastodon-tl--do-if-item (&rest body)
+ "Execute BODY if we have an item at point."
(declare (debug t))
`(if (and (not (mastodon-tl--profile-buffer-p))
- (not (mastodon-tl--property 'toot-json))) ; includes user listings
- (message "Looks like there's no toot or user at point?")
+ (not (mastodon-tl--property 'item-json))) ; includes users, hashtags
+ (message "Looks like there's no item at point?")
,@body))
(defmacro mastodon-tl--do-if-toot-strict (&rest body)
- "Execute BODY if we have a toot, and only a toot, at point."
+ "Execute BODY if we have a toot object at point.
+Includes boosts, and notifications that display toots."
(declare (debug t))
- `(if (not (mastodon-tl--property 'toot-id :no-move))
+ `(if (not (equal 'toot (mastodon-tl--property 'item-type :no-move)))
(message "Looks like there's no toot at point?")
,@body))
@@ -354,24 +355,21 @@ text, i.e. hidden spoiler text."
(interactive)
(mastodon-tl--next-tab-item :previous))
-(defun mastodon-tl--goto-toot-pos (find-pos refresh &optional pos)
- "Search for toot with FIND-POS.
+(defun mastodon-tl--goto-item-pos (find-pos refresh &optional pos)
+ "Search for item with function FIND-POS.
If search returns nil, execute REFRESH function.
Optionally start from POS."
(let* ((npos (or ; toot/user items have byline:
(funcall find-pos
(or pos (point))
+ ;; 'item-type ; breaks nav to last item in a view?
'byline
- (current-buffer))
- ;; some other things don't, so just tab-stop:
- (funcall find-pos
- (or pos (point))
- 'mastodon-tab-stop
(current-buffer)))))
(if npos
- (if (not (or (get-text-property npos 'toot-id) ; toots, etc.
- (get-text-property npos 'mastodon-tab-stop))) ; generic
- (mastodon-tl--goto-toot-pos find-pos refresh npos)
+ (if (not (or
+ ;; (get-text-property npos 'item-id) ; toots, users, not tags
+ (get-text-property npos 'item-type))) ; generic
+ (mastodon-tl--goto-item-pos find-pos refresh npos)
(goto-char npos)
;; force display of help-echo on moving to a toot byline:
(mastodon-tl--message-help-echo))
@@ -380,13 +378,13 @@ Optionally start from POS."
(defun mastodon-tl--goto-next-toot ()
"Jump to next toot header."
(interactive)
- (mastodon-tl--goto-toot-pos 'next-single-property-change
+ (mastodon-tl--goto-item-pos 'next-single-property-change
'mastodon-tl--more))
(defun mastodon-tl--goto-prev-toot ()
"Jump to last toot header."
(interactive)
- (mastodon-tl--goto-toot-pos 'previous-single-property-change
+ (mastodon-tl--goto-item-pos 'previous-single-property-change
'mastodon-tl--update))
(defun mastodon-tl--goto-first-item ()
@@ -401,13 +399,13 @@ Used on initializing a timeline or thread."
(defun mastodon-tl--goto-next-item ()
"Jump to next item, e.g. filter or follow request."
(interactive)
- (mastodon-tl--goto-toot-pos 'next-single-property-change
+ (mastodon-tl--goto-item-pos 'next-single-property-change
'next-line))
(defun mastodon-tl--goto-prev-item ()
"Jump to previous item, e.g. filter or follow request."
(interactive)
- (mastodon-tl--goto-toot-pos 'previous-single-property-change
+ (mastodon-tl--goto-item-pos 'previous-single-property-change
'previous-line))
@@ -490,7 +488,7 @@ With a double PREFIX arg, limit results to your own instance."
"Call message on `help-echo' property at point.
Do so if type of status at poins is not follow_request/follow."
(let ((type (alist-get 'type
- (mastodon-tl--property 'toot-json :no-move)))
+ (mastodon-tl--property 'item-json :no-move)))
(echo (mastodon-tl--property 'help-echo :no-move)))
(when echo ; not for followers/following in profile
(unless (or (string= type "follow_request")
@@ -970,9 +968,9 @@ content should be hidden."
"Toggle the visibility of the spoiler text in the current toot."
(interactive)
(let* ((toot-range (or (mastodon-tl--find-property-range
- 'toot-json (point))
+ 'item-json (point))
(mastodon-tl--find-property-range
- 'toot-json (point) t)))
+ 'item-json (point) t)))
(spoiler-range (when toot-range
(mastodon-tl--find-property-range
'mastodon-content-warning-body
@@ -1196,7 +1194,7 @@ displayed when the duration is smaller than a minute)."
(defun mastodon-tl--read-poll-option ()
"Read a poll option to vote on a poll."
- (let* ((toot (mastodon-tl--property 'toot-json))
+ (let* ((toot (mastodon-tl--property 'item-json))
(poll (mastodon-tl--field 'poll toot))
(options (mastodon-tl--field 'options poll))
(options-titles (mastodon-tl--map-alist 'title options))
@@ -1221,9 +1219,9 @@ displayed when the duration is smaller than a minute)."
(defun mastodon-tl--poll-vote (option)
"If there is a poll at point, prompt user for OPTION to vote on it."
(interactive (mastodon-tl--read-poll-option))
- (if (null (mastodon-tl--field 'poll (mastodon-tl--property 'toot-json)))
+ (if (null (mastodon-tl--field 'poll (mastodon-tl--property 'item-json)))
(message "No poll here.")
- (let* ((toot (mastodon-tl--property 'toot-json))
+ (let* ((toot (mastodon-tl--property 'item-json))
(poll (mastodon-tl--field 'poll toot))
(poll-id (alist-get 'id poll))
(url (mastodon-http--api (format "polls/%s/votes" poll-id)))
@@ -1304,16 +1302,16 @@ Runs `mastodon-tl--render-text' and fetches poll or media."
(mastodon-tl--get-poll toot))
(mastodon-tl--media toot))))
-(defun mastodon-tl--prev-toot-id ()
+(defun mastodon-tl--prev-item-id ()
"Return the id of the last toot inserted into the buffer."
(let ((prev-pos
(1- (save-excursion
- (previous-single-property-change (point) 'base-toot-id)))))
- (get-text-property prev-pos 'base-toot-id)))
+ (previous-single-property-change (point) 'base-item-id)))))
+ (get-text-property prev-pos 'base-item-id)))
(defun mastodon-tl--after-reply-status (reply-to-id)
"T if REPLY-TO-ID is equal to that of the last toot inserted in the bufer."
- (let ((prev-id (mastodon-tl--prev-toot-id)))
+ (let ((prev-id (mastodon-tl--prev-item-id)))
(string= reply-to-id prev-id)))
(defun mastodon-tl--insert-status (toot body author-byline action-byline
@@ -1328,7 +1326,7 @@ such as boosting favouriting and following to the byline. It also
takes a single function. By default it is
`mastodon-tl--byline-boosted'.
ID is that of the status if it is a notification, which is
-attached as a `toot-id' property if provided. If the
+attached as a `item-id' property if provided. If the
status is a favourite or boost notification, BASE-TOOT is the
JSON of the toot responded to.
DETAILED-P means display more detailed info. For now
@@ -1355,14 +1353,15 @@ THREAD means the status will be displayed in a thread view."
body)
" \n"
(mastodon-tl--byline toot author-byline action-byline detailed-p))
- 'toot-id (or id ; notification's own id
+ 'item-type 'toot
+ 'item-id (or id ; notification's own id
(alist-get 'id toot)) ; toot id
- 'base-toot-id (mastodon-tl--toot-id
+ 'base-item-id (mastodon-tl--item-id
;; if status is a notif, get id from base-toot
- ;; (-tl--toot-id toot) will not work here:
+ ;; (-tl--item-id toot) will not work here:
(or base-toot
toot)) ; else normal toot with reblog check
- 'toot-json toot
+ 'item-json toot
'base-toot base-toot
'cursor-face 'mastodon-cursor-highlight-face)
"\n")
@@ -1373,7 +1372,7 @@ THREAD means the status will be displayed in a thread view."
(defun mastodon-tl--toot-for-stats (&optional toot)
"Return the TOOT on which we want to extract stats.
If no TOOT is given, the one at point is considered."
- (let* ((original-toot (or toot (get-text-property (point) 'toot-json)))
+ (let* ((original-toot (or toot (get-text-property (point) 'item-json)))
(toot (or (alist-get 'status original-toot)
(when (alist-get 'type original-toot)
original-toot)
@@ -1710,16 +1709,16 @@ BACKWARD means move backward (up) the timeline."
(get-text-property (point) prop)))))
(defun mastodon-tl--newest-id ()
- "Return toot-id from the top of the buffer."
+ "Return item-id from the top of the buffer."
(save-excursion
(goto-char (point-min))
- (mastodon-tl--property 'toot-id)))
+ (mastodon-tl--property 'item-id)))
(defun mastodon-tl--oldest-id ()
- "Return toot-id from the bottom of the buffer."
+ "Return item-id from the bottom of the buffer."
(save-excursion
(goto-char (point-max))
- (mastodon-tl--property 'toot-id nil :backward)))
+ (mastodon-tl--property 'item-id nil :backward)))
(defun mastodon-tl--as-string (numeric)
"Convert NUMERIC to string."
@@ -1729,7 +1728,7 @@ BACKWARD means move backward (up) the timeline."
(t (error "Numeric:%s must be either a string or a number"
numeric))))
-(defun mastodon-tl--toot-id (json)
+(defun mastodon-tl--item-id (json)
"Find approproiate toot id in JSON.
If the toot has been boosted use the id found in the
reblog portion of the toot. Otherwise, use the body of
@@ -1775,14 +1774,14 @@ view all branches of a thread."
(if (not (eq (mastodon-tl--get-buffer-type) 'thread))
(user-error "You need to be viewing a thread to call this")
(goto-char (point-min))
- (let ((id (mastodon-tl--property 'base-toot-id)))
+ (let ((id (mastodon-tl--property 'base-item-id)))
(mastodon-tl--thread id))))
(defun mastodon-tl--thread (&optional id)
"Open thread buffer for toot at point or with ID."
(interactive)
- (let* ((id (or id (mastodon-tl--property 'base-toot-id :no-move)))
- (type (mastodon-tl--field 'type (mastodon-tl--property 'toot-json :no-move))))
+ (let* ((id (or id (mastodon-tl--property 'base-item-id :no-move)))
+ (type (mastodon-tl--field 'type (mastodon-tl--property 'item-json :no-move))))
(if (or (string= type "follow_request")
(string= type "follow")) ; no can thread these
(user-error "No thread")
@@ -1839,7 +1838,7 @@ If UNMUTE, unmute it."
(mastodon-tl--buffer-type-eq 'notifications))
(let* ((id
(if (mastodon-tl--buffer-type-eq 'notifications)
- (get-text-property (point) 'base-toot-id)
+ (get-text-property (point) 'base-item-id)
(save-match-data
(string-match "statuses/\\(?2:[[:digit:]]+\\)/context"
endpoint)
@@ -1887,7 +1886,7 @@ Can be called to toggle NOTIFY on users already being followed.
LANGS is an array parameters alist of languages to filer user's posts by."
(interactive
(list (mastodon-tl--user-handles-get "follow")))
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(mastodon-tl--do-user-action-and-response
user-handle "follow" nil notify langs)))
@@ -1895,7 +1894,7 @@ LANGS is an array parameters alist of languages to filer user's posts by."
"Query for USER-HANDLE and enable notifications when they post."
(interactive
(list (mastodon-tl--user-handles-get "enable")))
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(mastodon-tl--follow-user user-handle "true")))
(defun mastodon-tl--disable-notify-user-posts (user-handle)
@@ -1911,7 +1910,7 @@ the instance API."
(interactive
(list (mastodon-tl--user-handles-get "filter by language")))
(let ((langs (mastodon-tl--read-filter-langs)))
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(mastodon-tl--follow-user user-handle nil langs))))
(defun mastodon-tl--read-filter-langs (&optional langs)
@@ -1933,14 +1932,14 @@ LANGS is the accumulated array param alist if we re-run recursively."
"Query for USER-HANDLE from current status and unfollow that user."
(interactive
(list (mastodon-tl--user-handles-get "unfollow")))
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(mastodon-tl--do-user-action-and-response user-handle "unfollow" t)))
(defun mastodon-tl--block-user (user-handle)
"Query for USER-HANDLE from current status and block that user."
(interactive
(list (mastodon-tl--user-handles-get "block")))
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(mastodon-tl--do-user-action-and-response user-handle "block")))
(defun mastodon-tl--unblock-user (user-handle)
@@ -1955,7 +1954,7 @@ LANGS is the accumulated array param alist if we re-run recursively."
"Query for USER-HANDLE from current status and mute that user."
(interactive
(list (mastodon-tl--user-handles-get "mute")))
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(mastodon-tl--do-user-action-and-response user-handle "mute")))
(defun mastodon-tl--unmute-user (user-handle)
@@ -1970,14 +1969,14 @@ LANGS is the accumulated array param alist if we re-run recursively."
"Query for USER-HANDLE from current status and compose a message to that user."
(interactive
(list (mastodon-tl--user-handles-get "message")))
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(mastodon-toot--compose-buffer (concat "@" user-handle))
(setq mastodon-toot--visibility "direct")
(mastodon-toot--update-status-fields)))
(defun mastodon-tl--user-handles-get (action)
"Get the list of user-handles for ACTION from the current toot."
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(let ((user-handles
(cond ((or ; follow suggests / search / foll requests compat:
(mastodon-tl--buffer-type-eq 'follow-suggestions)
@@ -1986,9 +1985,9 @@ LANGS is the accumulated array param alist if we re-run recursively."
;; profile follows/followers but not statuses:
(mastodon-tl--buffer-type-eq 'profile-followers)
(mastodon-tl--buffer-type-eq 'profile-following))
- ;; fetch 'toot-json:
+ ;; fetch 'item-json:
(list (alist-get 'acct
- (mastodon-tl--property 'toot-json :no-move))))
+ (mastodon-tl--property 'item-json :no-move))))
;; profile view, point in profile details, poss no toots
;; needed for e.g. gup.pe groups which show no toots publically:
((and (mastodon-tl--profile-buffer-p)
@@ -1997,7 +1996,7 @@ LANGS is the accumulated array param alist if we re-run recursively."
(mastodon-profile--profile-json))))
(t
(mastodon-profile--extract-users-handles
- (mastodon-profile--toot-json))))))
+ (mastodon-profile--item-json))))))
;; return immediately if only 1 handle:
(if (eq 1 (length user-handles))
(car user-handles)
@@ -2040,7 +2039,7 @@ LANGS is an array parameters alist of languages to filer user's posts by."
user-handle (mastodon-profile--profile-json))
;; muting/blocking, select from handles in current status
(mastodon-profile--lookup-account-in-status
- user-handle (mastodon-profile--toot-json)))))
+ user-handle (mastodon-profile--item-json)))))
(user-id (alist-get 'id account))
(name (if (string-empty-p (alist-get 'display_name account))
(alist-get 'username account)
@@ -2087,7 +2086,7 @@ ARGS is an alist of any parameters to send with the request."
(defun mastodon-tl--get-tags-list ()
"Return the list of tags of the toot at point."
(let* ((toot (or (mastodon-tl--property 'base-toot :no-move) ; fave/boost notifs
- (mastodon-tl--property 'toot-json :no-move)))
+ (mastodon-tl--property 'item-json :no-move)))
(tags (mastodon-tl--field 'tags toot)))
(mapcar (lambda (x)
(alist-get 'name x))
@@ -2173,25 +2172,25 @@ PREFIX is for `mastodon-tl--show-tag-timeline', which see."
ACCOUNT and TOOT are the data to use."
(let* ((account-id (alist-get 'id account))
(comment (read-string "Add comment [optional]: "))
- (toot-id (when (y-or-n-p "Also report status at point? ")
- (mastodon-tl--toot-id toot))) ; base toot if poss
+ (item-id (when (y-or-n-p "Also report status at point? ")
+ (mastodon-tl--item-id toot))) ; base toot if poss
(forward-p (when (y-or-n-p "Forward to remote admin? ") "true"))
(rules (when (y-or-n-p "Cite a rule broken? ")
(mastodon-tl--read-rules-ids)))
(cat (unless rules (if (y-or-n-p "Spam? ") "spam" "other"))))
- (mastodon-tl--report-build-params account-id comment toot-id
+ (mastodon-tl--report-build-params account-id comment item-id
forward-p cat rules)))
(defun mastodon-tl--report-build-params
- (account-id comment toot-id forward-p cat &optional rules)
+ (account-id comment item-id forward-p cat &optional rules)
"Build the parameters alist based on user responses.
-ACCOUNT-ID, COMMENT, TOOT-ID, FORWARD-P, CAT, and RULES are all from
+ACCOUNT-ID, COMMENT, ITEM-ID, FORWARD-P, CAT, and RULES are all from
`mastodon-tl--report-params', which see."
(let ((params `(("account_id" . ,account-id)
,(when comment
`("comment" . ,comment))
- ,(when toot-id
- `("status_ids[]" . ,toot-id))
+ ,(when item-id
+ `("status_ids[]" . ,item-id))
,(when forward-p
`("forward" . ,forward-p))
,(when cat
@@ -2212,11 +2211,11 @@ Optionally report the toot at point, add a comment, cite rules
that have been broken, forward the report to the remove admin,
report the account for spam."
(interactive)
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(when (y-or-n-p "Report author of toot at point?")
(let* ((url (mastodon-http--api "reports"))
(toot (mastodon-tl--toot-or-base
- (mastodon-tl--property 'toot-json :no-move)))
+ (mastodon-tl--property 'item-json :no-move)))
(account (alist-get 'account toot))
(handle (alist-get 'acct account))
(params (mastodon-tl--report-params account toot))
@@ -2599,6 +2598,7 @@ This location is defined by a non-nil value of
(interactive)
(if (or (mastodon-tl--buffer-type-eq 'trending-statuses)
(mastodon-tl--buffer-type-eq 'trending-tags)
+ (mastodon-tl--buffer-type-eq 'follow-suggestions)
(mastodon-tl--search-buffer-p))
(message "update not available in this view.")
;; FIXME: handle update for search and trending buffers
@@ -2606,7 +2606,7 @@ This location is defined by a non-nil value of
(update-function (mastodon-tl--update-function)))
;; update a thread, without calling `mastodon-tl--updated-json':
(if (mastodon-tl--buffer-type-eq 'thread)
- (let ((thread-id (mastodon-tl--property 'toot-id)))
+ (let ((thread-id (mastodon-tl--property 'item-id)))
(funcall update-function thread-id))
;; update other timelines:
(let* ((id (mastodon-tl--newest-id))
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 51e0458..e9b98dd 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -75,7 +75,7 @@
(autoload 'mastodon-tl--as-string "mastodon-tl")
(autoload 'mastodon-tl--buffer-type-eq "mastodon-tl")
(autoload 'mastodon-tl--clean-tabs-and-nl "mastodon-tl")
-(autoload 'mastodon-tl--do-if-toot-strict "mastodon-tl")
+(autoload 'mastodon-tl--do-if-item-strict "mastodon-tl")
(autoload 'mastodon-tl--field "mastodon-tl")
(autoload 'mastodon-tl--find-property-range "mastodon-tl")
(autoload 'mastodon-tl--find-property-range "mastodon-tl")
@@ -86,7 +86,7 @@
(autoload 'mastodon-tl--render-text "mastodon-tl")
(autoload 'mastodon-tl--set-buffer-spec "mastodon-tl")
(autoload 'mastodon-tl--symbol "mastodon-tl")
-(autoload 'mastodon-tl--toot-id "mastodon-tl")
+(autoload 'mastodon-tl--item-id "mastodon-tl")
(autoload 'mastodon-toot "mastodon")
(autoload 'mastodon-views--cancel-scheduled-toot "mastodon-views")
(autoload 'mastodon-views--view-scheduled-toots "mastodon-views")
@@ -203,7 +203,7 @@ Should be at least 5 minutes into the future.")
(defvar-local mastodon-toot--reply-to-id nil
"Buffer-local variable to hold the id of the toot being replied to.")
-(defvar-local mastodon-toot--edit-toot-id nil
+(defvar-local mastodon-toot--edit-item-id nil
"The id of the toot being edited.")
(defvar-local mastodon-toot-previous-window-config nil
@@ -335,7 +335,7 @@ Remove MARKER if REMOVE is non-nil, otherwise add it."
"Take ACTION on toot at point, then execute CALLBACK.
Makes a POST request to the server. Used for favouriting,
boosting, or bookmarking toots."
- (let* ((id (mastodon-tl--property 'base-toot-id))
+ (let* ((id (mastodon-tl--property 'base-item-id))
(url (mastodon-http--api
(concat "statuses/" (mastodon-tl--as-string id) "/" action)))
(response (mastodon-http--post url)))
@@ -344,13 +344,13 @@ boosting, or bookmarking toots."
(defun mastodon-toot--toggle-boost-or-favourite (type)
"Toggle boost or favourite of toot at `point'.
TYPE is a symbol, either `favourite' or `boost.'"
- (mastodon-tl--do-if-toot-strict
+ (mastodon-tl--do-if-item-strict
(let* ((boost-p (equal type 'boost))
- ;; (has-id (mastodon-tl--property 'base-toot-id))
+ ;; (has-id (mastodon-tl--property 'base-item-id))
(byline-region ;(when has-id
(mastodon-tl--find-property-range 'byline (point)))
(id (when byline-region
- (mastodon-tl--as-string (mastodon-tl--property 'base-toot-id))))
+ (mastodon-tl--as-string (mastodon-tl--property 'base-item-id))))
(boosted (when byline-region
(get-text-property (car byline-region) 'boosted-p)))
(faved (when byline-region
@@ -361,16 +361,16 @@ TYPE is a symbol, either `favourite' or `boost.'"
(msg (if boosted "unboosted" "boosted"))
(action-string (if boost-p "boost" "favourite"))
(remove (if boost-p (when boosted t) (when faved t)))
- (toot-json (mastodon-tl--property 'toot-json))
- (toot-type (alist-get 'type toot-json))
- (visibility (mastodon-tl--field 'visibility toot-json)))
+ (item-json (mastodon-tl--property 'item-json))
+ (toot-type (alist-get 'type item-json))
+ (visibility (mastodon-tl--field 'visibility item-json)))
(if byline-region
(if (and (or (equal visibility "direct")
(equal visibility "private"))
boost-p)
(message "You cant boost posts with visibility: %s" visibility)
(cond ;; actually there's nothing wrong with faving/boosting own toots!
- ;;((mastodon-toot--own-toot-p (mastodon-tl--property 'toot-json))
+ ;;((mastodon-toot--own-toot-p (mastodon-tl--property 'item-json))
;;(error "You can't %s your own toots" action-string))
;; & nothing wrong with faving/boosting own toots from notifs:
;; this boosts/faves the base toot, not the notif status
@@ -443,8 +443,8 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement."
(defun mastodon-toot--toggle-bookmark ()
"Bookmark or unbookmark toot at point."
(interactive)
- (mastodon-tl--do-if-toot-strict
- (let* ((id (mastodon-tl--property 'base-toot-id))
+ (mastodon-tl--do-if-item-strict
+ (let* ((id (mastodon-tl--property 'base-item-id))
(bookmarked-p (mastodon-tl--property 'bookmarked-p))
(prompt (if bookmarked-p
(format "Toot already bookmarked. Remove? ")
@@ -484,8 +484,8 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement."
(defun mastodon-toot--list-toot-boosters-or-favers (&optional favourite)
"List the favouriters or boosters of toot at point.
With FAVOURITE, list favouriters, else list boosters."
- (mastodon-tl--do-if-toot-strict
- (let* ((base-toot (mastodon-tl--property 'base-toot-id))
+ (mastodon-tl--do-if-item-strict
+ (let* ((base-toot (mastodon-tl--property 'base-item-id))
(endpoint (if favourite "favourited_by" "reblogged_by"))
(url (mastodon-http--api (format "statuses/%s/%s" base-toot endpoint)))
(params '(("limit" . "80")))
@@ -515,7 +515,7 @@ base toot."
(defun mastodon-toot--toot-url ()
"Return the URL of the base toot at point."
(let* ((toot (or (mastodon-tl--property 'base-toot)
- (mastodon-tl--property 'toot-json))))
+ (mastodon-tl--property 'item-json))))
(if (mastodon-tl--field 'reblog toot)
(alist-get 'url (alist-get 'reblog toot))
(alist-get 'url toot))))
@@ -526,7 +526,7 @@ If the toot is a fave/boost notification, copy the text of the
base toot."
(interactive)
(let* ((toot (or (mastodon-tl--property 'base-toot)
- (mastodon-tl--property 'toot-json))))
+ (mastodon-tl--property 'item-json))))
(kill-new (mastodon-tl--content toot))
(message "Toot content copied to the clipboard.")))
@@ -537,7 +537,7 @@ Uses `lingva.el'."
(if (not (require 'lingva nil :no-error))
(message "Looks like you need to install lingva.el first.")
(if mastodon-tl--buffer-spec
- (if-let ((toot (mastodon-tl--property 'toot-json)))
+ (if-let ((toot (mastodon-tl--property 'item-json)))
(lingva-translate nil
(mastodon-tl--content toot)
(when mastodon-tl--enable-proportional-fonts
@@ -555,7 +555,7 @@ Uses `lingva.el'."
"Pin or unpin user's toot at point."
(interactive)
(let* ((toot (or (mastodon-tl--property 'base-toot) ;fave/boost notifs
- (mastodon-tl--property 'toot-json)))
+ (mastodon-tl--property 'item-json)))
(pinnable-p (mastodon-toot--own-toot-p toot))
(pinned-p (equal (alist-get 'pinned toot) t))
(action (if pinned-p "unpin" "pin"))
@@ -584,8 +584,8 @@ Uses `lingva.el'."
NO-REDRAFT means delete toot only."
(interactive)
(let* ((toot (or (mastodon-tl--property 'base-toot) ;fave/boost notifs
- (mastodon-tl--property 'toot-json)))
- (id (mastodon-tl--as-string (mastodon-tl--toot-id toot)))
+ (mastodon-tl--property 'item-json)))
+ (id (mastodon-tl--as-string (mastodon-tl--item-id toot)))
(url (mastodon-http--api (format "statuses/%s" id)))
(toot-cw (alist-get 'spoiler_text toot))
(toot-visibility (alist-get 'visibility toot))
@@ -806,13 +806,13 @@ to `emojify-user-emojis', and the emoji data is updated."
"POST contents of new-toot buffer to Mastodon instance and kill buffer.
If media items have been attached and uploaded with
`mastodon-toot--attach-media', they are attached to the toot.
-If `mastodon-toot--edit-toot-id' is non-nil, PUT contents to
+If `mastodon-toot--edit-item-id' is non-nil, PUT contents to
instance to edit a toot."
(interactive)
(let* ((toot (mastodon-toot--remove-docs))
(scheduled mastodon-toot--scheduled-for)
(scheduled-id mastodon-toot--scheduled-id)
- (edit-id mastodon-toot--edit-toot-id)
+ (edit-id mastodon-toot--edit-item-id)
(endpoint (if edit-id ; we are sending an edit:
(mastodon-http--api (format "statuses/%s" edit-id))
(mastodon-http--api "statuses")))
@@ -879,10 +879,10 @@ instance to edit a toot."
"Edit the user's toot at point."
(interactive)
(let ((toot (or (mastodon-tl--property 'base-toot) ; fave/boost notifs
- (mastodon-tl--property 'toot-json))))
+ (mastodon-tl--property 'item-json))))
(if (not (mastodon-toot--own-toot-p toot))
(message "You can only edit your own toots.")
- (let* ((id (mastodon-tl--as-string (mastodon-tl--toot-id toot)))
+ (let* ((id (mastodon-tl--as-string (mastodon-tl--item-id toot)))
(source (mastodon-toot--get-toot-source id))
(content (alist-get 'text source))
(source-cw (alist-get 'spoiler_text source))
@@ -896,7 +896,7 @@ instance to edit a toot."
(mastodon-toot--set-toot-properties reply-id toot-visibility
source-cw toot-language)
(mastodon-toot--update-status-fields)
- (setq mastodon-toot--edit-toot-id id))))))
+ (setq mastodon-toot--edit-item-id id))))))
(defun mastodon-toot--get-toot-source (id)
"Fetch the source JSON of toot with ID."
@@ -911,7 +911,7 @@ instance to edit a toot."
(defun mastodon-toot--view-toot-edits ()
"View editing history of the toot at point in a popup buffer."
(interactive)
- (let ((id (mastodon-tl--property 'base-toot-id))
+ (let ((id (mastodon-tl--property 'base-item-id))
(history (mastodon-tl--property 'edit-history))
(buf "*mastodon-toot-edits*"))
(with-mastodon-buffer buf #'special-mode :other-window
@@ -1070,8 +1070,8 @@ If TAGS, we search for tags, else we search for handles."
Customize `mastodon-toot-display-orig-in-reply-buffer' to display
text of the toot being replied to in the compose buffer."
(interactive)
- (mastodon-tl--do-if-toot-strict
- (let* ((toot (mastodon-tl--property 'toot-json))
+ (mastodon-tl--do-if-item-strict
+ (let* ((toot (mastodon-tl--property 'item-json))
;; no-move arg for base toot: don't try next toot
(base-toot (mastodon-tl--property 'base-toot :no-move)) ; for new notifs handling
(id (mastodon-tl--as-string (mastodon-tl--field 'id (or base-toot toot))))
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 7a65b30..8571e15 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -55,7 +55,7 @@
(autoload 'mastodon-tl--goto-prev-toot "mastodon-tl")
(autoload 'mastodon-tl--goto-next-item "mastodon-tl")
(autoload 'mastodon-tl--goto-first-item "mastodon-tl")
-(autoload 'mastodon-tl--do-if-toot "mastodon-tl")
+(autoload 'mastodon-tl--do-if-item "mastodon-tl")
(autoload 'mastodon-tl--set-buffer-spec "mastodon-tl")
(autoload 'mastodon-tl--render-text "mastodon-tl")
(autoload 'mastodon-notifications--follow-request-accept "mastodon-notifications")
@@ -179,7 +179,8 @@ provides the JSON data."
(format "Looks like you have no %s for now." view-name)
'face 'font-lock-comment-face
'byline t
- 'toot-id "0")) ; so point can move here when no item
+ 'item-type 'no-item ; for nav
+ 'item-id "0")) ; so point can move here when no item
(funcall insert-fun data)
(goto-char (point-min)))
;; (when data
@@ -226,7 +227,8 @@ provides the JSON data."
(insert
(propertize list-name
'byline t ; so we nav here
- 'toot-id "0" ; so we nav here
+ 'item-id "0" ; so we nav here
+ 'item-type 'user
'help-echo "RET: view list timeline, d: delete this list, \
a: add account to this list, r: remove account from this list"
'list t
@@ -402,7 +404,7 @@ If ACCOUNT-ID and HANDLE are provided use them rather than prompting."
(defun mastodon-views--add-toot-account-at-point-to-list ()
"Prompt for a list, and add the account of the toot at point to it."
(interactive)
- (let* ((toot (mastodon-tl--property 'toot-json))
+ (let* ((toot (mastodon-tl--property 'item-json))
(account (mastodon-tl--field 'account toot))
(account-id (mastodon-tl--field 'id account))
(handle (mastodon-tl--field 'acct account)))
@@ -509,7 +511,7 @@ JSON is the data returned by the server."
" | "
(mastodon-toot--iso-to-human .scheduled_at))
'byline t ; so we nav here
- 'toot-id "0" ; so we nav here
+ 'item-id "0" ; so we nav here
'face 'font-lock-comment-face
'keymap mastodon-views--scheduled-map
'scheduled-json toot
@@ -614,7 +616,7 @@ JSON is the filters data."
(mapconcat #'identity contexts ", "))))
(insert
(propertize filter-string
- 'toot-id id ;for goto-next-filter compat
+ 'item-id id ;for goto-next-filter compat
'phrase phrase
'byline t) ;for goto-next-filter compat
"\n\n")))
@@ -653,7 +655,7 @@ Prompt for a context, must be a list containting at least one of \"home\",
(defun mastodon-views--delete-filter ()
"Delete filter at point."
(interactive)
- (let* ((filter-id (mastodon-tl--property 'toot-id :no-move))
+ (let* ((filter-id (mastodon-tl--property 'item-id :no-move))
(phrase (mastodon-tl--property 'phrase :no-move))
(url (mastodon-http--api (format "filters/%s" filter-id))))
(if (null phrase)
@@ -745,14 +747,14 @@ MISSKEY means the instance is a Misskey or derived server."
(let ((response (mastodon-http--get-json
(mastodon-http--api "instance") nil nil :vector)))
(mastodon-views--instance-response-fun response brief instance))
- (mastodon-tl--do-if-toot
+ (mastodon-tl--do-if-item
(let* ((toot (if (mastodon-tl--profile-buffer-p)
;; we may be on profile description itself:
(or (mastodon-tl--property 'profile-json)
;; or on profile account listings, or just toots:
- (mastodon-tl--property 'toot-json))
+ (mastodon-tl--property 'item-json))
;; normal timeline/account listing:
- (mastodon-tl--property 'toot-json)))
+ (mastodon-tl--property 'item-json)))
(reblog (alist-get 'reblog toot))
(account (or (alist-get 'account reblog)
(alist-get 'account toot)
diff --git a/mastodon.info b/mastodon.info
index 7b77261..47c9b9a 100644
--- a/mastodon.info
+++ b/mastodon.info
@@ -1,4 +1,4 @@
-This is mastodon.info, produced by makeinfo version 6.7 from
+This is mastodon.info, produced by makeinfo version 6.8 from
mastodon.texi.
INFO-DIR-SECTION Emacs
@@ -537,7 +537,7 @@ looks like:
"Translate text of toot at point.
Uses `lingva.el'."
(interactive)
- (let* ((toot (mastodon-tl--property 'toot-json)))
+ (let* ((toot (mastodon-tl--property 'item-json)))
(if toot
(lingva-translate nil (mastodon-tl--content toot))
(message "No toot to translate?"))))
@@ -585,10 +585,10 @@ Mastodon API.
• Gotosocial (gotosocial.org (https://gotosocial.org/))
It does not support the non-Mastodon API servers Misskey (misskey.io
-(https://misskey.io/)) and Firefish (joinfirefish.org
-(https://joinfirefish.org/), formerly Calkey), but it should fully
-support displaying and interacting with posts and users on those
-platforms.
+(https://misskey.io/)), Firefish (joinfirefish.org
+(https://joinfirefish.org/), formerly Calkey) and Friendica, but it
+should fully support displaying and interacting with posts and users on
+those platforms.
If you attempt to use ‘mastodon.el’ with a server and run into
problems, feel free to open an issue.
@@ -714,12 +714,12 @@ Node: Translating toots18911
Node: Bookmarks and mastodonel20093
Node: Dependencies20565
Node: Network compatibility21175
-Node: Contributing22046
-Node: Bug reports22335
-Node: Fixes and features23241
-Node: Coding style23724
-Node: Supporting mastodonel24348
-Node: Contributors24915
+Node: Contributing22057
+Node: Bug reports22346
+Node: Fixes and features23252
+Node: Coding style23735
+Node: Supporting mastodonel24359
+Node: Contributors24926
End Tag Table
diff --git a/mastodon.texi b/mastodon.texi
index c1b48b3..872fb81 100644
--- a/mastodon.texi
+++ b/mastodon.texi
@@ -658,7 +658,7 @@ to your translator function as its text argument. Here's what
"Translate text of toot at point.
Uses `lingva.el'."
(interactive)
- (let* ((toot (mastodon-tl--property 'toot-json)))
+ (let* ((toot (mastodon-tl--property 'item-json)))
(if toot
(lingva-translate nil (mastodon-tl--content toot))
(message "No toot to translate?"))))
@@ -707,7 +707,7 @@ Akkoma (@uref{https://akkoma.social/, akkoma.social})
Gotosocial (@uref{https://gotosocial.org/, gotosocial.org})
@end itemize
-It does not support the non-Mastodon API servers Misskey (@uref{https://misskey.io/, misskey.io}) and Firefish (@uref{https://joinfirefish.org/, joinfirefish.org}, formerly Calkey), but it should fully support displaying and interacting with posts and users on those platforms.
+It does not support the non-Mastodon API servers Misskey (@uref{https://misskey.io/, misskey.io}), Firefish (@uref{https://joinfirefish.org/, joinfirefish.org}, formerly Calkey) and Friendica, but it should fully support displaying and interacting with posts and users on those platforms.
If you attempt to use @samp{mastodon.el} with a server and run into problems, feel
free to open an issue.
diff --git a/test/mastodon-profile-tests.el b/test/mastodon-profile-tests.el
index 1936b99..d187e2d 100644
--- a/test/mastodon-profile-tests.el
+++ b/test/mastodon-profile-tests.el
@@ -158,11 +158,11 @@ When formatting Gargon's state we want to see
t))
(should
(equal
- (get-text-property 4 'toot-id)
+ (get-text-property 4 'item-id)
(alist-get 'id gargron-profile-json)))
(should
(equal
- (get-text-property 4 'toot-json)
+ (get-text-property 4 'item-json)
gargron-profile-json)))))
(ert-deftest mastodon-profile--search-account-by-handle--removes-at ()
diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el
index 899960e..be72f66 100644
--- a/test/mastodon-tl-tests.el
+++ b/test/mastodon-tl-tests.el
@@ -168,16 +168,16 @@ Strict-Transport-Security: max-age=31536000
(let ((input "foobar
"))
(should (string= (mastodon-tl--remove-html input) "foobar\n\n"))))
-(ert-deftest mastodon-tl--toot-id-boosted ()
+(ert-deftest mastodon-tl--item-id-boosted ()
"If a toot is boostedm, return the reblog id."
(should (string= (mastodon-tl--as-string
- (mastodon-tl--toot-id mastodon-tl-test-base-boosted-toot))
+ (mastodon-tl--item-id mastodon-tl-test-base-boosted-toot))
"4543919")))
-(ert-deftest mastodon-tl--toot-id ()
+(ert-deftest mastodon-tl--item-id ()
"If a toot is boostedm, return the reblog id."
(should (string= (mastodon-tl--as-string
- (mastodon-tl--toot-id mastodon-tl-test-base-toot))
+ (mastodon-tl--item-id mastodon-tl-test-base-toot))
"61208")))
(ert-deftest mastodon-tl--as-string-1 ()
@@ -926,19 +926,19 @@ constant."
(insert "some text before\n")
(setq toot-start (point))
(with-mock
- (mock (mastodon-profile--get-preferences-pref
- 'reading:expand:spoilers)
- => :json-false)
- (stub create-image => '(image "fake data"))
- (stub shr-render-region => nil) ;; Travis's Emacs doesn't have libxml
- (insert
- (mastodon-tl--spoiler normal-toot-with-spoiler)))
+ (mock (mastodon-profile--get-preferences-pref
+ 'reading:expand:spoilers)
+ => :json-false)
+ (stub create-image => '(image "fake data"))
+ (stub shr-render-region => nil) ;; Travis's Emacs doesn't have libxml
+ (insert
+ (mastodon-tl--spoiler normal-toot-with-spoiler)))
(setq toot-end (point))
(insert "\nsome more text.")
(add-text-properties
toot-start toot-end
- (list 'toot-json normal-toot-with-spoiler
- 'toot-id (cdr (assoc 'id normal-toot-with-spoiler))))
+ (list 'item-json normal-toot-with-spoiler
+ 'item-id (cdr (assoc 'id normal-toot-with-spoiler))))
(goto-char toot-start)
;; (should (eq t (looking-at "This is the spoiler warning text")))
@@ -1147,28 +1147,28 @@ correct value for following, as well as notifications enabled or disabled."
(let* ((toot mastodon-tl-test-base-toot)
(account (alist-get 'account toot)))
(with-mock
- ;; no longer needed after our refactor
- ;; (mock (mastodon-http--api "reports") => "https://instance.url/api/v1/reports")
- ;; (mock (mastodon-tl--toot-or-base
- ;; (mastodon-tl--property 'toot-json :no-move))
- ;; => mastodon-tl-test-base-toot)
- (mock (read-string "Add comment [optional]: ") => "Dummy complaint")
- (stub y-or-n-p => nil) ; no to all
+ ;; no longer needed after our refactor
+ ;; (mock (mastodon-http--api "reports") => "https://instance.url/api/v1/reports")
+ ;; (mock (mastodon-tl--toot-or-base
+ ;; (mastodon-tl--property 'item-json :no-move))
+ ;; => mastodon-tl-test-base-toot)
+ (mock (read-string "Add comment [optional]: ") => "Dummy complaint")
+ (stub y-or-n-p => nil) ; no to all
+ (should (equal (mastodon-tl--report-params account toot)
+ '(("account_id" . 42)
+ ("comment" . "Dummy complaint")
+ ("category" . "other"))))
+ (with-mock
+ (stub y-or-n-p => t) ; yes to all
+ (mock (mastodon-tl--read-rules-ids) => '(1 2 3))
(should (equal (mastodon-tl--report-params account toot)
- '(("account_id" . 42)
+ '(("rule_ids[]" . 3)
+ ("rule_ids[]" . 2)
+ ("rule_ids[]" . 1)
+ ("account_id" . 42)
("comment" . "Dummy complaint")
- ("category" . "other"))))
- (with-mock
- (stub y-or-n-p => t) ; yes to all
- (mock (mastodon-tl--read-rules-ids) => '(1 2 3))
- (should (equal (mastodon-tl--report-params account toot)
- '(("rule_ids[]" . 3)
- ("rule_ids[]" . 2)
- ("rule_ids[]" . 1)
- ("account_id" . 42)
- ("comment" . "Dummy complaint")
- ("status_ids[]" . 61208)
- ("forward" . "true")))))))))
+ ("status_ids[]" . 61208)
+ ("forward" . "true")))))))))
(ert-deftest mastodon-tl--report-build-params ()
""
diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el
index 69333c0..5efe2e1 100644
--- a/test/mastodon-toot-tests.el
+++ b/test/mastodon-toot-tests.el
@@ -40,7 +40,7 @@ Transfer-Encoding: chunked")
(defconst mastodon-toot--mock-toot
(propertize "here is a mock toot text."
- 'toot-json mastodon-toot-test-base-toot))
+ 'item-json mastodon-toot-test-base-toot))
(defconst mastodon-toot--multi-mention
'((mentions .
@@ -143,7 +143,7 @@ mention string."
(with-mock
(mock (mastodon-auth--user-acct) => "joebogus")
;; (mock (mastodon-toot--own-toot-p toot) => nil)
- (mock (mastodon-tl--property 'toot-json) => mastodon-toot-test-base-toot)
+ (mock (mastodon-tl--property 'item-json) => mastodon-toot-test-base-toot)
(mock (mastodon-tl--property 'base-toot) => toot)
(should (equal (mastodon-toot--delete-toot)
"You can only delete (and redraft) your own toots.")))))
@@ -155,7 +155,7 @@ mention string."
(let ((delete-response (current-buffer))
(toot mastodon-toot-test-base-toot))
(with-mock
- (mock (mastodon-tl--property 'toot-json) => toot)
+ (mock (mastodon-tl--property 'item-json) => toot)
(mock (mastodon-tl--property 'base-toot) => toot)
;; (mock (mastodon-toot--own-toot-p toot) => t)
(mock (mastodon-auth--user-acct) => "acct42@example.space")
@@ -175,7 +175,7 @@ mention string."
(toot mastodon-toot-test-base-toot)
(id 61208))
(with-mock
- (mock (mastodon-tl--property 'base-toot-id) => id)
+ (mock (mastodon-tl--property 'base-item-id) => id)
(mock (mastodon-http--api "statuses/61208/pin")
=> "https://example.space/statuses/61208/pin")
(mock (mastodon-http--post "https://example.space/statuses/61208/pin")
@@ -190,7 +190,7 @@ mention string."
(let ((pin-response (current-buffer))
(toot mastodon-toot-test-base-toot))
(with-mock
- (mock (mastodon-tl--property 'toot-json) => toot)
+ (mock (mastodon-tl--property 'item-json) => toot)
(mock (mastodon-tl--property 'base-toot) => toot)
(mock (mastodon-auth--user-acct) => "joebogus@example.space")
(should (equal (mastodon-toot--pin-toot-toggle)
--
cgit v1.2.3
From d59b8d0f8bae9c7ab8490cb6b1683d4c9beafd0d Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sun, 15 Oct 2023 12:12:54 +0200
Subject: next-/prev-toot>next-/prev-item, cond-case around pos update call
---
lisp/mastodon-discover.el | 4 ++--
lisp/mastodon-tl.el | 46 +++++++++++++++++++++-------------------------
lisp/mastodon-toot.el | 4 ++--
lisp/mastodon-views.el | 12 ++++++------
lisp/mastodon.el | 8 ++++----
mastodon-index.org | 4 ++--
6 files changed, 37 insertions(+), 41 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-discover.el b/lisp/mastodon-discover.el
index b3d8537..da25196 100644
--- a/lisp/mastodon-discover.el
+++ b/lisp/mastodon-discover.el
@@ -55,8 +55,8 @@
("c" "Toggle hidden text (CW)" mastodon-tl--toggle-spoiler-text-in-toot)
("k" "Bookmark toot" mastodon-toot--toggle-bookmark)
("v" "Vote on poll" mastodon-tl--poll-vote)
- ("n" "Next" mastodon-tl--goto-next-toot)
- ("p" "Prev" mastodon-tl--goto-prev-toot)
+ ("n" "Next" mastodon-tl--goto-next-item)
+ ("p" "Prev" mastodon-tl--goto-prev-item)
("TAB" "Next link item" mastodon-tl--next-tab-item)
("S-TAB" "Prev link item" mastodon-tl--previous-tab-item)
;; NB: (when (require 'mpv etc. calls don't work here
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 1600b49..ac00079 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -274,7 +274,7 @@ types of mastodon links and not just shr.el-generated ones.")
(define-key map (kbd "RET") #'mastodon-profile--get-toot-author)
map))
"The keymap to be set for the author byline.
-It is active where point is placed by `mastodon-tl--goto-next-toot.'")
+It is active where point is placed by `mastodon-tl--goto-next-item.'")
;;; MACROS
@@ -373,16 +373,22 @@ Optionally start from POS."
(goto-char npos)
;; force display of help-echo on moving to a toot byline:
(mastodon-tl--message-help-echo))
- (funcall refresh))))
+ ;; FIXME: this doesn't really work, as the funcall doesn't return if we
+ ;; run into an endless refresh loop
+ (condition-case nil
+ (funcall refresh)
+ (error "No more items")))))
-(defun mastodon-tl--goto-next-toot ()
- "Jump to next toot header."
+(defun mastodon-tl--goto-next-item ()
+ "Jump to next item.
+Load more items it no next item."
(interactive)
(mastodon-tl--goto-item-pos 'next-single-property-change
'mastodon-tl--more))
-(defun mastodon-tl--goto-prev-toot ()
- "Jump to last toot header."
+(defun mastodon-tl--goto-prev-item ()
+ "Jump to previous item.
+Update if no previous items"
(interactive)
(mastodon-tl--goto-item-pos 'previous-single-property-change
'mastodon-tl--update))
@@ -390,23 +396,13 @@ Optionally start from POS."
(defun mastodon-tl--goto-first-item ()
"Jump to first toot or item in buffer.
Used on initializing a timeline or thread."
- ;; goto-next-toot assumes we already have toots, and is therefore
+ ;; goto-next-item assumes we already have items, and is therefore
;; incompatible with any view where it is possible to have no items.
;; when that is the case the call to goto-toot-pos loops infinitely
(goto-char (point-min))
- (mastodon-tl--goto-next-item))
-
-(defun mastodon-tl--goto-next-item ()
- "Jump to next item, e.g. filter or follow request."
- (interactive)
(mastodon-tl--goto-item-pos 'next-single-property-change
'next-line))
-
-(defun mastodon-tl--goto-prev-item ()
- "Jump to previous item, e.g. filter or follow request."
- (interactive)
- (mastodon-tl--goto-item-pos 'previous-single-property-change
- 'previous-line))
+;; (mastodon-tl--goto-next-item))
;;; TIMELINES
@@ -541,7 +537,7 @@ With arg AVATAR, include the account's avatar image."
Displays a toot's media types and optionally the binding to play
moving image media from the byline.
Used when point is at the start of a byline, i.e. where
-`mastodon-tl--goto-next-toot' leaves point."
+`mastodon-tl--goto-next-item' leaves point."
(let* ((toot-to-count
(or ; simply praying this order works
(alist-get 'status toot) ; notifications timeline
@@ -634,7 +630,7 @@ this just means displaying toot client."
(concat
;; Boosted/favourited markers are not technically part of the byline, so
;; we don't propertize them with 'byline t', as per the rest. This
- ;; ensures that `mastodon-tl--goto-next-toot' puts point on
+ ;; ensures that `mastodon-tl--goto-next-item' puts point on
;; author-byline, not before the (F) or (B) marker. Not propertizing like
;; this makes the behaviour of these markers consistent whether they are
;; displayed for an already boosted/favourited toot or as the result of
@@ -649,7 +645,7 @@ this just means displaying toot client."
(mastodon-tl--format-faved-or-boosted-byline
(mastodon-tl--symbol 'bookmark))))
;; we remove avatars from the byline also, so that they also do not mess
- ;; with `mastodon-tl--goto-next-toot':
+ ;; with `mastodon-tl--goto-next-item':
(when (and mastodon-tl--show-avatars
mastodon-tl--display-media-p
(if (version< emacs-version "27.1")
@@ -1704,8 +1700,8 @@ BACKWARD means move backward (up) the timeline."
(or (get-text-property (point) prop)
(save-excursion
(if backward
- (mastodon-tl--goto-prev-toot)
- (mastodon-tl--goto-next-toot))
+ (mastodon-tl--goto-prev-item)
+ (mastodon-tl--goto-next-item))
(get-text-property (point) prop)))))
(defun mastodon-tl--newest-id ()
@@ -1813,7 +1809,7 @@ view all branches of a thread."
:thread)
;; put point at the toot:
(goto-char (marker-position marker))
- (mastodon-tl--goto-next-toot)))
+ (mastodon-tl--goto-next-item)))
;; else just print the lone toot:
(mastodon-tl--single-toot id)))))))
@@ -2416,7 +2412,7 @@ HEADERS is the http headers returned in the response, if any."
(if (eq (mastodon-tl--get-buffer-type) 'thread)
;; if thread view, call --thread with parent ID
(progn (goto-char (point-min))
- (mastodon-tl--goto-next-toot)
+ (mastodon-tl--goto-next-item)
(funcall (mastodon-tl--update-function))
(goto-char point-before)
(message "Loaded full thread."))
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index e9b98dd..426a371 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -79,7 +79,7 @@
(autoload 'mastodon-tl--field "mastodon-tl")
(autoload 'mastodon-tl--find-property-range "mastodon-tl")
(autoload 'mastodon-tl--find-property-range "mastodon-tl")
-(autoload 'mastodon-tl--goto-next-toot "mastodon-tl")
+(autoload 'mastodon-tl--goto-next-item "mastodon-tl")
(autoload 'mastodon-tl--map-alist "mastodon-tl")
(autoload 'mastodon-tl--property "mastodon-tl")
(autoload 'mastodon-tl--reload-timeline-or-profile "mastodon-tl")
@@ -329,7 +329,7 @@ Remove MARKER if REMOVE is non-nil, otherwise add it."
;; we don't move to the following toot:
(beginning-of-line)
(forward-line -1)
- (mastodon-tl--goto-next-toot)))))
+ (mastodon-tl--goto-next-item)))))
(defun mastodon-toot--action (action callback)
"Take ACTION on toot at point, then execute CALLBACK.
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 8571e15..24a9de0 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -51,8 +51,8 @@
(autoload 'mastodon-tl--set-face "mastodon-tl")
(autoload 'mastodon-tl--buffer-type-eq "mastodon-tl")
(autoload 'mastodon-tl--profile-buffer-p "mastodon-tl")
-(autoload 'mastodon-tl--goto-next-toot "mastodon-tl")
-(autoload 'mastodon-tl--goto-prev-toot "mastodon-tl")
+(autoload 'mastodon-tl--goto-next-item "mastodon-tl")
+(autoload 'mastodon-tl--goto-prev-item "mastodon-tl")
(autoload 'mastodon-tl--goto-next-item "mastodon-tl")
(autoload 'mastodon-tl--goto-first-item "mastodon-tl")
(autoload 'mastodon-tl--do-if-item "mastodon-tl")
@@ -87,8 +87,8 @@
(defvar mastodon-views-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map mastodon-mode-map)
- (define-key map (kbd "n") #'mastodon-tl--goto-next-toot)
- (define-key map (kbd "p") #'mastodon-tl--goto-prev-toot)
+ (define-key map (kbd "n") #'mastodon-tl--goto-next-item)
+ (define-key map (kbd "p") #'mastodon-tl--goto-prev-item)
map)
"Base keymap for minor mastodon views.")
@@ -97,7 +97,7 @@
(set-keymap-parent map mastodon-views-map)
(define-key map (kbd "d") #'mastodon-views--delete-filter)
(define-key map (kbd "c") #'mastodon-views--create-filter)
- (define-key map (kbd "TAB") #'mastodon-tl--goto-next-item)
+ (define-key map (kbd "TAB") #'mastodon-tl--next-tab-item)
(define-key map (kbd "g") #'mastodon-views--view-filters)
map)
"Keymap for viewing filters.")
@@ -185,7 +185,7 @@ provides the JSON data."
(goto-char (point-min)))
;; (when data
;; FIXME: this seems to trigger a new request, but ideally would run.
- ;; (mastodon-tl--goto-next-toot))
+ ;; (mastodon-tl--goto-next-item))
)
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 11be674..10c2745 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -72,8 +72,8 @@
(autoload 'mastodon-tl--get-home-timeline "mastodon-tl")
(autoload 'mastodon-tl--get-local-timeline "mastodon-tl")
(autoload 'mastodon-tl--get-tag-timeline "mastodon-tl")
-(autoload 'mastodon-tl--goto-next-toot "mastodon-tl")
-(autoload 'mastodon-tl--goto-prev-toot "mastodon-tl")
+(autoload 'mastodon-tl--goto-next-item "mastodon-tl")
+(autoload 'mastodon-tl--goto-prev-item "mastodon-tl")
(autoload 'mastodon-tl--init-sync "mastodon-tl")
(autoload 'mastodon-tl--list-followed-tags "mastodon-tl")
(autoload 'mastodon-tl--mute-user "mastodon-tl")
@@ -145,8 +145,8 @@ Use. e.g. \"%c\" for your locale's date and time format."
(defvar mastodon-mode-map
(let ((map (make-sparse-keymap)))
;; navigation inside a timeline
- (define-key map (kbd "n") #'mastodon-tl--goto-next-toot)
- (define-key map (kbd "p") #'mastodon-tl--goto-prev-toot)
+ (define-key map (kbd "n") #'mastodon-tl--goto-next-item)
+ (define-key map (kbd "p") #'mastodon-tl--goto-prev-item)
(define-key map (kbd "M-n") #'mastodon-tl--next-tab-item)
(define-key map (kbd "M-p") #'mastodon-tl--previous-tab-item)
(define-key map [?\t] #'mastodon-tl--next-tab-item)
diff --git a/mastodon-index.org b/mastodon-index.org
index 6199328..9227df5 100644
--- a/mastodon-index.org
+++ b/mastodon-index.org
@@ -115,9 +115,9 @@
| L | mastodon-tl--get-local-timeline | Open local timeline. |
| # | mastodon-tl--get-tag-timeline | Prompt for tag and opens its timeline. |
| | mastodon-tl--goto-next-item | Jump to next item, e.g. filter or follow request. |
-| C-, n | mastodon-tl--goto-next-toot | Jump to next toot header. |
+| C-, n | mastodon-tl--goto-next-item | Jump to next toot header. |
| | mastodon-tl--goto-prev-item | Jump to previous item, e.g. filter or follow request. |
-| C-, p | mastodon-tl--goto-prev-toot | Jump to last toot header. |
+| C-, p | mastodon-tl--goto-prev-item | Jump to last toot header. |
| " | mastodon-tl--list-followed-tags | List followed tags. View timeline of tag user choses. |
| C- | mastodon-tl--mpv-play-video-at-point | Play the video or gif at point with an mpv process. |
| | mastodon-tl--mpv-play-video-from-byline | Run `mastodon-tl--mpv-play-video-at-point' on first moving image in post. |
--
cgit v1.2.3
From d19cc98b57b481515631fa47d62216e4370adbb6 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sun, 15 Oct 2023 13:49:02 +0200
Subject: remove redundant next-/prev-item from views maps
---
lisp/mastodon-views.el | 6 ------
1 file changed, 6 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 24a9de0..423f1a1 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -51,9 +51,6 @@
(autoload 'mastodon-tl--set-face "mastodon-tl")
(autoload 'mastodon-tl--buffer-type-eq "mastodon-tl")
(autoload 'mastodon-tl--profile-buffer-p "mastodon-tl")
-(autoload 'mastodon-tl--goto-next-item "mastodon-tl")
-(autoload 'mastodon-tl--goto-prev-item "mastodon-tl")
-(autoload 'mastodon-tl--goto-next-item "mastodon-tl")
(autoload 'mastodon-tl--goto-first-item "mastodon-tl")
(autoload 'mastodon-tl--do-if-item "mastodon-tl")
(autoload 'mastodon-tl--set-buffer-spec "mastodon-tl")
@@ -87,8 +84,6 @@
(defvar mastodon-views-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map mastodon-mode-map)
- (define-key map (kbd "n") #'mastodon-tl--goto-next-item)
- (define-key map (kbd "p") #'mastodon-tl--goto-prev-item)
map)
"Base keymap for minor mastodon views.")
@@ -97,7 +92,6 @@
(set-keymap-parent map mastodon-views-map)
(define-key map (kbd "d") #'mastodon-views--delete-filter)
(define-key map (kbd "c") #'mastodon-views--create-filter)
- (define-key map (kbd "TAB") #'mastodon-tl--next-tab-item)
(define-key map (kbd "g") #'mastodon-views--view-filters)
map)
"Keymap for viewing filters.")
--
cgit v1.2.3
From 8eda8fb5fa7bcca5de083a5d9841a0942281a432 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sun, 15 Oct 2023 13:52:03 +0200
Subject: fix rename do-if-item-strict
---
lisp/mastodon-tl.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index ac00079..27375c3 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -303,7 +303,7 @@ than `switch-to-buffer'."
(message "Looks like there's no item at point?")
,@body))
-(defmacro mastodon-tl--do-if-toot-strict (&rest body)
+(defmacro mastodon-tl--do-if-item-strict (&rest body)
"Execute BODY if we have a toot object at point.
Includes boosts, and notifications that display toots."
(declare (debug t))
--
cgit v1.2.3
From b86d546cbe38c3eec0516e872009f13a3f80750d Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sun, 15 Oct 2023 14:05:10 +0200
Subject: fix do-if-item comment: doesn't inc. tags, corrent for our use
---
lisp/mastodon-tl.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 27375c3..e25b57c 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -299,7 +299,7 @@ than `switch-to-buffer'."
"Execute BODY if we have an item at point."
(declare (debug t))
`(if (and (not (mastodon-tl--profile-buffer-p))
- (not (mastodon-tl--property 'item-json))) ; includes users, hashtags
+ (not (mastodon-tl--property 'item-json))) ; includes users but not tags
(message "Looks like there's no item at point?")
,@body))
--
cgit v1.2.3
From 0bd2bea47d41545e0b8b6bcbaaa9fca06d202d19 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Mon, 16 Oct 2023 15:38:34 +0200
Subject: override shr-linkmap 'u' binding, to update. 'w' is copy-url already
---
lisp/mastodon-tl.el | 3 +++
1 file changed, 3 insertions(+)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index e25b57c..3e4e31e 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -237,6 +237,9 @@ etc.")
(define-key map [remap shr-previous-link] #'mastodon-tl--previous-tab-item)
;; keep new my-profile binding; shr 'O' doesn't work here anyway
(define-key map (kbd "O") #'mastodon-profile--my-profile)
+ ;; remove shr's u binding, as it the maybe-probe-and-copy-url
+ ;; is already bound to w also
+ (define-key map (kbd "u") #'mastodon-tl--update)
(define-key map [remap shr-browse-url] #'mastodon-url-lookup)
map)
"The keymap to be set for shr.el generated links that are not images.
--
cgit v1.2.3
From a169646f8cb37d3c249b61ddea93906097d1847a Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Fri, 20 Oct 2023 22:37:41 +0200
Subject: mastodon-toot--own-toot-p: call toot-or-base: we can edit our boosted
toots
---
lisp/mastodon-toot.el | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 426a371..6fba951 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -546,10 +546,12 @@ Uses `lingva.el'."
(message "No mastodon buffer?"))))
(defun mastodon-toot--own-toot-p (toot)
- "Check if TOOT is user's own, e.g. for deleting it."
- (and (not (alist-get 'reblog toot))
- (equal (alist-get 'acct (alist-get 'account toot))
- (mastodon-auth--user-acct))))
+ "Check if TOOT is user's own, for deleting, editing, or pinning it."
+ ;; this check needs to allow acting on own toots displayed as boosts, so we
+ ;; call `mastodon-tl--toot-or-base'.
+ (let ((json (mastodon-tl--toot-or-base toot)))
+ (equal (alist-get 'acct (alist-get 'account json))
+ (mastodon-auth--user-acct))))
(defun mastodon-toot--pin-toot-toggle ()
"Pin or unpin user's toot at point."
--
cgit v1.2.3
From 47865bd21551616d5d149afa6c574b2bfd0f118f Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sun, 22 Oct 2023 11:08:00 +0200
Subject: tl--prev-toot-id: don't assume our funs return anything.
fixes a bug that would break thread loading, perhaps because an ancestor toot
wasn't there when it was supposed to be, so we were check for prev id when
there was no prev toot. maybe caused by viewing threads that include toots by
ppl on blocked servers, which don't display.
---
lisp/mastodon-tl.el | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 3e4e31e..e279ee3 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1303,10 +1303,13 @@ Runs `mastodon-tl--render-text' and fetches poll or media."
(defun mastodon-tl--prev-item-id ()
"Return the id of the last toot inserted into the buffer."
- (let ((prev-pos
- (1- (save-excursion
- (previous-single-property-change (point) 'base-item-id)))))
- (get-text-property prev-pos 'base-item-id)))
+ (let* ((prev-change
+ (save-excursion
+ (previous-single-property-change (point) 'base-toot-id)))
+ (prev-pos
+ (when prev-change (1- prev-change))))
+ (when prev-pos
+ (get-text-property prev-pos 'base-toot-id))))
(defun mastodon-tl--after-reply-status (reply-to-id)
"T if REPLY-TO-ID is equal to that of the last toot inserted in the bufer."
--
cgit v1.2.3
From e954ae162cb559f35373e1203f0225a470f65c98 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Mon, 23 Oct 2023 10:48:08 +0200
Subject: no y-or-n-p for (un)bookmarking
---
lisp/mastodon-toot.el | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 6fba951..3f20a14 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -446,9 +446,6 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement."
(mastodon-tl--do-if-item-strict
(let* ((id (mastodon-tl--property 'base-item-id))
(bookmarked-p (mastodon-tl--property 'bookmarked-p))
- (prompt (if bookmarked-p
- (format "Toot already bookmarked. Remove? ")
- (format "Bookmark this toot? ")))
(byline-region (when id
(mastodon-tl--find-property-range 'byline (point))))
(action (if bookmarked-p "unbookmark" "bookmark"))
@@ -458,17 +455,16 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement."
"Toot bookmarked!"))
(remove (when bookmarked-p t)))
(if byline-region
- (when (y-or-n-p prompt)
- (mastodon-toot--action
- action
- (lambda ()
- (let ((inhibit-read-only t))
- (add-text-properties (car byline-region)
- (cdr byline-region)
- (list 'bookmarked-p (not bookmarked-p))))
- (mastodon-toot--action-success bookmark-str
- byline-region remove)
- (message (format "%s #%s" message id)))))
+ (mastodon-toot--action
+ action
+ (lambda ()
+ (let ((inhibit-read-only t))
+ (add-text-properties (car byline-region)
+ (cdr byline-region)
+ (list 'bookmarked-p (not bookmarked-p))))
+ (mastodon-toot--action-success bookmark-str
+ byline-region remove)
+ (message (format "%s #%s" message id))))
(message (format "Nothing to %s here?!?" action))))))
(defun mastodon-toot--list-toot-boosters ()
--
cgit v1.2.3
From f7ec0268e0fcf4d9f6f80ae3d246d878d9350cc8 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Tue, 24 Oct 2023 13:48:19 +0200
Subject: FIX #502. add "exclusive" param to create/edit lists.
---
lisp/mastodon-views.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 423f1a1..a6f319b 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -290,10 +290,13 @@ If ID is provided, use that list."
(replies-policy (completing-read "Replies policy: " ; give this a proper name
'("followed" "list" "none")
nil t nil nil "list"))
+ (exclusive (when (y-or-n-p "Exclude items from home timeline? ")
+ "true"))
(url (mastodon-http--api (format "lists/%s" id)))
(response (mastodon-http--put url
`(("title" . ,name-choice)
- ("replies_policy" . ,replies-policy)))))
+ ("replies_policy" . ,replies-policy)
+ ("exclusive" . ,exclusive)))))
(mastodon-http--triage response
(lambda ()
(with-current-buffer response
@@ -332,10 +335,12 @@ Prompt for name and replies policy."
(replies-policy (completing-read "Replies policy: " ; give this a proper name
'("followed" "list" "none")
nil t nil nil "list")) ; default
+ (exclusive (when (y-or-n-p "Exclude items from home timeline? ")
+ "true"))
(response (mastodon-http--post (mastodon-http--api "lists")
`(("title" . ,title)
- ("replies_policy" . ,replies-policy))
- nil)))
+ ("replies_policy" . ,replies-policy)
+ ("exclusive" . ,exclusive)))))
(mastodon-views--list-action-triage
response "list %s created!" title)))
--
cgit v1.2.3
From c3db1170e80c90563ccfee76b6d12502f4d53f2a Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Tue, 24 Oct 2023 14:10:07 +0200
Subject: edit toot at point: do-if-item-strict
---
lisp/mastodon-toot.el | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 3f20a14..682f6ca 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -876,25 +876,26 @@ instance to edit a toot."
(defun mastodon-toot--edit-toot-at-point ()
"Edit the user's toot at point."
(interactive)
- (let ((toot (or (mastodon-tl--property 'base-toot) ; fave/boost notifs
- (mastodon-tl--property 'item-json))))
- (if (not (mastodon-toot--own-toot-p toot))
- (message "You can only edit your own toots.")
- (let* ((id (mastodon-tl--as-string (mastodon-tl--item-id toot)))
- (source (mastodon-toot--get-toot-source id))
- (content (alist-get 'text source))
- (source-cw (alist-get 'spoiler_text source))
- (toot-visibility (alist-get 'visibility toot))
- (toot-language (alist-get 'language toot))
- (reply-id (alist-get 'in_reply_to_id toot)))
- (when (y-or-n-p "Edit this toot? ")
- (mastodon-toot--compose-buffer nil reply-id nil content :edit)
- (goto-char (point-max))
- ;; adopt reply-to-id, visibility, CW, and language:
- (mastodon-toot--set-toot-properties reply-id toot-visibility
- source-cw toot-language)
- (mastodon-toot--update-status-fields)
- (setq mastodon-toot--edit-item-id id))))))
+ (mastodon-tl--do-if-item-strict
+ (let ((toot (or (mastodon-tl--property 'base-toot) ; fave/boost notifs
+ (mastodon-tl--property 'item-json))))
+ (if (not (mastodon-toot--own-toot-p toot))
+ (message "You can only edit your own toots.")
+ (let* ((id (mastodon-tl--as-string (mastodon-tl--item-id toot)))
+ (source (mastodon-toot--get-toot-source id))
+ (content (alist-get 'text source))
+ (source-cw (alist-get 'spoiler_text source))
+ (toot-visibility (alist-get 'visibility toot))
+ (toot-language (alist-get 'language toot))
+ (reply-id (alist-get 'in_reply_to_id toot)))
+ (when (y-or-n-p "Edit this toot? ")
+ (mastodon-toot--compose-buffer nil reply-id nil content :edit)
+ (goto-char (point-max))
+ ;; adopt reply-to-id, visibility, CW, and language:
+ (mastodon-toot--set-toot-properties reply-id toot-visibility
+ source-cw toot-language)
+ (mastodon-toot--update-status-fields)
+ (setq mastodon-toot--edit-item-id id)))))))
(defun mastodon-toot--get-toot-source (id)
"Fetch the source JSON of toot with ID."
--
cgit v1.2.3
From 826c228d096a886ec2e451cc5d2251bcf356d846 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Tue, 24 Oct 2023 14:10:25 +0200
Subject: edit list: exclusive proper true/false strings
---
lisp/mastodon-views.el | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index a6f319b..d7d8e7e 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -290,8 +290,9 @@ If ID is provided, use that list."
(replies-policy (completing-read "Replies policy: " ; give this a proper name
'("followed" "list" "none")
nil t nil nil "list"))
- (exclusive (when (y-or-n-p "Exclude items from home timeline? ")
- "true"))
+ (exclusive (if (y-or-n-p "Exclude items from home timeline? ")
+ "true"
+ "false"))
(url (mastodon-http--api (format "lists/%s" id)))
(response (mastodon-http--put url
`(("title" . ,name-choice)
--
cgit v1.2.3
From f1bc8d83d4a5fe324821ee890bf9dca6f05c6596 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Tue, 24 Oct 2023 14:10:43 +0200
Subject: display replies policy & exclusive status for lists
---
lisp/mastodon-views.el | 71 ++++++++++++++++++++++++++------------------------
1 file changed, 37 insertions(+), 34 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index d7d8e7e..6dfb8a2 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -207,41 +207,44 @@ provides the JSON data."
(defun mastodon-views--print-list-set (lists)
"Print each account plus a separator for each list in LISTS."
- (let ((lists-names (mastodon-tl--map-alist 'title lists)))
- (mapc (lambda (x)
- (mastodon-views--print-list-accounts x)
- (insert (propertize (concat " " mastodon-tl--horiz-bar "\n\n")
- 'face 'success)))
- lists-names)))
-
-(defun mastodon-views--print-list-accounts (list-name)
- "Insert the accounts in list named LIST-NAME."
- (let* ((id (mastodon-views--get-list-id list-name))
- (accounts (mastodon-views--accounts-in-list id)))
- (insert
- (propertize list-name
- 'byline t ; so we nav here
- 'item-id "0" ; so we nav here
- 'item-type 'user
- 'help-echo "RET: view list timeline, d: delete this list, \
+ (mapc (lambda (x)
+ (mastodon-views--print-list-accounts x)
+ (insert (propertize (concat " " mastodon-tl--horiz-bar "\n\n")
+ 'face 'success)))
+ lists))
+
+(defun mastodon-views--print-list-accounts (list)
+ "Insert the accounts in list named LIST, an alist."
+ (let-alist list
+ (let* ((accounts (mastodon-views--accounts-in-list .id)))
+ (insert
+ (propertize .title
+ 'byline t ; so we nav here
+ 'item-id "0" ; so we nav here
+ 'item-type 'user
+ 'help-echo "RET: view list timeline, d: delete this list, \
a: add account to this list, r: remove account from this list"
- 'list t
- 'face 'link
- 'keymap mastodon-views--list-name-keymap
- 'list-name list-name
- 'list-id id)
- (propertize "\n\n"
- 'list t
- 'keymap mastodon-views--list-name-keymap
- 'list-name list-name
- 'list-id id)
- (propertize
- (mapconcat #'mastodon-search--propertize-user accounts
- " ")
- 'list t
- 'keymap mastodon-views--list-name-keymap
- 'list-name list-name
- 'list-id id))))
+ 'list t
+ 'face 'link
+ 'keymap mastodon-views--list-name-keymap
+ 'list-name .title
+ 'list-id .id)
+ (propertize (format " [replies: %s, exclusive %s]"
+ .replies_policy
+ (when (eq t .exclusive) "true"))
+ 'face 'font-lock-comment-face)
+ (propertize "\n\n"
+ 'list t
+ 'keymap mastodon-views--list-name-keymap
+ 'list-name .title
+ 'list-id .id)
+ (propertize
+ (mapconcat #'mastodon-search--propertize-user accounts
+ " ")
+ 'list t
+ 'keymap mastodon-views--list-name-keymap
+ 'list-name .title
+ 'list-id .id)))))
(defun mastodon-views--get-users-lists ()
"Get the list of the user's lists from the server."
--
cgit v1.2.3
From 78ff4a75ea22635dced765a94a48b0512c412811 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Tue, 24 Oct 2023 14:11:23 +0200
Subject: item-type list for list, not user (stray value)
---
lisp/mastodon-views.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 6dfb8a2..dafa359 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -221,7 +221,7 @@ provides the JSON data."
(propertize .title
'byline t ; so we nav here
'item-id "0" ; so we nav here
- 'item-type 'user
+ 'item-type 'list
'help-echo "RET: view list timeline, d: delete this list, \
a: add account to this list, r: remove account from this list"
'list t
--
cgit v1.2.3
From 48d362c6d9ab28fa7c0c0c78eae038a5551ddc5a Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Tue, 24 Oct 2023 14:28:27 +0200
Subject: no pagination for lists
---
lisp/mastodon-tl.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index e279ee3..7f03e9f 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2375,7 +2375,8 @@ and profile pages when showing followers or accounts followed."
(mastodon-http--get-response-async url nil 'mastodon-tl--more* (current-buffer)
(point) :headers))))
(cond ( ; no paginate
- (mastodon-tl--buffer-type-eq 'follow-suggestions)
+ (or (mastodon-tl--buffer-type-eq 'follow-suggestions)
+ (mastodon-tl--buffer-type-eq 'lists))
(message "No more results"))
;; offset paginate (search, trending, user lists, ...?):
((or (string-prefix-p "*mastodon-trending-" (buffer-name))
--
cgit v1.2.3
From 3dc21b91b1ea9777c8b8ebec0a742a13c27a80b7 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Tue, 24 Oct 2023 14:33:26 +0200
Subject: tl--update: add lists, and note abt what we shd actually do
---
lisp/mastodon-tl.el | 3 +++
1 file changed, 3 insertions(+)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 7f03e9f..8a4e023 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2599,9 +2599,12 @@ This location is defined by a non-nil value of
(defun mastodon-tl--update ()
"Update timeline with new toots."
(interactive)
+ ;; FIXME: actually these buffers should just reload by calling their own
+ ;; load function:
(if (or (mastodon-tl--buffer-type-eq 'trending-statuses)
(mastodon-tl--buffer-type-eq 'trending-tags)
(mastodon-tl--buffer-type-eq 'follow-suggestions)
+ (mastodon-tl--buffer-type-eq 'lists)
(mastodon-tl--search-buffer-p))
(message "update not available in this view.")
;; FIXME: handle update for search and trending buffers
--
cgit v1.2.3
From fd697f98c3e295950701e1d4f6d05c3b34379591 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Tue, 24 Oct 2023 14:34:47 +0200
Subject: no more/update for filters view
---
lisp/mastodon-tl.el | 2 ++
1 file changed, 2 insertions(+)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 8a4e023..16292d5 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2376,6 +2376,7 @@ and profile pages when showing followers or accounts followed."
(point) :headers))))
(cond ( ; no paginate
(or (mastodon-tl--buffer-type-eq 'follow-suggestions)
+ (mastodon-tl--buffer-type-eq 'filters)
(mastodon-tl--buffer-type-eq 'lists))
(message "No more results"))
;; offset paginate (search, trending, user lists, ...?):
@@ -2605,6 +2606,7 @@ This location is defined by a non-nil value of
(mastodon-tl--buffer-type-eq 'trending-tags)
(mastodon-tl--buffer-type-eq 'follow-suggestions)
(mastodon-tl--buffer-type-eq 'lists)
+ (mastodon-tl--buffer-type-eq 'filters)
(mastodon-tl--search-buffer-p))
(message "update not available in this view.")
;; FIXME: handle update for search and trending buffers
--
cgit v1.2.3
From 5f237982e53f0804f03f88d20eecab864ab575d3 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Fri, 27 Oct 2023 18:15:08 +0200
Subject: a quick hack to toggle display of a user's boosts in timeline. FIX#
503
---
lisp/mastodon-tl.el | 46 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 10 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 16292d5..673856b 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1880,7 +1880,7 @@ ID is that of the post the context is currently displayed for."
;;; FOLLOW/BLOCK/MUTE, ETC
-(defun mastodon-tl--follow-user (user-handle &optional notify langs)
+(defun mastodon-tl--follow-user (user-handle &optional notify langs reblogs)
"Query for USER-HANDLE from current status and follow that user.
If NOTIFY is \"true\", enable notifications when that user posts.
If NOTIFY is \"false\", disable notifications when that user posts.
@@ -1890,8 +1890,9 @@ LANGS is an array parameters alist of languages to filer user's posts by."
(list (mastodon-tl--user-handles-get "follow")))
(mastodon-tl--do-if-item
(mastodon-tl--do-user-action-and-response
- user-handle "follow" nil notify langs)))
+ user-handle "follow" nil notify langs reblogs)))
+;; TODO: make this action "enable/disable notifications"
(defun mastodon-tl--enable-notify-user-posts (user-handle)
"Query for USER-HANDLE and enable notifications when they post."
(interactive
@@ -1905,6 +1906,18 @@ LANGS is an array parameters alist of languages to filer user's posts by."
(list (mastodon-tl--user-handles-get "disable")))
(mastodon-tl--follow-user user-handle "false"))
+(defun mastodon-tl--follow-user-disable-boosts (user-handle)
+ ""
+ (interactive
+ (list (mastodon-tl--user-handles-get "disable boosts")))
+ (mastodon-tl--follow-user user-handle nil nil "false"))
+
+(defun mastodon-tl--follow-user-enable-boosts (user-handle)
+ ""
+ (interactive
+ (list (mastodon-tl--user-handles-get "enable boosts")))
+ (mastodon-tl--follow-user user-handle nil nil "true"))
+
(defun mastodon-tl--filter-user-user-posts-by-language (user-handle)
"Query for USER-HANDLE and enable notifications when they post.
This feature is experimental and for now not easily varified by
@@ -2002,10 +2015,14 @@ LANGS is the accumulated array param alist if we re-run recursively."
;; return immediately if only 1 handle:
(if (eq 1 (length user-handles))
(car user-handles)
- (completing-read (if (or (equal action "disable")
- (equal action "enable"))
- (format "%s notifications when user posts: " action)
- (format "Handle of user to %s: " action))
+ (completing-read (cond ((or ; TODO: make this "enable/disable notifications"
+ (equal action "disable")
+ (equal action "enable"))
+ (format "%s notifications when user posts: " action))
+ ((string-suffix-p "boosts" action)
+ (format "%s by user: " action))
+ (t
+ (format "Handle of user to %s: " action)))
user-handles
nil ; predicate
'confirm)))))
@@ -2025,13 +2042,15 @@ Action must be either \"unblock\" or \"unmute\"."
accts nil t)))) ; require match
(defun mastodon-tl--do-user-action-and-response
- (user-handle action &optional negp notify langs)
+ (user-handle action &optional negp notify langs reblogs)
"Do ACTION on user USER-HANDLE.
NEGP is whether the action involves un-doing something.
If NOTIFY is \"true\", enable notifications when that user posts.
If NOTIFY is \"false\", disable notifications when that user posts.
NOTIFY is only non-nil when called by `mastodon-tl--follow-user'.
-LANGS is an array parameters alist of languages to filer user's posts by."
+LANGS is an array parameters alist of languages to filer user's posts by.
+REBLOGS is a boolean string like NOTIFY, enabling or disabling
+display of the user's boosts in your timeline."
(let* ((account (if negp
;; unmuting/unblocking, handle from mute/block list
(mastodon-profile--search-account-by-handle user-handle)
@@ -2048,17 +2067,18 @@ LANGS is an array parameters alist of languages to filer user's posts by."
(alist-get 'display_name account)))
(args (cond (notify `(("notify" . ,notify)))
(langs langs)
+ (reblogs `(("reblogs" . ,reblogs)))
(t nil)))
(url (mastodon-http--api (format "accounts/%s/%s" user-id action))))
(if account
(if (equal action "follow") ; y-or-n for all but follow
- (mastodon-tl--do-user-action-function url name user-handle action notify args)
+ (mastodon-tl--do-user-action-function url name user-handle action notify args reblogs)
(when (y-or-n-p (format "%s user %s? " action name))
(mastodon-tl--do-user-action-function url name user-handle action args)))
(message "Cannot find a user with handle %S" user-handle))))
(defun mastodon-tl--do-user-action-function
- (url name user-handle action &optional notify args)
+ (url name user-handle action &optional notify args reblogs)
"Post ACTION on user NAME/USER-HANDLE to URL.
NOTIFY is either \"true\" or \"false\", and used when we have been called
by `mastodon-tl--follow-user' to enable or disable notifications.
@@ -2073,6 +2093,12 @@ ARGS is an alist of any parameters to send with the request."
((string-equal notify "false")
(message "Not receiving notifications for user %s (@%s)!"
name user-handle))
+ ((string-equal reblogs "true")
+ (message "Receiving boosts by user %s (@%s)!"
+ name user-handle))
+ ((string-equal reblogs "false")
+ (message "Not receiving boosts by user %s (@%s)!"
+ name user-handle))
((or (string-equal action "mute")
(string-equal action "unmute"))
(message "User %s (@%s) %sd!" name user-handle action))
--
cgit v1.2.3
From b8d0c9b967fbc1e38e4012ad357a7f29c621acc1 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 28 Oct 2023 11:36:58 +0200
Subject: triage: call cb on response. do-user-action-fun: check response data
this means the triage callback always needs to handle 1 arg.
---
lisp/mastodon-http.el | 2 +-
lisp/mastodon-notifications.el | 6 +--
lisp/mastodon-profile.el | 10 ++--
lisp/mastodon-tl.el | 60 +++++++++++++-----------
lisp/mastodon-toot.el | 12 ++---
lisp/mastodon-views.el | 10 ++--
test/mastodon-http-tests.el | 6 +--
test/mastodon-tl-tests.el | 102 +++++++++++++++++++++++------------------
test/mastodon-toot-tests.el | 2 +-
9 files changed, 115 insertions(+), 95 deletions(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index 3d26dc5..1edc8b5 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -91,7 +91,7 @@ RESPONSE if unsuccessful."
(let ((status (with-current-buffer response
(mastodon-http--status))))
(if (string-prefix-p "2" status)
- (funcall success)
+ (funcall success response)
(if (string-prefix-p "404" status)
(message "Error %s: page not found" status)
(let ((json-response (with-current-buffer response
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index cce5810..a1aea31 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -116,7 +116,7 @@ follow-requests view."
(mastodon-http--api "follow_requests")
(format "/%s/%s" .id (if reject "reject" "authorize"))))))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(if f-reqs-view-p
(mastodon-views--view-follow-requests)
(mastodon-tl--reload-timeline-or-profile))
@@ -311,7 +311,7 @@ Status notifications are created when you call
(let ((response
(mastodon-http--post (mastodon-http--api "notifications/clear"))))
(mastodon-http--triage
- response (lambda ()
+ response (lambda (_)
(when mastodon-tl--buffer-spec
(mastodon-tl--reload-timeline-or-profile))
(message "All notifications cleared!"))))))
@@ -326,7 +326,7 @@ Status notifications are created when you call
(mastodon-http--post (mastodon-http--api
(format "notifications/%s/dismiss" id)))))
(mastodon-http--triage
- response (lambda ()
+ response (lambda (_)
(when mastodon-tl--buffer-spec
(mastodon-tl--reload-timeline-or-profile))
(message "Notification dismissed!")))))
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 9850b81..1003853 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -319,7 +319,7 @@ Ask for confirmation if length > 500 characters."
"Send PATCH request with the updated profile NOTE to URL."
(let ((response (mastodon-http--patch url `(("note" . ,note)))))
(mastodon-http--triage response
- (lambda () (message "Profile note updated!")))))
+ (lambda (_) (message "Profile note updated!")))))
(defun mastodon-profile--update-preference (pref val &optional source)
"Update account PREF erence to setting VAL.
@@ -329,7 +329,7 @@ SOURCE means that the preference is in the `source' part of the account JSON."
(pref-formatted (if source (concat "source[" pref "]") pref))
(response (mastodon-http--patch url `((,pref-formatted . ,val)))))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(mastodon-profile--fetch-server-account-settings)
(message "Account setting %s updated to %s!" pref val)))))
@@ -441,7 +441,7 @@ Returns an alist."
(params (mastodon-profile--make-meta-fields-params fields-updated))
(response (mastodon-http--patch url params)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(mastodon-profile--fetch-server-account-settings)
(message "Metadata fields updated to %s!"
fields-updated)))))
@@ -816,7 +816,7 @@ Optionally provide the ID of the account to remove."
(when (y-or-n-p (format "Remove follower %s? " handle))
(let ((response (mastodon-http--post url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "Follower %s removed!" handle)))))))
(defun mastodon-profile--remove-from-followers-at-point ()
@@ -862,7 +862,7 @@ NOTE-OLD is the text of any existing note."
(url (mastodon-http--api (format "accounts/%s/note" id)))
(response (mastodon-http--post url params)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "Private note on %s added!" handle)))))
(defun mastodon-profile--view-account-private-note ()
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 673856b..088e3db 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1229,7 +1229,7 @@ displayed when the duration is smaller than a minute)."
(arg `(("choices[]" . ,option-as-arg)))
(response (mastodon-http--post url arg)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "You voted for option %s: %s!"
(car option) (cdr option)))))))
@@ -1852,7 +1852,7 @@ If UNMUTE, unmute it."
(when (y-or-n-p (format "%s this thread? " (capitalize mute-str)))
(let ((response (mastodon-http--post url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(if unmute
(message "Thread unmuted!")
(message "Thread muted!")))))))))))
@@ -2086,27 +2086,35 @@ ARGS is an alist of any parameters to send with the request."
(let ((response (mastodon-http--post url args)))
(mastodon-http--triage
response
- (lambda ()
- (cond ((string-equal notify "true")
- (message "Receiving notifications for user %s (@%s)!"
- name user-handle))
- ((string-equal notify "false")
- (message "Not receiving notifications for user %s (@%s)!"
- name user-handle))
- ((string-equal reblogs "true")
- (message "Receiving boosts by user %s (@%s)!"
- name user-handle))
- ((string-equal reblogs "false")
- (message "Not receiving boosts by user %s (@%s)!"
- name user-handle))
- ((or (string-equal action "mute")
- (string-equal action "unmute"))
- (message "User %s (@%s) %sd!" name user-handle action))
- ((assoc "languages[]" args #'equal)
- (message "User %s filtered by language(s): %s" name
- (mapconcat #'cdr args " ")))
- ((eq notify nil)
- (message "User %s (@%s) %sed!" name user-handle action)))))))
+ (lambda (response)
+ (let ((json (with-current-buffer response
+ (mastodon-http--process-json))))
+ ;; TODO: when > if, with failure msg
+ (cond ((string-equal notify "true")
+ (when (equal 't (alist-get 'notifying json))
+ (message "Receiving notifications for user %s (@%s)!"
+ name user-handle)))
+ ((string-equal notify "false")
+ (when (equal :json-false (alist-get 'notifying json))
+ (message "Not receiving notifications for user %s (@%s)!"
+ name user-handle)))
+ ((string-equal reblogs "true")
+ (when (equal 't (alist-get 'showing_reblogs json))
+ (message "Receiving boosts by user %s (@%s)!"
+ name user-handle)))
+ ((string-equal reblogs "false")
+ (when (equal :json-false (alist-get 'showing_reblogs json))
+ (message "Not receiving boosts by user %s (@%s)!"
+ name user-handle)))
+ ((or (string-equal action "mute")
+ (string-equal action "unmute"))
+ (message "User %s (@%s) %sd!" name user-handle action))
+ ((assoc "languages[]" args #'equal)
+ (message "User %s filtered by language(s): %s" name
+ (mapconcat #'cdr args " ")))
+ ((and (eq notify nil)
+ (eq reblogs nil))
+ (message "User %s (@%s) %sed!" name user-handle action))))))))
;; FOLLOW TAGS
@@ -2135,7 +2143,7 @@ If TAG provided, follow it."
(url (mastodon-http--api (format "tags/%s/follow" tag)))
(response (mastodon-http--post url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "tag #%s followed!" tag)))))
(defun mastodon-tl--followed-tags ()
@@ -2153,7 +2161,7 @@ If TAG is provided, unfollow it."
(url (mastodon-http--api (format "tags/%s/unfollow" tag)))
(response (mastodon-http--post url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "tag #%s unfollowed!" tag)))))
(defun mastodon-tl--list-followed-tags (&optional prefix)
@@ -2249,7 +2257,7 @@ report the account for spam."
(params (mastodon-tl--report-params account toot))
(response (mastodon-http--post url params)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "User %s reported!" handle)))))))
(defvar crm-separator)
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 682f6ca..e10e7e8 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -386,7 +386,7 @@ TYPE is a symbol, either `favourite' or `boost.'"
(t
(mastodon-toot--action
action
- (lambda ()
+ (lambda (_)
(let ((inhibit-read-only t))
(add-text-properties (car byline-region)
(cdr byline-region)
@@ -457,7 +457,7 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement."
(if byline-region
(mastodon-toot--action
action
- (lambda ()
+ (lambda (_)
(let ((inhibit-read-only t))
(add-text-properties (car byline-region)
(cdr byline-region)
@@ -563,7 +563,7 @@ Uses `lingva.el'."
(message "You can only pin your own toots.")
(when (y-or-n-p (format "%s this toot? " msg-y-or-n))
(mastodon-toot--action action
- (lambda ()
+ (lambda (_)
(when mastodon-tl--buffer-spec
(mastodon-tl--reload-timeline-or-profile))
(message "Toot %s!" msg)))))))
@@ -597,7 +597,7 @@ NO-REDRAFT means delete toot only."
(let* ((response (mastodon-http--delete url)))
(mastodon-http--triage
response
- (lambda ()
+ (lambda (_)
(if no-redraft
(progn
(when mastodon-tl--buffer-spec
@@ -856,7 +856,7 @@ instance to edit a toot."
(mastodon-http--post endpoint args))))
(mastodon-http--triage
response
- (lambda ()
+ (lambda (_)
(mastodon-toot--kill)
(if scheduled
(message "Toot scheduled!")
@@ -1343,7 +1343,7 @@ With RESCHEDULE, reschedule the scheduled toot at point without editing."
(url (mastodon-http--api (format "scheduled_statuses/%s" id)))
(response (mastodon-http--put url args)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
;; reschedule means we are in scheduled toots view:
(mastodon-views--view-scheduled-toots)
(message
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index dafa359..b1ff70d 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -302,7 +302,7 @@ If ID is provided, use that list."
("replies_policy" . ,replies-policy)
("exclusive" . ,exclusive)))))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(with-current-buffer response
(let* ((json (mastodon-http--process-json))
(name-new (alist-get 'title json)))
@@ -442,7 +442,7 @@ If ID is provided, use that list."
(defun mastodon-views--list-action-triage (response &rest args)
"Call `mastodon-http--triage' on RESPONSE and call message on ARGS."
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(when (mastodon-tl--buffer-type-eq 'lists)
(mastodon-views--view-lists))
(apply #'message args))))
@@ -559,7 +559,7 @@ NO-CONFIRM means there is no ask or message, there is only do."
(let* ((url (mastodon-http--api (format "scheduled_statuses/%s" id)))
(response (mastodon-http--delete url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(mastodon-views--view-scheduled-toots)
(unless no-confirm
(message "Toot cancelled!")))))))))
@@ -650,7 +650,7 @@ Prompt for a context, must be a list containting at least one of \"home\",
`("phrase" . ,word)
contexts-processed))))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "Filter created for %s!" word)
(when (mastodon-tl--buffer-type-eq 'filters)
(mastodon-views--view-filters))))))
@@ -666,7 +666,7 @@ Prompt for a context, must be a list containting at least one of \"home\",
(when (y-or-n-p (format "Delete filter %s? " phrase))
(let ((response (mastodon-http--delete url)))
(mastodon-http--triage
- response (lambda ()
+ response (lambda (_)
(mastodon-views--view-filters)
(message "Filter for \"%s\" deleted!" phrase))))))))
diff --git a/test/mastodon-http-tests.el b/test/mastodon-http-tests.el
index b3a02bc..96f9304 100644
--- a/test/mastodon-http-tests.el
+++ b/test/mastodon-http-tests.el
@@ -62,11 +62,11 @@ Strict-Transport-Security: max-age=31536000
(let ((response-buffer
(get-buffer-create "mastodon-http--triage-buffer")))
(with-current-buffer response-buffer
- (erase-buffer)
+ (erase-buffer)
(insert mastodon-http--example-200))
(should (equal (mastodon-http--triage
response-buffer
- (lambda ()
+ (lambda (_)
(message "success call")))
"success call"))))
@@ -80,7 +80,7 @@ Strict-Transport-Security: max-age=31536000
(insert mastodon-http--example-400))
(should (equal (mastodon-http--triage
response-buffer
- (lambda ()
+ (lambda (_)
(message "success call")))
"Error 444: some unhappy complaint"))))
diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el
index be72f66..2aa0505 100644
--- a/test/mastodon-tl-tests.el
+++ b/test/mastodon-tl-tests.el
@@ -1090,56 +1090,68 @@ correct value for following, as well as notifications enabled or disabled."
(let ((response-buffer-true (current-buffer)))
(insert mastodon-tl--follow-notify-true-response)
(with-mock
- (mock (mastodon-http--post url-follow-only nil)
- => response-buffer-true)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-follow-only
- user-name
- user-handle
- "follow")
- "User some-user (@some-user@instance.url) followed!"))
- (mock (mastodon-http--post url-mute nil)
- => response-buffer-true)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-mute
- user-name
- user-handle
- "mute")
- "User some-user (@some-user@instance.url) muted!"))
- (mock (mastodon-http--post url-block nil)
- => response-buffer-true)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-block
- user-name
- user-handle
- "block")
- "User some-user (@some-user@instance.url) blocked!")))
+ (mock (mastodon-http--post url-follow-only nil)
+ => response-buffer-true)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-follow-only
+ user-name
+ user-handle
+ "follow")
+ "User some-user (@some-user@instance.url) followed!")))))
+ (with-temp-buffer
+ (let ((response-buffer-true (current-buffer)))
+ (insert mastodon-tl--follow-notify-true-response)
+ (with-mock
+ (mock (mastodon-http--post url-mute nil)
+ => response-buffer-true)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-mute
+ user-name
+ user-handle
+ "mute")
+ "User some-user (@some-user@instance.url) muted!")))))
+ (with-temp-buffer
+ (let ((response-buffer-true (current-buffer)))
+ (insert mastodon-tl--follow-notify-true-response)
+ (with-mock
+ (mock (mastodon-http--post url-block nil)
+ => response-buffer-true)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-block
+ user-name
+ user-handle
+ "block")
+ "User some-user (@some-user@instance.url) blocked!")))))
+ (with-temp-buffer
+ (let ((response-buffer-true (current-buffer)))
+ (insert mastodon-tl--follow-notify-true-response)
(with-mock
- (mock (mastodon-http--post url-true nil) => response-buffer-true)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-true
- user-name
- user-handle
- "follow"
- "true")
- "Receiving notifications for user some-user (@some-user@instance.url)!")))))
+ (with-mock
+ (mock (mastodon-http--post url-true nil) => response-buffer-true)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-true
+ user-name
+ user-handle
+ "follow"
+ "true")
+ "Receiving notifications for user some-user (@some-user@instance.url)!"))))))
(with-temp-buffer
(let ((response-buffer-false (current-buffer)))
(insert mastodon-tl--follow-notify-false-response)
(with-mock
- (mock (mastodon-http--post url-false nil) => response-buffer-false)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-false
- user-name
- user-handle
- "follow"
- "false")
- "Not receiving notifications for user some-user (@some-user@instance.url)!")))))))
+ (mock (mastodon-http--post url-false nil) => response-buffer-false)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-false
+ user-name
+ user-handle
+ "follow"
+ "false")
+ "Not receiving notifications for user some-user (@some-user@instance.url)!")))))))
(ert-deftest mastodon-tl--report-to-mods-params-alist ()
""
diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el
index 5efe2e1..6133453 100644
--- a/test/mastodon-toot-tests.el
+++ b/test/mastodon-toot-tests.el
@@ -180,7 +180,7 @@ mention string."
=> "https://example.space/statuses/61208/pin")
(mock (mastodon-http--post "https://example.space/statuses/61208/pin")
=> pin-response)
- (should (equal (mastodon-toot--action "pin" (lambda ()
+ (should (equal (mastodon-toot--action "pin" (lambda (_)
(message "Toot pinned!")))
"Toot pinned!"))))))
--
cgit v1.2.3
From 1bfcb22043580d6bc4252300f55135aac8c50aea Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 28 Oct 2023 14:50:18 +0200
Subject: note re tags timeline limit number of tags
---
lisp/mastodon-tl.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 088e3db..135c7f5 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2177,7 +2177,9 @@ PREFIX is sent to `mastodon-tl--get-tag-timeline', which see."
(defun mastodon-tl--followed-tags-timeline (&optional prefix)
"Open a timeline of all your followed tags.
-PREFIX is sent to `mastodon-tl--show-tag-timeline', which see."
+PREFIX is sent to `mastodon-tl--show-tag-timeline', which see.
+Note that the number of tags supported is undocumented, and from
+manual testing appears to be limited to a total of four tags."
(interactive "p")
(let* ((followed-tags-json (mastodon-tl--followed-tags))
(tags (mastodon-tl--map-alist 'name followed-tags-json)))
--
cgit v1.2.3
From 979f95575a140556b855bd7dfe304141576161b7 Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Sat, 28 Oct 2023 14:50:18 +0200
Subject: note re tags timeline limit number of tags
---
lisp/mastodon-tl.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'lisp')
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 673856b..7859413 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2169,7 +2169,9 @@ PREFIX is sent to `mastodon-tl--get-tag-timeline', which see."
(defun mastodon-tl--followed-tags-timeline (&optional prefix)
"Open a timeline of all your followed tags.
-PREFIX is sent to `mastodon-tl--show-tag-timeline', which see."
+PREFIX is sent to `mastodon-tl--show-tag-timeline', which see.
+Note that the number of tags supported is undocumented, and from
+manual testing appears to be limited to a total of four tags."
(interactive "p")
(let* ((followed-tags-json (mastodon-tl--followed-tags))
(tags (mastodon-tl--map-alist 'name followed-tags-json)))
--
cgit v1.2.3
From c18aee54214b47c8e0fd2c9f33441316d42f7fca Mon Sep 17 00:00:00 2001
From: marty hiatt
Date: Mon, 30 Oct 2023 12:44:26 +0100
Subject: request-auth-code: select-enable-clipboard.
---
lisp/mastodon-auth.el | 1 +
1 file changed, 1 insertion(+)
(limited to 'lisp')
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el
index 5069271..5867b97 100644
--- a/lisp/mastodon-auth.el
+++ b/lisp/mastodon-auth.el
@@ -134,6 +134,7 @@ When ASK is absent return nil."
(defun mastodon-auth--request-authorization-code ()
"Ask authorization code and return it."
(let ((url (mastodon-auth--get-browser-login-url))
+ (select-enable-clipboard t)
authorization-code)
(kill-new url)
(message "%s" url)
--
cgit v1.2.3