From 9b935d195debde2772682f9308cbf3e833d859d7 Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Sat, 13 Jun 2015 23:41:54 +0200 Subject: [PATCH] refactor helm-dash-search --- helm-dash.el | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/helm-dash.el b/helm-dash.el index 1e0af82..ffd3044 100644 --- a/helm-dash.el +++ b/helm-dash.el @@ -330,24 +330,21 @@ Ex: This avoids searching for redis in redis unless you type 'redis redis'" (defun helm-dash-search () "Iterates every `helm-dash-connections' looking for the `helm-pattern'." - (let ((full-res (list)) - (connections (helm-dash-maybe-narrow-docsets helm-pattern))) - - (dolist (docset connections) - (let* ((docset-type (cl-caddr docset)) - (res - (helm-dash-sql - (cadr docset) - (helm-dash-sql-execute 'select - docset-type - (helm-dash-sub-docset-name-in-pattern helm-pattern (car docset)))))) - ;; how to do the appending properly? - (setq full-res - (append full-res - (mapcar (lambda (x) - (cons (format "%s %s" (car docset) (cadr x)) (list (car docset) x))) - res))))) - full-res)) + (let ((connections (helm-dash-maybe-narrow-docsets helm-pattern))) + (cl-loop for docset in connections + append (cl-loop for row in (helm-dash--run-query docset) + collect (helm-dash--candidate docset row))))) + +(defun helm-dash--run-query (docset) + (let ((docset-type (cl-caddr docset))) + (helm-dash-sql + (cadr docset) + (helm-dash-sql-execute 'select + docset-type + (helm-dash-sub-docset-name-in-pattern helm-pattern (car docset)))))) + +(defun helm-dash--candidate (docset x) + (cons (format "%s %s" (car docset) (cadr x)) (list (car docset) x))) (defun helm-dash-result-url (docset-name filename &optional anchor) "Return the full, absolute URL to documentation: either a file:// URL joining