From db477cd54fa51f7604a8cba815848c7ea1b7ba37 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 12 Feb 2015 10:01:03 -0200 Subject: sx-question-list-order-by bound to O --- sx-question-list.el | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 7757503..1240c0f 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -367,6 +367,9 @@ into consideration. The same holds for `sx-question-list--order'. ([?\r] sx-display) )) +(sx--define-conditional-key sx-question-list-mode-map "O" #'sx-question-list-order-by + (and (boundp 'sx-question-list--order) sx-question-list--order)) + (defun sx-question-list-hide (data) "Hide question under point. Non-interactively, DATA is a question alist." -- cgit v1.2.3 From 67af840cb9a9eb18d5d7ddb16f75676ed47852fd Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 12 Feb 2015 10:13:24 -0200 Subject: Define sx-question-list--descending for inverting the order --- sx-question-list.el | 20 ++++++++++++++++---- sx-search.el | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'sx-question-list.el') 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) -- cgit v1.2.3 From 590b4c52574c7fcdeaf21b44ecea9cbb861ccfca Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 12 Feb 2015 10:30:45 -0200 Subject: Imrpove sx-question-list--order-methods --- sx-question-list.el | 5 ++--- sx-search.el | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index 77281d7..c66c04b 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -230,12 +230,11 @@ This is ignored if `sx-question-list--refresh-function' is set.") ": Quit") "Header-line used on the question list.") -(defconst sx-question-list--order-methods +(defvar sx-question-list--order-methods '(("Recent Activity" . activity) ("Creation Date" . creation) ("Most Voted" . votes) - ("Score" . votes) - ("Hot" . hot)) + ("Score" . votes)) "Alist of possible values to be passed to the `sort' keyword.") (make-variable-buffer-local 'sx-question-list--order-methods) diff --git a/sx-search.el b/sx-search.el index e6746a3..febeeef 100644 --- a/sx-search.el +++ b/sx-search.el @@ -64,8 +64,7 @@ KEYWORDS is passed to `sx-method-call'." (defconst sx-search--order-methods (cons '("Relevance" . relevance) - (cl-remove-if (lambda (x) (eq (cdr x) 'hot)) - (default-value 'sx-question-list--order-methods))) + (default-value 'sx-question-list--order-methods)) "Alist of possible values to be passed to the `sort' keyword.") (defcustom sx-search-default-order 'activity -- cgit v1.2.3 From b61a296ed58c0cb2fda1dd610ae739c82d872ed8 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 12 Feb 2015 10:52:26 -0200 Subject: Define sx-question-list--make-pager helper function --- sx-question-list.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sx-question-list.el') diff --git a/sx-question-list.el b/sx-question-list.el index c66c04b..5812ff2 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -247,6 +247,20 @@ is used." (mapcar #'car sx-question-list--order-methods)))) (cdr-safe (assoc-string order sx-question-list--order-methods)))) +(defun sx-question-list--make-pager (method &optional submethod) + "Return a function suitable for use as a question list pager. +Meant to be used as `sx-question-list--next-page-function'." + (lambda (page) + (sx-method-call method + :keywords `((page . ,page) + ,@(when sx-question-list--order + `((order . ,(if sx-question-list--descending 'desc 'asc)) + (sort . ,sx-question-list--order)))) + :site sx-question-list--site + :auth t + :submethod submethod + :filter sx-browse-filter))) + ;;; Mode Definition (define-derived-mode sx-question-list-mode -- cgit v1.2.3