aboutsummaryrefslogtreecommitdiff
path: root/sx-search.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2015-02-11 21:56:46 -0600
committerSean Allred <code@seanallred.com>2015-02-11 21:56:46 -0600
commit78cc17295c255dc188c96ea7a401ee9a915b9269 (patch)
tree698c387304126f88c6223b4b27d9eab42b8c28cc /sx-search.el
parent384855876c6fcb0048551ceed335805babc19b1f (diff)
parent2c2becfa47d0b13d633f85a7c18f4d40193dc454 (diff)
Merge pull request #256 from vermiculus/issue-254--sorting-options
Implement sorting options Fix #254.
Diffstat (limited to 'sx-search.el')
-rw-r--r--sx-search.el20
1 files changed, 17 insertions, 3 deletions
diff --git a/sx-search.el b/sx-search.el
index cd2f4e7..55964b9 100644
--- a/sx-search.el
+++ b/sx-search.el
@@ -39,7 +39,9 @@
;;; Basic function
-(defun sx-search-get-questions (site page query &optional tags excluded-tags keywords)
+(defun sx-search-get-questions (site page query
+ &optional tags excluded-tags
+ &rest keywords)
"Like `sx-question-get-questions', but restrict results by a search.
Perform search on SITE. PAGE is an integer indicating which page
@@ -52,7 +54,6 @@ fail. EXCLUDED-TAGS is only is used if TAGS is also provided.
KEYWORDS is passed to `sx-method-call'."
(sx-method-call 'search
:keywords `((page . ,page)
- (sort . activity)
(intitle . ,query)
(tagged . ,tags)
(nottagged . ,excluded-tags)
@@ -61,6 +62,16 @@ KEYWORDS is passed to `sx-method-call'."
:auth t
:filter sx-browse-filter))
+(defconst sx-search--order-methods
+ (cons '("Relevance" . relevance)
+ (cl-remove-if (lambda (x) (eq (cdr x) 'hot))
+ (default-value 'sx-question-list--order-methods)))
+ "Alist of possible values to be passed to the `sort' keyword.")
+
+(defvar sx-search-default-order 'activity
+ "Default ordering method used on new searches.
+Possible values are the cdrs of `sx-search--order-methods'.")
+
;;;###autoload
(defun sx-search (site query &optional tags excluded-tags)
@@ -98,8 +109,11 @@ prefix argument, the user is asked for everything."
(lambda (page)
(sx-search-get-questions
sx-question-list--site page
- query tags excluded-tags)))
+ query tags excluded-tags
+ (cons 'sort sx-question-list--order))))
(setq sx-question-list--site site)
+ (setq sx-question-list--order sx-search-default-order)
+ (setq sx-question-list--order-methods sx-search--order-methods)
(sx-question-list-refresh 'redisplay)
(switch-to-buffer (current-buffer))))