aboutsummaryrefslogtreecommitdiff
path: root/sx-interaction.el
diff options
context:
space:
mode:
Diffstat (limited to 'sx-interaction.el')
-rw-r--r--sx-interaction.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/sx-interaction.el b/sx-interaction.el
index 3877035..80c8e5a 100644
--- a/sx-interaction.el
+++ b/sx-interaction.el
@@ -189,6 +189,24 @@ If WINDOW nil, the window is decided by
(switch-to-buffer sx-question-mode--buffer))))
+;;; Favoriting
+(defun sx-favorite (data &optional undo)
+ "Favorite question given by DATA.
+Interactively, it is guessed from context at point.
+With the UNDO prefix argument, unfavorite the question instead."
+ (interactive (list (sx--error-if-unread (sx--data-here 'question))
+ current-prefix-arg))
+ (sx-assoc-let data
+ (sx-method-call 'questions
+ :id .question_id
+ :submethod (if undo 'favorite/undo 'favorite)
+ :auth 'warn
+ :site .site_par
+ :url-method "POST"
+ :filter sx-browse-filter)))
+(defalias 'sx-star #'sx-favorite)
+
+
;;; Voting
(defun sx-toggle-upvote (data)
"Apply or remove upvote from DATA.