aboutsummaryrefslogtreecommitdiff
path: root/sx-question-mode.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-02-12 15:00:05 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-02-12 15:01:59 -0200
commitfe7e31a55cdd9c25f3d0c1fba088d5499a887af9 (patch)
tree451deb607fd307eeef8a3e670d7c8348ea123ae4 /sx-question-mode.el
parent85109b7dd2ffb896151ccef2c014c7d9ea33e682 (diff)
Sort answers with O
Diffstat (limited to 'sx-question-mode.el')
-rw-r--r--sx-question-mode.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el
index 6125416..846ad7f 100644
--- a/sx-question-mode.el
+++ b/sx-question-mode.el
@@ -214,6 +214,7 @@ Letters do not insert themselves; instead, they are commands.
("v" sx-visit-externally)
("u" sx-upvote)
("d" sx-downvote)
+ ("O" sx-question-mode-order-by)
("q" quit-window)
(" " scroll-up-command)
("a" sx-answer)
@@ -256,6 +257,18 @@ query the api."
(unless (derived-mode-p 'sx-question-mode)
(error "Not in `sx-question-mode'")))
+(defun sx-question-mode-order-by (sort)
+ "Order answers in the current buffer by the method SORT.
+Sets `sx-question-list--order' and then calls
+`sx-question-list-refresh' with `redisplay'."
+ (interactive
+ (list (let ((order (sx-completing-read "Order answers by: "
+ (mapcar #'car sx-question-mode--sort-methods))))
+ (cdr-safe (assoc-string order sx-question-mode--sort-methods)))))
+ (when (and sort (functionp sort))
+ (setq sx-question-mode-answer-sort-function sort)
+ (sx-question-mode-refresh 'no-update)))
+
(provide 'sx-question-mode)
;;; sx-question-mode.el ends here