From 528494a2340c46cdf5d589cc95d16d7b3b1a1208 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 10 May 2023 08:39:27 +0200 Subject: refactor format-heading in search.el --- lisp/mastodon-search.el | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 4b5f2e0..5e0cc20 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -135,6 +135,14 @@ PRINT-FUN is the function used to print the data from the response." ;; functions for mastodon search +(defun mastodon-search--format-heading (heading) + "Format HEADING as a heading." + (insert + (mastodon-tl--set-face (concat "\n " mastodon-tl--horiz-bar "\n " + heading "\n" + " " mastodon-tl--horiz-bar "\n") + 'success))) + (defun mastodon-search--search-query (query) "Prompt for a search QUERY and return accounts, statuses, and hashtags." (interactive "sSearch mastodon for: ") @@ -156,25 +164,13 @@ PRINT-FUN is the function used to print the data from the response." "api/v2/search" nil) ;; user results: - (insert (mastodon-tl--set-face - (concat "\n " mastodon-tl--horiz-bar "\n" - " USERS\n" - " " mastodon-tl--horiz-bar "\n\n") - 'success)) + (mastodon-search--format-heading "USERS") (mastodon-search--insert-users-propertized accts :note) ;; hashtag results: - (insert (mastodon-tl--set-face - (concat "\n " mastodon-tl--horiz-bar "\n" - " HASHTAGS\n" - " " mastodon-tl--horiz-bar "\n\n") - 'success)) + (mastodon-search--format-heading "HASHTAGS") (mastodon-search--print-tags-list tags-list) ;; status results: - (insert (mastodon-tl--set-face - (concat "\n " mastodon-tl--horiz-bar "\n" - " STATUSES\n" - " " mastodon-tl--horiz-bar "\n") - 'success)) + (mastodon-search--format-heading "STATUSES") (mapc #'mastodon-tl--toot toots-list-json) (goto-char (point-min))))) -- cgit v1.2.3