diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-08-20 12:46:52 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-08-20 12:46:52 +0200 |
commit | 43baced1733b318a4fbe0a2ddba02c252f109c41 (patch) | |
tree | 7b0475d0d2f3e9b5164d10167a8372d8c95d9d38 /lisp | |
parent | b8838b8a2fb8932227c4daf2cf823ad9d0e1eea6 (diff) | |
parent | 7be929c123d8ce94934a8b6f7c214df1d0bc346f (diff) |
Merge branch 'develop'
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-discover.el | 4 | ||||
-rw-r--r-- | lisp/mastodon-profile.el | 41 | ||||
-rw-r--r-- | lisp/mastodon-tl.el | 29 | ||||
-rw-r--r-- | lisp/mastodon-toot.el | 33 |
4 files changed, 64 insertions, 43 deletions
diff --git a/lisp/mastodon-discover.el b/lisp/mastodon-discover.el index c8a40c9..f33b25d 100644 --- a/lisp/mastodon-discover.el +++ b/lisp/mastodon-discover.el @@ -90,8 +90,8 @@ ("u" "copy URL" 'shr-maybe-probe-and-copy-url)) ("Profile view" ("g" "Show following" mastodon-profile--open-following) - ("s" "Show followers" mastodon-profile--open-followers) - + ("s" "Show followers" mastodon-profile--open-followers) + ("C-c C-c" "Cycle profile views" mastodon-profile-account-view-cycle) ("R" "View follow requests" mastodon-profile--view-follow-requests) ("a" "Accept follow request" mastodon-profile--follow-request-accept) ("j" "Reject follow request" mastodon-profile--follow-request-reject) diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 5748fa3..b8a6114 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -78,6 +78,7 @@ (let ((map (make-sparse-keymap))) (define-key map (kbd "s") #'mastodon-profile--open-followers) (define-key map (kbd "g") #'mastodon-profile--open-following) + (define-key map (kbd "C-c C-c") #'mastodon-profile--account-view-cycle) map) "Keymap for `mastodon-profile-mode'.") @@ -88,7 +89,7 @@ (define-key map (kbd "a") #'mastodon-notifications--follow-request-accept) (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-profile--view-follow-requests) + (define-key map (kbd "g") #'mastodon-profile--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) @@ -130,6 +131,19 @@ extra keybindings." (mastodon-profile--make-profile-buffer-for account "statuses" #'mastodon-tl--timeline)) +;; TODO: we shd just load all views' data then switch coz this is slow af: +(defun mastodon-profile-account-view-cycle () + "Cycle through profile view: toots, followers, and following." + (interactive) + (let ((endpoint (plist-get mastodon-tl--buffer-spec 'endpoint))) + (cond ((string-suffix-p "statuses" endpoint) + (mastodon-profile--open-followers)) + ((string-suffix-p "followers" endpoint) + (mastodon-profile--open-following)) + (t + (mastodon-profile--make-profile-buffer-for + mastodon-profile--account "statuses" #'mastodon-tl--timeline))))) + (defun mastodon-profile--open-following () "Open a profile buffer showing the accounts that current profile follows." (interactive) @@ -239,37 +253,25 @@ JSON is the data returned by the server." (defun mastodon-profile--fields-get (account) "Fetch the fields vector (aka profile metadata) from profile of ACCOUNT. - Returns a list of lists." (let ((fields (mastodon-profile--account-field account 'fields))) (when fields - (mapcar - (lambda (el) - (list - (alist-get 'name el) - (alist-get 'value el))) - fields)))) + (mapcar (lambda (el) + (list (alist-get 'name el) + (alist-get 'value el))) + fields)))) (defun mastodon-profile--fields-insert (fields) "Format and insert field pairs (a.k.a profile metadata) in FIELDS." (let* ((car-fields (mapcar 'car fields)) - ;; (cdr-fields (mapcar 'cadr fields)) - ;; (cdr-fields-rendered - ;; (list - ;; (mapcar (lambda (x) - ;; (mastodon-tl--render-text x nil)) - ;; cdr-fields))) (left-width (car (sort (mapcar 'length car-fields) '>)))) - ;; (right-width (car (sort (mapcar 'length cdr-fields) '>)))) (mapconcat (lambda (field) (mastodon-tl--render-text (concat (format "_ %s " (car field)) (make-string (- (+ 1 left-width) (length (car field))) ?_) (format " :: %s" (cadr field))) - ;; (make-string (- (+ 1 right-width) (length (cdr field))) ?_) - ;; " |") - field)) ; nil)) ; hack to make links tabstops + field)) ; hack to make links tabstops fields ""))) (defun mastodon-profile--get-statuses-pinned (account) @@ -421,7 +423,8 @@ If toot is a boost, opens the profile of the booster." (if account (progn (message "Loading profile of user %s..." user-handle) - (mastodon-profile--make-author-buffer account)) + (mastodon-profile--make-author-buffer account) + (message "'C-c C-c' to cycle profile views: toots, followers, following")) (message "Cannot find a user with handle %S" user-handle))))) (defun mastodon-profile--my-profile () diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 249c4a8..1d18b01 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -264,7 +264,7 @@ text, i.e. hidden spoiler text." "local" "timelines/public?local=true" 'mastodon-tl--timeline)) (defun mastodon-tl--get-tag-timeline () - "Prompts for tag and opens its timeline." + "Prompt for tag and opens its timeline." (interactive) (let* ((word (or (word-at-point) "")) (input (read-string (format "Load timeline for tag (%s): " word))) @@ -532,6 +532,7 @@ By default it is `mastodon-tl--byline-boosted'" (parsed-time (date-to-time created-time)) (faved (equal 't (mastodon-tl--field 'favourited toot))) (boosted (equal 't (mastodon-tl--field 'reblogged toot))) + (bookmarked (equal 't (mastodon-tl--field 'bookmarked toot))) (visibility (mastodon-tl--field 'visibility toot))) (concat ;; Boosted/favourited markers are not technically part of the byline, so @@ -544,18 +545,23 @@ By default it is `mastodon-tl--byline-boosted'" (concat (when boosted (mastodon-tl--format-faved-or-boosted-byline "B")) (when faved - (mastodon-tl--format-faved-or-boosted-byline "F"))) + (mastodon-tl--format-faved-or-boosted-byline "F")) + (when bookmarked + (mastodon-tl--format-faved-or-boosted-byline + (if (fontp (char-displayable-p #10r128278)) + "🔖" + "K")))) (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)) + (if (fontp (char-displayable-p #10r9993)) " ✉" " [direct]")) ((equal visibility "private") - (if (fontp (char-displayable-p #10r9993)) + (if (fontp (char-displayable-p #10r128274)) " 🔒" " [followers]"))) (funcall action-byline toot) @@ -575,9 +581,18 @@ By default it is `mastodon-tl--byline-boosted'" (defun mastodon-tl--format-faved-or-boosted-byline (letter) "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))) +LETTER is a string, F for favourited, B for boosted, or K for bookmarked." + (let ((help-string (cond ((equal letter "F") + "favourited") + ((equal letter "B") + "boosted") + ((equal letter (or "🔖" "K")) + "bookmarked")))) + (format "(%s) " + (propertize letter 'face 'mastodon-boost-fave-face + ;; emojify breaks this for 🔖: + 'help-echo (format "You have %s this status." + help-string))))) (defun mastodon-tl--render-text (string toot) "Return a propertized text rendering the given HTML string STRING. diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 897bf67..56b9417 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -366,6 +366,12 @@ NO-REDRAFT means delete toot only." toot-visibility toot-cw))))))))) +(defun mastodon-toot-set-cw (&optional cw) + "Set content warning to CW if it is non-nil" + (unless (equal cw "") + (setq mastodon-toot--content-warning t) + (setq mastodon-toot--content-warning-from-reply-or-redraft cw))) + (defun mastodon-toot--redraft (response &optional reply-id toot-visibility toot-cw) "Opens a new toot compose buffer using values from RESPONSE buffer. REPLY-ID, TOOT-VISIBILITY, and TOOT-CW of deleted toot are preseved." @@ -379,9 +385,7 @@ REPLY-ID, TOOT-VISIBILITY, and TOOT-CW of deleted toot are preseved." (when reply-id (setq mastodon-toot--reply-to-id reply-id)) (setq mastodon-toot--visibility toot-visibility) - (when (not (equal toot-cw "")) - (setq mastodon-toot--content-warning t) - (setq mastodon-toot--content-warning-from-reply-or-redraft toot-cw)) + (mastodon-toot-set-cw toot-cw) (mastodon-toot--update-status-fields)))) (defun mastodon-toot--bookmark-toot-toggle () @@ -466,10 +470,10 @@ The list is formatted for `emojify-user-emojis', which see." (mapc (lambda (x) (push `(,(concat ":" - (file-name-base x) - ":") . (("name" . ,(file-name-base x)) - ("image" . ,(concat mastodon-custom-emojis-dir x)) - ("style" . "github"))) + (file-name-base x) ":") + . (("name" . ,(file-name-base x)) + ("image" . ,(concat mastodon-custom-emojis-dir x)) + ("style" . "github"))) mastodon-emojify-user-emojis)) custom-emoji-files) (reverse mastodon-emojify-user-emojis))) @@ -483,7 +487,8 @@ to `emojify-user-emojis', and the emoji data is updated." (unless (file-exists-p (concat (expand-file-name emojify-emojis-dir) "/mastodon-custom-emojis/")) - (when (y-or-n-p "Looks like you haven't downloaded your instance's custom emoji yet. Download now? ") + (when (y-or-n-p "Looks like you haven't downloaded your + instance's custom emoji yet. Download now? ") (mastodon-toot--download-custom-emoji))) (setq emojify-user-emojis (append (mastodon-toot--collect-custom-emoji) @@ -886,12 +891,10 @@ REPLY-JSON is the full JSON of the toot being replied to." (when reply-to-user (insert (format "%s " reply-to-user)) (setq mastodon-toot--reply-to-id reply-to-id) - (if (not (equal mastodon-toot--visibility - reply-visibility)) - (setq mastodon-toot--visibility reply-visibility)) - (when (not (equal reply-cw "")) - (setq mastodon-toot--content-warning t) - (setq mastodon-toot--content-warning-from-reply-or-redraft reply-cw))))) + (unless (equal mastodon-toot--visibility + reply-visibility) + (setq mastodon-toot--visibility reply-visibility)) + (mastodon-toot-set-cw reply-cw)))) (defun mastodon-toot--update-status-fields (&rest _args) "Update the status fields in the header based on the current state." @@ -941,7 +944,7 @@ REPLY-JSON is the full JSON of the toot being replied to." (switch-to-buffer-other-window buffer) (text-mode) (mastodon-toot-mode t) - (when (not buffer-exists) + (unless buffer-exists (mastodon-toot--display-docs-and-status-fields) (mastodon-toot--setup-as-reply reply-to-user reply-to-id reply-json)) (unless mastodon-toot--max-toot-chars |