aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoha <boynux@gmail.com>2022-12-31 18:02:44 +0100
committerMoha <boynux@gmail.com>2023-01-01 12:18:48 +0100
commitbaa5ae92733ce95ea5036ca6b18575ebfa80af9b (patch)
tree8818673d52cac4dc74749da95a06ff0e1c1e4a8c
parent8a633d9ab01e9c8cb47e9edf54d52f44e26c57f9 (diff)
Add option to set the default reply visibility
This change introduces a new option `mastodon-toot-default-reply-visibility`. The default is set to "Public". Replies will be defaulted to the value of this parameter unless the original toot has a more restrictive visiblity. For example: with `mastodon-toot--default-reply-visibility` set to "unlisted" - Original post visibility: public - Reply default visibility: unlinsted - Original post visbility: private (only-followers) - Repy default visibility: private
-rw-r--r--README.org3
-rw-r--r--lisp/mastodon-toot.el24
2 files changed, 26 insertions, 1 deletions
diff --git a/README.org b/README.org
index 85ff179..35ebb99 100644
--- a/README.org
+++ b/README.org
@@ -263,6 +263,9 @@ work without first loading =mastodon.el=:
- =mastodon-profile--account-sensitive-toggle=: Toggle whether your posts are
marked as sensitive (nsfw) by default.
+- =mastodon-toot--default-reply-visibility=: Set the default visibility for replies.
+ This visibility is used only when the original post has less restrictive visibility.
+
*** Customization
See =M-x customize-group RET mastodon= to view all customize options.
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index c18f751..9e8a2cc 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -140,6 +140,16 @@ You need to install company yourself to use this."
:group 'mastodon-toot
:type 'integer)
+(defcustom mastodon-toot--default-reply-visibility "public"
+ "Default visibility settings when replying.
+If the original toot visibility is different we use the more restricted one."
+ :group 'mastodon-toot
+ :type '(choice
+ (const :tag "public" "public")
+ (const :tag "unlisted" "unlisted")
+ (const :tag "followers only" "private")
+ (const :tag "direct" "direct")))
+
(defcustom mastodon-toot--enable-custom-instance-emoji nil
"Whether to enable your instance's custom emoji by default."
:group 'mastodon-toot
@@ -1348,11 +1358,23 @@ REPLY-TEXT is the text of the toot being replied to."
'read-only "Edit your message below."
'toot-post-header t))))
+(defun mastodon-toot--most-restrictive-visibility (reply-visibility)
+ "Return REPLY-VISIBILITY or default visibility, whichever is more restrictive.
+The default is given by `mastodon-toot--default-reply-visibility'."
+ (unless (null reply-visibility)
+ (let ((less-restrictive (member (intern mastodon-toot--default-reply-visibility)
+ mastodon-toot-visibility-list)))
+ (insert (format "%s" reply-visibility))
+ (if (member (intern reply-visibility) less-restrictive)
+ mastodon-toot--default-reply-visibility reply-visibility))))
+
(defun mastodon-toot--setup-as-reply (reply-to-user reply-to-id reply-json)
"If REPLY-TO-USER is provided, inject their handle into the message.
If REPLY-TO-ID is provided, set `mastodon-toot--reply-to-id'.
REPLY-JSON is the full JSON of the toot being replied to."
- (let ((reply-visibility (alist-get 'visibility reply-json))
+ (let ((reply-visibility
+ (mastodon-toot--most-restrictive-visibility
+ (alist-get 'visibility reply-json)))
(reply-cw (alist-get 'spoiler_text reply-json)))
(when reply-to-user
(insert (format "%s " reply-to-user))