Skip to content

Instantly share code, notes, and snippets.

@theanalyst
Last active December 23, 2015 12:09
Show Gist options
  • Save theanalyst/6633290 to your computer and use it in GitHub Desktop.
Save theanalyst/6633290 to your computer and use it in GitHub Desktop.
(require 'grapnel)
(require 'json)
(defgroup elix nil
"Elix -- Emacs ix.io client"
:tag "Elix"
:group 'tools)
(defcustom ix-user nil
"user name for posting at http://ix.io"
:type 'string
:group 'elix)
(defcustom ix-token nil
"token/password for posting at http://ix.io"
:type 'string
:group 'elix)
(defun ix-post (text)
(grapnel-retrieve-url "http://ix.io"
`((success . (lambda (res hdrs) (message "url: %s" res) )) ;; TODO add this to kill-ring
(failure . (lambda (res hdrs) (message "failure! %s" hdrs)))
(error . (lambda (res err) (message "err %s" err)))
(complete . (lambda (res err) (message "%s %s" res err)))) ;;debugging
"POST"
nil
`((,(format "%s:%s" "f" (length text)) . ,text) ;;make something like
("login" . ,ix-user)
("token" . ,ix-token))))
(defun ix (start end)
(interactive
(if mark-active
(list (region-beginning) (region-end))
(list (point-min) (point-max))))
(let ((selection (buffer-substring-no-properties start end)))
(message "posting...")
(ix-post selection)))
(provide 'elix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment