diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-08-07 17:21:23 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-08-07 17:21:23 +0200 |
commit | 23280f33214b2990de673376e770bdbc7efec57f (patch) | |
tree | 41603e849fc622bee3ed4f184031ba8f80225842 /lisp | |
parent | d347107cbed62d74b33a2c1902eea87b5aa9b3af (diff) |
toot.el: refactor set-cw
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-toot.el | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index d571b6e..022cbec 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -365,6 +365,12 @@ NO-REDRAFT means delete toot only." toot-visibility toot-cw))))))))) +(defun mastodon-toot-set-cw (cw) + "Set content warning to CW if it is non-nil" + (unless (equal cw "") + (setq mastodon-toot--content-warning t) + (setq mastodon-toot--content-warning-from-reply-or-redraft cw))) + (defun mastodon-toot--redraft (response &optional reply-id toot-visibility toot-cw) "Opens a new toot compose buffer using values from RESPONSE buffer. REPLY-ID, TOOT-VISIBILITY, and TOOT-CW of deleted toot are preseved." @@ -378,9 +384,7 @@ REPLY-ID, TOOT-VISIBILITY, and TOOT-CW of deleted toot are preseved." (when reply-id (setq mastodon-toot--reply-to-id reply-id)) (setq mastodon-toot--visibility toot-visibility) - (when (not (equal toot-cw "")) - (setq mastodon-toot--content-warning t) - (setq mastodon-toot--content-warning-from-reply-or-redraft toot-cw)) + (mastodon-toot-set-cw toot-cw) (mastodon-toot--update-status-fields)))) (defun mastodon-toot--bookmark-toot-toggle () @@ -885,12 +889,10 @@ REPLY-JSON is the full JSON of the toot being replied to." (when reply-to-user (insert (format "%s " reply-to-user)) (setq mastodon-toot--reply-to-id reply-to-id) - (if (not (equal mastodon-toot--visibility - reply-visibility)) - (setq mastodon-toot--visibility reply-visibility)) - (when (not (equal reply-cw "")) - (setq mastodon-toot--content-warning t) - (setq mastodon-toot--content-warning-from-reply-or-redraft reply-cw))))) + (unless (equal mastodon-toot--visibility + reply-visibility) + (setq mastodon-toot--visibility reply-visibility)) + (mastodon-toot-set-cw reply-cw)))) (defun mastodon-toot--update-status-fields (&rest _args) "Update the status fields in the header based on the current state." @@ -940,7 +942,7 @@ REPLY-JSON is the full JSON of the toot being replied to." (switch-to-buffer-other-window buffer) (text-mode) (mastodon-toot-mode t) - (when (not buffer-exists) + (unless buffer-exists (mastodon-toot--display-docs-and-status-fields) (mastodon-toot--setup-as-reply reply-to-user reply-to-id reply-json)) (unless mastodon-toot--max-toot-chars |