From e8a8a700a45c87c91c1a42d66386b0eee03a536c Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 23 Aug 2012 09:21:47 +0200 Subject: Add raw option to avandu--send-command-sync This is useful for functions that need to check something outside of the "content" list of the result. Probably all of them should though. * avandu.el (avandu--send-command-sync): New parameter: raw. Return the content part of the results if RAW is nil, otherwise return the results onmodified. (avandu-login): Pass a RAW argument to `avandu--send-command-sync'. --- avandu.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'avandu.el') diff --git a/avandu.el b/avandu.el index 78a7b6a..ec10823 100644 --- a/avandu.el +++ b/avandu.el @@ -368,7 +368,7 @@ FUNC should be a callback function as defined by (unless (url-retrieve avandu-tt-rss-api-url func) (message "Complete.")))) -(defun avandu--send-command-sync (data) +(defun avandu--send-command-sync (data &optional raw) "Send a command with parameters DATA to tt-rss. The current session-id is added to the request and then DATA is passed on to `json-encode'. @@ -378,8 +378,9 @@ For example: (avandu--send-command-sync '((op . \"isLoggedIn\"))) -This function returns the result of `json-read' passed over the -returned json." +This function returns the content part of the result of +`json-read' passed over the returned json, unless RAW is non-nil, +in which case the result is returned as-is." (let* ((url-request-data (avandu--prep-params data)) (url-request-method "POST") (buffer (url-retrieve-synchronously avandu-tt-rss-api-url)) @@ -389,7 +390,9 @@ returned json." (search-forward "\n\n") (setq result (json-read))) (kill-buffer buffer) - (avu-prop result content))) + (if (not raw) + (avu-prop result content) + result))) (defun avandu-categories (&optional unread) "Get the created categories. If UNREAD is non-nil only get @@ -554,7 +557,7 @@ otherwise." (let ((result (avandu--send-command-sync `((op . "login") (user . ,avandu-user) - (password . ,(avandu--password)))))) + (password . ,(avandu--password))) t))) (if (eq (avandu--get-status-id result) 0) (progn (setq avandu--session-id (avandu--get-session-id result)) -- cgit v1.2.3-54-g00ecf