diff options
author | martianh <martianh@noreply.codeberg.org> | 2023-01-10 01:09:49 +0000 |
---|---|---|
committer | martianh <martianh@noreply.codeberg.org> | 2023-01-10 01:09:49 +0000 |
commit | 531386d6b4c1376efd27aea2b88ebeb1d0ade227 (patch) | |
tree | 87110cc0a7ffb5191475c2c1a2b9da981f521363 /lisp | |
parent | b8cf48227809612c578aa011ddf821a8c6f6ce41 (diff) | |
parent | baa5ae92733ce95ea5036ca6b18575ebfa80af9b (diff) |
Merge pull request 'Add option to set the default reply visibility' (#370) from boynux/mastodon.el:default-reply-visibility into develop
Reviewed-on: https://codeberg.org/martianh/mastodon.el/pulls/370
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-toot.el | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 99b5936..0d733bd 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -139,6 +139,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 @@ -1346,11 +1356,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)) |