diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-10-14 20:18:38 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-10-14 20:18:57 +0200 |
commit | 0fc64df90d9cb8ccb6b1968e0dc36ece6c9b639c (patch) | |
tree | 139c24408e123ab613eed00d49189ac0f6599460 | |
parent | 6d80f5b2d2dd71a0e28a7bcb700e8fb1757ac8d6 (diff) |
fix minor-view disaster disastrously: put it all init-sync
-rw-r--r-- | lisp/mastodon-tl.el | 15 | ||||
-rw-r--r-- | lisp/mastodon-views.el | 52 |
2 files changed, 43 insertions, 24 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d5d127d..47824c0 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2656,8 +2656,9 @@ JSON and http headers, without it just the JSON." link-header update-params hide-replies) (mastodon-tl--do-init json update-function)))))) -(defun mastodon-tl--init-sync (buffer-name endpoint update-function - &optional note-type params headers) +(defun mastodon-tl--init-sync + (buffer-name endpoint update-function + &optional note-type params headers view-name binding-str) "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. UPDATE-FUNCTION is used to receive more toots. Runs synchronously. @@ -2676,7 +2677,15 @@ Optional arg NOTE-TYPE means only get that type of note." (headers (if headers (cdr response) nil)) (link-header (mastodon-tl--get-link-header-from-response headers))) (with-mastodon-buffer buffer #'mastodon-mode nil - (mastodon-tl--set-buffer-spec buffer endpoint update-function link-header params) + ;; insert view-name/ heading-str + (when view-name + (mastodon-search--insert-heading view-name)) + (when binding-str + (insert (mastodon-tl--set-face (concat "[" binding-str "]\n\n") + 'font-lock-comment-face))) + + (mastodon-tl--set-buffer-spec buffer endpoint update-function + link-header params) (mastodon-tl--do-init json update-function) buffer))) diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el index d7fedb6..6e46eb9 100644 --- a/lisp/mastodon-views.el +++ b/lisp/mastodon-views.el @@ -155,7 +155,7 @@ ;;; GENERAL FUNCTION -(defun mastodon-views--minor-view (view-name bindings-string insert-fun data) +(defun mastodon-views--minor-view (view-name insert-fun data) "Load a minor view named VIEW-NAME. BINDINGS-STRING is a string explaining the view's local bindings. INSERT-FUN is the function to call to insert the view's elements. @@ -169,10 +169,10 @@ provides the JSON data." ;; either it should go in init-sync, or possibly in each view function ;; but either way, this function does almost nothing for us. ;; could we call init-sync in here pehaps? - (mastodon-search--insert-heading view-name) - (when bindings-string - (insert (mastodon-tl--set-face (concat "[" bindings-string "]\n\n") - 'font-lock-comment-face))) + ;; (mastodon-search--insert-heading view-name) + ;; (when bindings-string + ;; (insert (mastodon-tl--set-face (concat "[" bindings-string "]\n\n") + ;; 'font-lock-comment-face))) (if (seq-empty-p data) (insert (propertize (format "Looks like you have no %s for now." view-name) @@ -193,17 +193,19 @@ provides the JSON data." "Show the user's lists in a new buffer." (interactive) (mastodon-tl--init-sync "lists" "lists" - 'mastodon-views--insert-lists) + 'mastodon-views--insert-lists + nil nil nil + "your lists" + "C - create a list\n D - delete a list\ + \n A/R - add/remove account from a list\ + \n E - edit a list\n n/p - go to next/prev item") (with-current-buffer "*mastodon-lists*" (use-local-map mastodon-views--view-lists-keymap))) (defun mastodon-views--insert-lists (json) "Insert the user's lists from JSON." (mastodon-views--minor-view - "your lists" - "C - create a list\n D - delete a list\ - \n A/R - add/remove account from a list\ - \n E - edit a list\n n/p - go to next/prev item" + "lists" #'mastodon-views--print-list-set json)) @@ -446,14 +448,12 @@ If ID is provided, use that list." ;;; FOLLOW REQUESTS -;; TODO: paginates by link header (defun mastodon-views--insert-follow-requests (json) "Insert the user's current follow requests. JSON is the data returned by the server." (mastodon-views--minor-view "follow requests" - "a/j - accept/reject request at point\n n/p - go to next/prev request" #'mastodon-views--insert-users-propertized-note json)) @@ -465,7 +465,10 @@ JSON is the data returned by the server." 'mastodon-views--insert-follow-requests nil '(("limit" . "40")) ; server max is 80 - :headers) + :headers + "follow requests" + "a/j - accept/reject request at point\n\ + n/p - go to next/prev request") (mastodon-tl--goto-first-item) (with-current-buffer "*mastodon-follow-requests*" (use-local-map mastodon-views--view-follow-requests-keymap))) @@ -478,15 +481,18 @@ JSON is the data returned by the server." (interactive) (mastodon-tl--init-sync "scheduled-toots" "scheduled_statuses" - 'mastodon-views--insert-scheduled-toots) + 'mastodon-views--insert-scheduled-toots + nil nil nil + "your scheduled toots" + "n/p - prev/next\n r - reschedule\n\ + e/RET - edit toot\n c - cancel") (with-current-buffer "*mastodon-scheduled-toots*" (use-local-map mastodon-views--scheduled-map))) (defun mastodon-views--insert-scheduled-toots (json) "Insert the user's scheduled toots, from JSON." (mastodon-views--minor-view - "your scheduled toots" - "n/p - prev/next\n r - reschedule\n e/RET - edit toot\n c - cancel" + "scheduled toots" #'mastodon-views--insert-scheduled-toots-list json)) @@ -577,7 +583,11 @@ NO-CONFIRM means there is no ask or message, there is only do." "View the user's filters in a new buffer." (interactive) (mastodon-tl--init-sync "filters" "filters" - 'mastodon-views--insert-filters) + 'mastodon-views--insert-filters + nil nil nil + "current filters" + "c - create filter\n d - delete filter at point\n\ + n/p - go to next/prev filter") (with-current-buffer "*mastodon-filters*" (use-local-map mastodon-views--view-filters-keymap))) @@ -585,8 +595,7 @@ NO-CONFIRM means there is no ask or message, there is only do." "Insert the user's current filters. JSON is what is returned by by the server." (mastodon-views--minor-view - "current filters" - "c - create filter\n d - delete filter at point\n n/p - go to next/prev filter" + "filters" #'mastodon-views--insert-filter-string-set json)) @@ -666,7 +675,9 @@ Prompt for a context, must be a list containting at least one of \"home\", "suggestions" 'mastodon-views--insert-follow-suggestions nil - '(("limit" . "80"))) ; server max + '(("limit" . "80")) ; server max + nil + "suggested accounts") (with-current-buffer "*mastodon-follow-suggestions*" (use-local-map mastodon-views--follow-suggestions-map))) @@ -675,7 +686,6 @@ Prompt for a context, must be a list containting at least one of \"home\", JSON is the data returned by the server." (mastodon-views--minor-view "suggested accounts" - nil #'mastodon-views--insert-users-propertized-note json)) |