diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-02-12 10:13:24 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-02-12 10:13:24 -0200 |
commit | 67af840cb9a9eb18d5d7ddb16f75676ed47852fd (patch) | |
tree | 35659f94aa009dbea3904c4126d38adcb3159971 | |
parent | 0ddc0693f364ed547291bda199728a2dc8495c5f (diff) |
Define sx-question-list--descending for inverting the order
-rw-r--r-- | sx-question-list.el | 20 | ||||
-rw-r--r-- | sx-search.el | 1 |
2 files changed, 17 insertions, 4 deletions
diff --git a/sx-question-list.el b/sx-question-list.el index 1240c0f..77281d7 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -446,7 +446,14 @@ Non-interactively, DATA is a question alist." (make-variable-buffer-local 'sx-question-list--site) (defvar sx-question-list--order nil - "Order being displayed in the *question-list* buffer.") + "Order being displayed in the *question-list* buffer. +This is also affected by `sx-question-list--descending'.") +(make-variable-buffer-local 'sx-question-list--order) + +(defvar sx-question-list--descending t + "In which direction should `sx-question-list--order' be sorted. +If non-nil (default), descending. +If nil, ascending.") (make-variable-buffer-local 'sx-question-list--order) (defun sx-question-list-refresh (&optional redisplay no-update) @@ -621,17 +628,22 @@ Sets `sx-question-list--site' and then call (setq sx-question-list--site site) (sx-question-list-refresh 'redisplay))) -(defun sx-question-list-order-by (sort) +(defun sx-question-list-order-by (sort &optional ascend) "Order questions in the current list by the method SORT. Sets `sx-question-list--order' and then calls -`sx-question-list-refresh' with `redisplay'." +`sx-question-list-refresh' with `redisplay'. + +With a prefix argument or a non-nil ASCEND, invert the sorting +order." (interactive (list (when sx-question-list--order - (sx-question-list--interactive-order-prompt)))) + (sx-question-list--interactive-order-prompt)) + current-prefix-arg)) (unless sx-question-list--order (sx-user-error "This list can't be reordered")) (when (and sort (symbolp sort)) (setq sx-question-list--order sort) + (setq sx-question-list--descending (not ascend)) (sx-question-list-refresh 'redisplay))) (provide 'sx-question-list) diff --git a/sx-search.el b/sx-search.el index 235d5f7..e6746a3 100644 --- a/sx-search.el +++ b/sx-search.el @@ -115,6 +115,7 @@ prefix argument, the user is asked for everything." (sx-search-get-questions sx-question-list--site page query tags excluded-tags + (cons 'order (if sx-question-list--descending 'desc 'asc)) (cons 'sort sx-question-list--order)))) (setq sx-question-list--site site) (setq sx-question-list--order sx-search-default-order) |