From 1648b227fb6a42d1053fc1fd1b9555fab1add2c8 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 3 Aug 2022 21:58:47 +0200 Subject: cycle thru profile view: toots, followers, following --- lisp/mastodon-discover.el | 6 +++--- lisp/mastodon-profile.el | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-discover.el b/lisp/mastodon-discover.el index 7046070..a63d500 100644 --- a/lisp/mastodon-discover.el +++ b/lisp/mastodon-discover.el @@ -89,9 +89,9 @@ ("-" "zoom out" 'image-decrease-size) ("u" "copy URL" 'shr-maybe-probe-and-copy-url)) ("Profile view" - ("o" "Show following" mastodon-profile--open-following) - ("O" "Show followers" mastodon-profile--open-followers) - + ("g" "Show following" mastodon-profile--open-following) + ("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 6065bdd..0458e73 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) @@ -420,7 +434,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 () -- cgit v1.2.3 From d347107cbed62d74b33a2c1902eea87b5aa9b3af Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 3 Aug 2022 21:36:10 +0200 Subject: text-mode for update profile note --- lisp/mastodon-profile.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 0458e73..260c2d3 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -221,6 +221,7 @@ JSON is the data returned by the server." (buffer (get-buffer-create "*mastodon-update-profile*")) (inhibit-read-only t)) (switch-to-buffer-other-window buffer) + (text-mode) (setq-local header-line-format (propertize "Edit your profile note. C-c C-c to send, C-c C-k to cancel." -- cgit v1.2.3 From 23280f33214b2990de673376e770bdbc7efec57f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 7 Aug 2022 17:21:23 +0200 Subject: toot.el: refactor set-cw --- lisp/mastodon-toot.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index d571b6e..022cbec 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -365,6 +365,12 @@ NO-REDRAFT means delete toot only." toot-visibility toot-cw))))))))) +(defun mastodon-toot-set-cw (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." @@ -378,9 +384,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 () @@ -885,12 +889,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." @@ -940,7 +942,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 -- cgit v1.2.3 From bea7ad1d81f96f3476477758d6dacb3f9c985662 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 7 Aug 2022 20:39:58 +0200 Subject: emoji funs indentation --- lisp/mastodon-toot.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 022cbec..7ff2b78 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -469,10 +469,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))) @@ -486,7 +486,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) -- cgit v1.2.3 From ef6e809f9f16733ed81827afcfe3044bd4aad2ee Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 7 Aug 2022 20:40:32 +0200 Subject: optional cd in -set-ce refactor --- lisp/mastodon-toot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7ff2b78..e5e6ce1 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -365,7 +365,7 @@ NO-REDRAFT means delete toot only." toot-visibility toot-cw))))))))) -(defun mastodon-toot-set-cw (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) -- cgit v1.2.3 From f70edb1fae46afe8c26dd13020a3c67bd1b46f29 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 10 Aug 2022 14:57:19 +0200 Subject: fix formatting of unmute-user --- lisp/mastodon-tl.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 7aef0a1..4014772 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1444,7 +1444,8 @@ by `mastodon-tl--follow-user' to enable or disable notifications." ((string-equal notify "false") (message "Not receiving notifications for user %s (@%s)!" name user-handle)) - ((string-equal action "mute") + ((or (string-equal action "mute") + (string-equal action "unmute")) (message "User %s (@%s) %sd!" name user-handle action)) ((eq notify nil) (message "User %s (@%s) %sed!" name user-handle action))))))) -- cgit v1.2.3 From c18f3391b26a16c5a1bc7568cfd06a8ce6367c67 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 10 Aug 2022 15:00:53 +0200 Subject: remove commented code in profile--fields-insert --- lisp/mastodon-profile.el | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 260c2d3..cfea26c 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -253,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) -- cgit v1.2.3 From 6c04327b6c89529a19f196f2610ad86779ab8232 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 19 Aug 2022 09:21:39 +0200 Subject: tl--init*: fix a stray bracket --- lisp/mastodon-tl.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4014772..0d666ed 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1688,14 +1688,13 @@ JSON is the data returned from the server." #'mastodon-tl--update-timestamps-callback (current-buffer) nil))) - (unless - ;; for everything save profiles: - (string-prefix-p "accounts" endpoint)) - ;;(or (equal endpoint "notifications") - ;; (string-prefix-p "timelines" endpoint) - ;; (string-prefix-p "favourites" endpoint) - ;; (string-prefix-p "statuses" endpoint)) - (mastodon-tl--goto-first-item))) + (unless (string-prefix-p "accounts" endpoint) + ;; for everything save profiles + (mastodon-tl--goto-first-item)))) +;;(or (equal endpoint "notifications") +;; (string-prefix-p "timelines" endpoint) +;; (string-prefix-p "favourites" endpoint) +;; (string-prefix-p "statuses" endpoint)) (defun mastodon-tl--init-sync (buffer-name endpoint update-function) "Initialize BUFFER-NAME with timeline targeted by ENDPOINT. -- cgit v1.2.3 From b058512c3e437ec9334b59645d9c625528e40996 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 19 Aug 2022 09:35:44 +0200 Subject: format for bookmarked toots, help-echo for B/F/K format chars --- lisp/mastodon-tl.el | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 0d666ed..4330084 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -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,7 +545,9 @@ 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 "K"))) (propertize (concat ;; we propertize help-echo format faves for author name @@ -575,9 +578,17 @@ 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 "K") + "bookmarked")))) + (format "(%s) " + (propertize letter 'face 'mastodon-boost-fave-face + '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. -- cgit v1.2.3 From 4b39459c720f2ed8efe54efa23f1a92613bbe34e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 19 Aug 2022 09:23:59 +0200 Subject: docstring --- lisp/mastodon-tl.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4330084..638f01a 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))) -- cgit v1.2.3 From ea6e9675bdfffb682f2210312eea22d7d4c0a92f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 19 Aug 2022 10:18:16 +0200 Subject: FIX the post visibility marker displayable check --- lisp/mastodon-tl.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 638f01a..168523b 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -554,11 +554,11 @@ By default it is `mastodon-tl--byline-boosted'" ;; 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) -- cgit v1.2.3 From 05c42b95f48d57ac0d06a9a5c4cd910db77f073b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 19 Aug 2022 10:19:05 +0200 Subject: use bookmark emoji if possible --- lisp/mastodon-tl.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 168523b..d955a5e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -547,7 +547,10 @@ By default it is `mastodon-tl--byline-boosted'" (when faved (mastodon-tl--format-faved-or-boosted-byline "F")) (when bookmarked - (mastodon-tl--format-faved-or-boosted-byline "K"))) + (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 @@ -583,7 +586,7 @@ LETTER is a string, F for favourited, B for boosted, or K for bookmarked." "favourited") ((equal letter "B") "boosted") - ((equal letter "K") + ((equal letter (or "🔖" "K")) "bookmarked")))) (format "(%s) " (propertize letter 'face 'mastodon-boost-fave-face -- cgit v1.2.3 From 0e297693434939a70e1d323a4b6880c0ff5e7527 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 19 Aug 2022 10:19:05 +0200 Subject: use bookmark emoji if possible --- lisp/mastodon-tl.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d955a5e..8a600d4 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -590,6 +590,7 @@ LETTER is a string, F for favourited, B for boosted, or K for bookmarked." "bookmarked")))) (format "(%s) " (propertize letter 'face 'mastodon-boost-fave-face + ;; emojify breaks this for 🔖: 'help-echo (format "You have %s this status." help-string))))) -- cgit v1.2.3