diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-profile.el | 37 | ||||
-rw-r--r-- | lisp/mastodon.el | 2 |
2 files changed, 31 insertions, 8 deletions
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index fc318e2..31a1983 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -97,6 +97,7 @@ (let ((map (make-sparse-keymap))) (define-key map (kbd "C-c C-c") #'mastodon-profile--account-view-cycle) (define-key map (kbd "C-c C-s") #'mastodon-profile--account-search) + (define-key map (kbd "C-c #") #'mastodon-profile--open-statuses-tagged) map) "Keymap for `mastodon-profile-mode'.") @@ -142,12 +143,15 @@ contains") (mastodon-tl--property 'item-json)) (defun mastodon-profile--make-author-buffer - (account &optional no-reblogs no-replies only-media) + (account &optional no-reblogs no-replies only-media tag) "Take an ACCOUNT json and insert a user account into a new buffer. -NO-REBLOGS means do not display boosts in statuses." +NO-REBLOGS means do not display boosts in statuses. +NO-REPLIES means to exlude replies. +ONLY-MEDIA means show only posts containing attachments. +TAG is a hashtag to restrict posts to." (mastodon-profile--make-profile-buffer-for account "statuses" #'mastodon-tl--timeline no-reblogs nil - no-replies only-media)) + no-replies only-media tag)) ;; TODO: we shd just load all views' data then switch coz this is slow af: (defun mastodon-profile--account-view-cycle () @@ -190,6 +194,15 @@ NO-REBLOGS means do not display boosts in statuses." mastodon-profile--account nil nil :only-media) (user-error "Not in a mastodon profile"))) +(defun mastodon-profile--open-statuses-tagged () + "Prompt for a hashtag and display a profile with only statuses containing it." + (interactive) + (let ((tag (read-string "Statuses containing tag: "))) + (if mastodon-profile--account + (mastodon-profile--make-author-buffer + mastodon-profile--account nil nil nil tag) + (user-error "Not in a mastodon profile")))) + (defun mastodon-profile--open-following () "Open a profile buffer showing the accounts that current profile follows." (interactive) @@ -578,10 +591,13 @@ FIELDS means provide a fields vector fetched by other means." (defun mastodon-profile--make-profile-buffer-for (account endpoint-type update-function - &optional no-reblogs headers no-replies only-media) + &optional no-reblogs headers no-replies only-media tag) "Display profile of ACCOUNT, using ENDPOINT-TYPE and UPDATE-FUNCTION. NO-REBLOGS means do not display boosts in statuses. -HEADERS means also fetch link headers for pagination." +HEADERS means also fetch link headers for pagination. +NO-REPLIES means to exlude replies. +ONLY-MEDIA means show only posts containing attachments. +TAG is a hashtag to restrict posts to." (let-alist account (let* ((args `(("limit" . ,mastodon-tl--timeline-posts-count))) (args (cond (no-reblogs @@ -590,6 +606,8 @@ HEADERS means also fetch link headers for pagination." (push '("exclude_replies" . "t") args)) (only-media (push '("only_media" . "t") args)) + (tag + (push `("tagged" . ,tag) args)) (t args))) (endpoint (format "accounts/%s/%s" .id endpoint-type)) @@ -599,6 +617,7 @@ HEADERS means also fetch link headers for pagination." (cond (no-reblogs "-no-boosts") (no-replies "-no-replies") (only-media "-only-media") + (tag (format "-tagged-%s" tag)) (t ""))) "*")) (response (if headers @@ -627,6 +646,10 @@ HEADERS means also fetch link headers for pagination." " TOOTS (no boosts)") (no-replies " TOOTS (no replies)") + (only-media + " TOOTS (media only)") + (tag + (format " TOOTS (containing #%s)" tag)) (t " TOOTS "))) (is-followers " FOLLOWERS ") @@ -704,8 +727,8 @@ HEADERS means also fetch link headers for pagination." (substitute-command-keys ;; "\\[mastodon-profile--account-view-cycle]" ; not always bound? "\\`C-c C-c' to cycle profile views: toots, no replies, no boosts,\ - followers, following. -\\`C-c C-s' to search user's toots.")))))) + only media, followers, following. +\\`C-c C-s' to search user's toots, \\`C-c \#' to search user's posts for a hashtag.")))))) (defun mastodon-profile--format-joined-date-string (joined) "Format a human-readable Joined string from timestamp JOINED. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index cc540f8..3504ef3 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -6,7 +6,7 @@ ;; Author: Johnson Denen <johnson.denen@gmail.com> ;; Marty Hiatt <martianhiatus@riseup.net> ;; Maintainer: Marty Hiatt <martianhiatus@riseup.net> -;; Version: 1.0.20 +;; Version: 1.0.21 ;; Package-Requires: ((emacs "27.1") (request "0.3.0") (persist "0.4")) ;; Homepage: https://codeberg.org/martianh/mastodon.el |