aboutsummaryrefslogtreecommitdiff
path: root/sx-question.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2014-12-30 17:47:42 -0500
committerSean Allred <code@seanallred.com>2014-12-30 17:47:42 -0500
commitb20f56b0c59b1e99fac745e408369d01de0f0bb5 (patch)
treefa30f72a8fbe94e5b319c9163b1d70d8768ad65e /sx-question.el
parentc215e84da4dcfa63c7a0c05996cc131e031efe64 (diff)
parent1267f300c850173e74dda0b7f704261b4a25b85c (diff)
Merge branch 'master' into issue-151--dot-variables
Conflicts: sx.el
Diffstat (limited to 'sx-question.el')
-rw-r--r--sx-question.el29
1 files changed, 21 insertions, 8 deletions
diff --git a/sx-question.el b/sx-question.el
index 9fb31fc..03ebb4b 100644
--- a/sx-question.el
+++ b/sx-question.el
@@ -54,6 +54,20 @@ If QUESTION-ID doesn't exist on SITE, raise an error."
(error "Couldn't find question %S in %S"
question-id site))))
+(defun sx-question-get-from-answer (site answer-id)
+ "Get question from SITE to which ANSWER-ID belongs.
+If ANSWER-ID doesn't exist on SITE, raise an error."
+ (let ((res (sx-method-call 'answers
+ :id answer-id
+ :site site
+ :submethod 'questions
+ :auth t
+ :filter sx-browse-filter)))
+ (if (vectorp res)
+ (elt res 0)
+ (error "Couldn't find answer %S in %S"
+ answer-id site))))
+
;;; Question Properties
@@ -145,14 +159,13 @@ If no cache exists for it, initialize one with SITE."
(let ((site-cell (assoc .site sx-question--user-hidden-list)))
;; 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?
+ (if (null site-cell)
+ ;; First question from this site.
+ (push (list .site .question_id) sx-question--user-hidden-list)
+ ;; Not first question and question wasn't present.
+ ;; Add it in, but make sure it's sorted (just in case we
+ ;; decide to rely on it later).
+ (sx-sorted-insert-skip-first .question_id site-cell >))
;; Save the results.
(sx-cache-set 'hidden-questions sx-question--user-hidden-list)))))