diff options
author | Sean Allred <code@seanallred.com> | 2015-01-16 00:54:32 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2015-01-16 00:54:32 -0500 |
commit | fe140f7891257890687ec6e3243d66f1aa95fc65 (patch) | |
tree | cee86917c73725c7f8d3a33e0f4cf85ae76a1efb /sx-question-print.el | |
parent | 22f86c35499f994f0eb7532b8eb27b0d990d889d (diff) | |
parent | 6c4e7c6b95e8bd7d83e5d0f868d9fb3a70c7a974 (diff) |
Merge pull request #228 from vermiculus/vermiculus/sort-answers
Customizable sorting; Fix #226. Generalization of #225.
Diffstat (limited to 'sx-question-print.el')
-rw-r--r-- | sx-question-print.el | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sx-question-print.el b/sx-question-print.el index 9a51efb..a25ff52 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -153,6 +153,15 @@ replaced with the comment." :type 'boolean :group 'sx-question-mode) +(defcustom sx-question-mode-answer-sort-function + #'sx-answer-higher-score-p + "Function used to sort answers in the question buffer." + :type '(choice + (const :tag "Higher-scoring first" sx-answer-higher-score-p) + (const :tag "Newer first" sx-answer-newer-p) + (const :tag "More active first" sx-answer-more-active-p)) + :group 'sx-question-mode) + ;;; Functions ;;;; Printing the general structure @@ -167,11 +176,7 @@ QUESTION must be a data structure returned by `json-read'." (sx-question-mode--print-section question) (sx-assoc-let question (mapc #'sx-question-mode--print-section - (cl-sort .answers - ;; Highest-voted first. @TODO: custom sorting - (lambda (a b) - (> (cdr (assoc 'score a)) - (cdr (assoc 'score b))))))) + (cl-sort .answers sx-question-list--sort-answer-function))) (insert "\n\n ") (insert-text-button "Write an Answer" :type 'sx-button-answer) ;; Go up |