diff options
-rw-r--r-- | stack-question-list.el | 9 | ||||
-rw-r--r-- | stack-question.el | 6 |
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 |