Get Khoj search-types enabled by user in Emacs

This commit is contained in:
Debanjum Singh Solanky 2022-08-07 17:28:43 +03:00
parent f3c1512c38
commit 6dc9801f45

View file

@ -180,6 +180,20 @@ Use `which-key` if available, else display simple message in echo area"
((or (equal file-extension "markdown") (equal file-extension "md")) "markdown") ((or (equal file-extension "markdown") (equal file-extension "md")) "markdown")
(t "org")))) (t "org"))))
(defun khoj--get-enabled-search-types ()
(let ((config-url (format "%s/config/data" khoj--server-url)))
(with-temp-buffer
(erase-buffer)
(url-insert-file-contents config-url)
(let* ((json-response (json-parse-buffer :object-type 'alist))
(content-type (cdr (assoc 'content-type json-response))))
;; return content-type items with configuration
(mapcar
'car
(cl-remove-if-not
'(lambda (a) (not (eq (cdr a) :null)))
content-type))))))
(defun khoj--construct-api-query (query search-type &optional rerank) (defun khoj--construct-api-query (query search-type &optional rerank)
(let ((rerank (or rerank "false")) (let ((rerank (or rerank "false"))
(results-count (or khoj--results-count 5)) (results-count (or khoj--results-count 5))