From 23280f33214b2990de673376e770bdbc7efec57f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 7 Aug 2022 17:21:23 +0200 Subject: toot.el: refactor set-cw --- lisp/mastodon-toot.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lisp/mastodon-toot.el') 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 -- cgit v1.2.3 From bea7ad1d81f96f3476477758d6dacb3f9c985662 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 7 Aug 2022 20:39:58 +0200 Subject: emoji funs indentation --- lisp/mastodon-toot.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 022cbec..7ff2b78 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -469,10 +469,10 @@ The list is formatted for `emojify-user-emojis', which see." (mapc (lambda (x) (push `(,(concat ":" - (file-name-base x) - ":") . (("name" . ,(file-name-base x)) - ("image" . ,(concat mastodon-custom-emojis-dir x)) - ("style" . "github"))) + (file-name-base x) ":") + . (("name" . ,(file-name-base x)) + ("image" . ,(concat mastodon-custom-emojis-dir x)) + ("style" . "github"))) mastodon-emojify-user-emojis)) custom-emoji-files) (reverse mastodon-emojify-user-emojis))) @@ -486,7 +486,8 @@ to `emojify-user-emojis', and the emoji data is updated." (unless (file-exists-p (concat (expand-file-name emojify-emojis-dir) "/mastodon-custom-emojis/")) - (when (y-or-n-p "Looks like you haven't downloaded your instance's custom emoji yet. Download now? ") + (when (y-or-n-p "Looks like you haven't downloaded your + instance's custom emoji yet. Download now? ") (mastodon-toot--download-custom-emoji))) (setq emojify-user-emojis (append (mastodon-toot--collect-custom-emoji) -- cgit v1.2.3 From ef6e809f9f16733ed81827afcfe3044bd4aad2ee Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 7 Aug 2022 20:40:32 +0200 Subject: optional cd in -set-ce refactor --- lisp/mastodon-toot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7ff2b78..e5e6ce1 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -365,7 +365,7 @@ NO-REDRAFT means delete toot only." toot-visibility toot-cw))))))))) -(defun mastodon-toot-set-cw (cw) +(defun mastodon-toot-set-cw (&optional cw) "Set content warning to CW if it is non-nil" (unless (equal cw "") (setq mastodon-toot--content-warning t) -- cgit v1.2.3