From 925b4ef8b503b22481e624905fa6e3af8d6d4077 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 17 Dec 2014 15:35:26 -0200 Subject: Implent getting question given answer id --- sx-question.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sx-question.el') diff --git a/sx-question.el b/sx-question.el index 9fb31fc..801384a 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 -- cgit v1.2.3 From 1ab0df0975e67a626c95d89120ae0c0e2fdcf9ff Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 27 Dec 2014 19:33:26 -0200 Subject: Fix `sx-question--mark-hidden', which was just plain wrong. --- sx-question.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'sx-question.el') diff --git a/sx-question.el b/sx-question.el index 801384a..03ebb4b 100644 --- a/sx-question.el +++ b/sx-question.el @@ -159,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))))) -- cgit v1.2.3