From 471d540c01ee45464bfc8a3d3cdcfaf91738ce99 Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 4 Feb 2022 13:00:02 +0100 Subject: update homepage and copyright boilerplate --- lisp/mastodon-search.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-search.el') diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 78c2ab4..5fee328 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -1,12 +1,11 @@ ;;; mastodon-search.el --- Search functions for mastodon.el -*- lexical-binding: t -*- -;; Copyright (C) 2017-2019 Johnson Denen -;; Author: Johnson Denen -;; Marty Hiatt +;; Copyright (C) 2017-2019 Marty Hiatt +;; Author: Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 0.10.0 ;; Package-Requires: ((emacs "27.1")) -;; Homepage: https://git.blast.noho.st/mouse/mastodon.el +;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. -- cgit v1.2.3 From 4bd42aa4c52d709a512be94524fe1182eac9c4f6 Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 7 Feb 2022 16:54:54 +0100 Subject: implement follow suggestions. this factors out display of accounts from mastodon-search--search-query into mastodon-search--insert-users-propertized. mastodon-tl--get-follow-suggestions is the fun to view suggestions. seeing as this allows easy display of profile note under the account handle, i also added this display to --search-query, but it cd be easily disabled by calling --insert-users-propertized without its second arg. --- lisp/mastodon-search.el | 40 +++++++++++++++++++++++++--------------- lisp/mastodon-tl.el | 20 ++++++++++++++++++++ 2 files changed, 45 insertions(+), 15 deletions(-) (limited to 'lisp/mastodon-search.el') diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 5fee328..6c85965 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -97,19 +97,7 @@ Returns a nested list containing user handle, display name, and URL." " USERS\n" " ------------\n\n") 'success)) - (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" - "\n")) - user-ids) + (mastodon-search--insert-users-propertized user-ids :note) ;; hashtag results: (insert (mastodon-tl--set-face (concat "\n ------------\n" @@ -135,11 +123,33 @@ 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 and account URL from ACCOUNT." + "Get user handle, display name, account URL and profile note from ACCOUNT." (list (alist-get 'display_name account) (alist-get 'acct account) - (alist-get 'url account))) + (alist-get 'url account) + (alist-get 'note account))) (defun mastodon-search--get-hashtag-info (tag) "Get hashtag name and URL from TAG." diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d3ab56b..13c6729 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -60,6 +60,7 @@ ;; make notifications--get available via M-x and outside our keymap: (autoload 'mastodon-notifications--get "mastodon-notifications" "Display NOTIFICATIONS in buffer." t) ; interactive +(autoload 'mastodon-search--insert-users-propertized "mastodon-search") (defvar mastodon-instance-url) (defvar mastodon-toot-timestamp-format) (defvar shr-use-fonts) ;; declare it since Emacs24 didn't have this @@ -991,6 +992,25 @@ webapp" (alist-get 'descendants context))))) (message "No Thread!")))) +(defun mastodon-tl--get-follow-suggestions () +"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-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. If NOTIFY is \"true\", enable notifications when that user posts. -- cgit v1.2.3 From 16685d4e3fb7fce2011d751fc26661aa41ddd3aa Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 7 Feb 2022 19:53:42 +0100 Subject: --search-accounts-query use http--api --- lisp/mastodon-search.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mastodon-search.el') diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 6c85965..8c654cc 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -57,7 +57,7 @@ "Prompt for a search QUERY and return accounts synchronously. Returns a nested list containing user handle, display name, and URL." (interactive "sSearch mastodon for: ") - (let* ((url (format "%s/api/v1/accounts/search" mastodon-instance-url)) + (let* ((url (mastodon-http--api "accounts/search")) ;; (buffer (format "*mastodon-search-%s*" query)) (response (if (equal mastodon-toot--enable-completion-for-mentions "following") (mastodon-http--get-search-json url query "following=true") -- cgit v1.2.3