aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-toot.el
diff options
context:
space:
mode:
authorclarkenciel <clarkenciel@gmail.com>2017-04-27 20:15:37 -0700
committerJohnson Denen <johnson.denen@gmail.com>2017-04-28 19:57:23 -0400
commite4dbf004008e5c7168e3f9b719a66266ba04c6e0 (patch)
tree6929f139b3bdb9042a12462194953338d8faa334 /lisp/mastodon-toot.el
parentdea076e2d1ab1088bc17f1857c30f433072a0361 (diff)
reformatting docs and changing removal func since we can't re-match on
the "Toot Text:" string
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r--lisp/mastodon-toot.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 09fd264..af86b5f 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -101,15 +101,19 @@ Set `mastodon-toot--content-warning' to nil."
(interactive)
(mastodon-toot--kill))
-(defun mastodon-toot--remove-docs (toot-buffer-contents)
- "Get the body of a toot from a TOOT-BUFFER-CONTENTS composed in a toot compose buffer."
- (let ((re "^=+\\(\n\\|.\\)*=+\nToot Text:\n\n"))
- (replace-regexp-in-string re "" toot-buffer-contents)))
+(defun mastodon-toot--remove-docs ()
+ "Get the body of a toot from the current compose buffer."
+ (let ((re "^|=+=|$"))
+ (save-excursion
+ (goto-char 0)
+ (re-search-forward re)
+ (re-search-forward re) ; end of the docs
+ (buffer-substring (+ 2 (point)) (length (buffer-string))))))
(defun mastodon-toot--send ()
"Kill new-toot buffer/window and POST contents to the Mastodon instance."
(interactive)
- (let* ((toot (mastodon-toot--remove-docs (buffer-string)))
+ (let* ((toot (mastodon-toot--remove-docs))
(endpoint (mastodon-http--api "statuses"))
(spoiler (when mastodon-toot--content-warning
(read-string "Warning: ")))
@@ -159,10 +163,10 @@ Set `mastodon-toot--content-warning' to nil."
"Create formatted documentation text for the mastodon-toot-mode."
(let ((kbinds (mastodon-toot--get-mode-kbinds)))
(concat
- "=================================================================\n"
- "Compose a new toot here. The following keybindings are available:"
+ "|=================================================================|\n"
+ " Compose a new toot here. The following keybindings are available:"
(mastodon-toot--format-kbinds kbinds)
- "\n=================================================================\n\n")))
+ "\n|=================================================================|\n\n")))
(defun mastodon-toot--display-docs ()
"Display documentation about mastodon-toot mode."