From f0f3d7675d6510add4b28fac1cb5823a658c1ec8 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 31 Oct 2014 18:11:56 -0400 Subject: Housekeeping and performance enhancements --- stack-core.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index c43d34a..1bdf20f 100644 --- a/stack-core.el +++ b/stack-core.el @@ -38,6 +38,7 @@ ;;; Package Logging (defun stack-message (format-string &rest args) + "Display a message" (message "[stack] %s" (apply #'format format-string args))) @@ -54,7 +55,8 @@ (defcustom stack-core-default-keyword-arguments-alist '(("filters/create") ("sites") - (t (site . emacs))) + ("questions" (site . emacs)) + (t nil)) "Keywords to use as the default for a given method. The first element of each list is the method call the keywords @@ -164,12 +166,12 @@ entire response as a complex alist." (with-current-buffer (url-retrieve-synchronously call) (goto-char (point-min)) (if (not (search-forward "\n\n" nil t)) - (error "Response corrupted") + (error "Response headers missing") (delete-region (point-min) (point)) (buffer-string))))) - (response - (with-demoted-errors "JSON Error: %s" - (json-read-from-string api-response)))) + (response + (with-demoted-errors "JSON Error: %s" + (json-read-from-string api-response)))) (unless response (stack-message "Printing response as message") (message response) @@ -180,9 +182,8 @@ entire response as a complex alist." (cdr (assoc 'error_id response)) (cdr (assoc 'error_name response)) (cdr (assoc 'error_message response)))) - (setq stack-core-remaining-api-requests - (cdr (assoc 'quota_remaining response))) - (when (< stack-core-remaining-api-requests + (when (< (setq stack-core-remaining-api-requests + (cdr (assoc 'quota_remaining response))) stack-core-remaining-api-requests-message-threshold) (stack-message "%d API requests remaining" stack-core-remaining-api-requests)) -- cgit v1.2.3 From 55111f36af271b85f452d3774beb89b0aa85cfc6 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 31 Oct 2014 18:51:00 -0400 Subject: Handle case where API response is compressed The StackExchange API explicitly states that responses to requests are gzipped. For some reason, they are not zipped when called locally on my machine, but they are zipped when run from Travis CI. I do not know if `url-retrieve-synchronously' is performing any magic. When I curl the request, I receive a gzipped response (as expected). A proper fix for this would be to somehow advise `url-*' to request as curl does. --- stack-core.el | 97 ++++++++++++++++++++++++++++++++++------------------------- tests.el | 8 +++++ 2 files changed, 64 insertions(+), 41 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 1bdf20f..082af83 100644 --- a/stack-core.el +++ b/stack-core.el @@ -143,51 +143,66 @@ with the given KEYWORD-ARGUMENTS." base (concat base "?" args)))) -(defun stack-core-make-request (method &optional keyword-arguments filter) +(defun stack-core-make-request + (method &optional keyword-arguments filter silent) "Make a request to the StackExchange API using METHOD and optional KEYWORD-ARGUMENTS. If no KEYWORD-ARGUMENTS are given, `stack-core-default-keyword-arguments-alist' is used. Return the entire response as a complex alist." - (let* ((api-response - (let ((call - (stack-core-build-request - method - (cons `(filter . ,(cond - (filter filter) - ((boundp 'stack-filter) - stack-filter))) - (if keyword-arguments keyword-arguments - (stack-core-get-default-keyword-arguments - method))))) - (url-automatic-caching stack-core-cache-requests)) - ;; TODO: url-retrieve-synchronously can return nil if the call is - ;; unsuccessful should handle this case - (stack-message "Request: %s" call) - (with-current-buffer (url-retrieve-synchronously call) - (goto-char (point-min)) - (if (not (search-forward "\n\n" nil t)) - (error "Response headers missing") - (delete-region (point-min) (point)) - (buffer-string))))) - (response - (with-demoted-errors "JSON Error: %s" - (json-read-from-string api-response)))) - (unless response - (stack-message "Printing response as message") - (message response) - (error "Response could not be read by json-read-string")) - (when (assoc 'error_id response) - (error "Request failed: (%s) [%i %s] %s" - method - (cdr (assoc 'error_id response)) - (cdr (assoc 'error_name response)) - (cdr (assoc 'error_message response)))) - (when (< (setq stack-core-remaining-api-requests - (cdr (assoc 'quota_remaining response))) - stack-core-remaining-api-requests-message-threshold) - (stack-message "%d API requests remaining" - stack-core-remaining-api-requests)) - (cdr (assoc 'items response)))) + (let ((url-automatic-caching stack-core-cache-requests) + (call + (stack-core-build-request + method + (cons `(filter . ,(cond (filter filter) + ((boundp 'stack-filter) stack-filter))) + (if keyword-arguments keyword-arguments + (stack-core-get-default-keyword-arguments method)))))) + ;; TODO: url-retrieve-synchronously can return nil if the call is + ;; unsuccessful should handle this case + (unless silent (stack-message "Request: %S" call)) + (let ((response-buffer (url-retrieve-synchronously + call silent))) + (if (not response-buffer) + (error "Something went wrong in `url-retrieve-synchronously'") + (with-current-buffer response-buffer + (let* ((data (progn + (goto-char (point-min)) + (if (not (search-forward "\n\n" nil t)) + (error "Response headers missing") + (delete-region (point-min) (point)) + (buffer-string)))) + (response (ignore-errors + (json-read-from-string data)))) + ;; if response isn't nil, the response was in plain text + (unless response + ;; try to decompress the response + (setq response + (with-demoted-errors "JSON Error: %s" + (shell-command-on-region + (point-min) (point-max) + stack-core-unzip-program + nil t) + (json-read-from-string (buffer-string)))) + ;; If it still fails, error out + (unless response + (stack-message "Unable to parse response") + (stack-message "Printing response as message") + (message "%S" response) + (error "Response could not be read by json-read-string"))) + ;; At this point, either response is a valid data structure + ;; or we have already thrown an error + (when (assoc 'error_id response) + (error "Request failed: (%s) [%i %s] %s" + method + (cdr (assoc 'error_id response)) + (cdr (assoc 'error_name response)) + (cdr (assoc 'error_message response)))) + (when (< (setq stack-core-remaining-api-requests + (cdr (assoc 'quota_remaining response))) + stack-core-remaining-api-requests-message-threshold) + (stack-message "%d API requests remaining" + stack-core-remaining-api-requests)) + (cdr (assoc 'items response)))))))) (provide 'stack-core) ;;; stack-core.el ends here diff --git a/tests.el b/tests.el index 0c2af0f..379c903 100644 --- a/tests.el +++ b/tests.el @@ -6,6 +6,8 @@ (unintern symbol))))) ;;; Tests + +(setq stack-core-remaining-api-requests-message-threshold 1000000000) (setq debug-on-error t) (require 'stack-core) @@ -13,9 +15,15 @@ (setq stack-core-remaining-api-requests-message-threshold 50000) +(ert-deftest test-basic-request () + "Test basic request functionality" + (should (stack-core-make-request "sites"))) + (ert-deftest test-question-retrieve () + "Test the ability to receive a list of questions." (should (stack-question-get-questions 'emacs))) (ert-deftest test-bad-request () + "Test a method given a bad set of keywords" (should-error (stack-core-make-request "questions" '(())))) -- cgit v1.2.3 From 94c434227d60e38d305e48043522774bcfa8ef31 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 31 Oct 2014 18:58:18 -0400 Subject: Strip properties from string sent to json-read --- stack-core.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 082af83..16a20c9 100644 --- a/stack-core.el +++ b/stack-core.el @@ -182,7 +182,9 @@ entire response as a complex alist." (point-min) (point-max) stack-core-unzip-program nil t) - (json-read-from-string (buffer-string)))) + (json-read-from-string + (buffer-substring + (point-min) (point-max))))) ;; If it still fails, error out (unless response (stack-message "Unable to parse response") -- cgit v1.2.3 From 51612733ae7948645632b044cf527e4f088cb804 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 1 Nov 2014 01:34:39 -0400 Subject: Use `url-retrieve-synchronously' dependendently Emacs 24.3 supposedly does not have a second argument to `url-retrieve-synchronously'. Introduce a switch dependent on `emacs-minor-version'. This hopefully fixes the url- issue. --- Cask | 1 + stack-core.el | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'stack-core.el') diff --git a/Cask b/Cask index a715b2a..f5be811 100644 --- a/Cask +++ b/Cask @@ -6,6 +6,7 @@ (files "stack-*.el") (depends-on "json" "1.4") +(depends-on "url") (development (depends-on "ert")) diff --git a/stack-core.el b/stack-core.el index 16a20c9..03a3afa 100644 --- a/stack-core.el +++ b/stack-core.el @@ -150,6 +150,7 @@ optional KEYWORD-ARGUMENTS. If no KEYWORD-ARGUMENTS are given, `stack-core-default-keyword-arguments-alist' is used. Return the entire response as a complex alist." (let ((url-automatic-caching stack-core-cache-requests) + (url-inhibit-uncompression t) (call (stack-core-build-request method @@ -160,8 +161,11 @@ entire response as a complex alist." ;; TODO: url-retrieve-synchronously can return nil if the call is ;; unsuccessful should handle this case (unless silent (stack-message "Request: %S" call)) - (let ((response-buffer (url-retrieve-synchronously - call silent))) + (let ((response-buffer (cond + ((= emacs-minor-version 4) + (url-retrieve-synchronously call silent)) + ((= emacs-minor-version 3) + (url-retrieve-synchronously call))))) (if (not response-buffer) (error "Something went wrong in `url-retrieve-synchronously'") (with-current-buffer response-buffer -- cgit v1.2.3 From a8e1a143701326da47f973d3ad6062919e614e31 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 1 Nov 2014 01:37:32 -0400 Subject: Support older versions than 24.3 --- stack-core.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 03a3afa..d48c873 100644 --- a/stack-core.el +++ b/stack-core.el @@ -164,8 +164,7 @@ entire response as a complex alist." (let ((response-buffer (cond ((= emacs-minor-version 4) (url-retrieve-synchronously call silent)) - ((= emacs-minor-version 3) - (url-retrieve-synchronously call))))) + (t (url-retrieve-synchronously call))))) (if (not response-buffer) (error "Something went wrong in `url-retrieve-synchronously'") (with-current-buffer response-buffer -- cgit v1.2.3 From 90dedf05061aa173143b27fea98de78e0c316dd4 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 1 Nov 2014 02:05:14 -0400 Subject: Add function to filter data structure Only works on flat structures right now. This should be used and let-bound to a variable when that variable is going to be used a lot. Theoretically, it should be faster than traversing through the entire data structure. Think of this as a Emacs-local version of the API's own filter. --- stack-core.el | 9 +++++++++ tests.el | 14 ++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index d48c873..cf7dde5 100644 --- a/stack-core.el +++ b/stack-core.el @@ -209,5 +209,14 @@ entire response as a complex alist." stack-core-remaining-api-requests)) (cdr (assoc 'items response)))))))) +(defun stack-core-filter-data (data desired-tree) + "Filters DATA and returns the DESIRED-TREE" + (delq + nil + (mapcar (lambda (cons-cell) + (when (member (car cons-cell) desired-tree) + cons-cell)) + data))) + (provide 'stack-core) ;;; stack-core.el ends here diff --git a/tests.el b/tests.el index c79cfc4..0c520d8 100644 --- a/tests.el +++ b/tests.el @@ -25,3 +25,17 @@ "Test a method given a bad set of keywords" (should-error (stack-core-make-request "questions" '(())))) + +(ert-deftest test-data-filter-1 () + "Test the meta-convenience function" + (should + (equal + '((1 . t) (2 . [1 2]) (3)) + (stack-core-filter-data '((0 . 3) + (1 . t) + (a . five) + (2 . [1 2]) + ("5" . bop) + (3) + (p . 4)) + '(1 2 3))))) -- cgit v1.2.3 From b6b0b8dd82031eb55189ad3bea5eaacd8444b9d5 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 1 Nov 2014 13:29:10 -0400 Subject: More work on data filter; add tests --- dev/data-samples/questions.el | 517 ------------------------------ dev/data-samples/sites.el | 711 ------------------------------------------ stack-core.el | 19 +- test/tests.el | 33 +- test/util.el | 12 - tests.el | 41 --- 6 files changed, 37 insertions(+), 1296 deletions(-) delete mode 100644 dev/data-samples/questions.el delete mode 100644 dev/data-samples/sites.el delete mode 100644 test/util.el delete mode 100644 tests.el (limited to 'stack-core.el') diff --git a/dev/data-samples/questions.el b/dev/data-samples/questions.el deleted file mode 100644 index 4437e7a..0000000 --- a/dev/data-samples/questions.el +++ /dev/null @@ -1,517 +0,0 @@ -[((title . "What are good tools for Emacs package development?") - (link . "http://emacs.stackexchange.com/questions/2949/what-are-good-tools-for-emacs-package-development") - (question_id . 2949) - (creation_date . 1414816866) - (last_activity_date . 1414816866) - (score . 0) - (answer_count . 1) - (view_count . 6) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/2264/sean-allred") - (display_name . "Sean Allred") - (accept_rate . 75) - (user_type . "registered") - (user_id . 2264) - (reputation . 543)) - (tags . ["elisp" "interactive-development" "package-development"])) -((title . "Is there a 'local undo' extension for Emacs?") - (link . "http://emacs.stackexchange.com/questions/2946/is-there-a-local-undo-extension-for-emacs") - (question_id . 2946) - (creation_date . 1414810154) - (last_activity_date . 1414813323) - (score . 3) - (answer_count . 1) - (accepted_answer_id . 2948) - (view_count . 10) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/600/mcb") - (display_name . "mcb") - (user_type . "registered") - (user_id . 600) - (reputation . 188)) - (tags . ["editing"])) -((title . "Helm color theme gets mixed results") - (link . "http://emacs.stackexchange.com/questions/2937/helm-color-theme-gets-mixed-results") - (question_id . 2937) - (creation_date . 1414795519) - (last_activity_date . 1414813299) - (score . 0) - (answer_count . 2) - (view_count . 16) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/35/ryan") - (display_name . "Ryan") - (user_type . "registered") - (user_id . 35) - (reputation . 255)) - (tags . ["helm" "themes"])) -((title . "`url-inhibit-uncompression` is ineffective; emulating curl with url.el") - (link . "http://emacs.stackexchange.com/questions/2947/url-inhibit-uncompression-is-ineffective-emulating-curl-with-url-el") - (question_id . 2947) - (creation_date . 1414812397) - (last_activity_date . 1414812397) - (score . 0) - (answer_count . 0) - (view_count . 3) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/2264/sean-allred") - (display_name . "Sean Allred") - (accept_rate . 75) - (user_type . "registered") - (user_id . 2264) - (reputation . 543)) - (tags . ["compression" "url"])) -((title . "How can I bring back `nil`?") - (link . "http://emacs.stackexchange.com/questions/2935/how-can-i-bring-back-nil") - (question_id . 2935) - (last_edit_date . 1414799073) - (creation_date . 1414792387) - (last_activity_date . 1414805588) - (score . 5) - (answer_count . 1) - (accepted_answer_id . 2938) - (view_count . 133) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/2264/sean-allred") - (display_name . "Sean Allred") - (accept_rate . 75) - (user_type . "registered") - (user_id . 2264) - (reputation . 543)) - (tags . ["elisp" "interactive-development"])) -((title . "org babel eval with no confirmation is explicit: :eval yes") - (link . "http://emacs.stackexchange.com/questions/2945/org-babel-eval-with-no-confirmation-is-explicit-eval-yes") - (question_id . 2945) - (creation_date . 1414805111) - (last_activity_date . 1414805111) - (score . 0) - (answer_count . 0) - (view_count . 5) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/55/wdkrnls") - (display_name . "wdkrnls") - (accept_rate . 100) - (user_type . "registered") - (user_id . 55) - (reputation . 362)) - (tags . ["org-mode" "org-babel"])) -((title . "Interpratation of Tabs in text copied from Emacs and pasted in other programs/editors") - (link . "http://emacs.stackexchange.com/questions/2944/interpratation-of-tabs-in-text-copied-from-emacs-and-pasted-in-other-programs-ed") - (question_id . 2944) - (creation_date . 1414804977) - (last_activity_date . 1414804977) - (score . 0) - (answer_count . 0) - (view_count . 5) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/2248/adam") - (display_name . "Adam") - (accept_rate . 80) - (user_type . "registered") - (user_id . 2248) - (reputation . 227)) - (tags . ["gnu-emacs"])) -((title . "Calling the calc stack from babel: displaying percentages") - (link . "http://emacs.stackexchange.com/questions/2943/calling-the-calc-stack-from-babel-displaying-percentages") - (question_id . 2943) - (creation_date . 1414804647) - (last_activity_date . 1414804647) - (score . 0) - (answer_count . 0) - (view_count . 2) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/55/wdkrnls") - (display_name . "wdkrnls") - (accept_rate . 100) - (user_type . "registered") - (user_id . 55) - (reputation . 362)) - (tags . ["org-mode" "org-babel" "calc"])) -((title . "eldoc in python-mode") - (link . "http://emacs.stackexchange.com/questions/2942/eldoc-in-python-mode") - (question_id . 2942) - (creation_date . 1414800979) - (last_activity_date . 1414800979) - (score . 1) - (answer_count . 0) - (view_count . 9) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/2191/nathaniel-flath") - (display_name . "Nathaniel Flath") - (accept_rate . 40) - (user_type . "registered") - (user_id . 2191) - (reputation . 170)) - (tags . ["python" "eldoc" "customization"])) -((title . "god-mode: swap keys") - (link . "http://emacs.stackexchange.com/questions/2903/god-mode-swap-keys") - (question_id . 2903) - (creation_date . 1414755674) - (last_activity_date . 1414800498) - (score . 2) - (answer_count . 2) - (accepted_answer_id . 2941) - (view_count . 42) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/2005/rekado") - (display_name . "rekado") - (user_type . "registered") - (user_id . 2005) - (reputation . 875)) - (tags . ["key-bindings" "keymap" "god-mode"])) -((title . "How to make `truncate-lines` nil and `auto-fill-mode` off in magit buffers") - (link . "http://emacs.stackexchange.com/questions/2890/how-to-make-truncate-lines-nil-and-auto-fill-mode-off-in-magit-buffers") - (question_id . 2890) - (last_edit_date . 1414798728) - (creation_date . 1414730361) - (last_activity_date . 1414798728) - (score . 0) - (answer_count . 1) - (accepted_answer_id . 2895) - (view_count . 23) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/794/codychan") - (display_name . "CodyChan") - (user_type . "registered") - (user_id . 794) - (reputation . 125)) - (tags . ["magit"])) -((title . "How can I determine if a file is compressed from Elisp?") - (link . "http://emacs.stackexchange.com/questions/2931/how-can-i-determine-if-a-file-is-compressed-from-elisp") - (question_id . 2931) - (last_edit_date . 1414798025) - (creation_date . 1414789578) - (last_activity_date . 1414798025) - (score . 1) - (answer_count . 0) - (view_count . 18) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/2264/sean-allred") - (display_name . "Sean Allred") - (accept_rate . 75) - (user_type . "registered") - (user_id . 2264) - (reputation . 543)) - (tags . ["compression" "url"])) -((title . "Focus-hook: attenuate colours when losing focus") - (link . "http://emacs.stackexchange.com/questions/2922/focus-hook-attenuate-colours-when-losing-focus") - (question_id . 2922) - (last_edit_date . 1414793447) - (creation_date . 1414774490) - (last_activity_date . 1414793447) - (score . 3) - (answer_count . 0) - (view_count . 20) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/2005/rekado") - (display_name . "rekado") - (user_type . "registered") - (user_id . 2005) - (reputation . 875)) - (tags . ["frames" "hooks" "focus"])) -((title . ""Making tag completion table" Freezes/Blocks -- how to disable") - (link . "http://emacs.stackexchange.com/questions/2919/making-tag-completion-table-freezes-blocks-how-to-disable") - (question_id . 2919) - (creation_date . 1414770468) - (last_activity_date . 1414793088) - (score . 2) - (answer_count . 1) - (view_count . 21) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/2265/cheezy") - (display_name . "cheezy") - (user_type . "registered") - (user_id . 2265) - (reputation . 11)) - (tags . ["autocomplete" "performance" "ctags"])) -((title . "Open edit-server files from emacsclient in a specific frame") - (link . "http://emacs.stackexchange.com/questions/2417/open-edit-server-files-from-emacsclient-in-a-specific-frame") - (question_id . 2417) - (last_edit_date . 1413990607) - (creation_date . 1413927107) - (last_activity_date . 1414790834) - (score . 5) - (answer_count . 2) - (view_count . 47) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/93/nispio") - (display_name . "nispio") - (accept_rate . 55) - (user_type . "registered") - (user_id . 93) - (reputation . 1714)) - (tags . ["frames" "emacsclient"])) -((title . "Babel doesn't wrap results in verbatim") - (link . "http://emacs.stackexchange.com/questions/2920/babel-doesnt-wrap-results-in-verbatim") - (question_id . 2920) - (last_edit_date . 1414770962) - (creation_date . 1414770503) - (last_activity_date . 1414784968) - (score . 0) - (answer_count . 1) - (view_count . 16) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/563/wvxvw") - (display_name . "wvxvw") - (user_type . "registered") - (user_id . 563) - (reputation . 255)) - (tags . ["org-mode" "org-export" "org-babel"])) -((title . "Can I change the background color of the inactive minibuffer?") - (link . "http://emacs.stackexchange.com/questions/2323/can-i-change-the-background-color-of-the-inactive-minibuffer") - (question_id . 2323) - (last_edit_date . 1413635904) - (creation_date . 1413626421) - (last_activity_date . 1414784512) - (score . 8) - (answer_count . 2) - (view_count . 93) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/600/mcb") - (display_name . "mcb") - (user_type . "registered") - (user_id . 600) - (reputation . 188)) - (tags . ["customize" "faces" "minibuffer"])) -((title . "Projectile project in folder without write access?") - (link . "http://emacs.stackexchange.com/questions/2891/projectile-project-in-folder-without-write-access") - (question_id . 2891) - (creation_date . 1414735834) - (last_activity_date . 1414784284) - (score . 2) - (answer_count . 2) - (view_count . 33) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/93/nispio") - (display_name . "nispio") - (accept_rate . 55) - (user_type . "registered") - (user_id . 93) - (reputation . 1714)) - (tags . ["projectile"])) -((title . "How to disable eldoc for `eval-expression`?") - (link . "http://emacs.stackexchange.com/questions/2917/how-to-disable-eldoc-for-eval-expression") - (question_id . 2917) - (last_edit_date . 1414770569) - (creation_date . 1414767244) - (last_activity_date . 1414776394) - (score . 1) - (answer_count . 1) - (accepted_answer_id . 2918) - (view_count . 35) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/2094/abo-abo") - (display_name . "abo-abo") - (user_type . "registered") - (user_id . 2094) - (reputation . 430)) - (tags . ["elisp" "emacs-25"])) -((title . "How to view and edit large delimiter separated value files?") - (link . "http://emacs.stackexchange.com/questions/972/how-to-view-and-edit-large-delimiter-separated-value-files") - (question_id . 972) - (last_edit_date . 1414713136) - (creation_date . 1412881152) - (last_activity_date . 1414775451) - (score . 6) - (answer_count . 1) - (accepted_answer_id . 2923) - (view_count . 93) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/315/holocronweaver") - (display_name . "holocronweaver") - (user_type . "registered") - (user_id . 315) - (reputation . 55)) - (tags . ["editing" "table" "large-files" "csv"])) -((title . "The old "how to fold xml" question") - (link . "http://emacs.stackexchange.com/questions/2884/the-old-how-to-fold-xml-question") - (question_id . 2884) - (creation_date . 1414720950) - (last_activity_date . 1414773563) - (score . 5) - (answer_count . 1) - (view_count . 26) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/215/mark-aufflick") - (display_name . "Mark Aufflick") - (user_type . "registered") - (user_id . 215) - (reputation . 203)) - (tags . ["xml" "nxml" "outline"])) -((title . "How can I turn [1..10] into [1,2,3,4,5,6,7,8,9,10] in calc?") - (link . "http://emacs.stackexchange.com/questions/2914/how-can-i-turn-1-10-into-1-2-3-4-5-6-7-8-9-10-in-calc") - (question_id . 2914) - (creation_date . 1414765664) - (last_activity_date . 1414766835) - (score . 3) - (answer_count . 1) - (accepted_answer_id . 2916) - (view_count . 105) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/503/mrbones") - (display_name . "MrBones") - (user_type . "registered") - (user_id . 503) - (reputation . 118)) - (tags . ["calc"])) -((title . "How to turn off "error" highlighting in emacs-lisp-mode for Emacs 25?") - (link . "http://emacs.stackexchange.com/questions/2907/how-to-turn-off-error-highlighting-in-emacs-lisp-mode-for-emacs-25") - (question_id . 2907) - (last_edit_date . 1414766064) - (creation_date . 1414759846) - (last_activity_date . 1414766064) - (score . 2) - (answer_count . 1) - (accepted_answer_id . 2913) - (view_count . 50) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/2094/abo-abo") - (display_name . "abo-abo") - (user_type . "registered") - (user_id . 2094) - (reputation . 430)) - (tags . ["elisp" "font-lock" "emacs-lisp-mode"])) -((title . "Kill buffer when frame is deleted") - (link . "http://emacs.stackexchange.com/questions/2888/kill-buffer-when-frame-is-deleted") - (question_id . 2888) - (creation_date . 1414725672) - (last_activity_date . 1414765666) - (score . 5) - (answer_count . 3) - (accepted_answer_id . 2915) - (view_count . 61) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/163/dharmatech") - (display_name . "dharmatech") - (user_type . "registered") - (user_id . 163) - (reputation . 216)) - (tags . ["buffers" "frames"])) -((title . "Is there a better way to handle multiline docstrings in elisp?") - (link . "http://emacs.stackexchange.com/questions/2887/is-there-a-better-way-to-handle-multiline-docstrings-in-elisp") - (question_id . 2887) - (last_edit_date . 1414741213) - (creation_date . 1414725439) - (last_activity_date . 1414764354) - (score . 7) - (answer_count . 3) - (view_count . 104) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/2345/krazy-glew") - (display_name . "Krazy Glew") - (user_type . "registered") - (user_id . 2345) - (reputation . 136)) - (tags . ["elisp" "documentation"])) -((title . "TAB does not auto-indent lines anymore") - (link . "http://emacs.stackexchange.com/questions/2904/tab-does-not-auto-indent-lines-anymore") - (question_id . 2904) - (last_edit_date . 1414760438) - (creation_date . 1414757159) - (last_activity_date . 1414760438) - (score . 1) - (answer_count . 0) - (view_count . 30) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/2305/vivian-maya") - (display_name . "Vivian Maya") - (user_type . "registered") - (user_id . 2305) - (reputation . 81)) - (tags . ["indentation"])) -((title . "Password/Key Management for multiple machines in emacs") - (link . "http://emacs.stackexchange.com/questions/2902/password-key-management-for-multiple-machines-in-emacs") - (question_id . 2902) - (creation_date . 1414755561) - (last_activity_date . 1414760173) - (score . 7) - (answer_count . 1) - (view_count . 64) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/294/gambo") - (display_name . "Gambo") - (user_type . "registered") - (user_id . 294) - (reputation . 175)) - (tags . ["tramp"])) -((title . ""Symbol's function definition is void: cl-macroexpand-all" when trying to install php-mode") - (link . "http://emacs.stackexchange.com/questions/2864/symbols-function-definition-is-void-cl-macroexpand-all-when-trying-to-instal") - (question_id . 2864) - (last_edit_date . 1414701459) - (creation_date . 1414700357) - (last_activity_date . 1414759512) - (score . 2) - (answer_count . 2) - (accepted_answer_id . 2866) - (view_count . 29) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/2342/cg433n") - (display_name . "cg433n") - (user_type . "registered") - (user_id . 2342) - (reputation . 13)) - (tags . ["package" "cl-lib" "php-mode"])) -((title . "Better debugging of crashing Emacs?") - (link . "http://emacs.stackexchange.com/questions/363/better-debugging-of-crashing-emacs") - (question_id . 363) - (last_edit_date . 1411830937) - (creation_date . 1411809580) - (last_activity_date . 1414757838) - (score . 5) - (answer_count . 2) - (accepted_answer_id . 373) - (view_count . 65) - (is_answered . t) - (owner - (link . "http://emacs.stackexchange.com/users/249/gsl") - (display_name . "gsl") - (accept_rate . 100) - (user_type . "registered") - (user_id . 249) - (reputation . 84)) - (tags . ["elisp" "fonts" "debugging" "crash"])) -((title . "org-mode and reftex giving this error: reftex-using-biblatex-p: Stack overflow in regexp matcher") - (link . "http://emacs.stackexchange.com/questions/2901/org-mode-and-reftex-giving-this-error-reftex-using-biblatex-p-stack-overflow-i") - (question_id . 2901) - (last_edit_date . 1414754843) - (creation_date . 1414754222) - (last_activity_date . 1414754843) - (score . 0) - (answer_count . 0) - (view_count . 11) - (is_answered . :json-false) - (owner - (link . "http://emacs.stackexchange.com/users/201/petrux") - (display_name . "petrux") - (user_type . "registered") - (user_id . 201) - (reputation . 41)) - (tags . ["org-mode" "reftex-mode" "bibtex"]))] diff --git a/dev/data-samples/sites.el b/dev/data-samples/sites.el deleted file mode 100644 index 9b02a39..0000000 --- a/dev/data-samples/sites.el +++ /dev/null @@ -1,711 +0,0 @@ -[((site_type . "main_site") - (name . "Stack Overflow") - (logo_url . "http://cdn.sstatic.net/stackoverflow/img/logo.png") - (api_site_parameter . "stackoverflow") - (site_url . "http://stackoverflow.com") - (audience . "professional and enthusiast programmers") - (icon_url . "http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/stackoverflow/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon@2.png") - (site_state . "normal") - (launch_date . 1221436800) - (markdown_extensions . ["Prettify"]) - (aliases . ["http://www.stackoverflow.com" "http://facebook.stackoverflow.com"]) - (related_sites . [((name . "Meta Stack Overflow") - (site_url . "http://meta.stackoverflow.com") - (api_site_parameter . "meta.stackoverflow") - (relation . "meta")) - ((name . "Stack Overflow Chat") - (site_url . "http://chat.stackoverflow.com") - (relation . "chat"))]) - (styling - (link_color . "#0077CC") - (tag_foreground_color . "#3E6D8E") - (tag_background_color . "#E0EAF1"))) - ((site_type . "main_site") - (name . "Server Fault") - (logo_url . "http://cdn.sstatic.net/serverfault/img/logo.png") - (api_site_parameter . "serverfault") - (site_url . "http://serverfault.com") - (audience . "professional system and network administrators") - (icon_url . "http://cdn.sstatic.net/serverfault/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/serverfault/img/favicon.ico") - (twitter_account . "ServerFault") - (high_resolution_icon_url . "http://cdn.sstatic.net/serverfault/img/apple-touch-icon@2.png") - (site_state . "normal") - (launch_date . 1243296000) - (markdown_extensions . ["Prettify"]) - (related_sites . [((name . "Meta Server Fault") - (site_url . "http://meta.serverfault.com") - (api_site_parameter . "meta.serverfault") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#10456A") - (tag_foreground_color . "#444444") - (tag_background_color . "#F3F1D9"))) - ((site_type . "main_site") - (name . "Super User") - (logo_url . "http://cdn.sstatic.net/superuser/img/logo.png") - (api_site_parameter . "superuser") - (site_url . "http://superuser.com") - (audience . "computer enthusiasts and power users") - (icon_url . "http://cdn.sstatic.net/superuser/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/superuser/img/favicon.ico") - (twitter_account . "super_user") - (high_resolution_icon_url . "http://cdn.sstatic.net/superuser/img/apple-touch-icon@2.png") - (site_state . "normal") - (launch_date . 1250553600) - (markdown_extensions . ["Prettify"]) - (related_sites . [((name . "Meta Super User") - (site_url . "http://meta.superuser.com") - (api_site_parameter . "meta.superuser") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#1086A4") - (tag_foreground_color . "#1087A4") - (tag_background_color . "#FFFFFF"))) - ((site_type . "main_site") - (name . "Meta Stack Exchange") - (logo_url . "http://cdn.sstatic.net/stackexchangemeta/img/logo.png") - (api_site_parameter . "meta") - (site_url . "http://meta.stackexchange.com") - (audience . "meta-discussion of the Stack Exchange family of Q&A websites") - (icon_url . "http://cdn.sstatic.net/stackexchangemeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/stackexchangemeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/stackexchangemeta/img/apple-touch-icon@2.png") - (site_state . "normal") - (launch_date . 1246147200) - (markdown_extensions . ["Prettify"]) - (related_sites . [((name . "Meta Stack Exchange Chat") - (site_url . "http://chat.meta.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#4E82C2") - (tag_foreground_color . "#566E76") - (tag_background_color . "#F7FDFF"))) - ((site_type . "main_site") - (name . "Web Applications") - (logo_url . "http://cdn.sstatic.net/webapps/img/logo.png") - (api_site_parameter . "webapps") - (site_url . "http://webapps.stackexchange.com") - (audience . "power users of web applications") - (icon_url . "http://cdn.sstatic.net/webapps/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/webapps/img/favicon.ico") - (twitter_account . "StackWebApps") - (high_resolution_icon_url . "http://cdn.sstatic.net/webapps/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1277856000) - (open_beta_date . 1278460800) - (launch_date . 1285804800) - (aliases . ["http://nothingtoinstall.com"]) - (related_sites . [((name . "Web Applications Meta Stack Exchange") - (site_url . "http://meta.webapps.stackexchange.com") - (api_site_parameter . "meta.webapps") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#426389") - (tag_foreground_color . "#5D7A9C") - (tag_background_color . "#E2EDFA"))) - ((site_type . "meta_site") - (name . "Web Applications Meta") - (logo_url . "http://cdn.sstatic.net/webappsmeta/img/logo.png") - (api_site_parameter . "meta.webapps") - (site_url . "http://meta.webapps.stackexchange.com") - (audience . "power users of web applications") - (icon_url . "http://cdn.sstatic.net/webappsmeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/webappsmeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/webappsmeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (aliases . ["http://meta.nothingtoinstall.com"]) - (related_sites . [((name . "Web Applications Stack Exchange") - (site_url . "http://webapps.stackexchange.com") - (api_site_parameter . "webapps") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#333C43") - (tag_foreground_color . "#666") - (tag_background_color . "#EBEBEB"))) - ((site_type . "main_site") - (name . "Arqade") - (logo_url . "http://cdn.sstatic.net/gaming/img/logo.png") - (api_site_parameter . "gaming") - (site_url . "http://gaming.stackexchange.com") - (audience . "passionate videogamers on all platforms") - (icon_url . "http://cdn.sstatic.net/gaming/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/gaming/img/favicon.ico") - (twitter_account . "TheArqade") - (high_resolution_icon_url . "http://cdn.sstatic.net/gaming/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1278460800) - (open_beta_date . 1279065600) - (launch_date . 1286323200) - (aliases . ["http://arqade.com" "http://thearqade.com"]) - (related_sites . [((name . "Arqade Meta") - (site_url . "http://meta.gaming.stackexchange.com") - (api_site_parameter . "meta.gaming") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#5A8F53") - (tag_foreground_color . "#666") - (tag_background_color . "#FFF"))) - ((site_type . "meta_site") - (name . "Arqade Meta") - (logo_url . "http://cdn.sstatic.net/gamingmeta/img/logo.png") - (api_site_parameter . "meta.gaming") - (site_url . "http://meta.gaming.stackexchange.com") - (audience . "passionate videogamers on all platforms") - (icon_url . "http://cdn.sstatic.net/gamingmeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/gamingmeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/gamingmeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (aliases . ["http://meta.arqade.com" "http://meta.thearqade.com"]) - (related_sites . [((name . "Arqade") - (site_url . "http://gaming.stackexchange.com") - (api_site_parameter . "gaming") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#666666") - (tag_foreground_color . "#666") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "Webmasters") - (logo_url . "http://cdn.sstatic.net/webmasters/img/logo.png") - (api_site_parameter . "webmasters") - (site_url . "http://webmasters.stackexchange.com") - (audience . "pro webmasters") - (icon_url . "http://cdn.sstatic.net/webmasters/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/webmasters/img/favicon.ico") - (twitter_account . "StackWebmasters") - (high_resolution_icon_url . "http://cdn.sstatic.net/webmasters/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1278547200) - (open_beta_date . 1279152000) - (launch_date . 1286928000) - (markdown_extensions . ["Prettify"]) - (aliases . ["http://webmaster.stackexchange.com"]) - (related_sites . [((name . "Webmasters Meta Stack Exchange") - (site_url . "http://meta.webmasters.stackexchange.com") - (api_site_parameter . "meta.webmasters") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#1C69A4") - (tag_foreground_color . "#1B8FBB") - (tag_background_color . "#FFF"))) - ((site_type . "meta_site") - (name . "Webmasters Meta") - (logo_url . "http://cdn.sstatic.net/webmastersmeta/img/logo.png") - (api_site_parameter . "meta.webmasters") - (site_url . "http://meta.webmasters.stackexchange.com") - (audience . "pro webmasters") - (icon_url . "http://cdn.sstatic.net/webmastersmeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/webmastersmeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/webmastersmeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (markdown_extensions . ["Prettify"]) - (aliases . ["http://meta.webmaster.stackexchange.com"]) - (related_sites . [((name . "Webmasters Stack Exchange") - (site_url . "http://webmasters.stackexchange.com") - (api_site_parameter . "webmasters") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#3D3D3D") - (tag_foreground_color . "#666666") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "Seasoned Advice") - (logo_url . "http://cdn.sstatic.net/cooking/img/logo.png") - (api_site_parameter . "cooking") - (site_url . "http://cooking.stackexchange.com") - (audience . "professional and amateur chefs") - (icon_url . "http://cdn.sstatic.net/cooking/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/cooking/img/favicon.ico") - (twitter_account . "StackCooking") - (high_resolution_icon_url . "http://cdn.sstatic.net/cooking/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1278633600) - (open_beta_date . 1279238400) - (launch_date . 1287014400) - (aliases . ["http://seasonedadvice.com"]) - (related_sites . [((name . "Seasoned Advice Meta") - (site_url . "http://meta.cooking.stackexchange.com") - (api_site_parameter . "meta.cooking") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#AB2020") - (tag_foreground_color . "#847454") - (tag_background_color . "#FFF5E4"))) - ((site_type . "meta_site") - (name . "Seasoned Advice Meta") - (logo_url . "http://cdn.sstatic.net/cookingmeta/img/logo.png") - (api_site_parameter . "meta.cooking") - (site_url . "http://meta.cooking.stackexchange.com") - (audience . "professional and amateur chefs") - (icon_url . "http://cdn.sstatic.net/cookingmeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/cookingmeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/cookingmeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (aliases . ["http://meta.seasonedadvice.com"]) - (related_sites . [((name . "Seasoned Advice") - (site_url . "http://cooking.stackexchange.com") - (api_site_parameter . "cooking") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#3D3D3D") - (tag_foreground_color . "#666666") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "Game Development") - (logo_url . "http://cdn.sstatic.net/gamedev/img/logo.png") - (api_site_parameter . "gamedev") - (site_url . "http://gamedev.stackexchange.com") - (audience . "professional and independent game developers") - (icon_url . "http://cdn.sstatic.net/gamedev/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/gamedev/img/favicon.ico") - (twitter_account . "StackGameDev") - (high_resolution_icon_url . "http://cdn.sstatic.net/gamedev/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1279065600) - (open_beta_date . 1279670400) - (launch_date . 1287619200) - (markdown_extensions . ["Prettify"]) - (related_sites . [((name . "Game Development Meta Stack Exchange") - (site_url . "http://meta.gamedev.stackexchange.com") - (api_site_parameter . "meta.gamedev") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#416D63") - (tag_foreground_color . "#444444") - (tag_background_color . "#eeeeee"))) - ((site_type . "meta_site") - (name . "Game Development Meta") - (logo_url . "http://cdn.sstatic.net/gamedevmeta/img/logo.png") - (api_site_parameter . "meta.gamedev") - (site_url . "http://meta.gamedev.stackexchange.com") - (audience . "professional and independent game developers") - (icon_url . "http://cdn.sstatic.net/gamedevmeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/gamedevmeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/gamedevmeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (related_sites . [((name . "Game Development Stack Exchange") - (site_url . "http://gamedev.stackexchange.com") - (api_site_parameter . "gamedev") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#3D3D3D") - (tag_foreground_color . "#666666") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "Photography") - (logo_url . "http://cdn.sstatic.net/photo/img/logo.png") - (api_site_parameter . "photo") - (site_url . "http://photo.stackexchange.com") - (audience . "professional, enthusiast and amateur photographers") - (icon_url . "http://cdn.sstatic.net/photo/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/photo/img/favicon.ico") - (twitter_account . "StackPhotos") - (high_resolution_icon_url . "http://cdn.sstatic.net/photo/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1279152000) - (open_beta_date . 1279756800) - (launch_date . 1288224000) - (aliases . ["http://photography.stackexchange.com" "http://photos.stackexchange.com"]) - (related_sites . [((name . "Photography Meta Stack Exchange") - (site_url . "http://meta.photo.stackexchange.com") - (api_site_parameter . "meta.photo") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#0077CC") - (tag_foreground_color . "#444") - (tag_background_color . "#F7F7F7"))) - ((site_type . "meta_site") - (name . "Photography Meta") - (logo_url . "http://cdn.sstatic.net/photometa/img/logo.png") - (api_site_parameter . "meta.photo") - (site_url . "http://meta.photo.stackexchange.com") - (audience . "professional, enthusiast and amateur photographers") - (icon_url . "http://cdn.sstatic.net/photometa/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/photometa/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/photometa/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (aliases . ["http://meta.photography.stackexchange.com" "http://meta.photos.stackexchange.com"]) - (related_sites . [((name . "Photography Stack Exchange") - (site_url . "http://photo.stackexchange.com") - (api_site_parameter . "photo") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#3D3D3D") - (tag_foreground_color . "#666666") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "Cross Validated") - (logo_url . "http://cdn.sstatic.net/stats/img/logo.png") - (api_site_parameter . "stats") - (site_url . "http://stats.stackexchange.com") - (audience . "people interested in statistics, machine learning, data analysis, data mining, and data visualization") - (icon_url . "http://cdn.sstatic.net/stats/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/stats/img/favicon.ico") - (twitter_account . "StackStats") - (high_resolution_icon_url . "http://cdn.sstatic.net/stats/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1279497600) - (open_beta_date . 1280102400) - (launch_date . 1288828800) - (markdown_extensions . ["MathJax" "Prettify"]) - (aliases . ["http://statistics.stackexchange.com" "http://crossvalidated.com"]) - (related_sites . [((name . "Cross Validated Meta") - (site_url . "http://meta.stats.stackexchange.com") - (api_site_parameter . "meta.stats") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#0077CC") - (tag_foreground_color . "#5D5D5D") - (tag_background_color . "#edefed"))) - ((site_type . "meta_site") - (name . "Cross Validated Meta") - (logo_url . "http://cdn.sstatic.net/statsmeta/img/logo.png") - (api_site_parameter . "meta.stats") - (site_url . "http://meta.stats.stackexchange.com") - (audience . "people interested in statistics, machine learning, data analysis, data mining, and data visualization") - (icon_url . "http://cdn.sstatic.net/statsmeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/statsmeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/statsmeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (markdown_extensions . ["MathJax"]) - (aliases . ["http://meta.statistics.stackexchange.com"]) - (related_sites . [((name . "Cross Validated") - (site_url . "http://stats.stackexchange.com") - (api_site_parameter . "stats") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#3D3D3D") - (tag_foreground_color . "#666666") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "Mathematics") - (logo_url . "http://cdn.sstatic.net/math/img/logo.png") - (api_site_parameter . "math") - (site_url . "http://math.stackexchange.com") - (audience . "people studying math at any level and professionals in related fields") - (icon_url . "http://cdn.sstatic.net/math/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/math/img/favicon.ico") - (twitter_account . "StackMath") - (high_resolution_icon_url . "http://cdn.sstatic.net/math/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1279584000) - (open_beta_date . 1280188800) - (launch_date . 1287964800) - (markdown_extensions . ["MathJax"]) - (aliases . ["http://maths.stackexchange.com" "http://mathematics.stackexchange.com"]) - (related_sites . [((name . "Mathematics Meta Stack Exchange") - (site_url . "http://meta.math.stackexchange.com") - (api_site_parameter . "meta.math") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#0077CC") - (tag_foreground_color . "#000") - (tag_background_color . "#888888"))) - ((site_type . "meta_site") - (name . "Mathematics Meta") - (logo_url . "http://cdn.sstatic.net/mathmeta/img/logo.png") - (api_site_parameter . "meta.math") - (site_url . "http://meta.math.stackexchange.com") - (audience . "people studying math at any level and professionals in related fields") - (icon_url . "http://cdn.sstatic.net/mathmeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/mathmeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/mathmeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (markdown_extensions . ["MathJax"]) - (related_sites . [((name . "Mathematics Stack Exchange") - (site_url . "http://math.stackexchange.com") - (api_site_parameter . "math") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#3D3D3D") - (tag_foreground_color . "#666666") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "Home Improvement") - (logo_url . "http://cdn.sstatic.net/diy/img/logo.png") - (api_site_parameter . "diy") - (site_url . "http://diy.stackexchange.com") - (audience . "contractors and serious DIYers") - (icon_url . "http://cdn.sstatic.net/diy/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/diy/img/favicon.ico") - (twitter_account . "StackDIY") - (high_resolution_icon_url . "http://cdn.sstatic.net/diy/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1279670400) - (open_beta_date . 1280275200) - (launch_date . 1299110400) - (related_sites . [((name . "Home Improvement Meta Stack Exchange") - (site_url . "http://meta.diy.stackexchange.com") - (api_site_parameter . "meta.diy") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#0077CC") - (tag_foreground_color . "#696969") - (tag_background_color . "#f5f5f5"))) - ((site_type . "meta_site") - (name . "Home Improvement Meta") - (logo_url . "http://cdn.sstatic.net/diymeta/img/logo.png") - (api_site_parameter . "meta.diy") - (site_url . "http://meta.diy.stackexchange.com") - (audience . "contractors and serious DIYers") - (icon_url . "http://cdn.sstatic.net/diymeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/diymeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/diymeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (related_sites . [((name . "Home Improvement Stack Exchange") - (site_url . "http://diy.stackexchange.com") - (api_site_parameter . "diy") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#3D3D3D") - (tag_foreground_color . "#666666") - (tag_background_color . "#FFF"))) - ((site_type . "meta_site") - (name . "Meta Super User") - (logo_url . "http://cdn.sstatic.net/superusermeta/img/logo.png") - (api_site_parameter . "meta.superuser") - (site_url . "http://meta.superuser.com") - (audience . "computer enthusiasts and power users") - (icon_url . "http://cdn.sstatic.net/superusermeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/superusermeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/superusermeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (markdown_extensions . ["Prettify"]) - (related_sites . [((name . "Super User") - (site_url . "http://superuser.com") - (api_site_parameter . "superuser") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#0077CC") - (tag_foreground_color . "#000") - (tag_background_color . "#FFF"))) - ((site_type . "meta_site") - (name . "Meta Server Fault") - (logo_url . "http://cdn.sstatic.net/serverfaultmeta/img/logo.png") - (api_site_parameter . "meta.serverfault") - (site_url . "http://meta.serverfault.com") - (audience . "system administrators and IT professionals") - (icon_url . "http://cdn.sstatic.net/serverfaultmeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/serverfaultmeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/serverfaultmeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (related_sites . [((name . "Server Fault") - (site_url . "http://serverfault.com") - (api_site_parameter . "serverfault") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#0077CC") - (tag_foreground_color . "#000") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "Geographic Information Systems") - (logo_url . "http://cdn.sstatic.net/gis/img/logo-small.png") - (api_site_parameter . "gis") - (site_url . "http://gis.stackexchange.com") - (audience . "cartographers, geographers and GIS professionals") - (icon_url . "http://cdn.sstatic.net/gis/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/gis/img/favicon.ico") - (twitter_account . "StackGIS") - (high_resolution_icon_url . "http://cdn.sstatic.net/gis/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1279756800) - (open_beta_date . 1280361600) - (launch_date . 1299456000) - (markdown_extensions . ["Prettify"]) - (related_sites . [((name . "Geographic Information Systems Meta Stack Exchange") - (site_url . "http://meta.gis.stackexchange.com") - (api_site_parameter . "meta.gis") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#176F8C") - (tag_foreground_color . "#696969") - (tag_background_color . "#f5f5f5"))) - ((site_type . "meta_site") - (name . "Geographic Information Systems Meta") - (logo_url . "http://cdn.sstatic.net/gismeta/img/logo-small.png") - (api_site_parameter . "meta.gis") - (site_url . "http://meta.gis.stackexchange.com") - (audience . "cartographers, geographers and GIS professionals") - (icon_url . "http://cdn.sstatic.net/gismeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/gismeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/gismeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (related_sites . [((name . "Geographic Information Systems Stack Exchange") - (site_url . "http://gis.stackexchange.com") - (api_site_parameter . "gis") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#3D3D3D") - (tag_foreground_color . "#666666") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "TeX - LaTeX") - (logo_url . "http://cdn.sstatic.net/tex/img/logo.png") - (api_site_parameter . "tex") - (site_url . "http://tex.stackexchange.com") - (audience . "users of TeX, LaTeX, ConTeXt, and related typesetting systems") - (icon_url . "http://cdn.sstatic.net/tex/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/tex/img/favicon.ico") - (twitter_account . "StackTeX") - (high_resolution_icon_url . "http://cdn.sstatic.net/tex/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1280102400) - (open_beta_date . 1280707200) - (launch_date . 1289433600) - (markdown_extensions . ["Prettify"]) - (related_sites . [((name . "TeX - LaTeX Meta Stack Exchange") - (site_url . "http://meta.tex.stackexchange.com") - (api_site_parameter . "meta.tex") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#0077CC") - (tag_foreground_color . "#444444") - (tag_background_color . "#FEFEFA"))) - ((site_type . "meta_site") - (name . "TeX - LaTeX Meta") - (logo_url . "http://cdn.sstatic.net/texmeta/img/logo.png") - (api_site_parameter . "meta.tex") - (site_url . "http://meta.tex.stackexchange.com") - (audience . "users of TeX, LaTeX, ConTeXt, and related typesetting systems") - (icon_url . "http://cdn.sstatic.net/texmeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/texmeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/texmeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (related_sites . [((name . "TeX - LaTeX Stack Exchange") - (site_url . "http://tex.stackexchange.com") - (api_site_parameter . "tex") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#3D3D3D") - (tag_foreground_color . "#666666") - (tag_background_color . "#FFF"))) - ((site_type . "main_site") - (name . "Ask Ubuntu") - (logo_url . "http://cdn.sstatic.net/askubuntu/img/logo.png") - (api_site_parameter . "askubuntu") - (site_url . "http://askubuntu.com") - (audience . "Ubuntu users and developers") - (icon_url . "http://cdn.sstatic.net/askubuntu/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/askubuntu/img/favicon.ico") - (twitter_account . "AskUbuntu") - (high_resolution_icon_url . "http://cdn.sstatic.net/askubuntu/img/apple-touch-icon@2.png") - (site_state . "normal") - (closed_beta_date . 1280275200) - (open_beta_date . 1280880000) - (launch_date . 1286668800) - (markdown_extensions . ["Prettify"]) - (aliases . ["http://ubuntu.stackexchange.com"]) - (related_sites . [((name . "Ask Ubuntu Meta") - (site_url . "http://meta.askubuntu.com") - (api_site_parameter . "meta.askubuntu") - (relation . "meta")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#333333") - (tag_foreground_color . "#5E5E5E") - (tag_background_color . "#E8E7E5"))) - ((site_type . "meta_site") - (name . "Ask Ubuntu Meta") - (logo_url . "http://cdn.sstatic.net/askubuntumeta/img/logo.png") - (api_site_parameter . "meta.askubuntu") - (site_url . "http://meta.askubuntu.com") - (audience . "Ubuntu users and developers") - (icon_url . "http://cdn.sstatic.net/askubuntumeta/img/apple-touch-icon.png") - (favicon_url . "http://cdn.sstatic.net/askubuntumeta/img/favicon.ico") - (high_resolution_icon_url . "http://cdn.sstatic.net/askubuntumeta/img/apple-touch-icon@2.png") - (site_state . "linked_meta") - (aliases . ["http://meta.ubuntu.stackexchange.com"]) - (related_sites . [((name . "Ask Ubuntu") - (site_url . "http://askubuntu.com") - (api_site_parameter . "askubuntu") - (relation . "parent")) - ((name . "Chat Stack Exchange") - (site_url . "http://chat.stackexchange.com") - (relation . "chat"))]) - (styling - (link_color . "#222222") - (tag_foreground_color . "#5E5E5E") - (tag_background_color . "#E8E7E5")))] diff --git a/stack-core.el b/stack-core.el index cf7dde5..be385c3 100644 --- a/stack-core.el +++ b/stack-core.el @@ -211,12 +211,19 @@ entire response as a complex alist." (defun stack-core-filter-data (data desired-tree) "Filters DATA and returns the DESIRED-TREE" - (delq - nil - (mapcar (lambda (cons-cell) - (when (member (car cons-cell) desired-tree) - cons-cell)) - data))) + (if (vectorp data) + (mapcar (lambda (entry) + (stack-core-filter-data + entry desired-tree)) + data) + (delq + nil + (mapcar (lambda (cons-cell) + (when (member (car cons-cell) desired-tree) + (if (sequencep (cdr cons-cell)) + (stack-core-filter-data )) + cons-cell)) + data)))) (provide 'stack-core) ;;; stack-core.el ends here diff --git a/test/tests.el b/test/tests.el index e8452af..cbeb80d 100644 --- a/test/tests.el +++ b/test/tests.el @@ -5,6 +5,19 @@ (if (string-prefix-p "stack-" (symbol-name symbol)) (unintern symbol))))) +(defmacro stack-test-sample-data (method &optional directory) + (with-current-buffer + (find-file-noselect + (concat "data-samples/" + (when directory (concat directory "/")) + method ".el")) + (eval (read (buffer-string))))) + +(setq stack-test-data-questions + (stack-test-sample-data "questions") + stack-test-data-sites + (stack-test-sample-data "sites")) + ;;; Tests (setq stack-core-remaining-api-requests-message-threshold 50000) @@ -44,12 +57,14 @@ "Test the meta-convenience function -- complex structure" (should (equal - '([()]) - (stack-core-filter-data '((0 . 3) - (1 . t) - (a . five) - (2 . [1 2]) - ("5" . bop) - (3) - (p . 4)) - '(1 2 3))))) + '((1 . [a b c]) (2 . [(a . 1)]) (3 . peach)) + (stack-core-filter-data '((1 . [a b c]) + (2 . [(a . 1) + (b . 2)]) + (3 . peach) + (4 . banana)) + '(1 (2 a) 3))))) + +(ert-deftest test-data-filter-3 () + "Test the meta-convenience function -- vector structure" + (equal)) diff --git a/test/util.el b/test/util.el deleted file mode 100644 index 7d5937f..0000000 --- a/test/util.el +++ /dev/null @@ -1,12 +0,0 @@ -(defmacro stack-test-get-sample-data (method &optional directory) - (with-current-buffer - (find-file-noselect - (concat "data-samples/" - (when directory (concat directory "/")) - method ".el")) - (eval (read (buffer-string))))) - -(setq stack-test-data-questions - (stack-test-get-sample-data "questions") - stack-test-data-sites - (stack-test-get-sample-data "sites")) diff --git a/tests.el b/tests.el deleted file mode 100644 index 0c520d8..0000000 --- a/tests.el +++ /dev/null @@ -1,41 +0,0 @@ -(defun -stack--nuke () - (interactive) - (mapatoms - (lambda (symbol) - (if (string-prefix-p "stack-" (symbol-name symbol)) - (unintern symbol))))) - -;;; Tests - -(setq stack-core-remaining-api-requests-message-threshold 50000) -(setq debug-on-error t) - -(require 'stack-core) -(require 'stack-question) - -(ert-deftest test-basic-request () - "Test basic request functionality" - (should (stack-core-make-request "sites"))) - -(ert-deftest test-question-retrieve () - "Test the ability to receive a list of questions." - (should (stack-question-get-questions 'emacs))) - -(ert-deftest test-bad-request () - "Test a method given a bad set of keywords" - (should-error - (stack-core-make-request "questions" '(())))) - -(ert-deftest test-data-filter-1 () - "Test the meta-convenience function" - (should - (equal - '((1 . t) (2 . [1 2]) (3)) - (stack-core-filter-data '((0 . 3) - (1 . t) - (a . five) - (2 . [1 2]) - ("5" . bop) - (3) - (p . 4)) - '(1 2 3))))) -- cgit v1.2.3 From 8831556b94b9d2f5f80b14103947add2b562f5f9 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 1 Nov 2014 14:06:57 -0400 Subject: Fix syntax issue --- stack-core.el | 7 +++++-- test/tests.el | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index be385c3..ef0dc9f 100644 --- a/stack-core.el +++ b/stack-core.el @@ -220,8 +220,11 @@ entire response as a complex alist." nil (mapcar (lambda (cons-cell) (when (member (car cons-cell) desired-tree) - (if (sequencep (cdr cons-cell)) - (stack-core-filter-data )) + (if (and (sequencep (cdr cons-cell)) + (sequencep (elt (cdr cons-cell) 0))) + (stack-core-filter-data + (cdr cons-cell) + (cdr (assoc (car cons-cell) desired-tree)))) cons-cell)) data)))) diff --git a/test/tests.el b/test/tests.el index 0787705..d8a653b 100644 --- a/test/tests.el +++ b/test/tests.el @@ -68,7 +68,9 @@ (ert-deftest test-data-filter-3 () "Test the meta-convenience function -- vector structure" (equal - '(((1 . 2) (2 . 3) (3 . 4)) ((1 . a) (2 . b) (3 . c)) nil ((1 . alpha) (2 . beta))) + '(((1 . 2) (2 . 3) (3 . 4)) + ((1 . a) (2 . b) (3 . c)) + nil ((1 . alpha) (2 . beta))) (stack-core-filter-data [((1 . 2) (2 . 3) (3 . 4)) ((1 . a) (2 . b) (3 . c) (5 . seven)) ((should-not-go)) -- cgit v1.2.3 From 0943b14b1991b42ce838c5f2189af92bb62f6d96 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 1 Nov 2014 18:58:34 -0400 Subject: Return the correct type from filter Vectors should not be turning into lists. See test cases. --- stack-core.el | 42 ++++++++++++++++++++++++--------- test/tests.el | 75 +++++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 86 insertions(+), 31 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index ef0dc9f..37ae2af 100644 --- a/stack-core.el +++ b/stack-core.el @@ -212,21 +212,41 @@ entire response as a complex alist." (defun stack-core-filter-data (data desired-tree) "Filters DATA and returns the DESIRED-TREE" (if (vectorp data) - (mapcar (lambda (entry) - (stack-core-filter-data - entry desired-tree)) - data) + (apply #'vector + (mapcar (lambda (entry) + (stack-core-filter-data + entry desired-tree)) + data)) + (mapcar #'identity '(1 2 3)) (delq nil (mapcar (lambda (cons-cell) - (when (member (car cons-cell) desired-tree) - (if (and (sequencep (cdr cons-cell)) - (sequencep (elt (cdr cons-cell) 0))) - (stack-core-filter-data - (cdr cons-cell) - (cdr (assoc (car cons-cell) desired-tree)))) - cons-cell)) + (let ((f (stack-core-filter-data--item-in-tree + (car cons-cell) desired-tree))) + (when f + (if (and (sequencep (cdr cons-cell)) + (sequencep (elt (cdr cons-cell) 0))) + (cons (car cons-cell) + (stack-core-filter-data + (cdr cons-cell) (cdr f))) + cons-cell)))) data)))) +(defun stack-core-filter-data--item-in-tree (item tree) + "Check if ITEM is in the direct leaves of TREE + +For example, when called with (f 'item '(some item here)), the +return would be `t'. When called as (f 'item '(some (item here) +in a (deep structure))), `(item here)' would be returned. +" + (when tree + (if (equal item (car tree)) tree + (if (and (listp (car tree)) + (equal item (caar tree))) + (car tree) + (stack-core-filter-data--item-in-tree item (cdr tree)))))) + +(stack-core-filter-data--item-in-tree 'a '(b (a 1 b c) c)) + (provide 'stack-core) ;;; stack-core.el ends here diff --git a/test/tests.el b/test/tests.el index 59c3413..01d501c 100644 --- a/test/tests.el +++ b/test/tests.el @@ -41,8 +41,9 @@ (should-error (stack-core-make-request "questions" '(())))) -(ert-deftest test-data-filter-1 () - "Test the meta-convenience function -- flat structure" +(ert-deftest test-tree-filter () + "`stack-core-filter-data'" + ;; flat (should (equal '((1 . t) (2 . [1 2]) (3)) @@ -53,28 +54,62 @@ ("5" . bop) (3) (p . 4)) - '(1 2 3))))) - -(ert-deftest test-data-filter-2 () - "Test the meta-convenience function -- complex structure" + '(1 2 3)))) + ;; complex (should (equal - '((1 . [a b c]) (2 . [(a . 1)]) (3 . peach)) + '((1 . [a b c]) (2 . [((a . 1) (c . 3)) ((a . 4) (c . 6))]) (3 . peach)) (stack-core-filter-data '((1 . [a b c]) - (2 . [(a . 1) - (b . 2)]) + (2 . [((a . 1) + (b . 2) + (c . 3)) + ((a . 4) + (b . 5) + (c . 6))]) (3 . peach) (4 . banana)) - '(1 (2 a) 3))))) + '(1 (2 a c) 3)))) -(ert-deftest test-data-filter-3 () - "Test the meta-convenience function -- vector structure" - (equal - '(((1 . 2) (2 . 3) (3 . 4)) + ;; vector + (should + (equal + [((1 . 2) (2 . 3) (3 . 4)) ((1 . a) (2 . b) (3 . c)) - nil ((1 . alpha) (2 . beta))) - (stack-core-filter-data [((1 . 2) (2 . 3) (3 . 4)) - ((1 . a) (2 . b) (3 . c) (5 . seven)) - ((should-not-go)) - ((1 . alpha) (2 . beta))] - '(1 2 3)))) + nil ((1 . alpha) (2 . beta))] + (stack-core-filter-data [((1 . 2) (2 . 3) (3 . 4)) + ((1 . a) (2 . b) (3 . c) (5 . seven)) + ((should-not-go)) + ((1 . alpha) (2 . beta))] + '(1 2 3))))) + +(ert-deftest test-tree-member () + "`stack-core-filter-data--item-in-tree'" + (should + (equal + '(a b c) + (stack-core-filter-data--item-in-tree 'a '(a b c)))) + + (should + (equal + '(a b c) + (stack-core-filter-data--item-in-tree 'a '(b a b c)))) + + (should + (equal + '(a b c) + (stack-core-filter-data--item-in-tree 'a '((a b c) 1 2)))) + + (should + (equal + '(a b c) + (stack-core-filter-data--item-in-tree 'a '(1 (a b c) 2)))) + + (should + (equal + '(a b c) + (stack-core-filter-data--item-in-tree 'a '(1 2 (a b c))))) + + (should + (equal + '(a a b c) + (stack-core-filter-data--item-in-tree 'a '(1 (a a b c) 2))))) -- cgit v1.2.3 From d4bbee5d4e7d3cc11bc7cdf1101d50dfa63cf30b Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 1 Nov 2014 18:59:06 -0400 Subject: Introduce `stack-core-silent-requests' as default If this value is `t', requests will default to being silent. --- stack-core.el | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 37ae2af..b1657eb 100644 --- a/stack-core.el +++ b/stack-core.el @@ -92,6 +92,10 @@ recent call. Set by `stack-core-make-request'.") number, `stack-core-make-request' will begin printing out the number of requests left every time it finishes a call.") +(defcustom stack-core-silent-requests + t + "When `t', requests default to being silent.") + ;;; Keyword Arguments @@ -151,6 +155,7 @@ optional KEYWORD-ARGUMENTS. If no KEYWORD-ARGUMENTS are given, entire response as a complex alist." (let ((url-automatic-caching stack-core-cache-requests) (url-inhibit-uncompression t) + (silent (or silent stack-core-silent-requests)) (call (stack-core-build-request method -- cgit v1.2.3 From ed05bfa3f27043d00690323b991284442bda1b90 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 1 Nov 2014 19:18:15 -0400 Subject: Remove test cruft --- stack-core.el | 2 -- 1 file changed, 2 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index b1657eb..1094d11 100644 --- a/stack-core.el +++ b/stack-core.el @@ -251,7 +251,5 @@ in a (deep structure))), `(item here)' would be returned. (car tree) (stack-core-filter-data--item-in-tree item (cdr tree)))))) -(stack-core-filter-data--item-in-tree 'a '(b (a 1 b c) c)) - (provide 'stack-core) ;;; stack-core.el ends here -- cgit v1.2.3 From 6d6fe8e7b7f0bb99b2895fe53c811857ce65e275 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 1 Nov 2014 19:29:38 -0400 Subject: Kill test cruft --- stack-core.el | 1 - 1 file changed, 1 deletion(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 1094d11..45d7cb3 100644 --- a/stack-core.el +++ b/stack-core.el @@ -222,7 +222,6 @@ entire response as a complex alist." (stack-core-filter-data entry desired-tree)) data)) - (mapcar #'identity '(1 2 3)) (delq nil (mapcar (lambda (cons-cell) -- cgit v1.2.3 From 39ec0ba8a34b3764fcf46f0e5deb1133b0e70e2c Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 2 Nov 2014 08:55:53 -0500 Subject: Use a simpler construct to test filter inclusion Also removed tests for `stack-core-filter-data--item-in-tree' since it no longer exists. --- stack-core.el | 23 +++++++---------------- test/tests.el | 32 -------------------------------- 2 files changed, 7 insertions(+), 48 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 45d7cb3..9a535cd 100644 --- a/stack-core.el +++ b/stack-core.el @@ -225,8 +225,13 @@ entire response as a complex alist." (delq nil (mapcar (lambda (cons-cell) - (let ((f (stack-core-filter-data--item-in-tree - (car cons-cell) desired-tree))) + ;; TODO the resolution of `f' is O(2n) in the worst + ;; case. It may be faster to implement the same + ;; functionality as a `while' loop to stop looking the + ;; list once it has found a match. Do speed tests. + ;; See edfab4443ec3d376c31a38bef12d305838d3fa2e. + (let ((f (or (memq (car cons-cell) desired-tree) + (assoc (car cons-cell) desired-tree)))) (when f (if (and (sequencep (cdr cons-cell)) (sequencep (elt (cdr cons-cell) 0))) @@ -236,19 +241,5 @@ entire response as a complex alist." cons-cell)))) data)))) -(defun stack-core-filter-data--item-in-tree (item tree) - "Check if ITEM is in the direct leaves of TREE - -For example, when called with (f 'item '(some item here)), the -return would be `t'. When called as (f 'item '(some (item here) -in a (deep structure))), `(item here)' would be returned. -" - (when tree - (if (equal item (car tree)) tree - (if (and (listp (car tree)) - (equal item (caar tree))) - (car tree) - (stack-core-filter-data--item-in-tree item (cdr tree)))))) - (provide 'stack-core) ;;; stack-core.el ends here diff --git a/test/tests.el b/test/tests.el index ac40cea..44b0de0 100644 --- a/test/tests.el +++ b/test/tests.el @@ -75,35 +75,3 @@ ((should-not-go)) ((1 . alpha) (2 . beta))] '(1 2 3))))) - -(ert-deftest test-tree-member () - "`stack-core-filter-data--item-in-tree'" - (should - (equal - '(a b c) - (stack-core-filter-data--item-in-tree 'a '(a b c)))) - - (should - (equal - '(a b c) - (stack-core-filter-data--item-in-tree 'a '(b a b c)))) - - (should - (equal - '(a b c) - (stack-core-filter-data--item-in-tree 'a '((a b c) 1 2)))) - - (should - (equal - '(a b c) - (stack-core-filter-data--item-in-tree 'a '(1 (a b c) 2)))) - - (should - (equal - '(a b c) - (stack-core-filter-data--item-in-tree 'a '(1 2 (a b c))))) - - (should - (equal - '(a a b c) - (stack-core-filter-data--item-in-tree 'a '(1 (a a b c) 2))))) -- cgit v1.2.3 From e91752e2d2b6c631fd774823a10868c5d7e40d8a Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 2 Nov 2014 10:25:21 -0500 Subject: Add cache directory as a customizable variable --- stack-core.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 9a535cd..3391d14 100644 --- a/stack-core.el +++ b/stack-core.el @@ -44,6 +44,10 @@ ;;; Constants and Customizable Options +(defcustom stack-cache-directory + (expand-file-name ".stackmode" user-emacs-directory) + "Directory containined cached files and precompiled filters.") + (defconst stack-core-api-version "2.2" "The current version of the API.") -- cgit v1.2.3 From d273e792fbc1cc7238e156e24099d25ed0b3c53e Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 2 Nov 2014 11:13:41 -0500 Subject: Add function to retrieve cache files --- stack-core.el | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 3391d14..fde06a8 100644 --- a/stack-core.el +++ b/stack-core.el @@ -245,5 +245,14 @@ entire response as a complex alist." cons-cell)))) data)))) +(defun stack-cache-get-file (filename) + "Return a buffer for FILENAME from `stack-cache-directory'." + (let ((find-file-hook nil) + (file (expand-file-name filename stack-cache-directory))) + (unless (file-exists-p stack-cache-directory) + (mkdir stack-cache-directory)) + (unless (file-exists-p file) + (find-file-noselect file)))) + (provide 'stack-core) ;;; stack-core.el ends here -- cgit v1.2.3 From 434b71bb59ceea9c6cf93fcf3b6450b31426a260 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 2 Nov 2014 11:49:49 -0500 Subject: Convenience function for retrieving cache files This should be sorted somewhere... Maybe stack-cache.el needs to be its own file. --- stack-core.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index fde06a8..0d87f48 100644 --- a/stack-core.el +++ b/stack-core.el @@ -245,10 +245,14 @@ entire response as a complex alist." cons-cell)))) data)))) +(defun stack-cache-get-file-name (filename) + "Expands FILENAME in the context of `stack-cache-directory'." + (expand-file-name filename stack-cache-directory)) + (defun stack-cache-get-file (filename) "Return a buffer for FILENAME from `stack-cache-directory'." (let ((find-file-hook nil) - (file (expand-file-name filename stack-cache-directory))) + (file (stack-cache-get-file-name filename))) (unless (file-exists-p stack-cache-directory) (mkdir stack-cache-directory)) (unless (file-exists-p file) -- cgit v1.2.3 From a4adbdf59250807d5c1872df7f034029d6f44b08 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 2 Nov 2014 11:50:42 -0500 Subject: Fix return when file already exists --- stack-core.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 0d87f48..f9b9669 100644 --- a/stack-core.el +++ b/stack-core.el @@ -255,8 +255,7 @@ entire response as a complex alist." (file (stack-cache-get-file-name filename))) (unless (file-exists-p stack-cache-directory) (mkdir stack-cache-directory)) - (unless (file-exists-p file) - (find-file-noselect file)))) + (find-file-noselect file))) (provide 'stack-core) ;;; stack-core.el ends here -- cgit v1.2.3 From f349fe5d764730a0a339045a59a46d53b9a33100 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 2 Nov 2014 13:11:15 -0500 Subject: Implement and use `stack-cache-get' and `-set' --- stack-core.el | 30 +++++++++++++++++++++++------- stack-filter.el | 24 +++++++++--------------- 2 files changed, 32 insertions(+), 22 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index f9b9669..c2aff15 100644 --- a/stack-core.el +++ b/stack-core.el @@ -249,13 +249,29 @@ entire response as a complex alist." "Expands FILENAME in the context of `stack-cache-directory'." (expand-file-name filename stack-cache-directory)) -(defun stack-cache-get-file (filename) - "Return a buffer for FILENAME from `stack-cache-directory'." - (let ((find-file-hook nil) - (file (stack-cache-get-file-name filename))) - (unless (file-exists-p stack-cache-directory) - (mkdir stack-cache-directory)) - (find-file-noselect file))) +(defun stack-cache-get (cache) + "Return the data within CACHE. + +As with `stack-cache-set', CACHE is a file name within the +context of `stack-cache-directory'." + (unless (file-exists-p stack-cache-directory) + (mkdir stack-cache-directory)) + (let ((file (stack-cache-get-file-name cache))) + (when (file-exists-p file) + (with-temp-buffer + (insert-file-contents (stack-cache-get-file-name cache)) + (read (buffer-string)))))) + +(defun stack-cache-set (cache data) + "Set the content of CACHE to DATA. + +As with `stack-cache-get', CACHE is a file name within the +context of `stack-cache-directory'." + (unless (file-exists-p stack-cache-directory) + (mkdir stack-cache-directory)) + (write-region (prin1-to-string data) nil + (stack-cache-get-file-name cache)) + data) (provide 'stack-core) ;;; stack-core.el ends here diff --git a/stack-filter.el b/stack-filter.el index e5fb54d..91c4875 100644 --- a/stack-filter.el +++ b/stack-filter.el @@ -74,9 +74,7 @@ or string." (defun stack-filter-get (filter) "Retrieve named FILTER from `stack-filter-cache-file'." - (with-current-buffer (stack-cache-get-file stack-filter-cache-file) - (or (cdr (ignore-errors (assoc filter (read (buffer-string))))) - nil))) + (cdr (assoc filter (stack-cache-get stack-filter-cache-file)))) (defun stack-filter-store (name filter) "Store NAME as FILTER in `stack-filter-cache-file'. @@ -85,17 +83,12 @@ NAME should be a symbol and FILTER is a string as compiled by `stack-filter-compile'." (unless (symbolp name) (error "Name must be a symbol: %S" name)) - (with-current-buffer (stack-cache-get-file stack-filter-cache-file) - (let* ((dict (or (ignore-errors - (read (buffer-string))) - nil)) - (entry (assoc name dict))) - (if entry (setf (cdr entry) filter) - (setq dict (cons (cons name filter) dict))) - (erase-buffer) - (insert (prin1-to-string dict)) - (save-buffer) - dict))) + (let* ((dict (stack-cache-get stack-filter-cache-file)) + (entry (assoc name dict))) + (if entry (setcdr entry filter) + (setq dict (cons (cons name filter) dict))) + + (stack-cache-set stack-filter-cache-file dict))) ;;; TODO tail recursion should be made more efficient for the ;;; byte-compiler @@ -104,7 +97,8 @@ NAME should be a symbol and FILTER is a string as compiled by (stack-filter-store (caar name-filter-alist) (cdar name-filter-alist)) - (stack-filter-store-all (cdr name-filter-alist)))) + (stack-filter-store-all + (cdr name-filter-alist)))) (provide 'stack-filter) ;;; stack-filter.el ends here -- cgit v1.2.3