aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2015-01-15 00:22:33 -0500
committerSean Allred <code@seanallred.com>2015-01-15 00:22:33 -0500
commitfe912f7a4871f7beedeafe5f29feb57ca65ecc47 (patch)
treec159b8e5f26b7f10297109ec81230a0f30dead42
parent9b093f7a7a02e31dc6985619f5277ee945f6f90d (diff)
Abstract sorting function into customizable option
-rw-r--r--sx-question-print.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index 210f99a..c19b0c3 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -166,6 +166,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 "Older first" sx-answer-older-p)
+ (const :tag "More active first" sx-answer-more-active-p))
+ :group 'sx-question-mode)
+
;;; Functions
;;;; Printing the general structure
@@ -180,7 +189,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 #'sx-answer-higher-score-p)))
+ (cl-sort .answers sx-question-list--sort-answer-function)))
(insert "\n\n ")
(insert-text-button "Write an Answer" :type 'sx-button-answer)
;; Go up