diff options
author | Sean Allred <code@seanallred.com> | 2015-01-04 15:33:54 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2015-01-04 15:33:54 -0500 |
commit | 3c05aae9915976e749591600f6e8f59cbccef1a4 (patch) | |
tree | 2e9b6b1f82247f1bff2871e6656c833bc4035ae6 /sx-interaction.el | |
parent | bc86289de1cccaca199639911439ec9a600f8f34 (diff) | |
parent | e39f18a1a27c9d74c04141d01b176caff869b0cd (diff) |
Merge pull request #194 from vermiculus/better-vote-logic
Better vote logic
Diffstat (limited to 'sx-interaction.el')
-rw-r--r-- | sx-interaction.el | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/sx-interaction.el b/sx-interaction.el index a72b14c..dc4398e 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -208,21 +208,23 @@ With the UNDO prefix argument, unfavorite the question instead." ;;; Voting -(defun sx-toggle-upvote (data) - "Apply or remove upvote from DATA. +(defun sx-upvote (data &optional undo) + "Upvote an object given by DATA. DATA can be a question, answer, or comment. Interactively, it is -guessed from context at point." - (interactive (list (sx--error-if-unread (sx--data-here)))) - (sx-assoc-let data - (sx-set-vote data "upvote" (null (eq .upvoted t))))) +guessed from context at point. +With UNDO prefix argument, remove upvote instead of applying it." + (interactive (list (sx--error-if-unread (sx--data-here)) + current-prefix-arg)) + (sx-set-vote data "upvote" (not undo))) -(defun sx-toggle-downvote (data) - "Apply or remove downvote from DATA. +(defun sx-downvote (data &optional undo) + "Downvote an object given by DATA. DATA can be a question or an answer. Interactively, it is guessed -from context at point." - (interactive (list (sx--error-if-unread (sx--data-here)))) - (sx-assoc-let data - (sx-set-vote data "downvote" (null (eq .downvoted t))))) +from context at point. +With UNDO prefix argument, remove downvote instead of applying it." + (interactive (list (sx--error-if-unread (sx--data-here)) + current-prefix-arg)) + (sx-set-vote data "downvote" (not undo))) (defun sx-set-vote (data type status) "Set the DATA's vote TYPE to STATUS. |