aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-toot.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r--lisp/mastodon-toot.el41
1 files changed, 35 insertions, 6 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 746b7d4..07ab400 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -2,10 +2,11 @@
;; Copyright (C) 2017-2019 Johnson Denen
;; Author: Johnson Denen <johnson.denen@gmail.com>
+;; Marty Hiatt <martianhiatus@riseup.net>
;; Maintainer: Marty Hiatt <martianhiatus@riseup.net>
;; Version: 0.10.0
;; Package-Requires: ((emacs "27.1"))
-;; Homepage: https://git.blast.noho.st/mouse/mastodon.el
+;; Homepage: https://codeberg.org/martianh/mastodon.el
;; This file is not part of GNU Emacs.
@@ -69,6 +70,11 @@
(autoload 'mastodon-tl--toot-id "mastodon-tl")
(autoload 'mastodon-toot "mastodon")
+; for mastodon-toot--translate-toot-text
+(autoload 'mastodon-tl--content "mastodon-tl")
+(when (require 'lingva nil :no-error)
+ (declare-function lingva-translate "lingva"))
+
(defgroup mastodon-toot nil
"Tooting in Mastodon."
:prefix "mastodon-toot-"
@@ -193,7 +199,10 @@ Remove MARKER if REMOVE is non-nil, otherwise add it."
(unless remove
(goto-char bol)
(insert (format "(%s) "
- (propertize marker 'face 'success)))))))
+ (propertize marker 'face 'success)))))
+ ;; leave point after the marker:
+ (unless remove
+ (mastodon-tl--goto-next-toot))))
(defun mastodon-toot--action (action callback)
"Take ACTION on toot at point, then execute CALLBACK.
@@ -255,7 +264,7 @@ Makes a POST request to the server."
(mastodon-toot--action-success
"F" byline-region remove))
(message (format "%s #%s" action id))))
- (message "Nothing to favorite here?!?"))))
+ (message "Nothing to favourite here?!?"))))
(defun mastodon-toot--copy-toot-url ()
"Copy URL of toot at point."
@@ -267,6 +276,25 @@ Makes a POST request to the server."
(kill-new url)
(message "Toot URL copied to the clipboard.")))
+(defun mastodon-toot--copy-toot-text ()
+ "Copy text of toot at point."
+ (interactive)
+ (let* ((toot (mastodon-tl--property 'toot-json)))
+ (kill-new (mastodon-tl--content toot))
+ (message "Toot content copied to the clipboard.")))
+
+;; (when (require 'lingva nil :no-error)
+ (defun mastodon-toot--translate-toot-text ()
+ "Translate text of toot at point.
+Uses `lingva.el'."
+ (interactive)
+ (if mastodon-tl--buffer-spec
+ (let* ((toot (mastodon-tl--property 'toot-json)))
+ (if toot
+ (lingva-translate nil (mastodon-tl--content toot))
+ (message "No toot to translate?")))
+ (message "No mastodon buffer?")))
+
(defun mastodon-toot--own-toot-p (toot)
"Check if TOOT is user's own, e.g. for deleting it."
(and (not (alist-get 'reblog toot))
@@ -589,11 +617,12 @@ candidate ARG. IGNORED remains a mystery."
"Reply to toot at `point'."
(interactive)
(let* ((toot (mastodon-tl--property 'toot-json))
+ (parent (mastodon-tl--property 'parent-toot)) ; for new notifs handling
(id (mastodon-tl--as-string (mastodon-tl--field 'id toot)))
(account (mastodon-tl--field 'account toot))
(user (alist-get 'acct account))
- (mentions (mastodon-toot--mentions toot))
- (boosted (mastodon-tl--field 'reblog toot))
+ (mentions (mastodon-toot--mentions (or parent toot)))
+ (boosted (mastodon-tl--field 'reblog (or parent toot)))
(booster (when boosted
(alist-get 'acct
(alist-get 'account toot)))))
@@ -609,7 +638,7 @@ candidate ARG. IGNORED remains a mystery."
mentions))
(concat (mastodon-toot--process-local user)
mentions)))
- id toot)))
+ id (or parent toot))))
(defun mastodon-toot--toggle-warning ()
"Toggle `mastodon-toot--content-warning'."