From e39f18a1a27c9d74c04141d01b176caff869b0cd Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 4 Jan 2015 17:02:43 -0200 Subject: "u" and "d" unconditionally apply votes instead of toggling. To remove votes, use C-u. --- sx-interaction.el | 26 ++++++++++++++------------ sx-question-list.el | 4 ++-- sx-question-mode.el | 4 ++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/sx-interaction.el b/sx-interaction.el index 80c8e5a..b85a8db 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 0a8e72c..a8b9fb3 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -319,8 +319,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) -- cgit v1.2.3