diff options
-rw-r--r-- | sx-interaction.el | 18 | ||||
-rw-r--r-- | sx-question-list.el | 1 | ||||
-rw-r--r-- | sx-question-mode.el | 1 | ||||
-rw-r--r-- | sx-switchto.el | 1 | ||||
-rw-r--r-- | sx-tab.el | 18 |
5 files changed, 39 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. diff --git a/sx-question-list.el b/sx-question-list.el index 9e08787..0a8e72c 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -323,6 +323,7 @@ into consideration. ("d" sx-toggle-downvote) ("h" sx-question-list-hide) ("m" sx-question-list-mark-read) + ("*" sx-favorite) ([?\r] sx-display) )) diff --git a/sx-question-mode.el b/sx-question-mode.el index c618c96..62bf241 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -233,6 +233,7 @@ Letters do not insert themselves; instead, they are commands. ("e" sx-edit) ("S" sx-search) ("s" sx-switchto-map) + ("*" sx-favorite) (,(kbd "S-SPC") scroll-down-command) ([backspace] scroll-down-command) ([tab] forward-button) diff --git a/sx-switchto.el b/sx-switchto.el index 1a2c3a0..76804e4 100644 --- a/sx-switchto.el +++ b/sx-switchto.el @@ -47,6 +47,7 @@ ("U" sx-tab-unanswered-my-tags) ("v" sx-tab-topvoted) ("w" sx-tab-week) + ("*" sx-tab-starred) )) @@ -232,6 +232,24 @@ If SITE is nil, use `sx-default-site'." nil t) +;;; Starred +(sx-tab--define "Starred" + (lambda (page) + (sx-method-call 'me + :page page + :site sx-question-list--site + :auth t + :submethod 'favorites + :filter sx-browse-filter))) +;;;###autoload +(autoload 'sx-tab-featured + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + + ;;; Inter-modes navigation (defun sx-tab-meta-or-main () "Switch to the meta version of a main site, or vice-versa. |