;;; Based on code by Rudi Schlatte. ;;; Needs this library: ;;; http://www.emacswiki.org/cgi-bin/wiki/XmlRpc (require 'xml-rpc) (defvar lisppaste-nick "chandler") (defvar lisppaste-channel "None") (defvar lisppaste-colorize-as "") (defvar lisppaste-prev-title "") (defun lisppaste-region (region-begin region-end &optional channel username title annotate) (interactive "r") (let* ((content (buffer-substring region-begin region-end)) (channel (or channel (read-from-minibuffer "Channel: " lisppaste-channel))) (username (or username (read-from-minibuffer "Nick: " lisppaste-nick))) (title (or title (read-from-minibuffer "Title: " lisppaste-prev-title))) (annotate (or annotate (string-to-number (read-from-minibuffer "Annotate? ")))) (colorize-as (if (zerop annotate) (read-from-minibuffer "Colorize as (empty for default): " lisppaste-colorize-as)))) (setf lisppaste-prev-title title) (let* ((ret (xml-rpc-method-call "http://common-lisp.net:8185/RPC2" 'newpaste channel username title content (or colorize-as annotate))) (url-beg (search "http://" ret)) (url-end (and url-beg (search " " ret :start2 url-beg))) (url (and url-end (substring ret url-beg url-end)))) (print ret) (and url (browse-url url)) (or url ret))))