aboutsummaryrefslogtreecommitdiff
path: root/sx-filter.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-01-04 17:11:07 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-01-04 17:11:07 -0200
commit917e70936ef82cfd2a34b541348ebd485049f46a (patch)
tree0fe936bfa609ea19c454cdcb4d1c2349d5c0c746 /sx-filter.el
parent89834aa61adf1fff29379c82ab96629f0b2960d0 (diff)
parent01df71244d3fe5412e2420127dcd2282d9fa39c7 (diff)
Merge pull request #192 from vermiculus/filter-macro
Filter macro
Diffstat (limited to 'sx-filter.el')
-rw-r--r--sx-filter.el86
1 files changed, 57 insertions, 29 deletions
diff --git a/sx-filter.el b/sx-filter.el
index c67d05b..d484f43 100644
--- a/sx-filter.el
+++ b/sx-filter.el
@@ -42,38 +42,26 @@ Structure:
;;; Creation
-
(defmacro sx-filter-from-nil (included)
"Creates a filter data structure with INCLUDED fields.
All wrapper fields are included by default."
- ;; @OTODO: it would be neat to have syntax like
- ;;
- ;; (field-a
- ;; field-b
- ;; (object-a subfield)
- ;; field-c
- ;; (object-b subfield-a subfield-b))
- ;;
- ;; expand into
- ;;
- ;; (field-a
- ;; field-b
- ;; object-a.subfield
- ;; field-c
- ;; object-b.subfield-a object-b.subfield-b)
- `(quote ((,@included
- .backoff
- .error_id
- .error_message
- .error_name
- .has_more
- .items
- .page
- .page_size
- .quota_max
- .quota_remaining
- .type)
- nil none)))
+ `(quote
+ ((,@(sx--tree-expand
+ (lambda (path)
+ (intern (mapconcat #'symbol-name path ".")))
+ included)
+ .backoff
+ .error_id
+ .error_message
+ .error_name
+ .has_more
+ .items
+ .page
+ .page_size
+ .quota_max
+ .quota_remaining
+ .total)
+ nil none)))
;;; @TODO allow BASE to be a precompiled filter name
(defun sx-filter-compile (&optional include exclude base)
@@ -113,6 +101,46 @@ return the compiled filter."
(sx-cache-set 'filter sx--filter-alist)
filter))))
+
+;;; Browsing filter
+(defvar sx-browse-filter
+ (sx-filter-from-nil
+ ((question body_markdown
+ comments
+ answers
+ last_editor
+ last_activity_date
+ accepted_answer_id
+ link
+ upvoted
+ downvoted
+ question_id
+ share_link)
+ (user display_name)
+ (comment owner
+ body_markdown
+ body
+ link
+ edited
+ creation_date
+ upvoted
+ score
+ post_type
+ post_id
+ comment_id)
+ (answer answer_id
+ last_editor
+ last_activity_date
+ link
+ share_link
+ owner
+ body_markdown
+ upvoted
+ downvoted
+ comments)))
+ "The filter applied when retrieving question data.
+See `sx-question-get-questions' and `sx-question-get-question'.")
+
(provide 'sx-filter)
;;; sx-filter.el ends here