From 7d08161609f6bcb1649e35c92b86e95316918fa9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 27 May 2024 22:50:41 +0200 Subject: add view-item-on-own-instance fun --- lisp/mastodon-tl.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index db923a4..ed6cfcc 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -473,7 +473,10 @@ You can enter any working instance domain. Domains that you want to regularly load can be stored in `mastodon-tl--remote-local-domains' for easy access with completion. Note that some instances do not make their local timelines public, in -which case this will not work." +which case this will not work. +To interact with any item, you must view it from your own +instance, which you can do with +`mastodon-tl--view-item-on-own-instance'." (interactive) (let* ((domain (completing-read "Domain for remote local tl: " mastodon-tl--remote-local-domains)) @@ -496,6 +499,15 @@ which case this will not work." "timelines/public" 'mastodon-tl--timeline nil params nil domain)))) +(defun mastodon-tl--view-item-on-own-instance () + "Load current toot on your own instance. +Use this to re-load remote-local items in order to interact with them." + (interactive) + (mastodon-tl--do-if-item + (let* ((toot (mastodon-tl--property 'item-json)) + (uri (mastodon-tl--field 'uri toot))) + (mastodon-url-lookup uri)))) + (defun mastodon-tl--get-local-timeline (&optional prefix) "Open local timeline. With a single PREFIX arg, hide-replies. -- cgit v1.2.3 From b6aa12f8e0c3ce0826ce656bf789df8793d5b1e9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 May 2024 19:01:35 +0200 Subject: filter post by language fix docstring --- lisp/mastodon-tl.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index ed6cfcc..a33be2e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2093,9 +2093,11 @@ display of 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 -the instance API." + "Query for USER-HANDLE and filter display of their posts by language. +If they are not already followed, they will be too. +To be filtered, a post has to be marked as in the language given. +This may mean that you will not see posts that are in your +desired language if they are not marked as such (or as anything)." (interactive (list (mastodon-tl--user-handles-get "filter by language"))) (let ((langs (mastodon-tl--read-filter-langs))) -- cgit v1.2.3 From 8e3b3ebb07a485f4f5e04ebaf49417bbdf0e6685 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 May 2024 19:02:02 +0200 Subject: get-source-pref > get-source-value --- lisp/mastodon-toot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 864d767..3eadf91 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1881,7 +1881,7 @@ EDIT means we are editing an existing toot, not composing a new one." (setq mastodon-toot--visibility (or (plist-get mastodon-profile-account-settings 'privacy) ;; use toot visibility setting from the server: - (mastodon-profile--get-source-pref 'privacy) + (mastodon-profile--get-source-value 'privacy) "public")) ; fallback (if mastodon-toot-display-orig-in-reply-buffer (progn -- cgit v1.2.3 From fa54e20779d0f2420fe8d59ab44fdc05942f494f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 May 2024 19:02:17 +0200 Subject: account settings var docstring. --- lisp/mastodon-profile.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 31a1983..98ac9de 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -130,7 +130,10 @@ It contains details of the current user's account.") Other clients can change these settings on the server at any time, so this list is not the canonical source for settings. It is updated on entering mastodon mode and on toggle any setting it -contains") +contains. +This variable is set from data in +`mastodon-profile-credential-account' not +`mastodon-profile-account-preferences-data'.") (define-minor-mode mastodon-profile-update-mode "Minor mode to update user profile." -- cgit v1.2.3 From 0bebd58588720537b5b9d949035d4f25db0b1dbc Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 May 2024 19:02:38 +0200 Subject: set default language in compose buffer from is set from mastodon-profile-acccount-preferences-data --- lisp/mastodon-toot.el | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 3eadf91..f17cc85 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1878,11 +1878,20 @@ EDIT means we are editing an existing toot, not composing a new one." (switch-to-buffer-other-window buffer) (text-mode) (mastodon-toot-mode t) + ;; set visibility: (setq mastodon-toot--visibility (or (plist-get mastodon-profile-account-settings 'privacy) ;; use toot visibility setting from the server: (mastodon-profile--get-source-value 'privacy) "public")) ; fallback + ;; default language: + ;; NB: this is not necessarily set in + ;; `mastodon-profile-credential-account' nor in + ;; `mastodon-profile-account-settings'! + (setq mastodon-toot--language + (alist-get 'posting:default:language + mastodon-profile-acccount-preferences-data)) + ;; display original toot: (if mastodon-toot-display-orig-in-reply-buffer (progn (mastodon-toot--display-docs-and-status-fields reply-text) -- cgit v1.2.3 From 355e1814be2496dfad9a23e07c5614b808cff2bd Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 May 2024 20:02:16 +0200 Subject: refactor remote-local domain checks --- lisp/mastodon-tl.el | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index a33be2e..eba7146 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -488,13 +488,9 @@ instance, which you can do with (mastodon-http--api "instance/peers"))))) ;; condition-case doesn't work here, so i added basic error handling to ;; `mastodon-tl--init*' instead - (if (not known) - (when (y-or-n-p - "Domain appears unknown to your instance. Proceed?") - ;; TODO: refactor these calls: - (mastodon-tl--init buf - "timelines/public" 'mastodon-tl--timeline nil - params nil domain)) + (when (or known + (y-or-n-p + "Domain appears unknown to your instance. Proceed?")) (mastodon-tl--init buf "timelines/public" 'mastodon-tl--timeline nil params nil domain)))) -- cgit v1.2.3 From e17cb2e2393981ad980d52b33c4ffd2f47c7f8cd Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 May 2024 20:16:31 +0200 Subject: docstrings --- lisp/mastodon-notifications.el | 6 ++---- lisp/mastodon-tl.el | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 9b40861..c26d0b0 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -59,13 +59,11 @@ :group 'mastodon) (defcustom mastodon-notifications--profile-note-in-foll-reqs t - "When non-nil, show some of a user's profile note in follow -request notifications." + "If non-nil, show a user's profile note in follow request notifications." :type '(boolean)) (defcustom mastodon-notifications--profile-note-in-foll-reqs-max-length nil - "The maximum character length for display of user profile note in -follow requests. + "The max character length for user profile note in follow requests. Profile notes are only displayed if `mastodon-notifications--profile-note-in-foll-reqs' is non-nil. If unset, profile notes of any size will be displayed, which may diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index eba7146..2d81160 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -213,7 +213,8 @@ respects the user's `browse-url' settings." :type '(boolean)) (defcustom mastodon-tl--remote-local-domains nil - "A list of domains to view the local timelines of using `mastodon-tl--get-remote-local-timeline'." + "A list of domains to view the local timelines of. +See `mastodon-tl--get-remote-local-timeline' for view remote local domains." :type '(repeat string)) -- cgit v1.2.3 From c194bfd5af1ac1ef77caf17022ae9555033b3e90 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 May 2024 20:19:36 +0200 Subject: autoloads --- lisp/mastodon-toot.el | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index f17cc85..89b1eec 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -50,6 +50,7 @@ (defvar mastodon-tl--buffer-spec) (defvar mastodon-tl--enable-proportional-fonts) (defvar mastodon-profile-account-settings) +(defvar mastodon-profile-acccount-preferences-data) (autoload 'iso8601-parse "iso8601") (autoload 'mastodon-auth--user-acct "mastodon-auth") @@ -92,6 +93,8 @@ (autoload 'mastodon-views--view-scheduled-toots "mastodon-views") (autoload 'org-read-date "org") (autoload 'mastodon-tl--toot-or-base "mastodon-tl") +(autoload 'mastodon-profile--get-source-value "mastodon-toot") +(autoload 'mastodon-tl--get-buffer-type "mastodon-tl") ;; for mastodon-toot--translate-toot-text (autoload 'mastodon-tl--content "mastodon-tl") -- cgit v1.2.3 From c688fd0b6eaa02b9fe0232fed860dd4d846bebdb Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 28 May 2024 20:38:19 +0200 Subject: fix setting lang un toot compose buffer --- lisp/mastodon-profile.el | 2 +- lisp/mastodon-toot.el | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 98ac9de..712d447 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -501,7 +501,7 @@ Returns the results as an alist." "Limit string X to 255 chars max." (if (> (length x) 255) (substring x 0 255) x)) -;; used in tl.el +;; used in tl.el and toot.el: (defun mastodon-profile--get-preferences-pref (pref) "Fetch PREF from the endpoint \"/preferences\". If `mastodon-profile-acccount-preferences-data' is set, fetch diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 89b1eec..654918c 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1892,8 +1892,7 @@ EDIT means we are editing an existing toot, not composing a new one." ;; `mastodon-profile-credential-account' nor in ;; `mastodon-profile-account-settings'! (setq mastodon-toot--language - (alist-get 'posting:default:language - mastodon-profile-acccount-preferences-data)) + (mastodon-profile--get-preferences-pref 'posting:default:language)) ;; display original toot: (if mastodon-toot-display-orig-in-reply-buffer (progn -- cgit v1.2.3 From 040c69ad67a380482fff36335bbe975c36c99cdb Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 29 May 2024 13:49:12 +0200 Subject: display filtered follow langs on user profiles. FIX #559. --- lisp/mastodon-profile.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 712d447..46a56f6 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -700,12 +700,20 @@ TAG is a hashtag to restrict posts to." 'success) ;; insert relationship (follows) (let-alist relationships - (let ((followsp (mastodon-profile--follows-p - (list .requested_by .following .followed_by)))) + (let* ((followsp (mastodon-profile--follows-p + (list .requested_by .following .followed_by))) + (rels (mastodon-profile--relationships-get .id)) + (langs-filtered (if-let ((langs (alist-get 'languages rels))) + (concat " (" + (mapconcat #'identity + langs + " ") + ")") + ""))) (if followsp (mastodon-tl--set-face (concat (when (equal .following 't) - " | FOLLOWED BY YOU") + (format " | FOLLOWED BY YOU%s" langs-filtered)) (when (equal .followed_by 't) " | FOLLOWS YOU") (when (equal .requested_by 't) -- cgit v1.2.3 From 87dfd9bd20692475a9ffa783566a74ef21525835 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 29 May 2024 15:04:46 +0200 Subject: not working unfilter user langs. adds json flag arg through action funs --- lisp/mastodon-http.el | 2 +- lisp/mastodon-tl.el | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 7ef6f77..5065ee5 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -141,7 +141,7 @@ Used for API form data parameters that take an array." &optional params headers unauthenticated-p json) "POST synchronously to URL, optionally with PARAMS and HEADERS. Authorization header is included by default unless -UNAUTHENTICATED-P is non-nil.If JSON, encode PARAMS as JSON for +UNAUTHENTICATED-P is non-nil. If JSON, encode PARAMS as JSON for the request data." (mastodon-http--authorized-request "POST" (let* ((url-request-data diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2d81160..7fd7f98 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2045,7 +2045,8 @@ 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 reblogs) +(defun mastodon-tl--follow-user (user-handle + &optional notify langs reblogs json) "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. @@ -2057,7 +2058,7 @@ display of the user's boosts in your timeline." (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 reblogs))) + user-handle "follow" nil notify langs reblogs json))) ;; TODO: make this action "enable/disable notifications" (defun mastodon-tl--enable-notify-user-posts (user-handle) @@ -2101,6 +2102,15 @@ desired language if they are not marked as such (or as anything)." (mastodon-tl--do-if-item (mastodon-tl--follow-user user-handle nil langs)))) +(defun mastodon-tl--unfilter-user-languages (user-handle) + "" + (interactive + (list (mastodon-tl--user-handles-get "filter by language"))) + (let ((langs "languages[]")) + (mastodon-tl--do-if-item + ;; we need ("languages[]") as a param, with no "=" + (mastodon-tl--follow-user user-handle nil langs nil :json)))) + (defun mastodon-tl--read-filter-langs (&optional langs) "Read language choices and return an alist array parameter. LANGS is the accumulated array param alist if we re-run recursively." @@ -2215,7 +2225,7 @@ 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 reblogs) + (user-handle action &optional negp notify langs reblogs json) "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. @@ -2245,18 +2255,18 @@ display of the user's boosts in your timeline." (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 reblogs) + (mastodon-tl--do-user-action-function url name user-handle action notify args reblogs json) (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 reblogs) + (url name user-handle action &optional notify args reblogs json) "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. ARGS is an alist of any parameters to send with the request." - (let ((response (mastodon-http--post url args))) + (let ((response (mastodon-http--post url args nil nil json))) (mastodon-http--triage response (lambda (response) -- cgit v1.2.3 From 9d043ea3fbb8f2b8d162329b570a84f4790fc6f6 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 29 May 2024 15:37:35 +0200 Subject: unfilter langs: POST raw params and it works! --- lisp/mastodon-http.el | 16 +++++++++++----- lisp/mastodon-tl.el | 4 +++- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 5065ee5..4721087 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -141,14 +141,20 @@ Used for API form data parameters that take an array." &optional params headers unauthenticated-p json) "POST synchronously to URL, optionally with PARAMS and HEADERS. Authorization header is included by default unless -UNAUTHENTICATED-P is non-nil. If JSON, encode PARAMS as JSON for -the request data." +UNAUTHENTICATED-P is non-nil. + +If JSON is :json, encode PARAMS as JSON for +the request data. If it is :raw, just use the plain params." (mastodon-http--authorized-request "POST" (let* ((url-request-data (when params - (if json - (json-encode params) - (mastodon-http--build-params-string params)))) + (cond ((eq json :json) + (json-encode + params)) + ((eq json :raw) + params) + (t + (mastodon-http--build-params-string params))))) (url-request-extra-headers (append url-request-extra-headers ; auth set in macro (unless (assoc "Content-Type" headers) ; pleroma compat: diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 7fd7f98..3d33e86 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2109,7 +2109,7 @@ desired language if they are not marked as such (or as anything)." (let ((langs "languages[]")) (mastodon-tl--do-if-item ;; we need ("languages[]") as a param, with no "=" - (mastodon-tl--follow-user user-handle nil langs nil :json)))) + (mastodon-tl--follow-user user-handle nil langs nil :raw)))) (defun mastodon-tl--read-filter-langs (&optional langs) "Read language choices and return an alist array parameter. @@ -2292,6 +2292,8 @@ ARGS is an alist of any parameters to send with the request." ((or (string-equal action "mute") (string-equal action "unmute")) (message "User %s (@%s) %sd!" name user-handle action)) + ((equal args "languages[]") + (message "User %s language filters removed!" name)) ((assoc "languages[]" args #'equal) (message "User %s filtered by language(s): %s" name (mapconcat #'cdr args " "))) -- cgit v1.2.3 From 9785650845b3f1d988b080ff14e166bbd390863e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 29 May 2024 15:56:31 +0200 Subject: docstring and index --- lisp/mastodon-http.el | 3 ++- lisp/mastodon-tl.el | 7 +++++-- mastodon-index.org | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 4721087..60654ff 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -142,9 +142,10 @@ Used for API form data parameters that take an array." "POST synchronously to URL, optionally with PARAMS and HEADERS. Authorization header is included by default unless UNAUTHENTICATED-P is non-nil. - If JSON is :json, encode PARAMS as JSON for the request data. If it is :raw, just use the plain params." + ;; NB: raw is used by `mastodon-tl--unfilter-user-languages'; not sure if + ;; there's a way around it? (mastodon-http--authorized-request "POST" (let* ((url-request-data (when params diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 3d33e86..67e13b6 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2103,12 +2103,15 @@ desired language if they are not marked as such (or as anything)." (mastodon-tl--follow-user user-handle nil langs)))) (defun mastodon-tl--unfilter-user-languages (user-handle) - "" + "Remove any language filters for USER-HANDLE. +This means you will receive posts of theirs marked as being in +any or no language." (interactive (list (mastodon-tl--user-handles-get "filter by language"))) (let ((langs "languages[]")) (mastodon-tl--do-if-item - ;; we need ("languages[]") as a param, with no "=" + ;; we need "languages[]" as a param, with no "=" and not json-encoded as + ;; a string (mastodon-tl--follow-user user-handle nil langs nil :raw)))) (defun mastodon-tl--read-filter-langs (&optional langs) diff --git a/mastodon-index.org b/mastodon-index.org index 0e0d739..4dd5ae3 100644 --- a/mastodon-index.org +++ b/mastodon-index.org @@ -140,7 +140,7 @@ | | mastodon-tl--toggle-spoiler-in-thread | Toggler content warning for all posts in current thread. | | c | mastodon-tl--toggle-spoiler-text-in-toot | Toggle the visibility of the spoiler text in the current toot. | | C-S-b | mastodon-tl--unblock-user | Query for USER-HANDLE from list of blocked users and unblock that user. | -| | mastodon-tl--unfilter-user-languages | | +| | mastodon-tl--unfilter-user-languages | Remove any language filters for USER-HANDLE. | | | mastodon-tl--unfollow-tag | Prompt for a followed tag, and unfollow it. | | C-S-w | mastodon-tl--unfollow-user | Query for USER-HANDLE from current status and unfollow that user. | | | mastodon-tl--unmute-thread | Mute the thread displayed in the current buffer. | -- cgit v1.2.3 From 89a166d1a217c7f86fdc48c651b2cd29100ed5c4 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 30 May 2024 10:44:55 +0200 Subject: \ binding for remote local tl --- lisp/mastodon.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 6eac3d8..da3ffe2 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -175,6 +175,7 @@ Use. e.g. \"%c\" for your locale's date and time format." (define-key map (kbd "P") #'mastodon-profile--show-user) (define-key map (kbd "s") #'mastodon-search--query) (define-key map (kbd "/") #'mastodon-switch-to-buffer) + (define-key map (kbd "\\") #'mastodon-tl--get-remote-local-timeline) ;; quitting mastodon (define-key map (kbd "q") #'kill-current-buffer) (define-key map (kbd "Q") #'mastodon-kill-window) -- cgit v1.2.3 From cbd1038eaf6fd353dca6edc950180398012da1f5 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 30 May 2024 21:51:30 +0200 Subject: add fallback to tl--init*: if no results, try trending statuses. FIX #562 --- lisp/mastodon-tl.el | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 67e13b6..bbc4b62 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -88,6 +88,7 @@ (autoload 'mastodon-http--get-response "mastodon-http") (autoload 'mastodon-search--insert-heading "mastodon-search") (autoload 'mastodon-media--process-full-sized-image-response "mastodon-media") +(autoload 'mastodon-search--trending-statuses "mastodon-search") (defvar mastodon-toot--visibility) (defvar mastodon-toot-mode) @@ -2053,7 +2054,8 @@ If NOTIFY is \"false\", disable notifications when that user posts. 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. REBLOGS is a boolean string like NOTIFY, enabling or disabling -display of the user's boosts in your timeline." +display of the user's boosts in your timeline. +JSON is a flag arg for `mastodon-http--post'." (interactive (list (mastodon-tl--user-handles-get "follow"))) (mastodon-tl--do-if-item @@ -2894,7 +2896,17 @@ RESPONSE is the data returned from the server by JSON and http headers, without it just the JSON." (let ((json (if headers (car response) response))) (cond ((not json) ; praying this is right here, else try "\n[]" - (message "Looks like nothing returned from endpoint: %s" endpoint)) + ;; this means that whatever tl was inited won't load, which is not + ;; always wanted, as sometimes you still need the page to load so + ;; you can be in eg mastodon-mode, have keymap, search etc. + (message "Looks like nothing returned from endpoint: %s" endpoint) + ;; if we are a new account, home tl may have nothing, but then + ;; this clause means we can never load mastodon.el at all! + ;; so as a fallback, load trending statuses: + ;; FIXME: this could possibly be a fallback for all timelines not + ;; just home? + (when (equal endpoint "timelines/home") + (mastodon-search--trending-statuses))) ((eq (caar json) 'error) (user-error "Looks like the server bugged out: \"%s\"" (cdar json))) (t -- cgit v1.2.3 From 0312b494a685af358005cc2ed6245f8438db8c31 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 31 May 2024 09:11:43 +0200 Subject: add unfilter user filter langs option to filter user langs --- lisp/mastodon-tl.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index bbc4b62..aa70507 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2102,7 +2102,9 @@ desired language if they are not marked as such (or as anything)." (list (mastodon-tl--user-handles-get "filter by language"))) (let ((langs (mastodon-tl--read-filter-langs))) (mastodon-tl--do-if-item - (mastodon-tl--follow-user user-handle nil langs)))) + (if (equal "" (cdar langs)) + (mastodon-tl--unfilter-user-languages user-handle) + (mastodon-tl--follow-user user-handle nil langs))))) (defun mastodon-tl--unfilter-user-languages (user-handle) "Remove any language filters for USER-HANDLE. @@ -2119,12 +2121,14 @@ any or no language." (defun mastodon-tl--read-filter-langs (&optional langs) "Read language choices and return an alist array parameter. LANGS is the accumulated array param alist if we re-run recursively." - (let* ((langs-alist langs) + (let* ((iso-const mastodon-iso-639-1) + (iso (cons '("None (all)" . "") iso-const)) + (langs-alist langs) (choice (completing-read "Filter user's posts by language: " - mastodon-iso-639-1))) + iso))) (when choice (setq langs-alist - (push `("languages[]" . ,(alist-get choice mastodon-iso-639-1 + (push `("languages[]" . ,(alist-get choice iso nil nil #'string=)) langs-alist)) (if (y-or-n-p "Filter by another language? ") -- cgit v1.2.3 From ac5684acaa2c0910350a5a79977b28dea8ddf8d7 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 31 May 2024 14:12:40 +0200 Subject: bump version --- lisp/mastodon.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index da3ffe2..a0b5bbc 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -6,7 +6,7 @@ ;; Author: Johnson Denen ;; Marty Hiatt ;; Maintainer: Marty Hiatt -;; Version: 1.0.22 +;; Version: 1.0.23 ;; Package-Requires: ((emacs "27.1") (request "0.3.0") (persist "0.4")) ;; Homepage: https://codeberg.org/martianh/mastodon.el -- cgit v1.2.3