From 3a3371d7f98f3097fb2b294b3a409d2a0d0f1bb8 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 27 Mar 2023 12:17:03 +0200 Subject: tl--update: make message the else clause of if json (parens) --- lisp/mastodon-tl.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index fbee377..690a98e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2346,8 +2346,8 @@ This location is defined by a non-nil value of (goto-char (or mastodon-tl--update-point (point-min))) (funcall update-function json) (when mastodon-tl--after-update-marker - (goto-char mastodon-tl--after-update-marker)))) - (message "nothing to update"))))) + (goto-char mastodon-tl--after-update-marker))) + (message "nothing to update")))))) ;;; LOADING TIMELINES -- cgit v1.2.3 From 5a3a6dcbadb60e4794733f8e26dc3c8d1f5c187c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 27 Mar 2023 12:17:35 +0200 Subject: add force arg to notifs-get, and use it in reload-timeline- --- lisp/mastodon-tl.el | 2 +- lisp/mastodon.el | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 690a98e..d041b2f 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2086,7 +2086,7 @@ For use after e.g. deleting a toot." ((mastodon-tl--buffer-type-eq 'local) (mastodon-tl--get-local-timeline)) ((mastodon-tl--buffer-type-eq 'notifications) - (mastodon-notifications-get)) + (mastodon-notifications-get nil nil :force)) ((mastodon-tl--buffer-type-eq 'own-profile) (mastodon-profile--my-profile)) ((save-match-data diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 5f7034e..a78685e 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -275,15 +275,18 @@ If REPLY-JSON is the json of the toot being replied to." (mastodon-toot--compose-buffer user reply-to-id reply-json)) ;;;###autoload -(defun mastodon-notifications-get (&optional type buffer-name) +(defun mastodon-notifications-get (&optional type buffer-name force) "Display NOTIFICATIONS in buffer. Optionally only print notifications of type TYPE, a string. -BUFFER-NAME is added to \"*mastodon-\" to create the buffer name." +BUFFER-NAME is added to \"*mastodon-\" to create the buffer name. +FORCE means do not try to update an existing buffer, but fetch +from the server and load anew." (interactive) (let ((buffer (if buffer-name (concat "*mastodon-" buffer-name "*") "*mastodon-notifications*"))) - (if (get-buffer buffer) + (if (and (not force) + (get-buffer buffer)) (progn (switch-to-buffer buffer) (mastodon-tl--update)) (message "Loading your notifications...") -- cgit v1.2.3 From cd44f7807ffea4ecb86f07bfd160f9416908eb5d Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 27 Mar 2023 12:22:11 +0200 Subject: remove all ;; Package-Requires: declarations save for main file main file is set in .dir-locals.el now --- lisp/mastodon-auth.el | 1 - lisp/mastodon-client.el | 1 - lisp/mastodon-discover.el | 1 - lisp/mastodon-http.el | 1 - lisp/mastodon-media.el | 1 - lisp/mastodon-notifications.el | 1 - lisp/mastodon-search.el | 1 - lisp/mastodon-tl.el | 1 - lisp/mastodon-toot.el | 1 - lisp/mastodon-views.el | 1 - 10 files changed, 10 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index ec56a05..0db8a19 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -5,7 +5,6 @@ ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index 5981a26..b358ed7 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -5,7 +5,6 @@ ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-discover.el b/lisp/mastodon-discover.el index 958df92..c06de1f 100644 --- a/lisp/mastodon-discover.el +++ b/lisp/mastodon-discover.el @@ -6,7 +6,6 @@ ;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 3632a11..49ffbf8 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -6,7 +6,6 @@ ;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1") (request "0.3.0")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index 63860bd..4d36f47 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -6,7 +6,6 @@ ;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 22228f2..fd48a65 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -6,7 +6,6 @@ ;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 3555238..e8ab093 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -4,7 +4,6 @@ ;; Author: Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d041b2f..3885220 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -6,7 +6,6 @@ ;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1") (ts "0.3")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 65fc357..dfc02ee 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -6,7 +6,6 @@ ;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1") (persist "0.4")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el index 75f34d3..558bf81 100644 --- a/lisp/mastodon-views.el +++ b/lisp/mastodon-views.el @@ -4,7 +4,6 @@ ;; Author: Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. -- cgit v1.2.3 From d1ffaca6e21b988255d1b980a9de6bb1d976e1af Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 27 Mar 2023 15:14:48 +0200 Subject: work on reloading a view after sending an edited toot. FIX #421. - fix up reload-timeline-or-profile - additions to --send for edited toots position of point is only rough, chosen from buffer point prior to reload, but buffers change on reload (things added if timeline, things removed if delete toot or clear notif. we may need to find a much better way. --- lisp/mastodon-tl.el | 47 +++++++++++++++++++++++++++++------------------ lisp/mastodon-toot.el | 34 +++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 33 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 3885220..c0c7e5e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2075,25 +2075,36 @@ the current view." (mastodon-http--get-json url args))) ;; TODO: add this to new posts in some cases, e.g. in thread view. -(defun mastodon-tl--reload-timeline-or-profile () +(defun mastodon-tl--reload-timeline-or-profile (&optional pos) "Reload the current timeline or profile page. -For use after e.g. deleting a toot." - (cond ((mastodon-tl--buffer-type-eq 'home) - (mastodon-tl--get-home-timeline)) - ((mastodon-tl--buffer-type-eq 'federated) - (mastodon-tl--get-federated-timeline)) - ((mastodon-tl--buffer-type-eq 'local) - (mastodon-tl--get-local-timeline)) - ((mastodon-tl--buffer-type-eq 'notifications) - (mastodon-notifications-get nil nil :force)) - ((mastodon-tl--buffer-type-eq 'own-profile) - (mastodon-profile--my-profile)) - ((save-match-data - (string-match - "statuses/\\(?2:[[:digit:]]+\\)/context" - (mastodon-tl--get-endpoint)) - (mastodon-tl--thread - (match-string 2 (mastodon-tl--get-endpoint))))))) +For use after e.g. deleting a toot. +POS is a number, where point will be placed." + (let ((type (mastodon-tl--get-buffer-type))) + (cond ((eq type 'home) + (mastodon-tl--get-home-timeline)) + ((eq type 'federated) + (mastodon-tl--get-federated-timeline)) + ((eq type 'local) + (mastodon-tl--get-local-timeline)) + ((eq type 'mentions) + (mastodon-notifications--get-mentions)) + ((eq type 'notifications) + (mastodon-notifications-get nil nil :force)) + ((eq type 'profile-statuses-no-boosts) + (mastodon-profile--open-statuses-no-reblogs)) + ((eq type 'profile-statuses) + (mastodon-profile--my-profile)) + ((eq type 'thread) + (save-match-data + (let ((endpoint (mastodon-tl--get-endpoint))) + (string-match + "statuses/\\(?2:[[:digit:]]+\\)/context" + endpoint) + (mastodon-tl--thread + (match-string 2 endpoint)))))) + ;; TODO: sends point to POS, which was where point was in buffer before reload. This is very rough; we may have removed an item (deleted a toot, cleared a notif), so the buffer will be smaller, point will end up past where we were, etc. + (when pos + (goto-char pos)))) (defun mastodon-tl--build-link-header-url (str) "Return a URL from STR, an http Link header." diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index dfc02ee..81185e8 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -773,11 +773,12 @@ instance to edit a toot." (let* ((toot (mastodon-toot--remove-docs)) (scheduled mastodon-toot--scheduled-for) (scheduled-id mastodon-toot--scheduled-id) + (edit-id mastodon-toot--edit-toot-id) (endpoint - (if mastodon-toot--edit-toot-id + (if edit-id ;; we are sending an edit: (mastodon-http--api (format "statuses/%s" - mastodon-toot--edit-toot-id)) + edit-id)) (mastodon-http--api "statuses"))) (spoiler (when (and (not (mastodon-toot--empty-p)) mastodon-toot--content-warning) @@ -819,22 +820,25 @@ instance to edit a toot." ((mastodon-toot--empty-p) (message "Empty toot. Cowardly refusing to post this.")) (t - (let ((response (if mastodon-toot--edit-toot-id + (let ((response (if edit-id ;; we are sending an edit: (mastodon-http--put endpoint args) (mastodon-http--post endpoint args)))) - (mastodon-http--triage response - (lambda () - (mastodon-toot--kill) - (if scheduled - (message "Toot scheduled!") - (message "Toot toot!")) - ;; cancel scheduled toot if we were editing it: - (when scheduled-id - (mastodon-views--cancel-scheduled-toot - scheduled-id :no-confirm)) - (mastodon-toot--restore-previous-window-config - prev-window-config)))))))) + (mastodon-http--triage + response + (lambda () + (mastodon-toot--kill) + (if scheduled + (message "Toot scheduled!") + (message "Toot toot!")) + ;; cancel scheduled toot if we were editing it: + (when scheduled-id + (mastodon-views--cancel-scheduled-toot + scheduled-id :no-confirm)) + (mastodon-toot--restore-previous-window-config prev-window-config) + (when edit-id + (let ((pos (marker-position (cadr prev-window-config)))) + (mastodon-tl--reload-timeline-or-profile pos)))))))))) ;; EDITING TOOTS: -- cgit v1.2.3 From 2c3b1259852be0d3ca16e8c3c294c540f53b4bd6 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 27 Mar 2023 15:17:39 +0200 Subject: tl autoloads --- lisp/mastodon-tl.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index c0c7e5e..e07d3dd 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -39,6 +39,9 @@ (require 'mastodon-iso) (require 'mpv nil :no-error) +(autoload 'mastodon-mode "mastodon") +(autoload 'mastodon-notifications-get "mastodon") +(autoload 'mastodon-url-lookup "mastodon") (autoload 'mastodon-auth--get-account-id "mastodon-auth") (autoload 'mastodon-auth--get-account-name "mastodon-auth") (autoload 'mastodon-http--api "mastodon-http") @@ -55,10 +58,8 @@ (autoload 'mastodon-media--get-avatar-rendering "mastodon-media") (autoload 'mastodon-media--get-media-link-rendering "mastodon-media") (autoload 'mastodon-media--inline-images "mastodon-media") -(autoload 'mastodon-mode "mastodon") (autoload 'mastodon-notifications--filter-types-list "mastodon-notifications") -(autoload 'mastodon-notifications-get "mastodon-notifications" - "Display NOTIFICATIONS in buffer." t) ; interactive +(autoload 'mastodon-notifications--get-mentions "mastodon-notifications") (autoload 'mastodon-profile--account-field "mastodon-profile") (autoload 'mastodon-profile--account-from-id "mastodon-profile") (autoload 'mastodon-profile--extract-users-handles "mastodon-profile") @@ -67,6 +68,7 @@ (autoload 'mastodon-profile--lookup-account-in-status "mastodon-profile") (autoload 'mastodon-profile--make-author-buffer "mastodon-profile") (autoload 'mastodon-profile--my-profile "mastodon-profile") +(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") @@ -82,7 +84,6 @@ (autoload 'mastodon-toot--schedule-toot "mastodon-toot") (autoload 'mastodon-toot--set-toot-properties "mastodon-toot") (autoload 'mastodon-toot--update-status-fields "mastodon-toot") -(autoload 'mastodon-url-lookup "mastodon") (defvar mastodon-toot--visibility) (defvar mastodon-toot-mode) -- cgit v1.2.3 From 557c7f938ba3326e9051c837ad9aa33cc1d13169 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 27 Mar 2023 20:56:19 +0200 Subject: try moving to prev item after moving to POS on reload after action --- lisp/mastodon-tl.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index e07d3dd..fe86c7e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2105,7 +2105,8 @@ POS is a number, where point will be placed." (match-string 2 endpoint)))))) ;; TODO: sends point to POS, which was where point was in buffer before reload. This is very rough; we may have removed an item (deleted a toot, cleared a notif), so the buffer will be smaller, point will end up past where we were, etc. (when pos - (goto-char pos)))) + (goto-char pos) + (mastodon-tl--goto-prev-item)))) (defun mastodon-tl--build-link-header-url (str) "Return a URL from STR, an http Link header." -- cgit v1.2.3 From d599eda11f539236238e018d29757b4253cef334 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 29 Mar 2023 13:37:48 +0200 Subject: user-handles-get: return immediately if only one candidate FIX #420. --- lisp/mastodon-tl.el | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index fe86c7e..36539d3 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1921,13 +1921,16 @@ LANGS is the accumulated array param alist if we re-run recursively." (t (mastodon-profile--extract-users-handles (mastodon-profile--toot-json)))))) - (completing-read (if (or (equal action "disable") - (equal action "enable")) - (format "%s notifications when user posts: " action) - (format "Handle of user to %s: " action)) - user-handles - nil ; predicate - 'confirm)))) + ;; return immediately if only 1 handle: + (if (eq 1 (length user-handles)) + (car user-handles) + (completing-read (if (or (equal action "disable") + (equal action "enable")) + (format "%s notifications when user posts: " action) + (format "Handle of user to %s: " action)) + user-handles + nil ; predicate + 'confirm))))) (defun mastodon-tl--interactive-blocks-or-mutes-list-get (action) "Fetch the list of accounts for ACTION from the server. -- cgit v1.2.3 From 6362152c6553385ba4916e4091e0b5cccf25425e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 1 Apr 2023 09:53:24 +0200 Subject: add trending types to -get-buffer-type. FIX #427. --- lisp/mastodon-tl.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 36539d3..05189a2 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1490,8 +1490,13 @@ call this function after it is set or use something else." ;; search ((string-suffix-p "search" endpoint-fun) 'search) - ((string-suffix-p "trends" endpoint-fun) + ;; trends + ((equal "api/v1/trends/statuses" endpoint-fun) + 'trending-statuses) + ((equal "api/v1/trends/tags" endpoint-fun) 'trending-tags) + ((equal "api/v1/trends/links" endpoint-fun) + 'trending-links) ;; User's views: ((string= "filters" endpoint-fun) 'filters) -- cgit v1.2.3 From 4ef17374f084c5039d759682a192e87319d45114 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 1 Apr 2023 12:36:54 +0200 Subject: only_media tl arg: dbl prefix. --- lisp/mastodon-tl.el | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 05189a2..96f8f10 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -348,33 +348,41 @@ Used on initializing a timeline or thread." ;;; TIMELINES -(defun mastodon-tl--get-federated-timeline () - "Opens federated timeline." +(defun mastodon-tl--get-federated-timeline (&optional local) + "Open federated timeline. +If LOCAL, get only local timeline. +With a single prefix arg (C-u), hide-replies. +With a double prefix arg (C-u C-u), only show posts with media." (interactive) (message "Loading federated timeline...") (mastodon-tl--init - "federated" "timelines/public" 'mastodon-tl--timeline nil - `(("limit" . ,mastodon-tl--timeline-posts-count)) - (when current-prefix-arg t))) + (if local "local" "federated") + "timelines/public" 'mastodon-tl--timeline nil + `(("limit" . ,mastodon-tl--timeline-posts-count) + ,(when (eq (car current-prefix-arg) 16) + '("only_media" . "true")) + ,(when local + '("local" . "true"))) + (when (eq (car current-prefix-arg) 4) t))) (defun mastodon-tl--get-home-timeline () - "Opens home timeline." + "Open home timeline. +With a single prefix arg (C-u), hide-replies." (interactive) - (message "Loading home timeline...") - (mastodon-tl--init - "home" "timelines/home" 'mastodon-tl--timeline nil - `(("limit" . ,mastodon-tl--timeline-posts-count)) - (when current-prefix-arg t))) + (let ((params )) + (message "Loading home timeline...") + (mastodon-tl--init + "home" "timelines/home" 'mastodon-tl--timeline nil + `(("limit" . ,mastodon-tl--timeline-posts-count)) + (when (eq (car current-prefix-arg) 4) t)))) (defun mastodon-tl--get-local-timeline () - "Opens local timeline." + "Open local timeline. +With a single prefix arg (C-u), hide-replies. +With a double prefix arg (C-u C-u), only show posts with media." (interactive) (message "Loading local timeline...") - (mastodon-tl--init - "local" "timelines/public" 'mastodon-tl--timeline - nil `(("local" . "true") - ("limit" . ,mastodon-tl--timeline-posts-count)) - (when current-prefix-arg t))) + (mastodon-tl--get-federated-timeline :local)) (defun mastodon-tl--get-tag-timeline (&optional tag) "Prompt for tag and opens its timeline. -- cgit v1.2.3 From 5d54bf51a681e0a417983e983d163fd2386ad9b3 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 1 Apr 2023 13:04:43 +0200 Subject: clean up of timeline funs and their prefix args. FIX #379. --- lisp/mastodon-tl.el | 60 +++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 96f8f10..2f45336 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -348,41 +348,43 @@ Used on initializing a timeline or thread." ;;; TIMELINES -(defun mastodon-tl--get-federated-timeline (&optional local) +(defun mastodon-tl--get-federated-timeline (&optional prefix local) "Open federated timeline. If LOCAL, get only local timeline. -With a single prefix arg (C-u), hide-replies. -With a double prefix arg (C-u C-u), only show posts with media." - (interactive) - (message "Loading federated timeline...") - (mastodon-tl--init - (if local "local" "federated") - "timelines/public" 'mastodon-tl--timeline nil - `(("limit" . ,mastodon-tl--timeline-posts-count) - ,(when (eq (car current-prefix-arg) 16) - '("only_media" . "true")) - ,(when local - '("local" . "true"))) - (when (eq (car current-prefix-arg) 4) t))) - -(defun mastodon-tl--get-home-timeline () - "Open home timeline. -With a single prefix arg (C-u), hide-replies." - (interactive) - (let ((params )) - (message "Loading home timeline...") +With a single PREFIX arg, hide-replies. +With a double PREFIX arg, only show posts with media." + (interactive "p") + (let ((params + `(("limit" . ,mastodon-tl--timeline-posts-count)))) + ;; avoid adding 'nil' to our params alist: + (when (eq prefix 16) + (push '("only_media" . "true") params)) + (when local + (push '("local" . "true") params)) + (message "Loading federated timeline...") (mastodon-tl--init - "home" "timelines/home" 'mastodon-tl--timeline nil - `(("limit" . ,mastodon-tl--timeline-posts-count)) - (when (eq (car current-prefix-arg) 4) t)))) + (if local "local" "federated") + "timelines/public" 'mastodon-tl--timeline nil + params + (when (eq prefix 4) t)))) -(defun mastodon-tl--get-local-timeline () +(defun mastodon-tl--get-home-timeline (&optional arg) + "Open home timeline. +With a single prefix ARG, hide replies." + (interactive "p") + (message "Loading home timeline...") + (mastodon-tl--init + "home" "timelines/home" 'mastodon-tl--timeline nil + `(("limit" . ,mastodon-tl--timeline-posts-count)) + (when (eq arg 4) t))) + +(defun mastodon-tl--get-local-timeline (&optional prefix) "Open local timeline. -With a single prefix arg (C-u), hide-replies. -With a double prefix arg (C-u C-u), only show posts with media." - (interactive) +With a single PREFIX arg, hide-replies. +With a double PREFIX arg, only show posts with media." + (interactive "p") (message "Loading local timeline...") - (mastodon-tl--get-federated-timeline :local)) + (mastodon-tl--get-federated-timeline prefix :local)) (defun mastodon-tl--get-tag-timeline (&optional tag) "Prompt for tag and opens its timeline. -- cgit v1.2.3 From b028fd1cab992b90164665d5997c25782d621d93 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 1 Apr 2023 16:30:04 +0200 Subject: tag tl prefix args: 1- only media, 2- local results --- lisp/mastodon-tl.el | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2f45336..0c3630b 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -386,22 +386,35 @@ With a double PREFIX arg, only show posts with media." (message "Loading local timeline...") (mastodon-tl--get-federated-timeline prefix :local)) -(defun mastodon-tl--get-tag-timeline (&optional tag) +(defun mastodon-tl--get-tag-timeline (&optional prefix tag) "Prompt for tag and opens its timeline. -Optionally load TAG timeline directly." - (interactive) +Optionally load TAG timeline directly. +With a single PREFIX arg, only show posts with media. +With a double PREFIX arg, limit results to your own instance." + (interactive "p") (let* ((word (or (word-at-point) "")) (input (or tag (read-string (format "Load timeline for tag (%s): " word)))) (tag (or tag (if (string-empty-p input) word input)))) (message "Loading timeline for #%s..." tag) - (mastodon-tl--show-tag-timeline tag))) + (mastodon-tl--show-tag-timeline prefix tag))) + +(defun mastodon-tl--show-tag-timeline (&optional prefix tag) + "Opens a new buffer showing the timeline of posts with hastag TAG. +With a single PREFIX arg, only show posts with media. +With a double PREFIX arg, limit results to your own instance." + (let ((params + `(("limit" . ,mastodon-tl--timeline-posts-count)))) + ;; avoid adding 'nil' to our params alist: + (when (eq prefix 4) + (push '("only_media" . "true") params)) + (when (eq prefix 16) + (push '("local" . "true") params)) + (mastodon-tl--init (concat "tag-" tag) + (concat "timelines/tag/" tag) + 'mastodon-tl--timeline + nil + params))) -(defun mastodon-tl--show-tag-timeline (tag) - "Opens a new buffer showing the timeline of posts with hastag TAG." - (mastodon-tl--init - (concat "tag-" tag) (concat "timelines/tag/" tag) - 'mastodon-tl--timeline nil - `(("limit" . ,mastodon-tl--timeline-posts-count)))) ;;; BYLINES, etc. @@ -2063,7 +2076,7 @@ If TAG is provided, unfollow it." (tag (completing-read "Tag: " tags nil))) (if (null tag) (message "You have to follow some tags first.") - (mastodon-tl--get-tag-timeline tag)))) + (mastodon-tl--get-tag-timeline nil tag)))) ;;; UPDATING, etc. -- cgit v1.2.3 From 08dc0d1990754a94cf2dc0899c8a579bb485c377 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 1 Apr 2023 17:09:24 +0200 Subject: timeline of all followed tags. FIX #409. --- README.org | 1 + lisp/mastodon-tl.el | 22 ++++++++++++++++++---- lisp/mastodon.el | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/README.org b/README.org index fbff0cd..fa1afcb 100644 --- a/README.org +++ b/README.org @@ -136,6 +136,7 @@ not contain =:client_id= and =:client_secret=. | =U= | update your profile bio note | | =;= | view instance description for toot at point | | =:= | view followed tags and load a tag timeline | +| =M-:= | view timeline of all followed tags | | =,= | view favouriters of toot at point | | =.= | view boosters of toot at point | | =/= | switch between mastodon buffers | diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 0c3630b..46ea5da 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -400,6 +400,7 @@ With a double PREFIX arg, limit results to your own instance." (defun mastodon-tl--show-tag-timeline (&optional prefix tag) "Opens a new buffer showing the timeline of posts with hastag TAG. +If TAG is a list, show a timeline for all tags. With a single PREFIX arg, only show posts with media. With a double PREFIX arg, limit results to your own instance." (let ((params @@ -409,13 +410,18 @@ With a double PREFIX arg, limit results to your own instance." (push '("only_media" . "true") params)) (when (eq prefix 16) (push '("local" . "true") params)) - (mastodon-tl--init (concat "tag-" tag) - (concat "timelines/tag/" tag) + (when (listp tag) + (let ((list (mastodon-http--build-array-params-alist "any[]" (cdr tag)))) + (while list + (push (pop list) params)))) + (mastodon-tl--init (concat "tag-" (if (listp tag) "followed-tags" tag)) + (concat "timelines/tag/" (if (listp tag) + ;; endpoint needs to be /tag/:sometag + (car tag) tag)) 'mastodon-tl--timeline nil params))) - ;;; BYLINES, etc. @@ -899,7 +905,7 @@ Used for hitting RET on a given link." (cond ((eq link-type 'content-warning) (mastodon-tl--toggle-spoiler-text position)) ((eq link-type 'hashtag) - (mastodon-tl--show-tag-timeline (get-text-property position 'mastodon-tag))) + (mastodon-tl--show-tag-timeline nil (get-text-property position 'mastodon-tag))) ;; 'account / 'account-id is not set for mentions, only bylines ((eq link-type 'user-handle) (let ((account-json (get-text-property position 'account)) @@ -2078,6 +2084,14 @@ If TAG is provided, unfollow it." (message "You have to follow some tags first.") (mastodon-tl--get-tag-timeline nil tag)))) +(defun mastodon-tl--followed-tags-timeline () + "Open a timeline of all your followed tags." + (interactive) + (let* ((followed-tags-json (mastodon-tl--followed-tags)) + (tags (mastodon-tl--map-alist 'name followed-tags-json))) + (mastodon-tl--show-tag-timeline nil tags))) + + ;;; UPDATING, etc. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index ef0d2c0..1b975f2 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -64,6 +64,7 @@ (autoload 'mastodon-profile--view-favourites "mastodon-profile") (autoload 'mastodon-tl--block-user "mastodon-tl") (autoload 'mastodon-tl--follow-user "mastodon-tl") +(autoload 'mastodon-tl--followed-tags-timeline "mastodon-tl") (autoload 'mastodon-tl--get-buffer-type "mastodon-tl") (autoload 'mastodon-tl--get-federated-timeline "mastodon-tl") (autoload 'mastodon-tl--get-home-timeline "mastodon-tl") @@ -152,6 +153,7 @@ Use. e.g. \"%c\" for your locale's date and time format." ;; navigation between timelines (define-key map (kbd "#") #'mastodon-tl--get-tag-timeline) (define-key map (kbd ":") #'mastodon-tl--list-followed-tags) + (define-key map (kbd "M-:") #'mastodon-tl--followed-tags-timeline) (define-key map (kbd "A") #'mastodon-profile--get-toot-author) (define-key map (kbd "F") #'mastodon-tl--get-federated-timeline) (define-key map (kbd "H") #'mastodon-tl--get-home-timeline) -- cgit v1.2.3 From 9ac865cb0c418d9a651a3e617e14ca60facc5936 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 1 Apr 2023 17:24:03 +0200 Subject: prefix args for list-followed-tags and followed-tags-timelines --- lisp/mastodon-tl.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 46ea5da..794b198 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2074,22 +2074,24 @@ If TAG is provided, unfollow it." (lambda () (message "tag #%s unfollowed!" tag))))) -(defun mastodon-tl--list-followed-tags () - "List followed tags. View timeline of tag user choses." - (interactive) +(defun mastodon-tl--list-followed-tags (&optional prefix) + "List followed tags. View timeline of tag user choses. +Prefix is sent to `mastodon-tl--get-tag-timeline', which see." + (interactive "p") (let* ((followed-tags-json (mastodon-tl--followed-tags)) (tags (mastodon-tl--map-alist 'name followed-tags-json)) (tag (completing-read "Tag: " tags nil))) (if (null tag) (message "You have to follow some tags first.") - (mastodon-tl--get-tag-timeline nil tag)))) + (mastodon-tl--get-tag-timeline prefix tag)))) -(defun mastodon-tl--followed-tags-timeline () - "Open a timeline of all your followed tags." - (interactive) +(defun mastodon-tl--followed-tags-timeline (&optional prefix) + "Open a timeline of all your followed tags. +Prefix is sent to `mastodon-tl--show-tag-timeline', which see." + (interactive "p") (let* ((followed-tags-json (mastodon-tl--followed-tags)) (tags (mastodon-tl--map-alist 'name followed-tags-json))) - (mastodon-tl--show-tag-timeline nil tags))) + (mastodon-tl--show-tag-timeline prefix tags))) -- cgit v1.2.3