;;
(defun tracker-sparql (sparql-query)
(start-process "tracker-sparql" "tracker-sparql" "tracker" "sparql" "-q" sparql-query)
(switch-to-buffer-other-frame "tracker-sparql")
)
(defun tracker (search-term)
(interactive "sFulltext Search String: ")
(tracker-sparql (concat "SELECT nie:url(?f) WHERE { ?f fts:match '"
search-term
"' }")
)
)
(require 'dbus)
(defun tracker-dbus-async (search-terms)
(interactive "sFulltext Search String: ")
;; mapcar 'car --> mapcar 'url-file-truename --> dired cons
(defun tracker-results-process (search-terms results)
(dired (cons
(concat "Tracker Search: " search-terms)
(mapcar (lambda (x) (url-file-truename (car x))) results)
))
)
(fset 'tracker-results-process-fix-search-terms
(apply-partially 'tracker-results-process search-terms))
(let ((search-query (concat "SELECT nie:url(?f) WHERE {
?f a nfo:Document . ?f fts:match '" search-terms "'
} ORDER BY
DESC (fts:rank(?f))")))
;; search-query
(dbus-call-method-asynchronously
:session "org.freedesktop.Tracker1"
"/org/freedesktop/Tracker1/Resources"
"org.freedesktop.Tracker1.Resources"
"SparqlQuery"
'tracker-results-process-fix-search-terms
search-query
)
)
)
Calling tracker sparql query via D-Bus Asynchronous and showing the results in a dired buffer
Vishal Belsare
- 171
- 5