aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-tl.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r--lisp/mastodon-tl.el138
1 files changed, 69 insertions, 69 deletions
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))