Allow updating khoj content index from within khoj.el

- Split transient config menu by type
This commit is contained in:
Debanjum Singh Solanky 2023-01-18 23:07:59 -03:00
parent a8d0c7d905
commit 9d64a009fd

View file

@ -373,13 +373,28 @@ Render results in BUFFER-NAME."
;; trigger incremental search
(call-interactively #'khoj-incremental)))
(transient-define-suffix khoj--update (&optional args)
(interactive (list (transient-args transient-current-command)))
(let* ((force-update (if (member "--force-update" args) "true" "false"))
(content-type (or (transient-arg-value "--content-type=" args) (khoj--buffer-name-to-content-type (buffer-name))))
(config-url (format "%s/api/update?t=%s&force=%s" khoj-server-url content-type force-update))
(url-request-method "GET"))
;; Call khoj API to update content type
(url-retrieve
config-url
(lambda (_) (message "Khoj %s index %supdated!" content-type (if (member "--force-update" args) "force " ""))))))
;;;###autoload
(transient-define-prefix khoj ()
[["Set"
("t" "Content Type" khoj--content-type-switch)
("n" "Results Count" "--results-count=" :init-value (lambda (obj) (oset obj value (format "%s" khoj-results-count))))]]
[["Act" ("s" "Search" khoj--search)]])
("t" "Content Type" khoj--content-type-switch)]
["Set Search"
("n" "Results Count" "--results-count=" :init-value (lambda (obj) (oset obj value (format "%s" khoj-results-count))))]
["Set Update"
("-f" "Force Update" "--force-update")]]
[["Act"
("s" "Search" khoj--search)
("u" "Update" khoj--update)]])
;;;###autoload
(defun khoj-simple (query)