Emacsposting to gemlog.blue!

So I just figured out I can program emacs to POST a thing I've written to gemlog.blue. That's what I'm using right now, in fact! Here's the code that I've done it with[1]:

(defun post-to-gemlog-blue (post-title user pass)
  "Post current buffer to gemlog.blue."
  (interactive "sTitle: \nsUsername: \nsPassword: ")
  (request "https://gemlog.blue/post.php"
    :type "POST"
    :data
    `(("title" . ,post-title)
      ("post" . ,(buffer-string))
      ("gemloguser" . ,user)
      ("pw" . ,pass))
    :success
    (cl-function
     (lambda (&key data &allow-other-keys)
       (message
	"I sent: %S"
	(assoc-default 'form data))))
    :error
    (cl-function
     (lambda (&rest args &key error-thrown &allow-other-keys)
       (message "Got error: %S" error-thrown)))))

I'm actually testing this code with this post as well, so if you're seeing it, it worked!

I'm really enjoying the programmability of emacs. Though Vim was pretty programmable, VimScript is pretty baroque, as has been tirelessly repeated elsewhere. Elisp, in comparison, is nice -- a more-real programming language.

Still to do

Though I have :success and :error defined, there are no messages actually in the message buffer -- so I need to fix that. Ideally, on success I'd just open up elpher with the newly-minted URL, but I have much to learn for that still.

Also I'd like to auto-detect the title if the first line is a gemtext h1. So I need to figure out how to do that with (interactive).

Lastly, it'd be nice to allow for all the functionality of gemlog.blue (and by extension, breadpunk.club) through Emacs itself. I guess I have an idea for my first Emacs package!!

If you have any suggestions or comments about this code or the idea, feel free to email me (acdw@acdw.net) or write a post and backlink this one.

Footnotes

[1]: It requires emacs-request right now.

(github repo)

A stretch goal would probably be to use emacs' own `url` module, of course.