aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mastodon.el')
-rw-r--r--lisp/mastodon.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 722e927..f52579c 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -255,6 +255,21 @@ mastodon.el needs to be re-loaded for this to be correctly set.")
"Face used for reply text in toot compose buffer.
See `mastodon-toot-display-orig-in-reply-buffer'.")
+(defmacro with-mastodon-buffer (buffer mode-fun other-window &rest body)
+ "Evaluate BODY in a new or existing buffer called BUFFER.
+MODE-FUN is called to set the major mode.
+OTHER-WINDOW means call `switch-to-buffer-other-window' rather
+than `switch-to-buffer'."
+ (declare (debug 'body))
+ `(with-current-buffer (get-buffer-create ,buffer)
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (if ,other-window
+ (switch-to-buffer-other-window ,buffer)
+ (switch-to-buffer ,buffer))
+ (funcall ,mode-fun)
+ ,@body)))
+
;;;###autoload
(defun mastodon ()
"Connect Mastodon client to `mastodon-instance-url' instance."