diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-03 13:36:42 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-03 13:36:42 +0000 |
commit | b09dd861782b5926d8ac29459c2c3366bee2e70a (patch) | |
tree | 5da064435e1607aacb00b17a168ae72a816f1110 /stack-question-list.el | |
parent | e298e214bfca97456e16b5f8bf6766e9130a4888 (diff) |
Question list sort-by-date button.
Diffstat (limited to 'stack-question-list.el')
-rw-r--r-- | stack-question-list.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/stack-question-list.el b/stack-question-list.el index dab5504..bc8ad90 100644 --- a/stack-question-list.el +++ b/stack-question-list.el @@ -102,12 +102,23 @@ Letters do not insert themselves; instead, they are commands. (" A" 3 t :right-align t) ("Title" 0 stack-question-list--date-sort)]) (setq tabulated-list-padding 1) + ;; Sorting by title actually sorts by date. It's what we want, but + ;; it's not terribly intuitive. + (setq tabulated-list-sort-key '("Title" . nil)) (add-hook 'tabulated-list-revert-hook #'stack-question-list-refresh nil t) (add-hook 'tabulated-list-revert-hook #'stack-question-list--update-mode-line nil t) (tabulated-list-init-header)) +(defvar stack-question-list-date-sort-method 'last_activity_date + "Parameter which controls date sorting.") + +(defun stack-question-list--date-sort (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))))) + (mapc (lambda (x) (define-key stack-question-list-mode-map (car x) (cadr x))) |