diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2015-08-20 16:47:03 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2015-08-20 16:47:03 +0200 |
commit | 0e3e2ef186be5813a51c8151eb23fc4a9e50f930 (patch) | |
tree | 986c04694022453985fdd53aa33246f00b1949bc /helm-net.el | |
parent | e4ffc0633508f51beaf32c1c7404cd7751202ffb (diff) |
Don't use default parser in helm-net--url-retrieve-sync.
* helm-net.el (helm-net--url-retrieve-sync): Do it. No optional arg now.
(helm-google-suggest-parser): New.
(helm-google-suggest-fetch): Use it.
Diffstat (limited to 'helm-net.el')
-rw-r--r-- | helm-net.el | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/helm-net.el b/helm-net.el index 2b3dae3c..d3b72736 100644 --- a/helm-net.el +++ b/helm-net.el @@ -162,33 +162,33 @@ This is a format string, don't forget the `%s'." candidate)))) "List of additional actions for suggest sources.") -(defun helm-net--url-retrieve-sync (request &optional parser) - (let ((fetch (or parser - (lambda () - (cl-loop - with result-alist = (xml-get-children - (car (xml-parse-region - (point-min) (point-max))) - 'CompleteSuggestion) - for i in result-alist collect - (cdr (cl-caadr (assoc 'suggestion i)))))))) - (if helm-net-prefer-curl - (with-temp-buffer - (call-process "curl" nil t nil request) - (funcall fetch)) - (with-current-buffer - (url-retrieve-synchronously request) - (funcall fetch))))) +(defun helm-net--url-retrieve-sync (request parser) + (if helm-net-prefer-curl + (with-temp-buffer + (call-process "curl" nil t nil request) + (funcall parser)) + (with-current-buffer (url-retrieve-synchronously request) + (funcall parser)))) ;;; Google Suggestions ;; ;; +(defun helm-google-suggest-parser () + (cl-loop + with result-alist = (xml-get-children + (car (xml-parse-region + (point-min) (point-max))) + 'CompleteSuggestion) + for i in result-alist collect + (cdr (cl-caadr (assoc 'suggestion i))))) + (defun helm-google-suggest-fetch (input) "Fetch suggestions for INPUT from XML buffer." (let ((request (concat helm-google-suggest-url (url-hexify-string input)))) - (helm-net--url-retrieve-sync request))) + (helm-net--url-retrieve-sync + request #'helm-google-suggest-parser))) (defun helm-google-suggest-set-candidates (&optional request-prefix) "Set candidates with result and number of google results found." |