From e1a57f49379fa9345b662a721941edd7371db60b Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 4 Jan 2015 16:20:00 -0200 Subject: Implement listing starred questions. Fix #14 --- sx-switchto.el | 1 + sx-tab.el | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) 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) )) diff --git a/sx-tab.el b/sx-tab.el index 6a2552f..f97119a 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -231,6 +231,24 @@ If SITE is nil, use `sx-default-site'." (file-name-directory load-file-name))) 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 () -- cgit v1.2.3 From bfb0c17ee4bb63099f18f031d0ddeb9d62f18ded Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 4 Jan 2015 16:51:17 -0200 Subject: Implement favoriting --- sx-interaction.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sx-interaction.el b/sx-interaction.el index 3877035..17c23bd 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -188,6 +188,24 @@ If WINDOW nil, the window is decided by (select-window window) (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)) + 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) -- cgit v1.2.3 From 6bb1f537a130900b44d8170e61dbb946303af9b5 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 4 Jan 2015 16:52:24 -0200 Subject: Bind favoriting to "*" --- sx-question-list.el | 1 + sx-question-mode.el | 1 + 2 files changed, 2 insertions(+) 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) -- cgit v1.2.3 From 2f35ff59ca5c28129d9a3ca3546a8b41cdf1ec1d Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 4 Jan 2015 16:52:57 -0200 Subject: Only favorite questions --- sx-interaction.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sx-interaction.el b/sx-interaction.el index 17c23bd..80c8e5a 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -194,7 +194,7 @@ If WINDOW nil, the window is decided by "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)) + (interactive (list (sx--error-if-unread (sx--data-here 'question)) current-prefix-arg)) (sx-assoc-let data (sx-method-call 'questions -- cgit v1.2.3