From c6591296f2c2d65037fbf703d2b4ede197dcda15 Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 7 Feb 2022 19:52:35 +0100 Subject: add go to next toot to tl--thread --- 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 13c6729..c110fb2 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -989,7 +989,8 @@ webapp" (mastodon-tl--timeline (vconcat (alist-get 'ancestors context) `(,toot) - (alist-get 'descendants context))))) + (alist-get 'descendants context))) + (mastodon-tl--goto-next-toot))) (message "No Thread!")))) (defun mastodon-tl--get-follow-suggestions () -- cgit v1.2.3 From aa6044e06b1a5bb332ac565528adc87bc19c8d42 Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 7 Feb 2022 19:56:43 +0100 Subject: create filter first crack --- lisp/mastodon-tl.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index c110fb2..84df69f 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -993,6 +993,24 @@ webapp" (mastodon-tl--goto-next-toot))) (message "No Thread!")))) +(defun mastodon-tl--create-filter (word contexts) + "Create a filter for WORD. +CONTEXTS must be a list containting at least one of \"home\", +\"notifications\", \"public\", \"thread\". " + (interactive) + (let* ((url (mastodon-http--api "filters")) + (contexts-processed + (mapcar (lambda (x) + (cons "context[]" x)) + contexts)) + (response + (mastodon-http--post url (push + `("phrase" . ,word) + contexts-processed) + nil))) + (with-current-buffer response + (switch-to-buffer (current-buffer))))) + (defun mastodon-tl--get-follow-suggestions () "Display a buffer of suggested accounts to follow." (interactive) -- cgit v1.2.3 From 918d34782ae3dba7a891825104affa0160b61b2c Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 7 Feb 2022 20:42:22 +0100 Subject: fix go to first toot on thread load --- lisp/mastodon-tl.el | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 84df69f..67047a3 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -962,7 +962,6 @@ webapp" (reblog (alist-get 'reblog json))) (if reblog (alist-get 'id reblog) id))) - (defun mastodon-tl--thread () "Open thread buffer for toot under `point'." (interactive) @@ -977,20 +976,21 @@ webapp" (if (> (+ (length (alist-get 'ancestors context)) (length (alist-get 'descendants context))) 0) - (with-output-to-temp-buffer buffer - (switch-to-buffer buffer) - (mastodon-mode) - (setq mastodon-tl--buffer-spec - `(buffer-name ,buffer - endpoint ,(format "statuses/%s/context" id) - update-function - (lambda(toot) (message "END of thread.")))) - (let ((inhibit-read-only t)) - (mastodon-tl--timeline (vconcat - (alist-get 'ancestors context) - `(,toot) - (alist-get 'descendants context))) - (mastodon-tl--goto-next-toot))) + (progn + (with-output-to-temp-buffer buffer + (switch-to-buffer buffer) + (mastodon-mode) + (setq mastodon-tl--buffer-spec + `(buffer-name ,buffer + endpoint ,(format "statuses/%s/context" id) + update-function + (lambda (toot) (message "END of thread.")))) + (let ((inhibit-read-only t)) + (mastodon-tl--timeline (vconcat + (alist-get 'ancestors context) + `(,toot) + (alist-get 'descendants context))))) + (mastodon-tl--goto-next-toot)) (message "No Thread!")))) (defun mastodon-tl--create-filter (word contexts) -- cgit v1.2.3 From 2c75ce23691b885574c37fe84ab35015c12d4e19 Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 7 Feb 2022 20:43:08 +0100 Subject: second crack at create filter --- lisp/mastodon-tl.el | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 67047a3..2fbc889 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -993,23 +993,29 @@ webapp" (mastodon-tl--goto-next-toot)) (message "No Thread!")))) -(defun mastodon-tl--create-filter (word contexts) - "Create a filter for WORD. -CONTEXTS must be a list containting at least one of \"home\", -\"notifications\", \"public\", \"thread\". " +(defun mastodon-tl--create-filter () + "Create a filter for a word. +Prompt for a context, must be a list containting at least one of \"home\", +\"notifications\", \"public\", \"thread\"." (interactive) (let* ((url (mastodon-http--api "filters")) + (word (read-string + (format "Word to filter (%s): " (current-word)) + nil nil (current-word))) + (contexts (completing-read-multiple + "Contexts to filter [TAB for options]:" + '("home" "notifications" "public" "thread"))) (contexts-processed (mapcar (lambda (x) (cons "context[]" x)) contexts)) - (response - (mastodon-http--post url (push - `("phrase" . ,word) - contexts-processed) - nil))) - (with-current-buffer response - (switch-to-buffer (current-buffer))))) + (response (mastodon-http--post url (push + `("phrase" . ,word) + contexts-processed) + nil))) + (mastodon-http--triage response + (lambda () + (message "Filter created for %s!" word))))) (defun mastodon-tl--get-follow-suggestions () "Display a buffer of suggested accounts to follow." -- cgit v1.2.3 From 949520069569b3b5397a00cca0d9671f3445ddea Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 14 Feb 2022 16:12:17 +0100 Subject: view and delete filters --- lisp/mastodon-tl.el | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2fbc889..a87fc2e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -162,6 +162,12 @@ types of mastodon links and not just shr.el-generated ones.") We need to override the keymap so tabbing will navigate to all types of mastodon links and not just shr.el-generated ones.") +(defvar mastodon-tl--view-filters-keymap + (let ((map (make-sparse-keymap))) + (define-key map (kbd "d") 'mastodon-tl--delete-filter) + (keymap-canonicalize map)) + "Keymap for viewing filters.") + (defun mastodon-tl--next-tab-item () "Move to the next interesting item. @@ -1015,7 +1021,58 @@ Prompt for a context, must be a list containting at least one of \"home\", nil))) (mastodon-http--triage response (lambda () - (message "Filter created for %s!" word))))) + (message "Filter created for %s!" word) + (when (string= (plist-get mastodon-tl--buffer-spec 'buffer-name) + "*mastodon-filters*") + (mastodon-tl--view-filters)))))) + +(defun mastodon-tl--view-filters () + "" + (interactive) + (let ((url (mastodon-http--api "filters"))) + (mastodon-tl--init-sync "*mastodon-filters*" + "filters" + 'mastodon-tl--insert-filters) + (mastodon-tl--goto-next-toot))) + +(defun mastodon-tl--insert-filters (json) + "" + (insert (mastodon-tl--set-face + (concat "\n ------------\n" + " CURRENT FILTERS\n" + " ------------\n\n") + 'success)) + (mapc (lambda (x) + (mastodon-tl--insert-filter-string x) + (insert "\n\n")) + json)) + +(defun mastodon-tl--insert-filter-string (filter) + "" + (let* ((phrase (alist-get 'phrase filter)) + (contexts (alist-get 'context filter)) + (id (alist-get 'id filter)) + (filter-string (concat "- \"" phrase "\" filtered in: " + (mapconcat #'identity contexts ", ")))) + (insert + (propertize filter-string + 'toot-id id ;for goto-next-toot compat + 'phrase phrase + 'help-echo "d to delete filter at point, n/p to go to next/prev filter." + 'keymap mastodon-tl--view-filters-keymap + 'byline t)))) ;for goto-next-toot compat + +(defun mastodon-tl--delete-filter () + "" + (interactive) + (let* ((filter-id (mastodon-tl--property 'toot-id)) + (phrase (mastodon-tl--property 'phrase)) + (url (mastodon-http--api + (format "filters/%s" filter-id))) + (response (mastodon-http--delete url))) + (mastodon-http--triage response (lambda () + (message "Filter for \"%s\" deleted!" phrase) + (mastodon-tl--view-filters))))) (defun mastodon-tl--get-follow-suggestions () "Display a buffer of suggested accounts to follow." -- cgit v1.2.3 From 6e68b7051595bf99bade4d3052286f95d606a155 Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 14 Feb 2022 16:13:50 +0100 Subject: autoload -search--get-user-info for follow suggestions --- lisp/mastodon-tl.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index e33aadf..f3c3527 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -63,6 +63,7 @@ (autoload 'mastodon-notifications--get "mastodon-notifications" "Display NOTIFICATIONS in buffer." t) ; interactive (autoload 'mastodon-search--insert-users-propertized "mastodon-search") +(autoload 'mastodon-search--get-user-info "mastodon-search") (when (require 'mpv nil :no-error) (declare-function mpv-start "mpv")) (defvar mastodon-instance-url) -- cgit v1.2.3 From 51378f17d14ff877dfea29e496be64383b65da93 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 13:03:47 +0100 Subject: buffer local keymap, error handling, make filters nicer - separate goto-next/prev-filter commands - we use properties toot-id and byline so the navigation works, calqued on - goto-prev/next-toot - error handle no word or context supplied - reload filters view on create or delete --- README.org | 3 +- lisp/mastodon-tl.el | 115 ++++++++++++++++++++++++++++++++++++---------------- lisp/mastodon.el | 2 + 3 files changed, 83 insertions(+), 37 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/README.org b/README.org index a2ed08f..fff0b09 100644 --- a/README.org +++ b/README.org @@ -29,12 +29,13 @@ It adds the following features: | =D= | delete and redraft toot at point, preserving reply/CW/visibility | | =W=, =M=, =B= | (un)follow, (un)mute, (un)block author of toot at point | | =k=, =K= | toggle bookmark of toot at point, view bookmarked toots | +| =L= | view, create, and delete filters | | | display polls and vote on them | | | images are links to the full image, can be zoomed/rotated/saved (see image keymap) | | | images scale properly | | | toot visibility (direct, followers only) icon appears in toot bylines | | | display toot's number of favorites, boosts and replies | -| | play gifs and videos (requires =mpv= to be installed) | +| | play gifs and videos (requires =mpv= to be installed) | | | customize option to cache images | | Toots: | | | | mention booster in replies by default | diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d69cb1a..0423e2e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -64,6 +64,8 @@ "Display NOTIFICATIONS in buffer." t) ; interactive (autoload 'mastodon-search--insert-users-propertized "mastodon-search") (autoload 'mastodon-search--get-user-info "mastodon-search") +(autoload 'mastodon-http--delete "mastodon-http") + (when (require 'mpv nil :no-error) (declare-function mpv-start "mpv")) (defvar mastodon-instance-url) @@ -171,6 +173,14 @@ types of mastodon links and not just shr.el-generated ones.") (defvar mastodon-tl--view-filters-keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "d") 'mastodon-tl--delete-filter) + (define-key map (kbd "c") 'mastodon-tl--create-filter) + (define-key map (kbd "n") 'mastodon-tl--goto-next-filter) + (define-key map (kbd "p") 'mastodon-tl--goto-prev-filter) + (define-key map (kbd "TAB") 'mastodon-tl--goto-next-filter) + (define-key map (kbd "g") 'mastodon-tl--view-filters) + (define-key map (kbd "t") 'mastodon-toot) + (define-key map (kbd "q") 'kill-current-buffer) + (define-key map (kbd "Q") 'kill-buffer-and-window) (keymap-canonicalize map)) "Keymap for viewing filters.") @@ -1102,18 +1112,25 @@ Prompt for a context, must be a list containting at least one of \"home\", (interactive) (let* ((url (mastodon-http--api "filters")) (word (read-string - (format "Word to filter (%s): " (current-word)) - nil nil (current-word))) - (contexts (completing-read-multiple - "Contexts to filter [TAB for options]:" - '("home" "notifications" "public" "thread"))) + (format "Word(s) to filter (%s): " (or (current-word) "")) + nil nil (or (current-word) ""))) + (contexts + (if (equal "" word) + (error "You must select at least one word for a filter") + (completing-read-multiple + "Contexts to filter [TAB for options]:" + '("home" "notifications" "public" "thread") + nil ; no predicate + t))) ; require-match, as context is mandatory (contexts-processed - (mapcar (lambda (x) - (cons "context[]" x)) - contexts)) + (if (equal nil contexts) + (error "You must select at least one context for a filter") + (mapcar (lambda (x) + (cons "context[]" x)) + contexts))) (response (mastodon-http--post url (push - `("phrase" . ,word) - contexts-processed) + `("phrase" . ,word) + contexts-processed) nil))) (mastodon-http--triage response (lambda () @@ -1123,28 +1140,39 @@ Prompt for a context, must be a list containting at least one of \"home\", (mastodon-tl--view-filters)))))) (defun mastodon-tl--view-filters () - "" + "View the user's filters in a new buffer." (interactive) - (let ((url (mastodon-http--api "filters"))) - (mastodon-tl--init-sync "*mastodon-filters*" - "filters" - 'mastodon-tl--insert-filters) - (mastodon-tl--goto-next-toot))) + (mastodon-tl--init-sync "filters" + "filters" + 'mastodon-tl--insert-filters) + (use-local-map mastodon-tl--view-filters-keymap) + (mastodon-tl--goto-next-filter)) (defun mastodon-tl--insert-filters (json) - "" + "Insert the user's current filters. +JSON is what is returned by by the server." (insert (mastodon-tl--set-face (concat "\n ------------\n" " CURRENT FILTERS\n" " ------------\n\n") - 'success)) - (mapc (lambda (x) - (mastodon-tl--insert-filter-string x) - (insert "\n\n")) - json)) + 'success) + (mastodon-tl--set-face + "[c - create filter\n d - delete filter at point\n n/p - go to next/prev filter]\n\n" + 'font-lock-comment-face)) + (if (not (equal json '[])) + (progn + (mapc (lambda (x) + (mastodon-tl--insert-filter-string x) + (insert "\n\n")) + json)) + (insert (propertize + "Looks like you have no filters for now." + 'face font-lock-comment-face + 'byline t + 'toot-id "0")))) ; so point can move here when no filters (defun mastodon-tl--insert-filter-string (filter) - "" + "Insert a single FILTER." (let* ((phrase (alist-get 'phrase filter)) (contexts (alist-get 'context filter)) (id (alist-get 'id filter)) @@ -1152,23 +1180,38 @@ Prompt for a context, must be a list containting at least one of \"home\", (mapconcat #'identity contexts ", ")))) (insert (propertize filter-string - 'toot-id id ;for goto-next-toot compat + 'toot-id id ;for goto-next-filter compat 'phrase phrase - 'help-echo "d to delete filter at point, n/p to go to next/prev filter." - 'keymap mastodon-tl--view-filters-keymap - 'byline t)))) ;for goto-next-toot compat + ;'help-echo "n/p to go to next/prev filter, c to create new filter, d to delete filter at point." + ;'keymap mastodon-tl--view-filters-keymap + 'byline t)))) ;for goto-next-filter compat (defun mastodon-tl--delete-filter () - "" + "Delete filter at point." (interactive) - (let* ((filter-id (mastodon-tl--property 'toot-id)) - (phrase (mastodon-tl--property 'phrase)) - (url (mastodon-http--api - (format "filters/%s" filter-id))) - (response (mastodon-http--delete url))) - (mastodon-http--triage response (lambda () - (message "Filter for \"%s\" deleted!" phrase) - (mastodon-tl--view-filters))))) + (let* ((filter-id (get-text-property (point) 'toot-id)) + (phrase (get-text-property (point) 'phrase)) + (url (mastodon-http--api + (format "filters/%s" filter-id)))) + (if (equal nil filter-id) + (error "No filter at point?") + (when (y-or-n-p (format "Delete this filter? "))) + (let ((response (mastodon-http--delete url))) + (mastodon-http--triage response (lambda () + (mastodon-tl--view-filters) + (message "Filter for \"%s\" deleted!" phrase))))))) + +(defun mastodon-tl--goto-next-filter () + "Jump to next filter." + (interactive) + (mastodon-tl--goto-toot-pos 'next-single-property-change + 'next-line)) + +(defun mastodon-tl--goto-prev-filter () + "Jump to previous filter." + (interactive) + (mastodon-tl--goto-toot-pos 'previous-single-property-change + 'previous-line)) (defun mastodon-tl--get-follow-suggestions () "Display a buffer of suggested accounts to follow." diff --git a/lisp/mastodon.el b/lisp/mastodon.el index a52bf41..180674e 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -85,6 +85,7 @@ (autoload 'mastodon-tl--poll-vote "mastodon-http") ;; (autoload 'mastodon-toot--delete-and-redraft-toot "mastodon-toot") (autoload 'mastodon-profile--view-bookmarks "mastodon-profile") +(autoload 'mastoton-tl--view-filters "mastodon-tl") ;; (autoload 'mastodon-toot--bookmark-toot-toggle "mastodon-toot") (defgroup mastodon nil @@ -164,6 +165,7 @@ Use. e.g. \"%c\" for your locale's date and time format." (define-key map (kbd "v") #'mastodon-tl--poll-vote) (define-key map (kbd "k") #'mastodon-toot--bookmark-toot-toggle) (define-key map (kbd "K") #'mastodon-profile--view-bookmarks) + (define-key map (kbd "L") #'mastodon-tl--view-filters) map) "Keymap for `mastodon-mode'.") -- cgit v1.2.3 From 0b01efc1187ca5d40839c8eed2d9ae7ddef144f7 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 14:03:22 +0100 Subject: make accept/reject foll reqs cmds avail in foll reqs view! --- lisp/mastodon-profile.el | 13 +++++++++++++ lisp/mastodon-tl.el | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 5811a4a..d632e5e 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -57,6 +57,8 @@ (autoload 'mastodon-tl--init "mastodon-tl.el") (autoload 'mastodon-http--patch "mastodon-http") (autoload 'mastodon-http--patch-json "mastodon-http") +(autoload 'mastodon-notifications--follow-request-reject "mastodon-notifications") +(autoload 'mastodon-notifications--follow-request-accept "mastodon-notifications") (defvar mastodon-instance-url) (defvar mastodon-tl--buffer-spec) @@ -72,6 +74,17 @@ map) "Keymap for `mastodon-profile-mode'.") +(defvar mastodon-profile--view-follow-requests-keymap + (let ((map (make-sparse-keymap))) + (define-key map (kbd "r") #'mastodon-notifications--follow-request-reject) + (define-key map (kbd "a") #'mastodon-notifications--follow-request-accept) + ;; (define-key map (kbd "g") 'mastodon-notifications--view-follow-requests + ;; (define-key map (kbd "t") #'mastodon-toot) + (define-key map (kbd "q") #'kill-current-buffer) + (define-key map (kbd "Q") #'kill-buffer-and-window) + map) + "Keymap for viewing follow requests.") + (define-minor-mode mastodon-profile-mode "Toggle mastodon profile minor mode. diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index f3c3527..32bb73e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1462,7 +1462,8 @@ JSON is the data returned from the server." (mastodon-tl--goto-next-toot) (mastodon-mode) (when (equal endpoint "follow_requests") - (mastodon-profile-mode)) + (mastodon-profile-mode) + (use-local-map mastodon-profile--view-follow-requests-keymap)) (with-current-buffer buffer (setq mastodon-tl--buffer-spec `(buffer-name ,buffer -- cgit v1.2.3 From 907991314d0f4e2b88eeb093a6222468e77c9068 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 15:06:39 +0100 Subject: improve use of goto-next-toot on timeline loading --- lisp/mastodon-tl.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 32bb73e..efccc21 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1459,7 +1459,6 @@ JSON is the data returned from the server." mastodon-tl--timestamp-next-update (time-add (current-time) (seconds-to-time 300))) (funcall update-function json)) - (mastodon-tl--goto-next-toot) (mastodon-mode) (when (equal endpoint "follow_requests") (mastodon-profile-mode) @@ -1477,7 +1476,11 @@ JSON is the data returned from the server." nil ;; don't repeat #'mastodon-tl--update-timestamps-callback (current-buffer) - nil))))) + nil))) + (when (or (equal endpoint "notifications") + (string-prefix-p "timelines" endpoint) + (string-prefix-p "statuses" endpoint)) + (mastodon-tl--goto-next-toot)))) (defun mastodon-tl--init-sync (buffer-name endpoint update-function) "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. @@ -1509,7 +1512,11 @@ Runs synchronously." nil ;; don't repeat #'mastodon-tl--update-timestamps-callback (current-buffer) - nil)))) + nil))) + (when (or (equal endpoint "notifications") + (string-prefix-p "timelines" endpoint) + (string-prefix-p "statuses" endpoint)) + (mastodon-tl--goto-next-toot))) buffer)) (provide 'mastodon-tl) -- cgit v1.2.3 From 787f18dcff2ee7a4c5a5cbf331f4e2d26997e1cc Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 15:30:58 +0100 Subject: replace all calls to mastodon-search--insert-users-propertized with calls to mastodon-profile--add-author-bylines. --- lisp/mastodon-profile.el | 3 +-- lisp/mastodon-search.el | 24 ++---------------------- lisp/mastodon-tl.el | 3 ++- 3 files changed, 5 insertions(+), 25 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index d632e5e..8ac0b67 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -398,8 +398,7 @@ FIELD is used to identify regions under 'account" (defun mastodon-profile--add-author-bylines (tootv) "Convert TOOTV into a author-bylines and insert." (let ((inhibit-read-only t)) - (if (equal tootv '[]) - (message "Looks like you have no follow requests for the moment.") + (when (not (equal tootv '[])) (mapc (lambda (toot) (let ((start-pos (point))) (insert "\n" diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index d17b054..2f8054a 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -98,7 +98,8 @@ Returns a nested list containing user handle, display name, and URL." " USERS\n" " ------------\n\n") 'success)) - (mastodon-search--insert-users-propertized user-ids :note) + (mastodon-profile--add-author-bylines accts) + ;; (mastodon-search--insert-users-propertized user-ids :note) ;; hashtag results: (insert (mastodon-tl--set-face (concat "\n ------------\n" @@ -124,27 +125,6 @@ Returns a nested list containing user handle, display name, and URL." (mapc 'mastodon-tl--toot toots-list-json) (goto-char (point-min)))))) -(defun mastodon-search--insert-users-propertized (users &optional note) - "Insert USERS list into the buffer. -If NOTE is non-nil, include user's profile note. -This is also called by `mastodon-tl--get-follow-suggestions'." - (mapc (lambda (el) - (insert (propertize (car el) 'face 'mastodon-display-name-face) - " : \n : " - (propertize (concat "@" (car (cdr el))) - 'face 'mastodon-handle-face - 'mouse-face 'highlight - 'mastodon-tab-stop 'user-handle - 'keymap mastodon-tl--link-keymap - 'mastodon-handle (concat "@" (car (cdr el))) - 'help-echo (concat "Browse user profile of @" (car (cdr el)))) - " : \n" - (if note - (mastodon-tl--render-text (cadddr el) nil) - "") - "\n")) - users)) - (defun mastodon-search--get-user-info (account) "Get user handle, display name, account URL and profile note from ACCOUNT." (list (alist-get 'display_name account) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index efccc21..26364a6 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1107,7 +1107,8 @@ webapp" " SUGGESTED ACCOUNTS\n" " ------------\n\n") 'success)) - (mastodon-search--insert-users-propertized users :note))))) + (mastodon-profile--add-author-bylines response))))) + ;; (mastodon-search--insert-users-propertized users :note))))) (defun mastodon-tl--follow-user (user-handle &optional notify) "Query for USER-HANDLE from current status and follow that user. -- cgit v1.2.3 From b26b4f835aee9317c13e98922342994e26a54078 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 16:21:00 +0100 Subject: more robust goto-first-toot on timeline/thread load rather than using goto-next-toot, which loops when we have no items in buffer --- lisp/mastodon-tl.el | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index c059de8..deaa196 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -290,6 +290,15 @@ Optionally start from POS." (mastodon-tl--goto-toot-pos 'next-single-property-change 'mastodon-tl--more)) +(defun mastodon-tl--goto-first-toot () + "Jump to first toot or item in buffer. +Used on initializing a timeline or thread." + ;; goto-next-toot assumes we already have toots, and is therefore + ;; incompatible with any view where it is possible to have no items. + ;; when that is the case the call to goto-toot-pos loops infinitely + (mastodon-tl--goto-toot-pos 'next-single-property-change + 'next-line)) ;dummy function as we need to feed it something + (defun mastodon-tl--goto-prev-toot () "Jump to last toot header." (interactive) @@ -1604,7 +1613,7 @@ JSON is the data returned from the server." (when (or (equal endpoint "notifications") (string-prefix-p "timelines" endpoint) (string-prefix-p "statuses" endpoint)) - (mastodon-tl--goto-next-toot)))) + (mastodon-tl--goto-first-toot)))) (defun mastodon-tl--init-sync (buffer-name endpoint update-function) "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. @@ -1637,11 +1646,12 @@ Runs synchronously." #'mastodon-tl--update-timestamps-callback (current-buffer) nil))) - (when (or (equal endpoint "notifications") - (string-prefix-p "timelines" endpoint) - (string-prefix-p "statuses" endpoint)) - (mastodon-tl--goto-next-toot))) - buffer)) + (when (and (not (equal json '[])) + (or (equal endpoint "notifications") + (string-prefix-p "timelines" endpoint) + (string-prefix-p "statuses" endpoint)) + (mastodon-tl--goto-first-toot)))) + buffer)) (provide 'mastodon-tl) ;;; mastodon-tl.el ends here -- cgit v1.2.3 From 7058db5848987df4c089bd0c0e34813f830d372c Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 17:06:03 +0100 Subject: add generic goto-next/prev-item funs for filters/foll reqs fix remnant call to goto-next-filter --- lisp/mastodon-profile.el | 6 ++++-- lisp/mastodon-tl.el | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 857c349..c7f8963 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -78,8 +78,10 @@ (let ((map (make-sparse-keymap))) (define-key map (kbd "r") #'mastodon-notifications--follow-request-reject) (define-key map (kbd "a") #'mastodon-notifications--follow-request-accept) - ;; (define-key map (kbd "g") 'mastodon-notifications--view-follow-requests - ;; (define-key map (kbd "t") #'mastodon-toot) + (define-key map (kbd "n") #'mastodon-tl--goto-next-item) + (define-key map (kbd "p") #'mastodon-tl--goto-prev-item) + (define-key map (kbd "g") 'mastodon-notifications--view-follow-requests) + (define-key map (kbd "t") #'mastodon-toot) (define-key map (kbd "q") #'kill-current-buffer) (define-key map (kbd "Q") #'kill-buffer-and-window) map) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index deaa196..34b2881 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -174,8 +174,8 @@ types of mastodon links and not just shr.el-generated ones.") (let ((map (make-sparse-keymap))) (define-key map (kbd "d") 'mastodon-tl--delete-filter) (define-key map (kbd "c") 'mastodon-tl--create-filter) - (define-key map (kbd "n") 'mastodon-tl--goto-next-filter) - (define-key map (kbd "p") 'mastodon-tl--goto-prev-filter) + (define-key map (kbd "n") 'mastodon-tl--goto-next-item) + (define-key map (kbd "p") 'mastodon-tl--goto-prev-item) (define-key map (kbd "TAB") 'mastodon-tl--goto-next-filter) (define-key map (kbd "g") 'mastodon-tl--view-filters) (define-key map (kbd "t") 'mastodon-toot) @@ -1155,7 +1155,7 @@ Prompt for a context, must be a list containting at least one of \"home\", "filters" 'mastodon-tl--insert-filters) (use-local-map mastodon-tl--view-filters-keymap) - (mastodon-tl--goto-next-filter)) + (mastodon-tl--goto-next-item)) (defun mastodon-tl--insert-filters (json) "Insert the user's current filters. @@ -1210,14 +1210,14 @@ JSON is what is returned by by the server." (mastodon-tl--view-filters) (message "Filter for \"%s\" deleted!" phrase))))))) -(defun mastodon-tl--goto-next-filter () - "Jump to next filter." +(defun mastodon-tl--goto-next-item () + "Jump to next item, e.g. filter or follow request." (interactive) (mastodon-tl--goto-toot-pos 'next-single-property-change 'next-line)) -(defun mastodon-tl--goto-prev-filter () - "Jump to previous filter." +(defun mastodon-tl--goto-prev-item () + "Jump to previous item, e.g. filter or follow request." (interactive) (mastodon-tl--goto-toot-pos 'previous-single-property-change 'previous-line)) -- cgit v1.2.3 From 0be1c740ba3f4f3f86a3d81567fcb5cd1b9683a9 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 17:07:01 +0100 Subject: invert if call in filters insert --- lisp/mastodon-tl.el | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 34b2881..e8634dd 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1168,17 +1168,16 @@ JSON is what is returned by by the server." (mastodon-tl--set-face "[c - create filter\n d - delete filter at point\n n/p - go to next/prev filter]\n\n" 'font-lock-comment-face)) - (if (not (equal json '[])) - (progn - (mapc (lambda (x) - (mastodon-tl--insert-filter-string x) - (insert "\n\n")) - json)) - (insert (propertize - "Looks like you have no filters for now." - 'face font-lock-comment-face - 'byline t - 'toot-id "0")))) ; so point can move here when no filters + (if (equal json '[]) + (insert (propertize + "Looks like you have no filters for now." + 'face font-lock-comment-face + 'byline t + 'toot-id "0")) ; so point can move here when no filters + (mapc (lambda (x) + (mastodon-tl--insert-filter-string x) + (insert "\n\n")) + json))) (defun mastodon-tl--insert-filter-string (filter) "Insert a single FILTER." -- cgit v1.2.3 From 48a89e518d0a84d4b81c223c9e8cf151df619b1f Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 19:13:23 +0100 Subject: move faves count help-echo propertize into tl--byline this means that we only do the propertizing when we are actually doing an author byline, docstring for add-author-bylines it also needs renaming --- lisp/mastodon-profile.el | 6 ++++- lisp/mastodon-tl.el | 63 ++++++++++++++++++++++++------------------------ 2 files changed, 37 insertions(+), 32 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index e15a891..8388d05 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -415,7 +415,11 @@ FIELD is used to identify regions under 'account" (cdr (assoc field account))) (defun mastodon-profile--add-author-bylines (tootv) - "Convert TOOTV into a author-bylines and insert." + "Convert TOOTV into a author-bylines and insert. +Also insert their profile note. +Used to view a user's followers and those they're following, as +well as the list of suggested followers and for search results." + ;;FIXME change the name of this fun now that we've edited what it does! (let ((inhibit-read-only t)) (when (not (equal tootv '[])) (mapc (lambda (toot) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index e8634dd..327b682 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -333,11 +333,10 @@ Used on initializing a timeline or thread." 'face 'mastodon-display-name-face ;; enable playing of videos when point is on byline: 'attachments (mastodon-tl--get-attachments-for-byline toot) - 'keymap mastodon-tl--byline-link-keymap - ;; echo faves count when point on post author name: - ;; which is where --goto-next-toot puts point. - 'help-echo - (mastodon-tl--format-faves-count toot)) + 'keymap mastodon-tl--byline-link-keymap) + ;; help-echo propertized moved to `mastodon-tl--byline + ;; 'help-echo + ;; (mastodon-tl--format-faves-count toot)) " (" (propertize (concat "@" handle) 'face 'mastodon-handle-face @@ -505,32 +504,34 @@ By default it is `mastodon-tl--byline-boosted'" (when faved (mastodon-tl--format-faved-or-boosted-byline "F"))) (propertize - (concat - ;; we propertize help-echo format faves for author name - ;; in `mastodon-tl--byline-author' - (funcall author-byline toot) - (cond ((equal visibility "direct") - (if (fontp (char-displayable-p #10r128274)) - " ✉" - " [direct]")) - ((equal visibility "private") - (if (fontp (char-displayable-p #10r9993)) - " 🔒" - " [followers]"))) - (funcall action-byline toot) - " " - ;; TODO: Once we have a view for toot (responses etc.) make - ;; this a tab stop and attach an action. - (propertize - (format-time-string mastodon-toot-timestamp-format parsed-time) - 'timestamp parsed-time - 'display (if mastodon-tl--enable-relative-timestamps - (mastodon-tl--relative-time-description parsed-time) - parsed-time)) - (propertize "\n ------------\n" 'face 'default)) - 'favourited-p faved - 'boosted-p boosted - 'byline t)))) + ;; echo faves count when point on + ;; author byline, which is where --goto-next-toot puts + ;; point. + (concat (propertize + (funcall author-byline toot) + 'help-echo (mastodon-tl--format-faves-count toot)) + (cond ((equal visibility "direct") + (if (fontp (char-displayable-p #10r128274)) + " ✉" + " [direct]")) + ((equal visibility "private") + (if (fontp (char-displayable-p #10r9993)) + " 🔒" + " [followers]"))) + (funcall action-byline toot) + " " + ;; TODO: Once we have a view for toot (responses etc.) make + ;; this a tab stop and attach an action. + (propertize + (format-time-string mastodon-toot-timestamp-format parsed-time) + 'timestamp parsed-time + 'display (if mastodon-tl--enable-relative-timestamps + (mastodon-tl--relative-time-description parsed-time) + parsed-time)) + (propertize "\n ------------\n" 'face 'default)) + 'favourited-p faved + 'boosted-p boosted + 'byline t)))) (defun mastodon-tl--format-faved-or-boosted-byline (letter) "Format the byline marker for a boosted or favorited status. -- cgit v1.2.3 From 79790bad6b6d0bb5a43459e3d2f8da9701ed8908 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 19:23:25 +0100 Subject: improve follow suggestions suggestions fix fun names(!) --- lisp/mastodon-tl.el | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 327b682..6c6f4e1 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -184,6 +184,19 @@ types of mastodon links and not just shr.el-generated ones.") (keymap-canonicalize map)) "Keymap for viewing filters.") +(defvar mastodon-tl--view-suggestions-keymap + (let ((map (make-sparse-keymap))) + (define-key map (kbd "W") 'mastodon-tl--follow-user) + (define-key map (kbd "n") 'mastodon-tl--goto-next-item) + (define-key map (kbd "p") 'mastodon-tl--goto-prev-item) + (define-key map (kbd "TAB") 'mastodon-tl--goto-next-item) + (define-key map (kbd "g") 'mastodon-tl--get-follow-suggestions) + (define-key map (kbd "t") 'mastodon-toot) + (define-key map (kbd "q") 'kill-current-buffer) + (define-key map (kbd "Q") 'kill-buffer-and-window) + (keymap-canonicalize map)) + "Keymap for viewing follow suggestions.") + (defvar mastodon-tl--byline-link-keymap (when (require 'mpv nil :no-error) (let ((map (make-sparse-keymap))) @@ -1223,24 +1236,25 @@ JSON is what is returned by by the server." 'previous-line)) (defun mastodon-tl--get-follow-suggestions () -"Display a buffer of suggested accounts to follow." + "Display a buffer of suggested accounts to follow." (interactive) - (let* ((buffer (format "*mastodon-follow-suggestions*")) - (response - (mastodon-http--get-json - (mastodon-http--api "suggestions"))) - (users (mapcar 'mastodon-search--get-user-info response))) - (with-output-to-temp-buffer buffer - (let ((inhibit-read-only t)) - (switch-to-buffer buffer) - (mastodon-mode) - (insert (mastodon-tl--set-face - (concat "\n ------------\n" - " SUGGESTED ACCOUNTS\n" - " ------------\n\n") - 'success)) - (mastodon-profile--add-author-bylines response))))) - ;; (mastodon-search--insert-users-propertized users :note))))) + (mastodon-tl--init-sync "follow-suggestions" + "suggestions" + 'mastodon-tl--insert-follow-suggestions) + (use-local-map mastodon-tl--view-suggestions-keymap) + (mastodon-tl--goto-next-item)) + +(defun mastodon-tl--insert-follow-suggestions (response) + "Insert follow suggestions into buffer. +RESPONSE is the JSON returned by the server." + (let* ((users (mapcar 'mastodon-search--get-user-info response))) + (insert (mastodon-tl--set-face + (concat "\n ------------\n" + " SUGGESTED ACCOUNTS\n" + " ------------\n\n") + 'success)) + (mastodon-profile--add-author-bylines response) + (goto-char (point-min)))) (defun mastodon-tl--follow-user (user-handle &optional notify) "Query for USER-HANDLE from current status and follow that user. -- cgit v1.2.3 From 5ae600a4431f7d3f0b2b6c93999465f1c75391e2 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 19:33:44 +0100 Subject: fix reload on filter create in filter view --- lisp/mastodon-tl.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 6c6f4e1..8fa4813 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1158,8 +1158,9 @@ Prompt for a context, must be a list containting at least one of \"home\", (mastodon-http--triage response (lambda () (message "Filter created for %s!" word) - (when (string= (plist-get mastodon-tl--buffer-spec 'buffer-name) - "*mastodon-filters*") + ;; reload if we are in filters view: + (when (string= (mastodon-tl--get-endpoint) + "filters") (mastodon-tl--view-filters)))))) (defun mastodon-tl--view-filters () -- cgit v1.2.3 From f37c97de8b192caf68d4b39c3830e85b5aa09d2e Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 19:49:28 +0100 Subject: Revert "move faves count help-echo propertize into tl--byline" This reverts commit 48a89e518d0a84d4b81c223c9e8cf151df619b1f. --- lisp/mastodon-tl.el | 63 ++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 8fa4813..d82a0a5 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -346,10 +346,11 @@ Used on initializing a timeline or thread." 'face 'mastodon-display-name-face ;; enable playing of videos when point is on byline: 'attachments (mastodon-tl--get-attachments-for-byline toot) - 'keymap mastodon-tl--byline-link-keymap) - ;; help-echo propertized moved to `mastodon-tl--byline - ;; 'help-echo - ;; (mastodon-tl--format-faves-count toot)) + 'keymap mastodon-tl--byline-link-keymap + ;; echo faves count when point on post author name: + ;; which is where --goto-next-toot puts point. + 'help-echo + (mastodon-tl--format-faves-count toot)) " (" (propertize (concat "@" handle) 'face 'mastodon-handle-face @@ -517,34 +518,32 @@ By default it is `mastodon-tl--byline-boosted'" (when faved (mastodon-tl--format-faved-or-boosted-byline "F"))) (propertize - ;; echo faves count when point on - ;; author byline, which is where --goto-next-toot puts - ;; point. - (concat (propertize - (funcall author-byline toot) - 'help-echo (mastodon-tl--format-faves-count toot)) - (cond ((equal visibility "direct") - (if (fontp (char-displayable-p #10r128274)) - " ✉" - " [direct]")) - ((equal visibility "private") - (if (fontp (char-displayable-p #10r9993)) - " 🔒" - " [followers]"))) - (funcall action-byline toot) - " " - ;; TODO: Once we have a view for toot (responses etc.) make - ;; this a tab stop and attach an action. - (propertize - (format-time-string mastodon-toot-timestamp-format parsed-time) - 'timestamp parsed-time - 'display (if mastodon-tl--enable-relative-timestamps - (mastodon-tl--relative-time-description parsed-time) - parsed-time)) - (propertize "\n ------------\n" 'face 'default)) - 'favourited-p faved - 'boosted-p boosted - 'byline t)))) + (concat + ;; we propertize help-echo format faves for author name + ;; in `mastodon-tl--byline-author' + (funcall author-byline toot) + (cond ((equal visibility "direct") + (if (fontp (char-displayable-p #10r128274)) + " ✉" + " [direct]")) + ((equal visibility "private") + (if (fontp (char-displayable-p #10r9993)) + " 🔒" + " [followers]"))) + (funcall action-byline toot) + " " + ;; TODO: Once we have a view for toot (responses etc.) make + ;; this a tab stop and attach an action. + (propertize + (format-time-string mastodon-toot-timestamp-format parsed-time) + 'timestamp parsed-time + 'display (if mastodon-tl--enable-relative-timestamps + (mastodon-tl--relative-time-description parsed-time) + parsed-time)) + (propertize "\n ------------\n" 'face 'default)) + 'favourited-p faved + 'boosted-p boosted + 'byline t)))) (defun mastodon-tl--format-faved-or-boosted-byline (letter) "Format the byline marker for a boosted or favorited status. -- cgit v1.2.3 From 5c6fa1b6aae1c0b1bf09b2be700958351feb1861 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 20:28:44 +0100 Subject: Revert "replace all calls to mastodon-search--insert-users-propertized" This reverts commit 787f18dcff2ee7a4c5a5cbf331f4e2d26997e1cc. --- lisp/mastodon-search.el | 24 ++++++++++++++++++++++-- lisp/mastodon-tl.el | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 2f8054a..d17b054 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -98,8 +98,7 @@ Returns a nested list containing user handle, display name, and URL." " USERS\n" " ------------\n\n") 'success)) - (mastodon-profile--add-author-bylines accts) - ;; (mastodon-search--insert-users-propertized user-ids :note) + (mastodon-search--insert-users-propertized user-ids :note) ;; hashtag results: (insert (mastodon-tl--set-face (concat "\n ------------\n" @@ -125,6 +124,27 @@ Returns a nested list containing user handle, display name, and URL." (mapc 'mastodon-tl--toot toots-list-json) (goto-char (point-min)))))) +(defun mastodon-search--insert-users-propertized (users &optional note) + "Insert USERS list into the buffer. +If NOTE is non-nil, include user's profile note. +This is also called by `mastodon-tl--get-follow-suggestions'." + (mapc (lambda (el) + (insert (propertize (car el) 'face 'mastodon-display-name-face) + " : \n : " + (propertize (concat "@" (car (cdr el))) + 'face 'mastodon-handle-face + 'mouse-face 'highlight + 'mastodon-tab-stop 'user-handle + 'keymap mastodon-tl--link-keymap + 'mastodon-handle (concat "@" (car (cdr el))) + 'help-echo (concat "Browse user profile of @" (car (cdr el)))) + " : \n" + (if note + (mastodon-tl--render-text (cadddr el) nil) + "") + "\n")) + users)) + (defun mastodon-search--get-user-info (account) "Get user handle, display name, account URL and profile note from ACCOUNT." (list (alist-get 'display_name account) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d82a0a5..3167f9c 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1253,7 +1253,7 @@ RESPONSE is the JSON returned by the server." " SUGGESTED ACCOUNTS\n" " ------------\n\n") 'success)) - (mastodon-profile--add-author-bylines response) + (mastodon-search--insert-users-propertized users :note) (goto-char (point-min)))) (defun mastodon-tl--follow-user (user-handle &optional notify) -- cgit v1.2.3 From f545d8c1d65e3e2256f8b769bfdb87a5b6a1e3ea Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 20:30:34 +0100 Subject: move next/prev item funs --- lisp/mastodon-tl.el | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 3167f9c..ec9c033 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -303,6 +303,12 @@ Optionally start from POS." (mastodon-tl--goto-toot-pos 'next-single-property-change 'mastodon-tl--more)) +(defun mastodon-tl--goto-prev-toot () + "Jump to last toot header." + (interactive) + (mastodon-tl--goto-toot-pos 'previous-single-property-change + 'mastodon-tl--update)) + (defun mastodon-tl--goto-first-toot () "Jump to first toot or item in buffer. Used on initializing a timeline or thread." @@ -312,11 +318,17 @@ Used on initializing a timeline or thread." (mastodon-tl--goto-toot-pos 'next-single-property-change 'next-line)) ;dummy function as we need to feed it something -(defun mastodon-tl--goto-prev-toot () - "Jump to last toot header." +(defun mastodon-tl--goto-next-item () + "Jump to next item, e.g. filter or follow request." + (interactive) + (mastodon-tl--goto-toot-pos 'next-single-property-change + 'next-line)) + +(defun mastodon-tl--goto-prev-item () + "Jump to previous item, e.g. filter or follow request." (interactive) (mastodon-tl--goto-toot-pos 'previous-single-property-change - 'mastodon-tl--update)) + 'previous-line)) (defun mastodon-tl--remove-html (toot) "Remove unrendered tags from TOOT." @@ -1223,18 +1235,6 @@ JSON is what is returned by by the server." (mastodon-tl--view-filters) (message "Filter for \"%s\" deleted!" phrase))))))) -(defun mastodon-tl--goto-next-item () - "Jump to next item, e.g. filter or follow request." - (interactive) - (mastodon-tl--goto-toot-pos 'next-single-property-change - 'next-line)) - -(defun mastodon-tl--goto-prev-item () - "Jump to previous item, e.g. filter or follow request." - (interactive) - (mastodon-tl--goto-toot-pos 'previous-single-property-change - 'previous-line)) - (defun mastodon-tl--get-follow-suggestions () "Display a buffer of suggested accounts to follow." (interactive) -- cgit v1.2.3 From 1c0328ced821b152e3da911592a6acd12d8598dd Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 21:55:10 +0100 Subject: re-factor follow-user functions for various views - revert profile--extract-users-handles - rewrite search--insert-users-propertized to handle raw account JSON, and to call search--get-user-info itself, so we can add full acct JSON to each user displayed and use it for follow-user etc. - and to choose how we want to follow users, we edit tl--interactive-user-handles-get to work differently depending on context: - poss contexts are "follow suggestions" view, search results, and profiles displaying a user's followers/followed users. --- lisp/mastodon-profile.el | 11 +++-------- lisp/mastodon-search.el | 48 ++++++++++++++++++++++++++++-------------------- lisp/mastodon-tl.el | 15 ++++++++++++--- 3 files changed, 43 insertions(+), 31 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 8388d05..5504065 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -463,14 +463,9 @@ If the handle does not match a search return then retun NIL." These include the author, author of reblogged entries and any user mentioned." (when status - (let ((this-account - ;; follow suggestions view compat: - (if (or (equal (buffer-name) "*mastodon-follow-suggestions*") - (string-prefix-p "accounts" (mastodon-tl--get-endpoint))) - (mastodon-tl--property 'toot-json) - (alist-get 'account status))) - (mentions (alist-get 'mentions status)) - (reblog (alist-get 'reblog status))) + (let ((this-account (alist-get 'account status)) + (mentions (alist-get 'mentions status)) + (reblog (alist-get 'reblog status))) (seq-filter 'stringp (seq-uniq diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index d17b054..726b76e 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -89,16 +89,16 @@ Returns a nested list containing user handle, display name, and URL." status-ids-list))) (with-current-buffer (get-buffer-create buffer) (switch-to-buffer buffer) - (erase-buffer) (mastodon-mode) (let ((inhibit-read-only t)) + (erase-buffer) ;; user results: (insert (mastodon-tl--set-face (concat "\n ------------\n" " USERS\n" " ------------\n\n") 'success)) - (mastodon-search--insert-users-propertized user-ids :note) + (mastodon-search--insert-users-propertized accts :note) ;; hashtag results: (insert (mastodon-tl--set-face (concat "\n ------------\n" @@ -124,26 +124,34 @@ Returns a nested list containing user handle, display name, and URL." (mapc 'mastodon-tl--toot toots-list-json) (goto-char (point-min)))))) -(defun mastodon-search--insert-users-propertized (users &optional note) - "Insert USERS list into the buffer. +(defun mastodon-search--insert-users-propertized (json &optional note) + "Insert users list into the buffer. +JSON is the data from the server.. If NOTE is non-nil, include user's profile note. This is also called by `mastodon-tl--get-follow-suggestions'." - (mapc (lambda (el) - (insert (propertize (car el) 'face 'mastodon-display-name-face) - " : \n : " - (propertize (concat "@" (car (cdr el))) - 'face 'mastodon-handle-face - 'mouse-face 'highlight - 'mastodon-tab-stop 'user-handle - 'keymap mastodon-tl--link-keymap - 'mastodon-handle (concat "@" (car (cdr el))) - 'help-echo (concat "Browse user profile of @" (car (cdr el)))) - " : \n" - (if note - (mastodon-tl--render-text (cadddr el) nil) - "") - "\n")) - users)) + (mapc (lambda (acct) + (let ((user (mastodon-search--get-user-info acct))) + (insert + (propertize + (concat (propertize (car user) + 'face 'mastodon-display-name-face + 'byline t + 'toot-id "0") + " : \n : " + (propertize (concat "@" (cadr user)) + 'face 'mastodon-handle-face + 'mouse-face 'highlight + 'mastodon-tab-stop 'user-handle + 'keymap mastodon-tl--link-keymap + 'mastodon-handle (concat "@" (cadr user)) + 'help-echo (concat "Browse user profile of @" (cadr user))) + " : \n" + (if note + (mastodon-tl--render-text (cadddr user) nil) + "") + "\n") + 'user-json acct)))) + json)) (defun mastodon-search--get-user-info (account) "Get user handle, display name, account URL and profile note from ACCOUNT." diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index ec9c033..6bb5656 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1253,7 +1253,7 @@ RESPONSE is the JSON returned by the server." " SUGGESTED ACCOUNTS\n" " ------------\n\n") 'success)) - (mastodon-search--insert-users-propertized users :note) + (mastodon-search--insert-users-propertized response :note) (goto-char (point-min)))) (defun mastodon-tl--follow-user (user-handle &optional notify) @@ -1321,8 +1321,17 @@ Can be called to toggle NOTIFY on users already being followed." (defun mastodon-tl--interactive-user-handles-get (action) "Get the list of user-handles for ACTION from the current toot." - (let ((user-handles (mastodon-profile--extract-users-handles - (mastodon-profile--toot-json)))) + (let ((user-handles + ;; follow suggests / search compat: + (cond ((or (equal (buffer-name) "*mastodon-follow-suggestions*") + (string-prefix-p "*mastodon-search" (buffer-name))) + (list (alist-get 'acct (mastodon-tl--property 'user-json)))) + ;; profile view follows/followers compat: + ((string-prefix-p "accounts" (mastodon-tl--get-endpoint)) + (list (alist-get 'acct (mastodon-tl--property 'toot-json)))) + (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) -- cgit v1.2.3 From 507a1a00541863fc2a1e7c9a56176aa98167e791 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 22:38:09 +0100 Subject: rename goto-first-toot to goto-first-item and enable it in "favourites" buffer --- lisp/mastodon-tl.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 6bb5656..923ad79 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -309,14 +309,14 @@ Optionally start from POS." (mastodon-tl--goto-toot-pos 'previous-single-property-change 'mastodon-tl--update)) -(defun mastodon-tl--goto-first-toot () +(defun mastodon-tl--goto-first-item () "Jump to first toot or item in buffer. Used on initializing a timeline or thread." ;; goto-next-toot assumes we already have toots, and is therefore ;; incompatible with any view where it is possible to have no items. ;; when that is the case the call to goto-toot-pos loops infinitely - (mastodon-tl--goto-toot-pos 'next-single-property-change - 'next-line)) ;dummy function as we need to feed it something + (goto-char (point-min)) + (mastodon-tl--goto-next-item)) (defun mastodon-tl--goto-next-item () "Jump to next item, e.g. filter or follow request." @@ -1635,8 +1635,9 @@ JSON is the data returned from the server." nil))) (when (or (equal endpoint "notifications") (string-prefix-p "timelines" endpoint) + (string-prefix-p "favourites" endpoint) (string-prefix-p "statuses" endpoint)) - (mastodon-tl--goto-first-toot)))) + (mastodon-tl--goto-first-item)))) (defun mastodon-tl--init-sync (buffer-name endpoint update-function) "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. @@ -1672,8 +1673,9 @@ Runs synchronously." (when (and (not (equal json '[])) (or (equal endpoint "notifications") (string-prefix-p "timelines" endpoint) + (string-prefix-p "favourites" endpoint) (string-prefix-p "statuses" endpoint)) - (mastodon-tl--goto-first-toot)))) + (mastodon-tl--goto-first-item)))) buffer)) (provide 'mastodon-tl) -- cgit v1.2.3 From 241aa9b35101e6e8814e4aab64597caf6a285f75 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 15 Feb 2022 21:54:30 +0100 Subject: fix view filters/foll suggests - they get keymaps that inherit and so override the main masto keymap, which allows them to still have the basic timeline/view nav functions. - but we give them next-item rather than next toot so that they never try to e.g. load for toots into the buffer, which wouldn't work. - also remove the reference to foll requests view in tl--init as it is not longer needed. binding for follow suggestions remove tab from foll suggests keymap makes tab work as default, which means you can n/p to next/prev user, while still being able to tab to user next handle, to visit profile squashed commit: remove foll suggestions keymap --- lisp/mastodon-tl.el | 45 ++++++++++++++++++--------------------------- lisp/mastodon.el | 1 + 2 files changed, 19 insertions(+), 27 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 923ad79..eaafd74 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -71,6 +71,7 @@ (defvar mastodon-instance-url) (defvar mastodon-toot-timestamp-format) (defvar shr-use-fonts) ;; declare it since Emacs24 didn't have this +(defvar mastodon-mode-map) (defgroup mastodon-tl nil "Timelines in Mastodon." @@ -171,33 +172,27 @@ We need to override the keymap so tabbing will navigate to all types of mastodon links and not just shr.el-generated ones.") (defvar mastodon-tl--view-filters-keymap - (let ((map (make-sparse-keymap))) + (let ((map ;(make-sparse-keymap))) + (copy-keymap mastodon-mode-map))) (define-key map (kbd "d") 'mastodon-tl--delete-filter) (define-key map (kbd "c") 'mastodon-tl--create-filter) (define-key map (kbd "n") 'mastodon-tl--goto-next-item) (define-key map (kbd "p") 'mastodon-tl--goto-prev-item) - (define-key map (kbd "TAB") 'mastodon-tl--goto-next-filter) + (define-key map (kbd "TAB") 'mastodon-tl--goto-next-item) (define-key map (kbd "g") 'mastodon-tl--view-filters) - (define-key map (kbd "t") 'mastodon-toot) - (define-key map (kbd "q") 'kill-current-buffer) - (define-key map (kbd "Q") 'kill-buffer-and-window) (keymap-canonicalize map)) - "Keymap for viewing filters.") + "Keymap for viewing filters.") -(defvar mastodon-tl--view-suggestions-keymap - (let ((map (make-sparse-keymap))) - (define-key map (kbd "W") 'mastodon-tl--follow-user) +(defvar mastodon-tl--follow-suggestions-map + (let ((map ;(make-sparse-keymap))) + (copy-keymap mastodon-mode-map))) (define-key map (kbd "n") 'mastodon-tl--goto-next-item) (define-key map (kbd "p") 'mastodon-tl--goto-prev-item) - (define-key map (kbd "TAB") 'mastodon-tl--goto-next-item) (define-key map (kbd "g") 'mastodon-tl--get-follow-suggestions) - (define-key map (kbd "t") 'mastodon-toot) - (define-key map (kbd "q") 'kill-current-buffer) - (define-key map (kbd "Q") 'kill-buffer-and-window) (keymap-canonicalize map)) - "Keymap for viewing follow suggestions.") + "Keymap for viewing follow suggestions.") -(defvar mastodon-tl--byline-link-keymap + (defvar mastodon-tl--byline-link-keymap (when (require 'mpv nil :no-error) (let ((map (make-sparse-keymap))) (define-key map (kbd "") 'mastodon-tl--mpv-play-video-from-byline) @@ -1241,20 +1236,19 @@ JSON is what is returned by by the server." (mastodon-tl--init-sync "follow-suggestions" "suggestions" 'mastodon-tl--insert-follow-suggestions) - (use-local-map mastodon-tl--view-suggestions-keymap) + (use-local-map mastodon-tl--follow-suggestions-map) (mastodon-tl--goto-next-item)) (defun mastodon-tl--insert-follow-suggestions (response) "Insert follow suggestions into buffer. RESPONSE is the JSON returned by the server." - (let* ((users (mapcar 'mastodon-search--get-user-info response))) - (insert (mastodon-tl--set-face - (concat "\n ------------\n" - " SUGGESTED ACCOUNTS\n" - " ------------\n\n") - 'success)) - (mastodon-search--insert-users-propertized response :note) - (goto-char (point-min)))) + (insert (mastodon-tl--set-face + (concat "\n ------------\n" + " SUGGESTED ACCOUNTS\n" + " ------------\n\n") + 'success)) + (mastodon-search--insert-users-propertized response :note) + (goto-char (point-min))) (defun mastodon-tl--follow-user (user-handle &optional notify) "Query for USER-HANDLE from current status and follow that user. @@ -1616,9 +1610,6 @@ JSON is the data returned from the server." (seconds-to-time 300))) (funcall update-function json)) (mastodon-mode) - (when (equal endpoint "follow_requests") - (mastodon-profile-mode) - (use-local-map mastodon-profile--view-follow-requests-keymap)) (with-current-buffer buffer (setq mastodon-tl--buffer-spec `(buffer-name ,buffer diff --git a/lisp/mastodon.el b/lisp/mastodon.el index c8ceee7..51e27ec 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -166,6 +166,7 @@ Use. e.g. \"%c\" for your locale's date and time format." (define-key map (kbd "k") #'mastodon-toot--bookmark-toot-toggle) (define-key map (kbd "K") #'mastodon-profile--view-bookmarks) (define-key map (kbd "I") #'mastodon-tl--view-filters) + (define-key map (kbd "G") #'mastodon-tl--get-follow-suggestions) map) "Keymap for `mastodon-mode'.") -- cgit v1.2.3 From 7d12bfac3c9adfae63529cc2a9d10ab006fc7b5f Mon Sep 17 00:00:00 2001 From: mousebot Date: Wed, 16 Feb 2022 10:37:23 +0100 Subject: cleanup indentation in tl.el cleanup indents --- lisp/mastodon-profile.el | 4 +- lisp/mastodon-search.el | 46 ++++++++++----------- lisp/mastodon-tl.el | 102 +++++++++++++++++++++++------------------------ 3 files changed, 76 insertions(+), 76 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index b5e1489..0119a36 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -475,8 +475,8 @@ If the handle does not match a search return then retun NIL." These include the author, author of reblogged entries and any user mentioned." (when status (let ((this-account (alist-get 'account status)) - (mentions (alist-get 'mentions status)) - (reblog (alist-get 'reblog status))) + (mentions (alist-get 'mentions status)) + (reblog (alist-get 'reblog status))) (seq-filter 'stringp (seq-uniq diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 1c7f00e..e1ca81a 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -130,29 +130,29 @@ Returns a nested list containing user handle, display name, and URL." JSON is the data from the server.. If NOTE is non-nil, include user's profile note. This is also called by `mastodon-tl--get-follow-suggestions'." - (mapc (lambda (acct) - (let ((user (mastodon-search--get-user-info acct))) - (insert - (propertize - (concat (propertize (car user) - 'face 'mastodon-display-name-face - 'byline t - 'toot-id "0") - " : \n : " - (propertize (concat "@" (cadr user)) - 'face 'mastodon-handle-face - 'mouse-face 'highlight - 'mastodon-tab-stop 'user-handle - 'keymap mastodon-tl--link-keymap - 'mastodon-handle (concat "@" (cadr user)) - 'help-echo (concat "Browse user profile of @" (cadr user))) - " : \n" - (if note - (mastodon-tl--render-text (cadddr user) nil) - "") - "\n") - 'user-json acct)))) - json)) + (mapc (lambda (acct) + (let ((user (mastodon-search--get-user-info acct))) + (insert + (propertize + (concat (propertize (car user) + 'face 'mastodon-display-name-face + 'byline t + 'toot-id "0") + " : \n : " + (propertize (concat "@" (cadr user)) + 'face 'mastodon-handle-face + 'mouse-face 'highlight + 'mastodon-tab-stop 'user-handle + 'keymap mastodon-tl--link-keymap + 'mastodon-handle (concat "@" (cadr user)) + 'help-echo (concat "Browse user profile of @" (cadr user))) + " : \n" + (if note + (mastodon-tl--render-text (cadddr user) nil) + "") + "\n") + 'user-json acct)))) + json)) (defun mastodon-search--get-user-info (account) "Get user handle, display name, account URL and profile note from ACCOUNT." diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index eaafd74..2c2c6ec 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -362,12 +362,12 @@ Used on initializing a timeline or thread." (propertize (concat "@" handle) 'face 'mastodon-handle-face 'mouse-face 'highlight - 'mastodon-tab-stop 'user-handle + 'mastodon-tab-stop 'user-handle 'account account - 'shr-url profile-url - 'keymap mastodon-tl--link-keymap + 'shr-url profile-url + 'keymap mastodon-tl--link-keymap 'mastodon-handle (concat "@" handle) - 'help-echo (concat "Browse user profile of @" handle)) + 'help-echo (concat "Browse user profile of @" handle)) ")"))) (defun mastodon-tl--format-faves-count (toot) @@ -520,34 +520,34 @@ By default it is `mastodon-tl--byline-boosted'" ;; this makes the behaviour of these markers consistent whether they are ;; displayed for an already boosted/favourited toot or as the result of ;; the toot having just been favourited/boosted. - (concat (when boosted - (mastodon-tl--format-faved-or-boosted-byline "B")) - (when faved - (mastodon-tl--format-faved-or-boosted-byline "F"))) - (propertize - (concat - ;; we propertize help-echo format faves for author name - ;; in `mastodon-tl--byline-author' - (funcall author-byline toot) - (cond ((equal visibility "direct") - (if (fontp (char-displayable-p #10r128274)) - " ✉" - " [direct]")) - ((equal visibility "private") - (if (fontp (char-displayable-p #10r9993)) - " 🔒" - " [followers]"))) - (funcall action-byline toot) - " " - ;; TODO: Once we have a view for toot (responses etc.) make - ;; this a tab stop and attach an action. - (propertize - (format-time-string mastodon-toot-timestamp-format parsed-time) - 'timestamp parsed-time - 'display (if mastodon-tl--enable-relative-timestamps - (mastodon-tl--relative-time-description parsed-time) - parsed-time)) - (propertize "\n ------------\n" 'face 'default)) + (concat (when boosted + (mastodon-tl--format-faved-or-boosted-byline "B")) + (when faved + (mastodon-tl--format-faved-or-boosted-byline "F"))) + (propertize + (concat + ;; we propertize help-echo format faves for author name + ;; in `mastodon-tl--byline-author' + (funcall author-byline toot) + (cond ((equal visibility "direct") + (if (fontp (char-displayable-p #10r128274)) + " ✉" + " [direct]")) + ((equal visibility "private") + (if (fontp (char-displayable-p #10r9993)) + " 🔒" + " [followers]"))) + (funcall action-byline toot) + " " + ;; TODO: Once we have a view for toot (responses etc.) make + ;; this a tab stop and attach an action. + (propertize + (format-time-string mastodon-toot-timestamp-format parsed-time) + 'timestamp parsed-time + 'display (if mastodon-tl--enable-relative-timestamps + (mastodon-tl--relative-time-description parsed-time) + parsed-time)) + (propertize "\n ------------\n" 'face 'default)) 'favourited-p faved 'boosted-p boosted 'byline t)))) @@ -947,11 +947,11 @@ a notification." (let ((attachments (mastodon-tl--property 'attachments)) vids) (mapc (lambda (x) - (let ((att-type (plist-get x :type))) - (when (or (string= "video" att-type) - (string= "gifv" att-type)) - (push x vids)))) - attachments) + (let ((att-type (plist-get x :type))) + (when (or (string= "video" att-type) + (string= "gifv" att-type)) + (push x vids)))) + attachments) (car vids))) (defun mastodon-tl--mpv-play-video-from-byline () @@ -975,7 +975,7 @@ in which case play first video or gif from current toot." (type (or ;; in byline: type ;; point in toot: - (mastodon-tl--property 'mastodon-media-type)))) + (mastodon-tl--property 'mastodon-media-type)))) (if url (if (or (equal type "gifv") (equal type "video")) @@ -1211,24 +1211,24 @@ JSON is what is returned by by the server." (propertize filter-string 'toot-id id ;for goto-next-filter compat 'phrase phrase - ;'help-echo "n/p to go to next/prev filter, c to create new filter, d to delete filter at point." - ;'keymap mastodon-tl--view-filters-keymap + ;;'help-echo "n/p to go to next/prev filter, c to create new filter, d to delete filter at point." + ;;'keymap mastodon-tl--view-filters-keymap 'byline t)))) ;for goto-next-filter compat (defun mastodon-tl--delete-filter () "Delete filter at point." (interactive) - (let* ((filter-id (get-text-property (point) 'toot-id)) - (phrase (get-text-property (point) 'phrase)) - (url (mastodon-http--api - (format "filters/%s" filter-id)))) - (if (equal nil filter-id) - (error "No filter at point?") - (when (y-or-n-p (format "Delete this filter? "))) - (let ((response (mastodon-http--delete url))) - (mastodon-http--triage response (lambda () - (mastodon-tl--view-filters) - (message "Filter for \"%s\" deleted!" phrase))))))) + (let* ((filter-id (get-text-property (point) 'toot-id)) + (phrase (get-text-property (point) 'phrase)) + (url (mastodon-http--api + (format "filters/%s" filter-id)))) + (if (equal nil filter-id) + (error "No filter at point?") + (when (y-or-n-p (format "Delete this filter? "))) + (let ((response (mastodon-http--delete url))) + (mastodon-http--triage response (lambda () + (mastodon-tl--view-filters) + (message "Filter for \"%s\" deleted!" phrase))))))) (defun mastodon-tl--get-follow-suggestions () "Display a buffer of suggested accounts to follow." -- cgit v1.2.3 From 121a09f5986dff508d713b772a54a4c8b4d446c4 Mon Sep 17 00:00:00 2001 From: mousebot Date: Wed, 16 Feb 2022 10:37:48 +0100 Subject: run goto-first-item in tl--init, unless profile view - remove call to goto-next-item from view filters and view foll suggests tweak init-sync goto-first-item behaviour remove call to goto-next-toot on profile load --- lisp/mastodon-profile.el | 1 - lisp/mastodon-tl.el | 31 +++++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 0119a36..7e78fd7 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -378,7 +378,6 @@ Returns a list of lists." (mastodon-profile--insert-statuses-pinned pinned) (setq mastodon-tl--update-point (point))) ;updates to follow pinned toots (funcall update-function json))) - ;;(mastodon-tl--goto-next-toot) (goto-char (point-min)))) (defun mastodon-profile--get-toot-author () diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2c2c6ec..fef8a98 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1175,8 +1175,7 @@ Prompt for a context, must be a list containting at least one of \"home\", (mastodon-tl--init-sync "filters" "filters" 'mastodon-tl--insert-filters) - (use-local-map mastodon-tl--view-filters-keymap) - (mastodon-tl--goto-next-item)) + (use-local-map mastodon-tl--view-filters-keymap)) (defun mastodon-tl--insert-filters (json) "Insert the user's current filters. @@ -1236,8 +1235,7 @@ JSON is what is returned by by the server." (mastodon-tl--init-sync "follow-suggestions" "suggestions" 'mastodon-tl--insert-follow-suggestions) - (use-local-map mastodon-tl--follow-suggestions-map) - (mastodon-tl--goto-next-item)) + (use-local-map mastodon-tl--follow-suggestions-map)) (defun mastodon-tl--insert-follow-suggestions (response) "Insert follow suggestions into buffer. @@ -1624,11 +1622,14 @@ JSON is the data returned from the server." #'mastodon-tl--update-timestamps-callback (current-buffer) nil))) - (when (or (equal endpoint "notifications") - (string-prefix-p "timelines" endpoint) - (string-prefix-p "favourites" endpoint) - (string-prefix-p "statuses" endpoint)) - (mastodon-tl--goto-first-item)))) + (unless + ;; for everything save profiles: + (string-prefix-p "accounts" endpoint)) + ;;(or (equal endpoint "notifications") + ;; (string-prefix-p "timelines" endpoint) + ;; (string-prefix-p "favourites" endpoint) + ;; (string-prefix-p "statuses" endpoint)) + (mastodon-tl--goto-first-item))) (defun mastodon-tl--init-sync (buffer-name endpoint update-function) "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. @@ -1661,13 +1662,11 @@ Runs synchronously." #'mastodon-tl--update-timestamps-callback (current-buffer) nil))) - (when (and (not (equal json '[])) - (or (equal endpoint "notifications") - (string-prefix-p "timelines" endpoint) - (string-prefix-p "favourites" endpoint) - (string-prefix-p "statuses" endpoint)) - (mastodon-tl--goto-first-item)))) - buffer)) + (when ;(and (not (equal json '[])) + ;; for everything save profiles: + (not (string-prefix-p "accounts" endpoint)) + (mastodon-tl--goto-first-item))) + buffer)) (provide 'mastodon-tl) ;;; mastodon-tl.el ends here -- cgit v1.2.3 From 7ada5cb566568326627d9ec985b28142b1ddf220 Mon Sep 17 00:00:00 2001 From: mousebot Date: Wed, 16 Feb 2022 11:52:58 +0100 Subject: make interactive-user-handles-get work for all profile views - profile statuses: leave as is - profile followers/following: we extract handle direct from toot-json without running mastodon-profile--extract-users-handles on the toot, as with user views there is no toot --- lisp/mastodon-tl.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index fef8a98..c4b683d 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1319,8 +1319,10 @@ Can be called to toggle NOTIFY on users already being followed." (string-prefix-p "*mastodon-search" (buffer-name))) (list (alist-get 'acct (mastodon-tl--property 'user-json)))) ;; profile view follows/followers compat: - ((string-prefix-p "accounts" (mastodon-tl--get-endpoint)) - (list (alist-get 'acct (mastodon-tl--property 'toot-json)))) + ;; but not for profile statuses: + ((when (and (string-prefix-p "accounts" (mastodon-tl--get-endpoint)) + (not (string-suffix-p "statuses" (mastodon-tl--get-endpoint)))) + (list (alist-get 'acct (mastodon-tl--property 'toot-json))))) (t (mastodon-profile--extract-users-handles (mastodon-profile--toot-json)))))) -- cgit v1.2.3 From fce69f724310896f7bbb071e74c7a9c1663153de Mon Sep 17 00:00:00 2001 From: mousebot Date: Wed, 16 Feb 2022 20:30:13 +0100 Subject: no faves counts for following/followers in profile view --- 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 c4b683d..272ca15 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -357,7 +357,12 @@ Used on initializing a timeline or thread." ;; echo faves count when point on post author name: ;; which is where --goto-next-toot puts point. 'help-echo - (mastodon-tl--format-faves-count toot)) + ;; but don't add it to "following"/"follows" on profile views: + ;; we don't have a tl--buffer-spec yet: + (unless (or (string-suffix-p "-followers*" (buffer-name)) + (string-suffix-p "-following*" (buffer-name))) + ;; (mastodon-tl--get-endpoint))) + (mastodon-tl--format-faves-count toot))) " (" (propertize (concat "@" handle) 'face 'mastodon-handle-face -- cgit v1.2.3 From 0efc846bed8443c1ed38bdb15f3afc4f052b7615 Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 18 Feb 2022 14:59:07 +0100 Subject: tl--init: aslo set tl-buffer-spec before update-function --- lisp/mastodon-tl.el | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 272ca15..f23fe67 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -192,7 +192,7 @@ types of mastodon links and not just shr.el-generated ones.") (keymap-canonicalize map)) "Keymap for viewing follow suggestions.") - (defvar mastodon-tl--byline-link-keymap +(defvar mastodon-tl--byline-link-keymap (when (require 'mpv nil :no-error) (let ((map (make-sparse-keymap))) (define-key map (kbd "") 'mastodon-tl--mpv-play-video-from-byline) @@ -1326,8 +1326,8 @@ Can be called to toggle NOTIFY on users already being followed." ;; profile view follows/followers compat: ;; but not for profile statuses: ((when (and (string-prefix-p "accounts" (mastodon-tl--get-endpoint)) - (not (string-suffix-p "statuses" (mastodon-tl--get-endpoint)))) - (list (alist-get 'acct (mastodon-tl--property 'toot-json))))) + (not (string-suffix-p "statuses" (mastodon-tl--get-endpoint)))) + (list (alist-get 'acct (mastodon-tl--property 'toot-json))))) (t (mastodon-profile--extract-users-handles (mastodon-profile--toot-json)))))) @@ -1608,6 +1608,14 @@ UPDATE-FUNCTION is used to recieve more toots. JSON is the data returned from the server." (with-output-to-temp-buffer buffer (switch-to-buffer buffer) + ;; mastodon-mode wipes buffer-spec, so order must unforch be: + ;; 1 run update-function, 2 enable masto-mode, 3 set buffer spec. + ;; which means we cannot use buffer-spec for update-function + ;; unless we set it both before and after the others + (setq mastodon-tl--buffer-spec + `(buffer-name ,buffer + endpoint ,endpoint + update-function ,update-function)) (setq ;; Initialize with a minimal interval; we re-scan at least once ;; every 5 minutes to catch any timestamps we may have missed @@ -1648,6 +1656,14 @@ Runs synchronously." (json (mastodon-http--get-json url))) (with-output-to-temp-buffer buffer (switch-to-buffer buffer) + ;; mastodon-mode wipes buffer-spec, so order must unforch be: + ;; 1 run update-function, 2 enable masto-mode, 3 set buffer spec. + ;; which means we cannot use buffer-spec for update-function + ;; unless we set it both before and after the others + (setq mastodon-tl--buffer-spec + `(buffer-name ,buffer + endpoint ,endpoint + update-function ,update-function)) (setq ;; Initialize with a minimal interval; we re-scan at least once ;; every 5 minutes to catch any timestamps we may have missed @@ -1670,7 +1686,7 @@ Runs synchronously." (current-buffer) nil))) (when ;(and (not (equal json '[])) - ;; for everything save profiles: + ;; for everything save profiles: (not (string-prefix-p "accounts" endpoint)) (mastodon-tl--goto-first-item))) buffer)) -- cgit v1.2.3 From 868a5680953d35f66cb64f92e940f55d579c74b2 Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 18 Feb 2022 16:02:46 +0100 Subject: handle empty display_name in mastodon-tl--do-user-action-and-response --- lisp/mastodon-tl.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index f23fe67..2fa3526 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1371,7 +1371,9 @@ NOTIFY is only non-nil when called by `mastodon-tl--follow-user'." (mastodon-profile--lookup-account-in-status user-handle (mastodon-profile--toot-json)))) (user-id (mastodon-profile--account-field account 'id)) - (name (mastodon-profile--account-field account 'display_name)) + (name (if (not (equal "" (mastodon-profile--account-field account 'display_name))) + (mastodon-profile--account-field account 'display_name) + (mastodon-profile--account-field account 'username))) (url (mastodon-http--api (if notify (format "accounts/%s/%s?notify=%s" user-id action notify) -- cgit v1.2.3 From 58e23171ef8883b08cbf6d33d9c41deaf66f87ff Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 18 Feb 2022 16:03:26 +0100 Subject: FIX buffers that use alt acct fetch in interactive-user-handles-get --- lisp/mastodon-tl.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2fa3526..7ba78e4 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1319,15 +1319,15 @@ Can be called to toggle NOTIFY on users already being followed." (defun mastodon-tl--interactive-user-handles-get (action) "Get the list of user-handles for ACTION from the current toot." (let ((user-handles - ;; follow suggests / search compat: (cond ((or (equal (buffer-name) "*mastodon-follow-suggestions*") - (string-prefix-p "*mastodon-search" (buffer-name))) - (list (alist-get 'acct (mastodon-tl--property 'user-json)))) - ;; profile view follows/followers compat: - ;; but not for profile statuses: - ((when (and (string-prefix-p "accounts" (mastodon-tl--get-endpoint)) - (not (string-suffix-p "statuses" (mastodon-tl--get-endpoint)))) - (list (alist-get 'acct (mastodon-tl--property 'toot-json))))) + ;; follow suggests / search / foll requests compat: + (string-prefix-p "*mastodon-search" (buffer-name)) + (equal (buffer-name) "*mastodon-follow-requests*") + ;; profile view follows/followers compat: + ;; but not for profile statuses: + (and (string-prefix-p "accounts" (mastodon-tl--get-endpoint)) + (not (string-suffix-p "statuses" (mastodon-tl--get-endpoint))))) + (list (alist-get 'acct (mastodon-tl--property 'toot-json)))) (t (mastodon-profile--extract-users-handles (mastodon-profile--toot-json)))))) -- cgit v1.2.3 From 4f582388e0594753d15f0d386cbb1ab2eaad5a02 Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 18 Feb 2022 17:15:59 +0100 Subject: test for toot-json before following/muting/blocking etc this is more needed now that we have some other buffers like follow suggestions and follow requests, which want to be able to use these functions. previously, if any of them were called in these buffers when not on the correct item, the buffer would reload and duplicate. ultimately this was probably due to tl--property calls failing, which causes goto-next-toot to be called, which when it also fails calls tl--more. --- lisp/mastodon-tl.el | 70 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 28 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 7ba78e4..7a346c1 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1258,17 +1258,21 @@ RESPONSE is the JSON returned by the server." If NOTIFY is \"true\", enable notifications when that user posts. If NOTIFY is \"false\", disable notifications when that user posts. Can be called to toggle NOTIFY on users already being followed." - (interactive - (list - (mastodon-tl--interactive-user-handles-get "follow"))) - (mastodon-tl--do-user-action-and-response user-handle "follow" nil notify)) + (interactive + (list + (mastodon-tl--interactive-user-handles-get "follow"))) + (if (not (get-text-property (point) 'toot-json)) + (message "Looks like there's no toot or user at point?") + (mastodon-tl--do-user-action-and-response user-handle "follow" nil notify))) (defun mastodon-tl--enable-notify-user-posts (user-handle) "Query for USER-HANDLE and enable notifications when they post." (interactive (list (mastodon-tl--interactive-user-handles-get "enable"))) - (mastodon-tl--follow-user user-handle "true")) + (if (not (get-text-property (point) 'toot-json)) + (message "Looks like there's no toot or user at point?") + (mastodon-tl--follow-user user-handle "true"))) (defun mastodon-tl--disable-notify-user-posts (user-handle) "Query for USER-HANDLE and disable notifications when they post." @@ -1282,14 +1286,18 @@ Can be called to toggle NOTIFY on users already being followed." (interactive (list (mastodon-tl--interactive-user-handles-get "unfollow"))) - (mastodon-tl--do-user-action-and-response user-handle "unfollow" t)) + (if (not (get-text-property (point) 'toot-json)) + (message "Looks like there's no toot or user at point?") + (mastodon-tl--do-user-action-and-response user-handle "unfollow" t))) (defun mastodon-tl--block-user (user-handle) "Query for USER-HANDLE from current status and block that user." (interactive (list (mastodon-tl--interactive-user-handles-get "block"))) - (mastodon-tl--do-user-action-and-response user-handle "block")) + (if (not (get-text-property (point) 'toot-json)) + (message "Looks like there's no toot or user at point?") + (mastodon-tl--do-user-action-and-response user-handle "block"))) (defun mastodon-tl--unblock-user (user-handle) "Query for USER-HANDLE from list of blocked users and unblock that user." @@ -1305,7 +1313,9 @@ Can be called to toggle NOTIFY on users already being followed." (interactive (list (mastodon-tl--interactive-user-handles-get "mute"))) - (mastodon-tl--do-user-action-and-response user-handle "mute")) + (if (not (get-text-property (point) 'toot-json)) + (message "Looks like there's no toot or user at point?") + (mastodon-tl--do-user-action-and-response user-handle "mute"))) (defun mastodon-tl--unmute-user (user-handle) "Query for USER-HANDLE from list of muted users and unmute that user." @@ -1318,26 +1328,30 @@ Can be called to toggle NOTIFY on users already being followed." (defun mastodon-tl--interactive-user-handles-get (action) "Get the list of user-handles for ACTION from the current toot." - (let ((user-handles - (cond ((or (equal (buffer-name) "*mastodon-follow-suggestions*") - ;; follow suggests / search / foll requests compat: - (string-prefix-p "*mastodon-search" (buffer-name)) - (equal (buffer-name) "*mastodon-follow-requests*") - ;; profile view follows/followers compat: - ;; but not for profile statuses: - (and (string-prefix-p "accounts" (mastodon-tl--get-endpoint)) - (not (string-suffix-p "statuses" (mastodon-tl--get-endpoint))))) - (list (alist-get 'acct (mastodon-tl--property 'toot-json)))) - (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))) + (if (not (get-text-property (point) 'toot-json)) + (message "Looks like there's no toot or user at point?") + (let ((user-handles + (cond ((or (equal (buffer-name) "*mastodon-follow-suggestions*") + ;; follow suggests / search / foll requests compat: + (string-prefix-p "*mastodon-search" (buffer-name)) + (equal (buffer-name) "*mastodon-follow-requests*") + ;; profile view follows/followers compat: + ;; but not for profile statuses: + (and (string-prefix-p "accounts" (mastodon-tl--get-endpoint)) + (not (string-suffix-p "statuses" (mastodon-tl--get-endpoint))))) + ;; avoid tl--property here because it calls next-toot + ;; which breaks non-toot buffers like foll reqs etc.: + (list (alist-get 'acct (get-text-property (point) 'toot-json)))) + (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)))) (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 a14ecfce170e82ae610247b8ed1854077deed8c0 Mon Sep 17 00:00:00 2001 From: mousebot Date: Thu, 10 Mar 2022 13:09:47 +0100 Subject: display image caption in help echo --- lisp/mastodon-media.el | 10 +++++++--- lisp/mastodon-tl.el | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index 9441bdb..f79b1fa 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -307,12 +307,16 @@ Replace them with the referenced image." t image-options)) " "))) -(defun mastodon-media--get-media-link-rendering (media-url &optional full-remote-url type) +(defun mastodon-media--get-media-link-rendering (media-url &optional full-remote-url type caption) "Return the string to be written that renders the image at MEDIA-URL. FULL-REMOTE-URL is used for `shr-browse-image'. TYPE is the attachment's type field on the server." - (let ((help-echo - "RET/i: load full image (prefix: copy URL), +/-: zoom, r: rotate, o: save preview")) + (let* ((help-echo-base "RET/i: load full image (prefix: copy URL), +/-: zoom, r: rotate, o: save preview") + (help-echo (if caption + (concat help-echo-base + "\n\"" + caption "\"") + help-echo-base))) (concat (propertize "[img]" 'media-url media-url diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 7a346c1..6cd3ff0 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -817,10 +817,11 @@ message is a link which unhides/hides the main body." (or (alist-get 'remote_url media-attachement) ;; fallback b/c notifications don't have remote_url (alist-get 'url media-attachement))) - (type (alist-get 'type media-attachement))) + (type (alist-get 'type media-attachement)) + (caption (alist-get 'description media-attachement))) (if mastodon-tl--display-media-p (mastodon-media--get-media-link-rendering - preview-url remote-url type) ; 2nd arg for shr-browse-url + preview-url remote-url type caption) ; 2nd arg for shr-browse-url (concat "Media::" preview-url "\n")))) media-attachements ""))) (if (not (and mastodon-tl--display-media-p -- cgit v1.2.3 From 56995a8c693cca194e3272d17fec092c3585a3f4 Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 11 Mar 2022 09:26:19 +0100 Subject: favourite not favorite --- lisp/mastodon-notifications.el | 4 ++-- lisp/mastodon-tl.el | 4 ++-- lisp/mastodon-toot.el | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 719a77b..041918d 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -146,7 +146,7 @@ Can be called in notifications view or in follow-requests view." (defun mastodon-notifications--favourite (note) "Format for a `favourite' NOTE." - (mastodon-notifications--format-note note 'favorite)) + (mastodon-notifications--format-note note 'favourite)) (defun mastodon-notifications--reblog (note) "Format for a `boost' NOTE." @@ -202,7 +202,7 @@ Status notifications are given when (mastodon-notifications--byline-concat (cond ((equal type 'boost) "Boosted") - ((equal type 'favorite) + ((equal type 'favourite) "Favourited") ((equal type 'follow-request) "Requested to follow") diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 6cd3ff0..e517397 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -376,7 +376,7 @@ Used on initializing a timeline or thread." ")"))) (defun mastodon-tl--format-faves-count (toot) - "Format a favorites, boosts, replies count for a TOOT. + "Format a favourites, boosts, replies count for a TOOT. Used as a help-echo when point is at the start of a byline, i.e. where `mastodon-tl--goto-next-toot' leaves point. Also displays a toot's media types and optionally the binding to play moving @@ -558,7 +558,7 @@ By default it is `mastodon-tl--byline-boosted'" 'byline t)))) (defun mastodon-tl--format-faved-or-boosted-byline (letter) - "Format the byline marker for a boosted or favorited status. + "Format the byline marker for a boosted or favourited status. LETTER is a string, either F or B." (format "(%s) " (propertize letter 'face 'mastodon-boost-fave-face))) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 9c09441..76d7d41 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -264,7 +264,7 @@ Makes a POST request to the server." (mastodon-toot--action-success "F" byline-region remove)) (message (format "%s #%s" action id)))) - (message "Nothing to favorite here?!?")))) + (message "Nothing to favourite here?!?")))) (defun mastodon-toot--copy-toot-url () "Copy URL of toot at point." -- cgit v1.2.3 From bd9710c355093259ec8a8cad8572a2b387aa631a Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 11 Mar 2022 12:16:13 +0100 Subject: fix follow etc user when point on profile header info we just modify the if test to not run in accounts buffers, which means we end up using the next-toot solution, as was originally the case. hopefully a profile view will always have a toot or user or sth. else we cd find a better solution --- lisp/mastodon-tl.el | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index e517397..919bbbb 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1262,16 +1262,18 @@ Can be called to toggle NOTIFY on users already being followed." (interactive (list (mastodon-tl--interactive-user-handles-get "follow"))) - (if (not (get-text-property (point) 'toot-json)) + (if (and (not (string-prefix-p "accounts" (mastodon-tl--get-endpoint))) ;profile view + (not (get-text-property (point) 'toot-json))) (message "Looks like there's no toot or user at point?") - (mastodon-tl--do-user-action-and-response user-handle "follow" nil notify))) + (mastodon-tl--do-user-action-and-response user-handle "follow" nil notify))) (defun mastodon-tl--enable-notify-user-posts (user-handle) "Query for USER-HANDLE and enable notifications when they post." (interactive (list (mastodon-tl--interactive-user-handles-get "enable"))) - (if (not (get-text-property (point) 'toot-json)) + (if (and (not (string-prefix-p "accounts" (mastodon-tl--get-endpoint))) ;profile view + (not (get-text-property (point) 'toot-json))) (message "Looks like there's no toot or user at point?") (mastodon-tl--follow-user user-handle "true"))) @@ -1287,18 +1289,20 @@ Can be called to toggle NOTIFY on users already being followed." (interactive (list (mastodon-tl--interactive-user-handles-get "unfollow"))) - (if (not (get-text-property (point) 'toot-json)) + (if (and (not (string-prefix-p "accounts" (mastodon-tl--get-endpoint))) ;profile view + (not (get-text-property (point) 'toot-json))) (message "Looks like there's no toot or user at point?") - (mastodon-tl--do-user-action-and-response user-handle "unfollow" t))) + (mastodon-tl--do-user-action-and-response user-handle "unfollow" t))) (defun mastodon-tl--block-user (user-handle) "Query for USER-HANDLE from current status and block that user." (interactive (list (mastodon-tl--interactive-user-handles-get "block"))) - (if (not (get-text-property (point) 'toot-json)) + (if (and (not (string-prefix-p "accounts" (mastodon-tl--get-endpoint))) ;profile view + (not (get-text-property (point) 'toot-json))) (message "Looks like there's no toot or user at point?") - (mastodon-tl--do-user-action-and-response user-handle "block"))) + (mastodon-tl--do-user-action-and-response user-handle "block"))) (defun mastodon-tl--unblock-user (user-handle) "Query for USER-HANDLE from list of blocked users and unblock that user." @@ -1314,9 +1318,10 @@ Can be called to toggle NOTIFY on users already being followed." (interactive (list (mastodon-tl--interactive-user-handles-get "mute"))) - (if (not (get-text-property (point) 'toot-json)) + (if (and (not (string-prefix-p "accounts" (mastodon-tl--get-endpoint))) ;profile view + (not (get-text-property (point) 'toot-json))) (message "Looks like there's no toot or user at point?") - (mastodon-tl--do-user-action-and-response user-handle "mute"))) + (mastodon-tl--do-user-action-and-response user-handle "mute"))) (defun mastodon-tl--unmute-user (user-handle) "Query for USER-HANDLE from list of muted users and unmute that user." @@ -1329,7 +1334,8 @@ Can be called to toggle NOTIFY on users already being followed." (defun mastodon-tl--interactive-user-handles-get (action) "Get the list of user-handles for ACTION from the current toot." - (if (not (get-text-property (point) 'toot-json)) + (if (and (not (string-prefix-p "accounts" (mastodon-tl--get-endpoint))) ;profile view + (not (get-text-property (point) 'toot-json))) (message "Looks like there's no toot or user at point?") (let ((user-handles (cond ((or (equal (buffer-name) "*mastodon-follow-suggestions*") -- cgit v1.2.3 From f0f77a42fbd1b74fc0936dd1895812a4bc23d617 Mon Sep 17 00:00:00 2001 From: mousebot Date: Sat, 12 Mar 2022 09:03:02 +0100 Subject: make timestamps for boost/fave notifs the time of orig toot do not use the time stamp of the boosting/faving. in other views, mastodon-tl--field already handles this by fetching from 'reblog if present, but in notifs, there's no reblog section, and instead there's a status section. so we fetch from status if present, else fallback to using --field. this became necessary when we started attaching the boost/fave json to such notifs, rather than the json of the boosed/faved toot. --- lisp/mastodon-tl.el | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 919bbbb..4833a3f 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -513,10 +513,19 @@ the byline that takes one variable. ACTION-BYLINE is a function for adding an action, such as boosting, favouriting and following to the byline. It also takes a single function. By default it is `mastodon-tl--byline-boosted'" - (let ((parsed-time (date-to-time (mastodon-tl--field 'created_at toot))) - (faved (equal 't (mastodon-tl--field 'favourited toot))) - (boosted (equal 't (mastodon-tl--field 'reblogged toot))) - (visibility (mastodon-tl--field 'visibility toot))) + (let* ((created-time + ;; bosts and faves in notifs view + ;; (makes timestamps be for the original toot + ;; not the boost/fave): + (or (mastodon-tl--field 'created_at + (mastodon-tl--field 'status toot)) + ;; all other toots, inc. boosts/faves in timelines: + ;; (mastodon-tl--field auto fetches from reblogs if needed): + (mastodon-tl--field 'created_at toot))) + (parsed-time (date-to-time created-time)) + (faved (equal 't (mastodon-tl--field 'favourited toot))) + (boosted (equal 't (mastodon-tl--field 'reblogged toot))) + (visibility (mastodon-tl--field 'visibility toot))) (concat ;; Boosted/favourited markers are not technically part of the byline, so ;; we don't propertize them with 'byline t', as per the rest. This -- cgit v1.2.3 From c7b475160d2e7712e339e15adf168529f71b52c6 Mon Sep 17 00:00:00 2001 From: mousebot Date: Sat, 19 Mar 2022 16:07:44 +0100 Subject: attach parent JSON to fave/boost notifs to fix replies because we switched to using boost/fave JSON rather than parent, as 'toot-json, replies to these toots were broken (mentions, etc.) so now we attach both bits of data and selectively pull from each. --- lisp/mastodon-notifications.el | 9 ++++++--- lisp/mastodon-tl.el | 5 +++-- lisp/mastodon-toot.el | 7 ++++--- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 041918d..6b253ec 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -214,9 +214,12 @@ Status notifications are given when "Posted") ((equal type 'poll) "Posted a poll")))) - id))) + id + (when (or (equal type 'favourite) + (equal type 'boost)) + status)))) -(defun mastodon-notifications--insert-status (toot body author-byline action-byline id) +(defun mastodon-notifications--insert-status (toot body author-byline action-byline id &optional parent-toot) "Display the content and byline of timeline element TOOT. BODY will form the section of the toot above the byline. @@ -232,7 +235,7 @@ takes a single function. By default it is ID is the notification's own id, which is attached as a property." (when toot ; handle rare blank notif server bug - (mastodon-tl--insert-status toot body author-byline action-byline id))) + (mastodon-tl--insert-status toot body author-byline action-byline id parent-toot))) (defun mastodon-notifications--by-type (note) "Filters NOTE for those listed in `mastodon-notifications--types-alist'." diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4833a3f..40cbcae 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -852,7 +852,7 @@ Runs `mastodon-tl--render-text' and fetches poll or media." (mastodon-tl--get-poll toot)) (mastodon-tl--media toot)))) -(defun mastodon-tl--insert-status (toot body author-byline action-byline &optional id) +(defun mastodon-tl--insert-status (toot body author-byline action-byline &optional id parent-toot) "Display the content and byline of timeline element TOOT. BODY will form the section of the toot above the byline. @@ -876,7 +876,8 @@ a notification." 'toot-id (or id ; for notifications (alist-get 'id toot)) 'base-toot-id (mastodon-tl--toot-id toot) - 'toot-json toot) + 'toot-json toot + 'parent-toot parent-toot) "\n") (when mastodon-tl--display-media-p (mastodon-media--inline-images start-pos (point))))) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 780e726..07ab400 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -617,11 +617,12 @@ candidate ARG. IGNORED remains a mystery." "Reply to toot at `point'." (interactive) (let* ((toot (mastodon-tl--property 'toot-json)) + (parent (mastodon-tl--property 'parent-toot)) ; for new notifs handling (id (mastodon-tl--as-string (mastodon-tl--field 'id toot))) (account (mastodon-tl--field 'account toot)) (user (alist-get 'acct account)) - (mentions (mastodon-toot--mentions toot)) - (boosted (mastodon-tl--field 'reblog toot)) + (mentions (mastodon-toot--mentions (or parent toot))) + (boosted (mastodon-tl--field 'reblog (or parent toot))) (booster (when boosted (alist-get 'acct (alist-get 'account toot))))) @@ -637,7 +638,7 @@ candidate ARG. IGNORED remains a mystery." mentions)) (concat (mastodon-toot--process-local user) mentions))) - id toot))) + id (or parent toot)))) (defun mastodon-toot--toggle-warning () "Toggle `mastodon-toot--content-warning'." -- cgit v1.2.3 From fb69058495574a73df17856014c42370b23d81d7 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 5 Apr 2022 17:17:59 +0200 Subject: flychecks and docstrings --- lisp/mastodon-media.el | 3 ++- lisp/mastodon-notifications.el | 4 +++- lisp/mastodon-tl.el | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index 383e062..e5a1111 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -310,7 +310,8 @@ Replace them with the referenced image." (defun mastodon-media--get-media-link-rendering (media-url &optional full-remote-url type caption) "Return the string to be written that renders the image at MEDIA-URL. FULL-REMOTE-URL is used for `shr-browse-image'. -TYPE is the attachment's type field on the server." +TYPE is the attachment's type field on the server. +CAPTION is the image caption if provided." (let* ((help-echo-base "RET/i: load full image (prefix: copy URL), +/-: zoom, r: rotate, o: save preview") (help-echo (if caption (concat help-echo-base diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 6b253ec..5de7354 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -233,7 +233,9 @@ such as boosting favouriting and following to the byline. It also takes a single function. By default it is `mastodon-tl--byline-boosted'. -ID is the notification's own id, which is attached as a property." +ID is the notification's own id, which is attached as a property. +If the status is a favourite or a boost, PARENT-TOOT is the JSON +of the toot responded to." (when toot ; handle rare blank notif server bug (mastodon-tl--insert-status toot body author-byline action-byline id parent-toot))) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 40cbcae..3c96ecc 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -865,7 +865,8 @@ takes a single function. By default it is `mastodon-tl--byline-boosted'. ID is that of the toot, which is attached as a property if it is -a notification." +a notification. If the status is a favourite or a boost, +PARENT-TOOT is the JSON of the toot responded to." (let ((start-pos (point))) (insert (propertize -- cgit v1.2.3