From 3b35b51a36976d64bc3368d6bd8cce5edb350839 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 11 Jan 2023 00:23:48 +1100 Subject: customize number of posts displayed in a timeline or account view FIXES #363 --- lisp/mastodon-profile.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 7e3262a..f96ecb5 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -621,7 +621,8 @@ FIELDS means provide a fields vector fetched by other means." NO-REBLOGS means do not display boosts in statuses. HEADERS means also fetch link headers for pagination." (let* ((id (mastodon-profile--account-field account 'id)) - (args (when no-reblogs '(("exclude_reblogs" . "t")))) + (args `(("limit" . ,mastodon-tl--timeline-posts-count))) + (args (if no-reblogs (push '("exclude_reblogs" . "t") args) args)) (endpoint (format "accounts/%s/%s" id endpoint-type)) (url (mastodon-http--api endpoint)) (acct (mastodon-profile--account-field account 'acct)) -- cgit v1.2.3 From 3ff4af19255c3da92cc87edf9dd604eed567137a Mon Sep 17 00:00:00 2001 From: mouse Date: Sat, 21 Jan 2023 09:25:32 +0100 Subject: profile--format-joined-date-string - don't use ts.el to format --- lisp/mastodon-profile.el | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index f96ecb5..ac9feba 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -740,11 +740,8 @@ HEADERS means also fetch link headers for pagination." (defun mastodon-profile--format-joined-date-string (joined) "Format a human-readable Joined string from timestamp JOINED." - (let ((joined-ts (ts-parse joined))) - (format "Joined %s" (concat (ts-month-name joined-ts) - " " - (number-to-string - (ts-year joined-ts)))))) + (format-time-string "Joined: %d %B %Y" + (parse-iso8601-time-string joined))) (defun mastodon-profile--get-toot-author () "Open profile of author of toot under point. -- cgit v1.2.3 From 3f98af1a063da1aa863530b266a69fc1361a7b88 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 28 Jan 2023 13:43:08 +0100 Subject: docstrings/flychecks --- lisp/mastodon-profile.el | 2 +- lisp/mastodon-tl.el | 14 +++++++++----- lisp/mastodon-toot.el | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index ac9feba..b15b4bb 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -363,7 +363,7 @@ Ask for confirmation if length > 500 characters." (mastodon-profile--user-profile-send-updated-do url note)))) (defun mastodon-profile--user-profile-send-updated-do (url note) - "Send PATCH request with the updated profile note." + "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!"))))) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 867318b..3c6c702 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1392,12 +1392,14 @@ Optionally get it for BUFFER." (defun mastodon-tl--get-endpoint (&optional buffer no-error) "Get the ENDPOINT stored in `mastodon-tl--buffer-spec'. -Optionally set it for BUFFER." +Optionally set it for BUFFER. +NO-ERROR means to fail silently." (mastodon-tl--get-buffer-property 'endpoint buffer no-error)) (defun mastodon-tl--buffer-name (&optional buffer no-error) "Get the BUFFER-NAME stored in `mastodon-tl--buffer-spec'. -Optionally get it for BUFFER." +Optionally get it for BUFFER. +NO-ERROR means to fail silently." (mastodon-tl--get-buffer-property 'buffer-name buffer no-error)) (defun mastodon-tl--link-header (&optional buffer) @@ -1427,7 +1429,8 @@ If NO-ERROR is non-nil, do not error when property is empty." BUFFER is buffer name, ENDPOINT is buffer's enpoint, UPDATE-FUNCTION is its update function. LINK-HEADER is the http Link header if present. -UPDATE-PARAMS is any http parameters needed for the update function." +UPDATE-PARAMS is any http parameters needed for the update function. +HIDE-REPLIES is a flag indicating if replies are hidden in the current buffer." (setq mastodon-tl--buffer-spec `(account ,(cons mastodon-active-user mastodon-instance-url) @@ -1639,7 +1642,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.") + (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)))) @@ -3001,7 +3004,8 @@ This location is defined by a non-nil value of UPDATE-FUNCTION is used to recieve more toots. HEADERS means to also collect the response headers. Used for paginating favourites and bookmarks. -PARAMS is any parameters to send with the request." +PARAMS is any parameters to send with the request. +HIDE-REPLIES is a flag indicating if replies are hidden in the current buffer." (let ((url (mastodon-http--api endpoint)) (buffer (concat "*mastodon-" buffer-name "*"))) (if headers diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index e233fba..35fe457 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -359,7 +359,7 @@ TYPE is a symbol, either 'favourite or 'boost." (error "You can't %s favourites" action-string)) ((and (equal "private" visibility) (equal type 'boost)) - (error "You can't boost private toots.")) + (error "You can't boost private toots")) (t (mastodon-toot--action action @@ -1586,7 +1586,8 @@ If REPLY-TO-USER is provided, inject their handle into the message. If REPLY-TO-ID is provided, set the `mastodon-toot--reply-to-id' var. REPLY-JSON is the full JSON of the toot being replied to. INITIAL-TEXT is used by `mastodon-toot-insert-draft-toot' to add -a draft into the buffer." +a draft into the buffer. +EDIT means we are editing an existing toot, not composing a new one." (let* ((buffer-name (if edit "*edit toot*" "*new toot*")) (buffer-exists (get-buffer buffer-name)) (buffer (or buffer-exists (get-buffer-create buffer-name))) -- cgit v1.2.3 From a47d4be15d93b99c0dd621a9b3a916be14a4cc39 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 19 Feb 2023 21:44:50 +0100 Subject: more cases to use buffer-type-eq --- lisp/mastodon-profile.el | 19 +++++++++---------- lisp/mastodon-tl.el | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index b15b4bb..b0b3e0e 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -169,15 +169,14 @@ NO-REBLOGS means do not display boosts in statuses." (defun mastodon-profile--account-view-cycle () "Cycle through profile view: toots, followers, and following." (interactive) - (let ((endpoint (plist-get mastodon-tl--buffer-spec 'endpoint))) - (cond ((string-suffix-p "statuses" endpoint) - (mastodon-profile--open-followers)) - ((string-suffix-p "followers" endpoint) - (mastodon-profile--open-following)) - ((string-suffix-p "following" endpoint) - (mastodon-profile--open-statuses-no-reblogs)) - (t - (mastodon-profile--make-author-buffer mastodon-profile--account))))) + (cond ((mastodon-tl--buffer-type-eq 'profile-statuses) + (mastodon-profile--open-followers)) + ((mastodon-tl--buffer-type-eq 'profile-followers) + (mastodon-profile--open-following)) + ((mastodon-tl--buffer-type-eq 'profile-following) + (mastodon-profile--open-statuses-no-reblogs)) + (t + (mastodon-profile--make-author-buffer mastodon-profile--account)))) (defun mastodon-profile--open-statuses-no-reblogs () "Open a profile buffer showing statuses without reblogs." @@ -761,7 +760,7 @@ IMG_TYPE is the JSON key from the account data." "Query for USER-HANDLE from current status and show that user's profile." (interactive (list - (if (and (not (string-prefix-p "accounts" (mastodon-tl--get-endpoint))) ;profile view + (if (and (not (mastodon-tl--profile-buffer-p)) (not (get-text-property (point) 'toot-json))) (message "Looks like there's no toot or user at point?") (let ((user-handles (mastodon-profile--extract-users-handles diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 96b8311..2a20e73 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1733,7 +1733,7 @@ Note that you can only (un)mute threads you have posted in." "Mute a thread. If UNMUTE, unmute it." (let ((endpoint (mastodon-tl--get-endpoint))) - (if (string-suffix-p "context" endpoint) ; thread view + (if (mastodon-tl--buffer-type-eq 'thread) (let* ((id (save-match-data (string-match "statuses/\\(?2:[[:digit:]]+\\)/context" -- cgit v1.2.3 From 4f9a7be4926dbf3f33a717fcbed12de78c22b331 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 19 Feb 2023 21:53:48 +0100 Subject: autoloads, flychecks --- lisp/mastodon-profile.el | 4 ++++ lisp/mastodon-tl.el | 1 + lisp/mastodon-toot.el | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index b0b3e0e..aa4a12e 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -78,6 +78,9 @@ (autoload 'mastodon-tl--set-buffer-spec "mastodon-tl") (autoload 'mastodon-tl--symbol "mastodon-tl") (autoload 'mastodon-auth--get-account-id "mastodon-auth") +(autoload 'mastodon-tl--profile-buffer-p "mastodon tl") +(autoload 'mastodon-tl--buffer-type-eq "mastodon tl") +(autoload 'mastodon-toot--count-toot-chars "mastodon-toot") (defvar mastodon-instance-url) (defvar mastodon-tl--buffer-spec) @@ -86,6 +89,7 @@ (defvar mastodon-toot--max-toot-chars) (defvar mastodon-toot--visibility) (defvar mastodon-toot--content-nsfw) +(defvar mastodon-tl--timeline-posts-count) (defvar-local mastodon-profile--account nil "The data for the account being described in the current profile buffer.") diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2a20e73..ba6b1df 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -87,6 +87,7 @@ (autoload 'mastodon-toot--iso-to-human "mastodon-toot") (defvar mastodon-toot--visibility) +(defvar mastodon-toot-mode) (defvar mastodon-active-user) (when (require 'mpv nil :no-error) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 250aefd..64cdca1 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -41,7 +41,6 @@ (require 'cl-lib) (require 'persist) - (require 'mastodon-iso) (defvar mastodon-instance-url) @@ -83,6 +82,9 @@ (autoload 'mastodon-tl--cancel-scheduled-toot "mastodon-toot") (autoload 'org-read-date "org") (autoload 'iso8601-parse "iso8601") +(autoload 'mastodon-tl--buffer-type-eq "mastodon-tl") +(autoload 'mastodon-profile--show-user "mastodon-profile") +(autoload 'mastodon-tl--set-buffer-spec "mastodon-tl") ;; for mastodon-toot--translate-toot-text (autoload 'mastodon-tl--content "mastodon-tl") @@ -310,7 +312,7 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." ;; if point is inside the byline, back up first so ;; we don't move to the following toot: (beginning-of-line) - (previous-line) + (forward-line -1) (mastodon-tl--goto-next-toot))))) (defun mastodon-toot--action (action callback) -- cgit v1.2.3 From 43c4ae168441f523088c8139a09e8636fff404f4 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 20 Feb 2023 19:09:20 +0100 Subject: require parse-time --- lisp/mastodon-profile.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index aa4a12e..8d8d0c7 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -39,6 +39,7 @@ (require 'cl-lib) (require 'persist) (require 'ts) +(require 'parse-time) (autoload 'mastodon-http--api "mastodon-http.el") (autoload 'mastodon-http--get-json "mastodon-http.el") -- cgit v1.2.3