From 0ddc0693f364ed547291bda199728a2dc8495c5f Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 12 Feb 2015 10:07:18 -0200 Subject: Make sx-search-default-order a defcustom --- sx-search.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sx-search.el') diff --git a/sx-search.el b/sx-search.el index 55964b9..235d5f7 100644 --- a/sx-search.el +++ b/sx-search.el @@ -68,9 +68,14 @@ KEYWORDS is passed to `sx-method-call'." (default-value 'sx-question-list--order-methods))) "Alist of possible values to be passed to the `sort' keyword.") -(defvar sx-search-default-order 'activity +(defcustom sx-search-default-order 'activity "Default ordering method used on new searches. -Possible values are the cdrs of `sx-search--order-methods'.") +Possible values are the cdrs of `sx-search--order-methods'." + :type (cons 'choice + (mapcar (lambda (c) `(const :tag ,(car c) ,(cdr c))) + (cl-remove-duplicates + sx-search--order-methods + :key #'cdr)))) ;;;###autoload -- 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-search.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-search.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 a9509bb93d978fd35b0dc0ea07102c59b30de3a4 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 12 Feb 2015 14:18:01 -0200 Subject: compiler warnings --- sx-search.el | 3 ++- sx-tab.el | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'sx-search.el') diff --git a/sx-search.el b/sx-search.el index febeeef..4b0a0b2 100644 --- a/sx-search.el +++ b/sx-search.el @@ -74,7 +74,8 @@ Possible values are the cdrs of `sx-search--order-methods'." (mapcar (lambda (c) `(const :tag ,(car c) ,(cdr c))) (cl-remove-duplicates sx-search--order-methods - :key #'cdr)))) + :key #'cdr))) + :group 'sx-question-list) ;;;###autoload diff --git a/sx-tab.el b/sx-tab.el index 40cead8..a3c6107 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -67,7 +67,8 @@ Possible values are the cdrs of `sx-tab--order-methods'." (mapcar (lambda (c) `(const :tag ,(car c) ,(cdr c))) (cl-remove-duplicates sx-tab--order-methods - :key #'cdr)))) + :key #'cdr))) + :group 'sx-question-list) (defconst sx-tab--docstring-format "Display a list of %s questions for SITE. -- cgit v1.2.3