diff options
-rw-r--r-- | sx-interaction.el | 26 | ||||
-rw-r--r-- | sx-question-list.el | 4 | ||||
-rw-r--r-- | sx-question-mode.el | 4 |
3 files changed, 18 insertions, 16 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. diff --git a/sx-question-list.el b/sx-question-list.el index 40b72b9..3354052 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -349,8 +349,8 @@ into consideration. ("S" sx-search) ("s" sx-switchto-map) ("v" sx-visit-externally) - ("u" sx-toggle-upvote) - ("d" sx-toggle-downvote) + ("u" sx-upvote) + ("d" sx-downvote) ("h" sx-question-list-hide) ("m" sx-question-list-mark-read) ("*" sx-favorite) diff --git a/sx-question-mode.el b/sx-question-mode.el index 62bf241..b13caf3 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -225,8 +225,8 @@ Letters do not insert themselves; instead, they are commands. ("g" sx-question-mode-refresh) ("c" sx-comment) ("v" sx-visit-externally) - ("u" sx-toggle-upvote) - ("d" sx-toggle-downvote) + ("u" sx-upvote) + ("d" sx-downvote) ("q" quit-window) (" " scroll-up-command) ("a" sx-answer) |