aboutsummaryrefslogtreecommitdiff
path: root/sx-question-print.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-01-16 13:30:58 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-01-16 13:30:58 -0200
commit006c85d3a241e20b6b03ab4499dbc467f8431ddd (patch)
tree4799ce852da6e4308080669aa577906ef56f8bbc /sx-question-print.el
parentbed5191a0137cb115656baf6ae3535b2a646d0b2 (diff)
parent389e433953bba4003b102748dbbf5f8a9b421a51 (diff)
Merge branch 'master' into tag-buttons
Conflicts: sx-question.el
Diffstat (limited to 'sx-question-print.el')
-rw-r--r--sx-question-print.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index d7c2a20..b53b86a 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -148,6 +148,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
@@ -162,11 +171,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-mode-answer-sort-function)))
(insert "\n\n ")
(insert-text-button "Write an Answer" :type 'sx-button-answer)
;; Go up