Skip to content

Commit

Permalink
Display re-ranked results triggered via keybinding in khoj.el
Browse files Browse the repository at this point in the history
- Prevent immediate overwrite of re-ranked results by
  incremental-search without rerank triggered via post-command-hook.

- This triggers right after the reranking results are rendered, so
  user never ends up seeing them
  • Loading branch information
debanjum committed Aug 15, 2022
1 parent 7421ef2 commit 2647e6b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/interface/emacs/khoj.el
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
(when (member 'music enabled-content-types)
"C-x M | music\n"))))

(defvar khoj--rerank nil "Track when re-rank of results triggered")
(defun khoj--search-markdown () "Set search-type to 'markdown'." (interactive) (setq khoj--search-type "markdown"))
(defun khoj--search-org () "Set search-type to 'org-mode'." (interactive) (setq khoj--search-type "org"))
(defun khoj--search-ledger () "Set search-type to 'ledger'." (interactive) (setq khoj--search-type "ledger"))
Expand Down Expand Up @@ -285,15 +286,24 @@ Render results in BUFFER-NAME."
;; 1. user hasn't started typing query
;; 2. during recursive edits
;; 3. with contents of other buffers user may jump to
(when (and (not (equal query "")) (active-minibuffer-window) (equal (current-buffer) khoj--minibuffer-window))
;; 4. search not triggered right after rerank
;; ignore to not overwrite reranked results before the user even sees them
(if khoj--rerank
(setq khoj--rerank nil)
(when
(and
(not (equal query ""))
(active-minibuffer-window)
(equal (current-buffer) khoj--minibuffer-window))
(progn
(when rerank
(setq khoj--rerank t)
(message "Khoj: Rerank Results"))
(khoj--query-api-and-render-results
query
khoj--search-type
query-url
khoj-buffer-name)))))
khoj-buffer-name))))))

(defun khoj--delete-open-network-connections-to-server ()
"Delete all network connections to khoj server."
Expand Down

0 comments on commit 2647e6b

Please sign in to comment.