aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sx-method.el3
-rw-r--r--sx-question.el29
-rw-r--r--sx-request.el16
-rw-r--r--sx-tab.el7
4 files changed, 29 insertions, 26 deletions
diff --git a/sx-method.el b/sx-method.el
index 1b20cbf..83455b8 100644
--- a/sx-method.el
+++ b/sx-method.el
@@ -82,7 +82,8 @@ Return the entire response as a complex alist."
(prog1
(format "?site=%s" site)
(setq site nil)))))
- (call #'sx-request-make))
+ (call #'sx-request-make)
+ parameters)
(lwarn "sx-call-method" :debug "A: %S T: %S. M: %S,%s. F: %S" (equal 'warn auth)
access-token method-auth full-method filter-auth)
(unless access-token
diff --git a/sx-question.el b/sx-question.el
index 01ba030..f80a9bd 100644
--- a/sx-question.el
+++ b/sx-question.el
@@ -134,20 +134,21 @@ If no cache exists for it, initialize one with SITE."
(defun sx-question--mark-hidden (question)
"Mark QUESTION as being hidden."
- (let ((site-cell (assoc .site sx-question--user-hidden-list))
- cell)
- ;; If question already hidden, do nothing.
- (unless (memq .question_id site-cell)
- ;; First question from this site.
- (push (list .site .question_id) sx-question--user-hidden-list)
- ;; Question wasn't present.
- ;; Add it in, but make sure it's sorted (just in case we need
- ;; it later).
- (sx-sorted-insert-skip-first .question_id site-cell >)
- ;; This causes a small lag on `j' and `k' as the list gets large.
- ;; Should we do this on a timer?
- ;; Save the results.
- (sx-cache-set 'hidden-questions sx-question--user-hidden-list))))
+ (sx-assoc-let question
+ (let ((site-cell (assoc .site sx-question--user-hidden-list))
+ cell)
+ ;; If question already hidden, do nothing.
+ (unless (memq .question_id site-cell)
+ ;; First question from this site.
+ (push (list .site .question_id) sx-question--user-hidden-list)
+ ;; Question wasn't present.
+ ;; Add it in, but make sure it's sorted (just in case we need
+ ;; it later).
+ (sx-sorted-insert-skip-first .question_id site-cell >)
+ ;; This causes a small lag on `j' and `k' as the list gets large.
+ ;; Should we do this on a timer?
+ ;; Save the results.
+ (sx-cache-set 'hidden-questions sx-question--user-hidden-list)))))
;;;; Other data
diff --git a/sx-request.el b/sx-request.el
index a98af5a..6be363d 100644
--- a/sx-request.el
+++ b/sx-request.el
@@ -91,9 +91,8 @@ number of requests left every time it finishes a call."
;;; Making Requests
-(defun sx-request-make
- (method &optional args request-method)
- "Make a request to the API, executing METHOD with ARGS.
+(defun sx-request-make (method &optional args request-method)
+ "Make a request to the API, executing METHOD with ARGS.
You should almost certainly be using `sx-method-call' instead of
this function. REQUEST-METHOD is one of `GET' (default) or `POST'.
@@ -116,8 +115,7 @@ then read with `json-read-from-string'.
the main content of the response is returned."
(let* ((url-automatic-caching t)
(url-inhibit-uncompression t)
- (url-request-data (sx-request--build-keyword-arguments args
- nil))
+ (url-request-data (sx-request--build-keyword-arguments args nil))
(request-url (concat sx-request-api-root method))
(url-request-method request-method)
(url-request-extra-headers
@@ -168,15 +166,11 @@ Currently returns nil."
;;; Support Functions
-
-(defun sx-request--build-keyword-arguments (alist &optional
- kv-sep need-auth)
+(defun sx-request--build-keyword-arguments (alist &optional kv-sep)
"Format ALIST as a key-value list joined with KV-SEP.
If authentication is needed, include it also or error if it is
not available.
-If NEED-AUTH is non-nil, authentication is required.
-
Build a \"key=value&key=value&...\"-style string with the elements
of ALIST. If any value in the alist is nil, that pair will not
be included in the return. If you wish to pass a notion of
@@ -185,7 +179,7 @@ false, use the symbol `false'. Each element is processed with
;; Add API key to list of arguments, this allows for increased quota
;; automatically.
(let ((api-key (cons "key" sx-request-api-key))
- (auth (car (sx-cache-get 'auth))))
+ (auth (car (sx-cache-get 'auth))))
(push api-key alist)
(when auth
(push auth alist))
diff --git a/sx-tab.el b/sx-tab.el
index 154a90f..7ccbf18 100644
--- a/sx-tab.el
+++ b/sx-tab.el
@@ -97,6 +97,13 @@ If SITE is nil, use `sx-tab-default-site'."
(lambda (page)
(sx-question-get-questions
sx-question-list--site page)))
+;;;###autoload
+(autoload 'sx-tab-frontpage
+ (expand-file-name
+ "sx-tab"
+ (when load-file-name
+ (file-name-directory load-file-name)))
+ nil t)
(provide 'sx-tab)
;;; sx-tab.el ends here