aboutsummaryrefslogtreecommitdiff
path: root/sx-question.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2015-01-16 09:28:29 -0500
committerSean Allred <code@seanallred.com>2015-01-16 09:28:29 -0500
commit8fb868bef68337bf2b5539fbc3be2ceb42a4825a (patch)
tree1eaeea3e78200995ad746251a83624b81a99ec35 /sx-question.el
parent389e433953bba4003b102748dbbf5f8a9b421a51 (diff)
parent402bac079cd32d1260ea839667db639f94f4254e (diff)
Merge pull request #231 from vermiculus/malabarba/fix-display-from-inbox
Fix sx-display from inbox. Now RET should work on any inbox item. Much more usable!
Diffstat (limited to 'sx-question.el')
-rw-r--r--sx-question.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/sx-question.el b/sx-question.el
index 1e3a02c..1df4900 100644
--- a/sx-question.el
+++ b/sx-question.el
@@ -72,6 +72,26 @@ If ANSWER-ID doesn't exist on SITE, raise an error."
(error "Couldn't find answer %S in %S"
answer-id site))))
+(defun sx-question-get-from-comment (site comment-id)
+ "Get question from SITE to which COMMENT-ID belongs.
+If COMMENT-ID doesn't exist on SITE, raise an error.
+
+Note this requires two API requests. One for the comment and one
+for the post."
+ (let ((res (sx-method-call 'comments
+ :id comment-id
+ :site site
+ :auth t
+ :filter sx-browse-filter)))
+ (unless (vectorp res)
+ (error "Couldn't find comment %S in %S" comment-id site))
+ (sx-assoc-let (elt res 0)
+ (funcall (if (string= .post_type "answer")
+ #'sx-question-get-from-answer
+ #'sx-question-get-question)
+ .site_par
+ .post_id))))
+
;;; Question Properties