Skip to content

Commit

Permalink
Docstrings, renamed a generic unnamespaced function
Browse files Browse the repository at this point in the history
Many of us use describe-function to figure out how to use a package, so docstrings are nice to provide. read-url is not namespaced, and is far too generic a name for what it does, renamed to something less likely to clash with other packages.
  • Loading branch information
JustinGSmith committed Dec 9, 2013
1 parent 06692b4 commit aa21fe7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions refheap.el
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
:type 'string
:group 'refheap)

(defun read-url (status)
(defun read-refheap-url (status)
"Get the url from the refheap server response."
(search-forward "\n\n")
(let ((location (cdr (assoc 'url
(json-read-from-string
Expand All @@ -93,6 +94,7 @@
(kill-buffer (current-buffer))))

(defun refheap-paste (text mode private)
"Send text to the refheap server, with highlighting mode, optionally private."
(let ((url-request-method "POST")
(url-request-extra-headers
'(("Content-Type" . "application/x-www-form-urlencoded")))
Expand All @@ -103,27 +105,31 @@
(when (and refheap-user refheap-token)
(concat "&username=" refheap-user "&"
"token=" (url-hexify-string refheap-token))))))
(url-retrieve "https://www.refheap.com/api/paste" 'read-url)))
(url-retrieve "https://www.refheap.com/api/paste" 'read-refheap-url)))

;;;###autoload
(defun refheap-paste-region (begin end &optional private)
"Paste the current region to refheap. With prefix arg, paste privately."
(interactive "r\nP")
(let ((hl (or (cdr (assoc major-mode refheap-supported-modes))
"Plain Text")))
(refheap-paste (buffer-substring begin end) hl private)))

;;;###autoload
(defun refheap-paste-region-private (begin end)
"Paste the current region to a private refheap entry."
(interactive "r")
(refheap-paste-region begin end t))

;;;###autoload
(defun refheap-paste-buffer (&optional private)
"Paste the current buffer to refheap. With prefix arg, paste privately."
(interactive "P")
(refheap-paste-region (point-min) (point-max) private))

;;;###autoload
(defun refheap-paste-buffer-private ()
"Paste the current buffer to a private refheap entry."
(interactive)
(refheap-paste-buffer t))

Expand Down

0 comments on commit aa21fe7

Please sign in to comment.