From 6dc9801f45a6fe412b02e10c5f26f44b639e30a3 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sun, 7 Aug 2022 17:28:43 +0300 Subject: [PATCH] Get Khoj search-types enabled by user in Emacs --- src/interface/emacs/khoj.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/interface/emacs/khoj.el b/src/interface/emacs/khoj.el index 12e64918..6289060c 100644 --- a/src/interface/emacs/khoj.el +++ b/src/interface/emacs/khoj.el @@ -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") (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) (let ((rerank (or rerank "false")) (results-count (or khoj--results-count 5))