From 353afcad0f2a6802719eb987be6de861de3e2e8e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 10 Oct 2024 11:39:50 +0200 Subject: WIP. display fediverse account of link authors if available. --- lisp/mastodon-tl.el | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2e0588f..3f06756 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -875,17 +875,46 @@ links in the text. If TOOT is nil no parsing occurs." 0 (- (window-width) 3))))) (shr-render-region (point-min) (point-max))) - ;; Make all links a tab stop recognized by our own logic, make things point - ;; to our own logic (e.g. hashtags), and update keymaps where needed: + ;; Make all links a tab stop recognized by our own logic, make + ;; things point to our own logic (e.g. hashtags), and update keymaps + ;; where needed: (when toot (let (region) (while (setq region (mastodon-tl--find-property-range 'shr-url (or (cdr region) (point-min)))) (mastodon-tl--process-link toot (car region) (cdr region) - (get-text-property (car region) 'shr-url))))) + (get-text-property (car region) 'shr-url)) + (when (proper-list-p toot) ;; not on profile fields cons cells + (let* ((card (alist-get 'card toot)) + (card-url (alist-get 'url card)) + (authors (alist-get 'authors card)) + (url (buffer-substring (car region) (cdr region))) + (url-no-query (car (split-string url "?")))) + (when (and (string= url-no-query card-url) + ;; only if we have an account's data: + (alist-get 'account (car authors))) + (goto-char (point-max)) ;;(cdr region)) + (mastodon-tl--insert-card-authors authors))))))) (buffer-string)))) +(defun mastodon-tl--insert-card-authors (authors) + "Insert a string of card AUTHORS." + (insert + (concat + "\n(Authors: " + (cl-loop for x in authors + concat + (mastodon-tl--format-card-author x)) + ")\n"))) + +(defun mastodon-tl--format-card-author (data) + "Render card author DATA." + ;; FIXME: update as needed, data contains "name" "url" and "account" + (let-alist data + (when .account + (mastodon-search--propertize-user .account)))) + (defun mastodon-tl--process-link (toot start end url) "Process link URL in TOOT as hashtag, userhandle, or normal link. START and END are the boundaries of the link in the toot." @@ -1553,7 +1582,7 @@ NO-BYLINE means just insert toot body, used for folding." (propertize ;; body only: (concat "\n" - ;; relpy symbol (broken): + ;; relpy symbol: (when (and after-reply-status-p thread) (concat (mastodon-tl--symbol 'replied) "\n")) -- cgit v1.2.3 From 119bca6c441ef5fbed95ed8000a76ec8f7612796 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 10 Oct 2024 19:48:33 +0200 Subject: add mastodon-notifications--action-alist, use reblog in notifications.el --- lisp/mastodon-notifications.el | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 0c56cbb..db8b842 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -180,7 +180,7 @@ Can be called in notifications view or in follow-requests view." (defun mastodon-notifications--reblog (note) "Format for a `boost' NOTE." - (mastodon-notifications--format-note note 'boost)) + (mastodon-notifications--format-note note 'reblog)) (defun mastodon-notifications--status (note) "Format for a `status' NOTE. @@ -208,6 +208,16 @@ Status notifications are given when '(face (font-lock-comment-face shr-text))))) (buffer-string))) +(defvar mastodon-notifications--action-alist + '((reblog . "Boosted") + (favourite . "Favourited") + (follow-request . "Requested to follow") + (follow . "Followed") + (mention . "Mentioned") + (status . "Posted") + (poll . "Posted a poll") + (edit . "Edited"))) + (defun mastodon-notifications--format-note (note type) "Format for a NOTE of TYPE." ;; FIXME: apply/refactor filtering as per/with `mastodon-tl--toot' @@ -238,7 +248,7 @@ Status notifications are given when ;; reblogs/faves use 'note' to process their own json ;; not the toot's. this ensures following etc. work on such notifs ((or (eq type 'favourite) - (eq type 'boost)) + (eq type 'reblog)) note) (t status)) @@ -266,7 +276,7 @@ Status notifications are given when ":\n" (mastodon-notifications--comment-note-text body)))))) ((or (eq type 'favourite) - (eq type 'boost)) + (eq type 'reblog)) (mastodon-notifications--comment-note-text body)) (t body))) ;; author-byline @@ -279,26 +289,11 @@ Status notifications are given when ;; action-byline (lambda (_status) (mastodon-notifications--byline-concat - (cond ((eq type 'boost) - "Boosted") - ((eq type 'favourite) - "Favourited") - ((eq type 'follow-request) - "Requested to follow") - ((eq type 'follow) - "Followed") - ((eq type 'mention) - "Mentioned") - ((eq type 'status) - "Posted") - ((eq type 'poll) - "Posted a poll") - ((eq type 'edit) - "Edited")))) + (alist-get type mastodon-notifications--action-alist))) id ;; base toot (when (or (eq type 'favourite) - (eq type 'boost)) + (eq type 'reblog)) status))))) (defun mastodon-notifications--by-type (note) -- cgit v1.2.3 From 7ed54ce921e357d2b7d655921b694a5599cd9be0 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 10 Oct 2024 19:57:48 +0200 Subject: clean up cond predicates - use member! --- lisp/mastodon-notifications.el | 43 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index db8b842..2091118 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -240,18 +240,15 @@ Status notifications are given when nil (mastodon-tl--insert-status ;; toot - (cond ((or (eq type 'follow) - (eq type 'follow-request)) + (cond ((member type '(follow follow-request)) ;; Using reblog with an empty id will mark this as something ;; non-boostable/non-favable. (cons '(reblog (id . nil)) note)) ;; reblogs/faves use 'note' to process their own json ;; not the toot's. this ensures following etc. work on such notifs - ((or (eq type 'favourite) - (eq type 'reblog)) + ((member type '(favourite reblog)) note) - (t - status)) + (t status)) ;; body (let ((body (if-let ((match (assoc "warn" filters))) (mastodon-tl--spoiler toot (cadr match)) @@ -261,28 +258,25 @@ Status notifications are given when (if (eq 'follow-request type) (mastodon-tl--render-text profile-note) (mastodon-tl--content status))))))) - (cond ((or (eq type 'follow) - (eq type 'follow-request)) - (if (eq type 'follow) - (propertize "Congratulations, you have a new follower!" - 'face 'default) - (concat - (propertize - (format "You have a follow request from... %s" - follower) - 'face 'default) - (when mastodon-notifications--profile-note-in-foll-reqs + (cond ((eq type 'follow) + (propertize "Congratulations, you have a new follower!" + 'face 'default)) + ((eq type 'follow-request) + (concat + (propertize + (format "You have a follow request from... %s" + follower) + 'face 'default) + (if mastodon-notifications--profile-note-in-foll-reqs (concat ":\n" - (mastodon-notifications--comment-note-text body)))))) - ((or (eq type 'favourite) - (eq type 'reblog)) + (mastodon-notifications--comment-note-text body)) + ""))) + ((member type '(favourite reblog)) (mastodon-notifications--comment-note-text body)) (t body))) ;; author-byline - (if (or (eq type 'follow) - (eq type 'follow-request) - (eq type 'mention)) + (if (member type '(follow follow-request mention)) 'mastodon-tl--byline-author (lambda (_status &rest _args) ; unbreak stuff (mastodon-tl--byline-author note))) @@ -292,8 +286,7 @@ Status notifications are given when (alist-get type mastodon-notifications--action-alist))) id ;; base toot - (when (or (eq type 'favourite) - (eq type 'reblog)) + (when (member type '(favourite reblog)) status))))) (defun mastodon-notifications--by-type (note) -- cgit v1.2.3 From 96057a1b090b93adf4e72781e8894aae9f158588 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 13 Oct 2024 11:00:11 +0200 Subject: transient: factor out a field infix, to simplify mastodon-profile-fields --- lisp/mastodon-transient.el | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-transient.el b/lisp/mastodon-transient.el index fe70eac..dcf8fa4 100644 --- a/lisp/mastodon-transient.el +++ b/lisp/mastodon-transient.el @@ -173,15 +173,15 @@ the format fields.X.keyname." [:description "Fields" ["Name" - ("1 n" "" "fields.1.name" :alist-key fields.1.name :class mastodon-transient-field) - ("2 n" "" "fields.2.name" :alist-key fields.2.name :class mastodon-transient-field) - ("3 n" "" "fields.3.name" :alist-key fields.3.name :class mastodon-transient-field) - ("4 n" "" "fields.4.name" :alist-key fields.4.name :class mastodon-transient-field)] + ("1 n" "" mastodon-transient-field-infix :alist-key fields.1.name) + ("2 n" "" mastodon-transient-field-infix :alist-key fields.2.name) + ("3 n" "" mastodon-transient-field-infix :alist-key fields.3.name) + ("4 n" "" mastodon-transient-field-infix :alist-key fields.4.name)] ["Value" - ("1 v" "" "fields.1.value" :alist-key fields.1.value :class mastodon-transient-field) - ("2 v" "" "fields.2.value" :alist-key fields.2.value :class mastodon-transient-field) - ("3 v" "" "fields.3.value" :alist-key fields.3.value :class mastodon-transient-field) - ("4 v" "" "fields.4.value" :alist-key fields.4.value :class mastodon-transient-field)]] + ("1 v" "" mastodon-transient-field-infix :alist-key fields.1.value) + ("2 v" "" mastodon-transient-field-infix :alist-key fields.2.value) + ("3 v" "" mastodon-transient-field-infix :alist-key fields.3.value) + ("4 v" "" mastodon-transient-field-infix :alist-key fields.4.value)]] ["Update" ("C-c C-c" "Save settings" mastodon-profile-fields-update) ("C-c C-k" :info "Revert all changes")] @@ -193,9 +193,12 @@ the format fields.X.keyname." ;;; CLASSES (defclass mastodon-transient-field (tp-option-str) - ((always-read :initarg :always-read :initform t)) - "An infix option class for our options. -We always read.") + () + "An infix for our fields options.") + +(transient-define-infix mastodon-transient-field-infix () + :class 'mastodon-transient-field + :argument "junk") (cl-defmethod transient-init-value ((obj mastodon-transient-field)) "Initialize value of OBJ." -- cgit v1.2.3 From 11fc4f01c4934e5d687382f3ccb301cb8343a6d9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 13 Oct 2024 17:01:32 +0200 Subject: re-do display of card (link) author. #596 --- lisp/mastodon-tl.el | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 3f06756..c4abbf0 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -886,6 +886,7 @@ links in the text. If TOOT is nil no parsing occurs." (car region) (cdr region) (get-text-property (car region) 'shr-url)) (when (proper-list-p toot) ;; not on profile fields cons cells + ;; render card author maybe: (let* ((card (alist-get 'card toot)) (card-url (alist-get 'url card)) (authors (alist-get 'authors card)) @@ -894,7 +895,7 @@ links in the text. If TOOT is nil no parsing occurs." (when (and (string= url-no-query card-url) ;; only if we have an account's data: (alist-get 'account (car authors))) - (goto-char (point-max)) ;;(cdr region)) + (goto-char (point-max)) (mastodon-tl--insert-card-authors authors))))))) (buffer-string)))) @@ -903,17 +904,30 @@ links in the text. If TOOT is nil no parsing occurs." (insert (concat "\n(Authors: " - (cl-loop for x in authors - concat - (mastodon-tl--format-card-author x)) + (mapconcat #'mastodon-tl--format-card-author authors "\n") ")\n"))) (defun mastodon-tl--format-card-author (data) "Render card author DATA." ;; FIXME: update as needed, data contains "name" "url" and "account" - (let-alist data - (when .account - (mastodon-search--propertize-user .account)))) + (when (alist-get 'account data) ;.account + (let-alist (alist-get 'account data) ;.account + ;; FIXME: replace with refactored handle render fun + ;; in byline refactor branch: + (concat + (propertize .username + 'face 'mastodon-display-name-face + 'byline t + 'item-type 'user + 'item-id .id) + " " + (propertize (concat "@" .acct) + 'face 'mastodon-handle-face + 'mouse-face 'highlight + 'mastodon-tab-stop 'user-handle + 'keymap mastodon-tl--link-keymap + 'mastodon-handle (concat "@" .acct) + 'help-echo (concat "Browse user profile of @" .acct)))))) (defun mastodon-tl--process-link (toot start end url) "Process link URL in TOOT as hashtag, userhandle, or normal link. -- cgit v1.2.3 From f77c3b6334362c4bb7f8b41eb0a542eef2d19b64 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Oct 2024 09:57:15 +0200 Subject: flymake load-path dir-locals --- lisp/.dir-locals.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lisp') diff --git a/lisp/.dir-locals.el b/lisp/.dir-locals.el index bcb8ba5..da012d6 100644 --- a/lisp/.dir-locals.el +++ b/lisp/.dir-locals.el @@ -1,7 +1,6 @@ -;;; Directory Local Variables +;;; Directory Local Variables -*- no-byte-compile: t -*- ;;; For more information see (info "(emacs) Directory Variables") -;; Preferred indentation style: ((nil . ((indent-tabs-mode . nil))) - ;; setting this makes package-lint look in the main file for deps: - (emacs-lisp-mode . ((package-lint-main-file . "mastodon.el")))) + (emacs-lisp-mode . ((elisp-flymake-byte-compile-load-path . load-path) + (package-lint-main-file . "mastodon.el")))) -- cgit v1.2.3 From 8b4d1cbf0727879e5cbeb2f8af985cea1683c771 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Oct 2024 10:04:52 +0200 Subject: no byline prop for card author --- lisp/mastodon-tl.el | 1 - 1 file changed, 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index c4abbf0..b32fe70 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -917,7 +917,6 @@ links in the text. If TOOT is nil no parsing occurs." (concat (propertize .username 'face 'mastodon-display-name-face - 'byline t 'item-type 'user 'item-id .id) " " -- cgit v1.2.3 From 9b6769040e55b1c6372ee38266af42f92edf8a9c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Oct 2024 09:57:15 +0200 Subject: flymake load-path dir-locals --- lisp/.dir-locals.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lisp') diff --git a/lisp/.dir-locals.el b/lisp/.dir-locals.el index bcb8ba5..da012d6 100644 --- a/lisp/.dir-locals.el +++ b/lisp/.dir-locals.el @@ -1,7 +1,6 @@ -;;; Directory Local Variables +;;; Directory Local Variables -*- no-byte-compile: t -*- ;;; For more information see (info "(emacs) Directory Variables") -;; Preferred indentation style: ((nil . ((indent-tabs-mode . nil))) - ;; setting this makes package-lint look in the main file for deps: - (emacs-lisp-mode . ((package-lint-main-file . "mastodon.el")))) + (emacs-lisp-mode . ((elisp-flymake-byte-compile-load-path . load-path) + (package-lint-main-file . "mastodon.el")))) -- cgit v1.2.3 From 652c17da292065d760d8ad455dba9dd26ac49ba1 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Oct 2024 13:26:29 +0200 Subject: card authors tiny clean up. #596. --- lisp/mastodon-tl.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index b32fe70..e2cba94 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -901,17 +901,18 @@ links in the text. If TOOT is nil no parsing occurs." (defun mastodon-tl--insert-card-authors (authors) "Insert a string of card AUTHORS." - (insert - (concat - "\n(Authors: " - (mapconcat #'mastodon-tl--format-card-author authors "\n") - ")\n"))) + (let ((authors-str (format "Author%s: " + (if (< 1 (length authors)) "s" "")))) + (insert + (concat + "\n(" authors-str + (mapconcat #'mastodon-tl--format-card-author authors "\n") + ")\n")))) (defun mastodon-tl--format-card-author (data) "Render card author DATA." - ;; FIXME: update as needed, data contains "name" "url" and "account" - (when (alist-get 'account data) ;.account - (let-alist (alist-get 'account data) ;.account + (when-let ((account (alist-get 'account data))) ;.account + (let-alist account ;.account ;; FIXME: replace with refactored handle render fun ;; in byline refactor branch: (concat -- cgit v1.2.3 From 17bcc1ff7659b4eb6845a564a094bb3cae4fadd9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Oct 2024 15:32:30 +0200 Subject: byline: help echo timestamps in numbers --- lisp/mastodon-tl.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2e0588f..81be479 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -781,12 +781,15 @@ BASE-TOOT is JSON for the base toot, if any." (funcall action-byline toot) " " ;; timestamp: - (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)) + (let ((ts (format-time-string + mastodon-toot-timestamp-format parsed-time))) + (propertize ts + 'timestamp parsed-time + 'display + (if mastodon-tl--enable-relative-timestamps + (mastodon-tl--relative-time-description parsed-time) + parsed-time) + 'help-echo ts)) ;; detailed: (when detailed-p (let* ((app (alist-get 'application toot)) -- cgit v1.2.3 From e07fc229966a978fb22c741f40526301f204299f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Oct 2024 17:16:50 +0200 Subject: Revert "transient: factor out a field infix, to simplify mastodon-profile-fields" This reverts commit 96057a1b090b93adf4e72781e8894aae9f158588. --- lisp/mastodon-transient.el | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-transient.el b/lisp/mastodon-transient.el index dcf8fa4..fe70eac 100644 --- a/lisp/mastodon-transient.el +++ b/lisp/mastodon-transient.el @@ -173,15 +173,15 @@ the format fields.X.keyname." [:description "Fields" ["Name" - ("1 n" "" mastodon-transient-field-infix :alist-key fields.1.name) - ("2 n" "" mastodon-transient-field-infix :alist-key fields.2.name) - ("3 n" "" mastodon-transient-field-infix :alist-key fields.3.name) - ("4 n" "" mastodon-transient-field-infix :alist-key fields.4.name)] + ("1 n" "" "fields.1.name" :alist-key fields.1.name :class mastodon-transient-field) + ("2 n" "" "fields.2.name" :alist-key fields.2.name :class mastodon-transient-field) + ("3 n" "" "fields.3.name" :alist-key fields.3.name :class mastodon-transient-field) + ("4 n" "" "fields.4.name" :alist-key fields.4.name :class mastodon-transient-field)] ["Value" - ("1 v" "" mastodon-transient-field-infix :alist-key fields.1.value) - ("2 v" "" mastodon-transient-field-infix :alist-key fields.2.value) - ("3 v" "" mastodon-transient-field-infix :alist-key fields.3.value) - ("4 v" "" mastodon-transient-field-infix :alist-key fields.4.value)]] + ("1 v" "" "fields.1.value" :alist-key fields.1.value :class mastodon-transient-field) + ("2 v" "" "fields.2.value" :alist-key fields.2.value :class mastodon-transient-field) + ("3 v" "" "fields.3.value" :alist-key fields.3.value :class mastodon-transient-field) + ("4 v" "" "fields.4.value" :alist-key fields.4.value :class mastodon-transient-field)]] ["Update" ("C-c C-c" "Save settings" mastodon-profile-fields-update) ("C-c C-k" :info "Revert all changes")] @@ -193,12 +193,9 @@ the format fields.X.keyname." ;;; CLASSES (defclass mastodon-transient-field (tp-option-str) - () - "An infix for our fields options.") - -(transient-define-infix mastodon-transient-field-infix () - :class 'mastodon-transient-field - :argument "junk") + ((always-read :initarg :always-read :initform t)) + "An infix option class for our options. +We always read.") (cl-defmethod transient-init-value ((obj mastodon-transient-field)) "Initialize value of OBJ." -- cgit v1.2.3 From c1c0d3a71d5bf81ac9e6f0169716c9903e54df06 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Oct 2024 19:19:38 +0200 Subject: implement rough trending links, and link timeline --- lisp/mastodon-search.el | 38 +++++++++++++++++++++++++++++++++++++- lisp/mastodon-tl.el | 13 ++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 7fc4de3..90519ed 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -97,6 +97,41 @@ QUERY is the string to search." (mastodon-search--view-trending "statuses" #'mastodon-tl--timeline)) +(defun mastodon-search--trending-links () + "Display a list of links trending on your instance." + (interactive) + (mastodon-search--view-trending "links" + #'mastodon-search--render-links)) + +(defun mastodon-search--render-links (links) + "Render trending LINKS." + (cl-loop for l in links + do (mastodon-search--render-link l))) + +(defun mastodon-search--render-link (link) + "Render a trending LINK." + (let-alist link + (insert + (propertize + (mastodon-tl--render-text + (concat "" .url "\n" .title) + link) + 'item-type 'link + 'item-json link + 'shr-url .url + 'byline t ;; nav + 'help-echo + (substitute-command-keys + "\\[`mastodon-search--load-link-posts'] to view a link's timeline")) + ;; TODO: display card link author here + "\n\n"))) + +(defun mastodon-search--load-link-posts () + "Load timeline of posts containing link at point." + (interactive) + (let* ((url (mastodon-tl--property 'shr-url))) + (mastodon-tl--link-timeline url))) + (defun mastodon-search--view-trending (type print-fun) "Display a list of tags trending on your instance. TYPE is a string, either tags, statuses, or links. @@ -109,7 +144,8 @@ PRINT-FUN is the function used to print the data from the response." (offset '(("offset" . "0"))) (params (push limit offset)) (data (mastodon-http--get-json url params)) - (buffer (get-buffer-create (format "*mastodon-trending-%s*" type)))) + (buffer (get-buffer-create + (format "*mastodon-trending-%s*" type)))) (with-mastodon-buffer buffer #'mastodon-mode nil (mastodon-tl--set-buffer-spec (buffer-name buffer) (format "trends/%s" type) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 81be479..75bde95 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -279,6 +279,7 @@ etc.") ;; is already bound to w also (define-key map (kbd "u") #'mastodon-tl--update) (define-key map [remap shr-browse-url] #'mastodon-url-lookup) + (define-key map (kbd "M-RET") #'mastodon-search--load-link-posts) map) "The keymap to be set for shr.el generated links that are not images. We need to override the keymap so tabbing will navigate to all @@ -575,6 +576,14 @@ With a double PREFIX arg, limit results to your own instance." (concat "timelines/tag/" (if (listp tag) (car tag) tag)) ; must be /tag/:sth 'mastodon-tl--timeline nil params))) +(defun mastodon-tl--link-timeline (url) + "Load a link timeline, displaying posts containing URL." + (let ((endpoint (mastodon-http--api "timelines/link")) + (params `(("url" . ,url)))) + (mastodon-tl--init "links" "timelines/link" + 'mastodon-tl--timeline nil + params))) + ;;; BYLINES, etc. @@ -1987,7 +1996,9 @@ call this function after it is set or use something else." ((string= "*mastodon-toot-edits*" buffer-name) 'toot-edits) ((string= "*masto-image*" (buffer-name)) - 'mastodon-image)))) + 'mastodon-image) + ((mastodon-tl--endpoint-str-= "timelines/link") + 'link-timeline)))) (defun mastodon-tl--buffer-type-eq (type) "Return t if current buffer type is equal to symbol TYPE." -- cgit v1.2.3