aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-11-04 09:35:28 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-11-04 09:35:58 +0000
commit33383d630ce43045cd94c2b515df7567063fc885 (patch)
tree53d9e1ead073bfda15fccaebfd2840bf8a0731ca
parente4ef9753ba024dbc2c96e17a66cbfc1cb871c6cc (diff)
Rename -date-sort to -date-more-recent-p
-rw-r--r--stack-question-list.el9
-rw-r--r--stack-question.el6
2 files changed, 11 insertions, 4 deletions
diff --git a/stack-question-list.el b/stack-question-list.el
index efacb7f..2e354d3 100644
--- a/stack-question-list.el
+++ b/stack-question-list.el
@@ -100,7 +100,7 @@ Letters do not insert themselves; instead, they are commands.
(setq tabulated-list-format
[(" V" 3 t :right-align t)
(" A" 3 t :right-align t)
- ("Title" 0 stack-question-list--date-sort)])
+ ("Title" 0 stack-question-list--date-more-recent-p)])
(setq tabulated-list-padding 1)
;; Sorting by title actually sorts by date. It's what we want, but
;; it's not terribly intuitive.
@@ -119,10 +119,11 @@ Letters do not insert themselves; instead, they are commands.
:group 'stack-question-list)
-(defun stack-question-list--date-sort (x y)
+(defun stack-question-list--date-more-recent-p (x y)
"Non-nil if tabulated-entry X is newer than Y."
- (> (cdr (assoc stack-question-list-date-sort-method (car x)))
- (cdr (assoc stack-question-list-date-sort-method (car y)))))
+ (stack-question-list--<
+ stack-question-list-date-sort-method
+ (car x) (car y) #'>))
(mapc
(lambda (x) (define-key stack-question-list-mode-map
diff --git a/stack-question.el b/stack-question.el
index 66a4ea3..a7a74df 100644
--- a/stack-question.el
+++ b/stack-question.el
@@ -58,6 +58,12 @@
;; @TODO:
(cl-evenp (random)))
+(defun stack-question--< (property x y &optional pred)
+ "Non-nil if PROPERTY attribute of question X is less than that of Y.
+With optional argument predicate, use it instead of `<'."
+ (funcall (or pred #'<)
+ (cdr (assoc property x))
+ (cdr (assoc property y))))
;;; Displaying a question
(defvar stack-question--window nil