aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.org8
-rw-r--r--lisp/mastodon-discover.el29
-rw-r--r--lisp/mastodon-notifications.el25
-rw-r--r--lisp/mastodon-profile.el12
-rw-r--r--lisp/mastodon-tl.el64
-rw-r--r--test/mastodon-profile-tests.el4
-rw-r--r--test/mastodon-toot-tests.el11
7 files changed, 91 insertions, 62 deletions
diff --git a/README.org b/README.org
index 9f50042..ffe65df 100644
--- a/README.org
+++ b/README.org
@@ -133,7 +133,7 @@ take place if your =mastodon-token-file= does not contain =:client_id= and
| | *Other views* |
| =S= | search (posts, users, tags) (NB: only posts you have interacted with) |
| =I=, =c=, =d= | view, create, and delete filters |
-| =R=, =a=, =r= | view/accept/reject follow requests |
+| =R=, =a=, =j= | view/accept/reject follow requests |
| =G= | view follow suggestions |
| =V= | view your favourited toots |
| =K= | view bookmarked toots |
@@ -299,11 +299,11 @@ Optional dependencies:
** Nota Bene regarding work on this library
-I resurrected this library a few years ago, and have added stacks of features and fixes over time. But I only do it in my spare time, and I tend to implement features I want to use. I am not a professional programmer. I never aimed to implement all Mastodon features, nor do I aim to provide a professional service of any kind. I have implemented some things I don't use, such as filters, but mostly I can only fix bugs with things that I regularly rely on.
+I resurrected this library a few years ago, and have added stacks of features and fixes over time. I do it in my spare time and tend to implement features I want to use. I am not a professional programmer. I never aimed to implement all Mastodon features, nor to provide a professional service to others. I have implemented some things I don't use, such as filters, but mostly I can only fix bugs with things that I regularly rely on.
-Please keep this in mind when requesting features that are not implemented. Feel free to open an issue and start a discussion. But please do not feel free to order things from me as though I was a service provider, unless you are willing to consider also paying me as though I were a service provider.
+Please keep this in mind when requesting features that are not implemented. Feel free to open an issue and start a discussion, but don't try to order things from me.
-The better option is most likely going to be looking at the code and seeing how you can implement the feature yourself, especially as a lot of the functionality you're likely to need is already implemented. I'm happy to give pointers on what you might use. If that's not an option, then finding other contributors in order to cover more ground is what is needed.
+The better option is to look at the code and seeing how you can implement the feature yourself. A lot of the functionality you'll need is already implemented. I'm happy to give pointers on what you might use.
** Contributing
diff --git a/lisp/mastodon-discover.el b/lisp/mastodon-discover.el
index f33b25d..0ef64e2 100644
--- a/lisp/mastodon-discover.el
+++ b/lisp/mastodon-discover.el
@@ -51,10 +51,14 @@
("b" "Boost" mastodon-toot--boost)
("f" "Favourite" mastodon-toot--favourite)
("c" "Toggle hidden text (CW)" mastodon-tl--toggle-spoiler-text-in-toot)
+ ("k" "Bookmark toot" mastodon-toot--bookmark-toot-toggle)
+ ("v" "Vote on poll" mastodon-tl--poll-vote)
("n" "Next" mastodon-tl--goto-next-toot)
("p" "Prev" mastodon-tl--goto-prev-toot)
("TAB" "Next link item" mastodon-tl--next-tab-item)
("S-TAB" "Prev link item" mastodon-tl--previous-tab-item)
+ (when (require 'mpv nil :noerror)
+ ("C-RET" "Play media" mastodon-tl--mpv-play-video-at-point))
("t" "New toot" mastodon-toot)
("r" "Reply" mastodon-toot--reply)
("C" "Copy toot URL" mastodon-toot--copy-toot-url)
@@ -62,10 +66,12 @@
("D" "Delete and redraft (your) toot" mastodon-toot--delete-toot)
("i" "Pin/Unpin (your) toot" mastodon-toot--pin-toot-toggle)
("P" "View user profile" mastodon-profile--show-user)
+ (when (require 'lingva nil :noerror)
+ "s" "Translate toot at point" mastodon-toot--translate-toot-text)
("T" "View thread" mastodon-tl--thread)
("v" "Vote on poll" mastodon-tl--poll-vote))
- ("Timelines"
- ("h" "View mode help/keybindings" describe-mode)
+ ("Views"
+ ("h/?" "View mode help/keybindings" describe-mode)
("#" "Tag search" mastodon-tl--get-tag-timeline)
("F" "Federated" mastodon-tl--get-federated-timeline)
("H" "Home" mastodon-tl--get-home-timeline)
@@ -73,8 +79,13 @@
("N" "Notifications" mastodon-notifications--get)
("u" "Update timeline" mastodon-tl--update)
("S" "Search" mastodon-search--search-query)
- ("C-S-P" "Jump to your profile" mastodon-profile--my-profile)
- ("K" "View bookmarks" mastodon-profile--view-bookmarks))
+ ("O" "Jump to your profile" mastodon-profile--my-profile)
+ ("U" "Update your profile note" mastodon-profile--update-user-profile-note)
+ ("K" "View bookmarks" mastodon-profile--view-bookmarks)
+ ("V" "View favourites" mastodon-profile--view-favourites)
+ ("R" "View follow requests" mastodon-profile--view-follow-requests)
+ ("G" "View follow suggestions" mastodon-tl--get-follow-suggestions)
+ ("I" "View filters" mastodon-tl--view-filters))
("Users"
("W" "Follow" mastodon-tl--follow-user)
("C-S-W" "Unfollow" mastodon-tl--unfollow-user)
@@ -89,16 +100,10 @@
("-" "zoom out" 'image-decrease-size)
("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)
- ("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)
- ("U" "Update your profile note" mastodon-profile--update-user-profile-note))
+ ("C-c C-c" "Cycle profile views" mastodon-profile-account-view-cycle))
("Quit"
("q" "Quit mastodon and bury buffer." kill-this-buffer)
("Q" "Quit mastodon buffer and kill window." kill-buffer-and-window)))))))
-(provide 'mastodon-discover)
+ (provide 'mastodon-discover)
;;; mastodon-discover.el ends here
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 4e8fbdb..7c5d40b 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -52,7 +52,6 @@
(autoload 'mastodon-tl--reload-timeline-or-profile "mastodon-tl")
(defvar mastodon-tl--buffer-spec)
(defvar mastodon-tl--display-media-p)
-(defvar mastodon-tl--buffer-spec)
(defvar mastodon-notifications--types-alist
'(("mention" . mastodon-notifications--mention)
@@ -87,7 +86,6 @@
With no argument, the request is accepted. Argument REJECT means
reject the request. Can be called in notifications view or in
follow-requests view."
- (interactive)
(if (not (mastodon-tl--find-property-range 'toot-json (point)))
(message "No follow request at point?")
(let* ((toot-json (mastodon-tl--property 'toot-json))
@@ -269,19 +267,20 @@ of the toot responded to."
"notifications"
'mastodon-notifications--timeline))
-(defun mastodon-notifications-clear ()
+(defun mastodon-notifications--clear-all ()
"Clear all notifications."
(interactive)
- (let ((response
- (mastodon-http--post (mastodon-http--api "notifications/clear")
- nil nil)))
- (mastodon-http--triage
- response (lambda ()
- (when mastodon-tl--buffer-spec
- (mastodon-tl--reload-timeline-or-profile))
- (message "All notifications cleared!")))))
-
-(defun mastodon-notifications-clear-current-notif ()
+ (when (y-or-n-p "Clear all notifications?")
+ (let ((response
+ (mastodon-http--post (mastodon-http--api "notifications/clear")
+ nil nil)))
+ (mastodon-http--triage
+ response (lambda ()
+ (when mastodon-tl--buffer-spec
+ (mastodon-tl--reload-timeline-or-profile))
+ (message "All notifications cleared!"))))))
+
+(defun mastodon-notifications--clear-current ()
"Dismiss the notification at point."
(interactive)
(let* ((id (or (mastodon-tl--property 'toot-id)
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 56e5fef..63c062b 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -82,8 +82,11 @@
(defvar mastodon-profile-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map (kbd "s") #'mastodon-profile--open-followers)
- (define-key map (kbd "g") #'mastodon-profile--open-following)
+ ;; conflicts with `s' keybinding to translate toot at point
+ ;; seeing as we now have the C-c C-c cycle functionality,
+ ;; maybe we can retire both of these awful bindings
+ ;; (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'.")
@@ -91,7 +94,10 @@
(defvar mastodon-profile--view-follow-requests-keymap
(let ((map ;(make-sparse-keymap)))
(copy-keymap mastodon-mode-map)))
- (define-key map (kbd "r") #'mastodon-notifications--follow-request-reject)
+ ;; make reject binding match the binding in notifs view
+ ;; 'r' is then reserved for replying, even tho it is not avail
+ ;; in foll-reqs view
+ (define-key map (kbd "j") #'mastodon-notifications--follow-request-reject)
(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)
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 355c215..ebf3570 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -283,6 +283,18 @@ text, i.e. hidden spoiler text."
(mastodon-tl--init
(concat "tag-" tag) (concat "timelines/tag/" tag) 'mastodon-tl--timeline))
+(defun mastodon-tl--message-help-echo ()
+ "Call message on 'help-echo property at point.
+Do so if type of status at poins is not follow_request/follow."
+ (let ((type (alist-get
+ 'type
+ (get-text-property (point) 'toot-json)))
+ (echo (get-text-property (point) 'help-echo)))
+ (when echo ; not for followers/following in profile
+ (unless (or (string= type "follow_request")
+ (string= type "follow")) ; no counts for these
+ (message "%s" (get-text-property (point) 'help-echo))))))
+
(defun mastodon-tl--goto-toot-pos (find-pos refresh &optional pos)
"Search for toot with FIND-POS.
If search returns nil, execute REFRESH function.
@@ -295,7 +307,9 @@ Optionally start from POS."
(if npos
(if (not (get-text-property npos 'toot-id))
(mastodon-tl--goto-toot-pos find-pos refresh npos)
- (goto-char npos))
+ (goto-char npos)
+ ;; force display of help-echo on moving to a toot byline:
+ (mastodon-tl--message-help-echo))
(funcall refresh))))
(defun mastodon-tl--goto-next-toot ()
@@ -373,12 +387,12 @@ Used on initializing a timeline or thread."
(propertize (concat "@" handle)
'face 'mastodon-handle-face
'mouse-face 'highlight
- 'mastodon-tab-stop 'user-handle
+ 'mastodon-tab-stop 'user-handle
'account account
- 'shr-url profile-url
- 'keymap mastodon-tl--link-keymap
+ 'shr-url profile-url
+ 'keymap mastodon-tl--link-keymap
'mastodon-handle (concat "@" handle)
- 'help-echo (concat "Browse user profile of @" handle))
+ 'help-echo (concat "Browse user profile of @" handle))
")")))
(defun mastodon-tl--format-faves-count (toot)
@@ -398,22 +412,23 @@ image media from the byline."
toot)
(alist-get 'reblog toot) ; boosts
toot)) ; everything else
- (fol-req-p (equal (alist-get 'type toot-to-count) "follow"))
- (media-types (mastodon-tl--get-media-types toot))
- (format-faves (format "%s faves | %s boosts | %s replies"
- (alist-get 'favourites_count toot-to-count)
- (alist-get 'reblogs_count toot-to-count)
- (alist-get 'replies_count toot-to-count)))
- (format-media (when media-types
- (format " | media: %s"
- (mapconcat #'identity media-types " "))))
- (format-media-binding (when (and (or
- (member "video" media-types)
- (member "gifv" media-types))
- (require 'mpv nil :no-error))
- (format " | C-RET to view with mpv"))))
+ (fol-req-p (or (string= (alist-get 'type toot-to-count) "follow")
+ (string= (alist-get 'type toot-to-count) "follow_request"))))
(unless fol-req-p
- (format "%s" (concat format-faves format-media format-media-binding)))))
+ (let* ((media-types (mastodon-tl--get-media-types toot))
+ (format-faves (format "%s faves | %s boosts | %s replies"
+ (alist-get 'favourites_count toot-to-count)
+ (alist-get 'reblogs_count toot-to-count)
+ (alist-get 'replies_count toot-to-count)))
+ (format-media (when media-types
+ (format " | media: %s"
+ (mapconcat #'identity media-types " "))))
+ (format-media-binding (when (and (or
+ (member "video" media-types)
+ (member "gifv" media-types))
+ (require 'mpv nil :no-error))
+ (format " | C-RET to view with mpv"))))
+ (format "%s" (concat format-faves format-media format-media-binding))))))
(defun mastodon-tl--get-media-types (toot)
"Return a list of the media attachment types of the TOOT at point."
@@ -594,10 +609,10 @@ this just means displaying toot client."
'face 'mastodon-display-name-face
'follow-link t
'mouse-face 'highlight
- 'mastodon-tab-stop 'shr-url
- 'shr-url app-url
+ 'mastodon-tab-stop 'shr-url
+ 'shr-url app-url
'help-echo app-url
- 'keymap mastodon-tl--shr-map-replacement)))))
+ 'keymap mastodon-tl--shr-map-replacement)))))
(propertize "\n ------------\n" 'face 'default))
'favourited-p faved
'boosted-p boosted
@@ -1299,7 +1314,8 @@ ID is that of the toot to view."
;; this requires that 'base-toot-id always be set:
(get-text-property (point) 'base-toot-id)))
(type (mastodon-tl--field 'type (mastodon-tl--property 'toot-json))))
- (if (string= type "follow_request") ; no can thread this
+ (if (or (string= type "follow_request")
+ (string= type "follow")) ; no can thread these
(error "No thread")
(let* ((url (mastodon-http--api (format "statuses/%s/context" id)))
(buffer (format "*mastodon-thread-%s*" id))
diff --git a/test/mastodon-profile-tests.el b/test/mastodon-profile-tests.el
index 640afb7..267e48b 100644
--- a/test/mastodon-profile-tests.el
+++ b/test/mastodon-profile-tests.el
@@ -240,7 +240,7 @@ content generation in the function under test."
[])
(mock (mastodon-profile--relationships-get "1")
=>
- [((id . "1") (following . :json-false) (showing_reblogs . :json-false) (notifying . :json-false) (followed_by . :json-false) (blocking . :json-false) (blocked_by . :json-false) (muting . :json-false) (muting_notifications . :json-false) (requested . :json-false) (domain_blocking . :json-false) (endorsed . :json-false) (note . ""))])
+ '(((id . "1") (following . :json-false) (showing_reblogs . :json-false) (notifying . :json-false) (followed_by . :json-false) (blocking . :json-false) (blocked_by . :json-false) (muting . :json-false) (muting_notifications . :json-false) (requested . :json-false) (domain_blocking . :json-false) (endorsed . :json-false) (note . ""))))
;; Let's not do formatting as that makes it hard to not rely on
;; window width and reflowing the text.
(mock (shr-render-region * *) => nil)
@@ -259,7 +259,7 @@ content generation in the function under test."
(buffer-substring-no-properties (point-min) (point-max))
(concat
"\n"
- "[img] \n"
+ "[img] [img] \n"
"Eugen\n"
"@Gargron\n"
" ------------\n"
diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el
index 5b95cdc..39e0984 100644
--- a/test/mastodon-toot-tests.el
+++ b/test/mastodon-toot-tests.el
@@ -92,10 +92,13 @@ mention string."
;; TODO: test y-or-no-p with mastodon-toot--cancel
(ert-deftest mastodon-toot--kill ()
"Should kill the buffer when cancelling the toot."
- (with-mock
- (mock (kill-buffer-and-window))
- (mastodon-toot--kill)
- (mock-verify)))
+ (let ((mastodon-toot-previous-window-config
+ (list (current-window-configuration)
+ (point-marker))))
+ (with-mock
+ (mock (kill-buffer-and-window))
+ (mastodon-toot--kill)
+ (mock-verify))))
(ert-deftest mastodon-toot--own-toot-p-fail ()
"Should not return t if not own toot."