From baa5ae92733ce95ea5036ca6b18575ebfa80af9b Mon Sep 17 00:00:00 2001 From: Moha Date: Sat, 31 Dec 2022 18:02:44 +0100 Subject: 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 --- lisp/mastodon-toot.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-toot.el') 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)) -- cgit v1.2.3