From e1269b9fbf87013a9909cfced340fa47f43dc33a Mon Sep 17 00:00:00 2001 From: mousebot Date: Sun, 16 May 2021 13:05:26 +0200 Subject: display pinned toots first on a user's profile. also: profile--relationships-get no longer interactive. and docstrings for fields insert. indent "pinned" for pinned toots display --- lisp/mastodon-profile.el | 7 +++---- lisp/mastodon-tl.el | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index ec3dd0f..11ad02e 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -101,8 +101,7 @@ following the current profile." (error "Not in a mastodon profile"))) (defun mastodon-profile--relationships-get (id) - "Fetch info about logged in user's relationship to user with id ID." - (interactive) + "Fetch info about logged-in user's relationship to user with id ID." (let* ((their-id id) (url (mastodon-http--api (format "accounts/relationships?id[]=%s" @@ -110,7 +109,7 @@ following the current profile." (mastodon-http--get-json url))) (defun mastodon-profile--fields-get (account) - "Fetch the fields vector from a profile. + "Fetch the fields vector (a.k.a profile metadata) from a profile. Returns a list of lists." (let ((fields (mastodon-profile--account-field account 'fields))) @@ -123,7 +122,7 @@ Returns a list of lists." fields)))) (defun mastodon-profile--fields-insert (fields) - "Format and insert field pairs in FIELDS." + "Format and insert field pairs (a.k.a profile metadata) in FIELDS." (let* ((car-fields (mapcar 'car fields)) ;; (cdr-fields (mapcar 'cadr fields)) ;; (cdr-fields-rendered diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 7624088..8ac9d9c 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -673,9 +673,23 @@ it is `mastodon-tl--byline-boosted'" 'mastodon-tl--byline-boosted)) (defun mastodon-tl--timeline (toots) - "Display each toot in TOOTS." - (mapc 'mastodon-tl--toot toots) - (goto-char (point-min))) + "Display each toot in TOOTS. + +If any toots are pinned, display them first." + (let* ((pinned-list)) + (mapcar (lambda (toot) + (when (equal (cdr (assoc 'pinned toot)) 't) + (push toot pinned-list))) + toots) + (when pinned-list + (progn + (insert (mastodon-tl--set-face + " :pinned: " 'success)) + (mapc 'mastodon-tl--toot pinned-list) + (insert (mastodon-tl--set-face + " :end-pinned: \n" 'success)))) + (mapc 'mastodon-tl--toot toots) + (goto-char (point-min)))) (defun mastodon-tl--get-update-function (&optional buffer) "Get the UPDATE-FUNCTION stored in `mastodon-tl--buffer-spec'" -- cgit v1.2.3