From 4bfe8b8696ae36e3331f6900101aed003185be90 Mon Sep 17 00:00:00 2001
From: marty hiatt <martianhiatus [a t] riseup [d o t] net>
Date: Sat, 29 Oct 2022 13:27:51 +0200
Subject: restore -toot--kill fun for use with draft toot functionality

---
 lisp/mastodon-toot.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index a96bdbf..bcf9c83 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -465,12 +465,16 @@ REPLY-ID, TOOT-VISIBILITY, and TOOT-CW of deleted toot are preseved."
       (mastodon-toot-set-cw toot-cw)
       (mastodon-toot--update-status-fields))))
 
-(defun mastodon-toot--kill ()
-  "Kill `mastodon-toot-mode' buffer and window."
-  (with-current-buffer (get-buffer "*new toot*")
-    ;; FIXME: prevent some weird bug when cancelling a non-empty toot:
-    (delete #'mastodon-toot--save-toot-text after-change-functions)
-    (kill-buffer-and-window)))
+(defun mastodon-toot--kill (&optional cancel)
+  "Kill `mastodon-toot-mode' buffer and window.
+CANCEL means the toot was not sent, so we save the toot text as a draft."
+  (unless (eq mastodon-toot-current-toot-text nil)
+    (when cancel
+      (cl-pushnew mastodon-toot-current-toot-text
+                  mastodon-toot-draft-toots-list :test 'equal)))
+  ;; prevent some weird bug when cancelling a non-empty toot:
+  (delete #'mastodon-toot-save-toot-text after-change-functions)
+  (kill-buffer-and-window))
 
 (defun mastodon-toot--cancel ()
   "Kill new-toot buffer/window. Does not POST content to Mastodon.
-- 
cgit v1.2.3