aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-11-06 22:41:32 +0100
committerGravatar Tom Willemse2013-11-06 22:41:32 +0100
commit0f6c2b3228077b001872c423d5888b0d355d5a25 (patch)
treeb2062c763b80fd27cbc9ac0aa08a2c36b2a1b0f6
parent45610d700091a4d77987369ce2bb9063e36afeca (diff)
downloadhypo-emacs-0f6c2b3228077b001872c423d5888b0d355d5a25.tar.gz
hypo-emacs-0f6c2b3228077b001872c423d5888b0d355d5a25.zip
Add hypo-delete-last
This commit changes the workings of the `hypo--collect-url' function to store the hash of the last uploaded file or snippet. This is then used by `hypo-delete-last' to delete that same url.
-rw-r--r--NEWS5
-rw-r--r--hypo.el16
2 files changed, 21 insertions, 0 deletions
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..4b159a7
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,5 @@
+# -*- mode: org; -*-
+* v0.2.0
+
+ - Add =hypo-delete-last=, which deletes the last posted item of the
+ current session.
diff --git a/hypo.el b/hypo.el
index da7c773..3a24752 100644
--- a/hypo.el
+++ b/hypo.el
@@ -31,10 +31,17 @@
(autoload 'beginning-of-sexp "thingatpt")
(autoload 'end-of-sexp "thingatpt")
+(defvar hypo--last-post nil
+ "The hash of the last snippet sent to hypo.
+
+Will be used for certain commands that operate on the last thing
+sent to hypo.")
+
(defun hypo--collect-url ()
"Collect the returned url."
(let* ((start (search-forward "\n\n"))
(end (1- (search-forward "\n"))))
+ (setq hypo--last-post (buffer-substring-no-properties (- end 7) end))
(copy-region-as-kill start end)))
(defun hypo--collect-and-kill (status)
@@ -96,5 +103,14 @@ STATUS is ignored."
(progn (end-of-sexp) (point))
filename)))
+(defun hypo-delete-last ()
+ "Delete the last thing sent to hypo."
+ (interactive)
+ (unless hypo--last-post (error "Nothing posted this session"))
+ (let ((url-request-method "DELETE"))
+ (url-retrieve (concat "https://ryuslash.org/hypo/" hypo--last-post)
+ #'ignore)
+ (setq hypo--last-post nil)))
+
(provide 'hypo)
;;; hypo.el ends here