         (return (aref cookie 2))))))
 
 (defun plaster-make-cookie (var val &optional time path domain)
+  "Create a new cookie value in the expected format for URL.
+
+Argument VAR The name of the cookie variable.
+Argument VAL The name of the cookie value.
+Optional argument TIME The cookie's expiry date string.
+Optional argument PATH The cookie's path.
+Optional argument DOMAIN The cookie's active domain."
   (let ((time (or time (format-time-string "%a, %d %b %Y %H:%M:%S %z" (+ (float-time) 3600))))
         (path (or path "/"))
         (domain (or domain (url-host (url-generic-parse-url plaster-api)))))
     `[url-cookie ,var ,val ,time ,path ,domain nil]))
 
 (defun plaster-api (endpoint)
+  "Construct the URL to the given plaster API ENDPOINT."
   (concat plaster-root "api/plaster/" endpoint))
 
 (defun plaster-paste-url (id)
+  "Construct the URL to view the paste with the given ID."
   (concat plaster-root "view/" id))
 
 (defun plaster-to-string (a)
+  "Turn A into a string."
   (with-output-to-string (princ a)))
 
 (defun plaster-type-mode (type)
+  "Return the name of a suitable mode for the given paste TYPE if any."
   (let ((explicit-mode (cdr (assoc type plaster-type-mode-map)))
         (implicit-mode (intern-soft (concat type "-mode"))))
     (or (and explicit-mode (fboundp explicit-mode) explicit-mode)
         (and implicit-mode (fboundp implicit-mode) implicit-mode))))
 
 (defun plaster-request (endpoint params)
+  "Perform a request against the Radiance API.
+
+Argument ENDPOINT The URL of the endpoint to request against.
+Argument PARAMS An alist of request parameters."
   (let ((url-request-method "POST")
         (url-cookie-storage
           (when plaster-session-token

(require 'json)

(defun plaster-find-session-token (cookies)
  (let* ((domain (url-host (url-generic-parse-url plaster-api)))
         (cookies (dolist (cookie cookies)
                    (when (or (cl-search (car cookie) domain)

  "Log in to the remote plaster server.

On successful log in this will update the
‘plaster-session-token’ to a token that should be
associated with the given account.

Optional argument USERNAME The username of the account.
Optional argument PASSWORD The password to the account."
  (interactive)
  (let* ((username (or username (read-string "Username: ")))
         (password (or password (read-string "Password: "))))
