From d8e93a8089b45bda92d9e408f4f713242f9fad50 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 28 Nov 2022 19:33:17 +0100 Subject: add schedule toot function + binding --- lisp/mastodon-toot.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 42cce36..4a10131 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -164,10 +164,6 @@ 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.") @@ -180,6 +176,10 @@ Should be at least 5 minutes into the future.") (defvar-local mastodon-toot--language nil "The language of the toot being composed, in ISO 639 (two-letter).") +(defvar-local mastodon-toot--scheduled-for nil + "An ISO 8601 timestamp that specifying when the post should be published. +Should be at least 5 minutes into the future.") + (defvar-local mastodon-toot--reply-to-id nil "Buffer-local variable to hold the id of the toot being replied to.") @@ -233,6 +233,7 @@ send.") (define-key map (kbd "C-c !") #'mastodon-toot--clear-all-attachments) (define-key map (kbd "C-c C-p") #'mastodon-toot--create-poll) (define-key map (kbd "C-c C-l") #'mastodon-toot--set-toot-lang) + (define-key map (kbd "C-c C-s") #'mastodon-toot--schedule-toot) map) "Keymap for `mastodon-toot'.") @@ -1127,6 +1128,15 @@ Return its two letter ISO 639 1 code." (alist-get choice mastodon-iso-639-1 nil nil 'equal)) (message "Language set to %s" choice))) +(defun mastodon-toot--schedule-toot () + "Read a date (+ time) in the minibuffer and schedule the current toot." + (interactive) + (let* ((time-value (org-read-date nil t nil "Schedule toot:")) + (iso8601-string (format-time-string "%Y-%m-%dT%H:%M:%S%z" time-value)) + (msg-str (format-time-string "%Y-%m-%d at %H:%M[%z]" time-value))) + (setq-local mastodon-toot--scheduled-at iso8601-string) + (message (format "Toot scheduled for %s." msg-str)))) + ;; we'll need to revisit this if the binds get ;; more diverse than two-chord bindings (defun mastodon-toot--get-mode-kbinds () -- cgit v1.2.3