Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save DivineDominion/e632d5acde7369b61a95c06ecc3f086c to your computer and use it in GitHub Desktop.
Patch to offer post scheduling in Mastodon.el
From e17e2ecd417864c725fe5f182a25cf3024251263 Mon Sep 17 00:00:00 2001
From: Christian Tietze <ctietze@noreply.codeberg.org>
Date: Sat, 26 Nov 2022 11:07:24 +0000
Subject: [PATCH] add mastodon-toot--scheduled-at buffer-local variable to
optionally schedule posts
---
lisp/mastodon-toot.el | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index c99f088..eefceda 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -163,6 +163,10 @@ This is determined by the account setting on the server. To
change the setting on the server, see
`mastodon-toot--set-default-visibility'.")
+(defvar-local mastodon-toot--scheduled-at nil
+ "An ISO 8601 timestamp that declares when the post should be published.
+Should be at least 5 minutes into the future.")
+
(defvar-local mastodon-toot--media-attachments nil
"A list of the media attachments of the toot being composed.")
@@ -686,7 +690,8 @@ instance to edit a toot."
("sensitive" . ,(when mastodon-toot--content-nsfw
(symbol-name t)))
("spoiler_text" . ,spoiler)
- ("language" . ,mastodon-toot--language)))
+ ("language" . ,mastodon-toot--language)
+ ("scheduled_at" . ,mastodon-toot--scheduled-at)))
(args-media (when mastodon-toot--media-attachments
(mastodon-http--build-array-params-alist
"media_ids[]"
--
2.38.1
;;
;; Requires https://codeberg.org/martianh/mastodon.el/pulls/335/files (not yet merged into develop)
;; See .patch file below
;;
(require 'org)
(require 'mastodon)
;; Convention:
;; The compose window parses key bindings, extracts the `--schedule` part,
;; and shows `"Schedule"` as the action verb automatically.
(defun ct/mastodon-toot--schedule ()
(interactive)
(let* ((time-value (org-read-date nil t nil "Schedule post at:" (date-to-time "2022-11-26 00:00 am")))
(iso8601-string (format-time-string "%Y-%m-%dT%H:%M:%S%z" time-value)))
(setq-local mastodon-toot--scheduled-at iso8601-string)
(message (format "Scheduled post for '%s'." iso8601-string))))
(define-key mastodon-toot-mode-map (kbd "C-c C-s") #'ct/mastodon-toot--schedule)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment