From c151212966039601193f99698536e9284c98073c Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 2 Mar 2015 21:31:09 -0300 Subject: Set json-array-type to 'list and perform many simplifications due to usage of lists instead of vectors --- sx-interaction.el | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 368da09..cd8b5a0 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -264,7 +264,7 @@ changes." (sx-method-post-from-data data (concat type (unless status "/undo"))))) ;; The api returns the new DATA. - (when (> (length result) 0) + (when result (sx--copy-data (elt result 0) data) ;; Display the changes in `data'. (sx--maybe-update-display)))) @@ -326,7 +326,7 @@ TEXT is a string. Interactively, it is read from the minibufer." :site .site_par :keywords `((body . ,text))))) ;; The api returns the new DATA. - (when (> (length result) 0) + (when result (sx--add-comment-to-object (sx--ensure-owner-in-object (list (cons 'display_name "(You)")) (elt result 0)) (if .post_id (sx--get-post .post_type .site_par .post_id) data)) @@ -372,11 +372,8 @@ OBJECT can be a question or an answer." (progn (setcdr com-cell - (apply #'vector - (append - (cl-map 'list #'identity - (cdr com-cell)) - (list comment))))) + (append (cdr com-cell) + (list comment)))) ;; No previous comments, add it manually. (setcdr object (cons (car object) (cdr object))) (setcar object `(comments . [,comment])))) @@ -478,8 +475,7 @@ context at point. " "Add alist ANSWER to alist QUESTION in the right place." (let ((cell (assoc 'answers question))) (if cell - (setcdr cell (apply #'vector - (append (cdr cell) (list answer)))) + (setcdr cell (append (cdr cell) (list answer))) ;; No previous comments, add it manually. (setcdr question (cons (car question) (cdr question))) (setcar question `(answers . [,answer]))) -- cgit v1.2.3 From c00ed8c6bbd8e948a3142c71b3bbb3ab86c04959 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 2 Mar 2015 23:06:27 -0300 Subject: Fix a few leftover vectors --- sx-interaction.el | 4 ++-- sx-request.el | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index cd8b5a0..09fd270 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -376,7 +376,7 @@ OBJECT can be a question or an answer." (list comment)))) ;; No previous comments, add it manually. (setcdr object (cons (car object) (cdr object))) - (setcar object `(comments . [,comment])))) + (setcar object `(comments . (,comment))))) object) (defun sx--ensure-owner-in-object (owner object) @@ -478,7 +478,7 @@ context at point. " (setcdr cell (append (cdr cell) (list answer))) ;; No previous comments, add it manually. (setcdr question (cons (car question) (cdr question))) - (setcar question `(answers . [,answer]))) + (setcar question `(answers . (,answer)))) question)) (provide 'sx-interaction) diff --git a/sx-request.el b/sx-request.el index 546ae94..4914705 100644 --- a/sx-request.el +++ b/sx-request.el @@ -112,7 +112,7 @@ access the response wrapper." ;; @TODO: Refactor. This is the product of a late-night jam ;; session... it is not intended to be model code. (declare (indent 1)) - (let* ((return-value []) + (let* ((return-value nil) (current-page 1) (stop-when (or stop-when #'sx-request-all-stop-when-no-more)) (process-function #'identity) @@ -122,14 +122,14 @@ access the response wrapper." (while (not (funcall stop-when response)) (setq current-page (1+ current-page) return-value - (vconcat return-value - (cdr (assoc 'items response)))) + (nconc return-value + (cdr (assoc 'items response)))) (sleep-for sx-request-all-items-delay) (setq response (sx-request-make method `((page . ,current-page) ,@args) request-method process-function))) - (vconcat return-value - (cdr (assoc 'items response))))) + (nconc return-value + (cdr (assoc 'items response))))) ;;; NOTE: Whenever this is arglist changes, `sx-request-fallback' must ;;; also change. -- cgit v1.2.3