From a0b03c8bb185a157400fdc7205bce2471fd63d10 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 23 Jan 2023 10:01:25 -0300 Subject: [PATCH] Get current entry text when point at heading for Find Similar in khoj.el Previously if cursor was at heading of current entry, it would find entries similar to the previous outline heading, instead of the current one --- src/interface/emacs/khoj.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/interface/emacs/khoj.el b/src/interface/emacs/khoj.el index f515f9a4..a138c4ac 100644 --- a/src/interface/emacs/khoj.el +++ b/src/interface/emacs/khoj.el @@ -395,9 +395,16 @@ Use `which-key` if available, else display simple message in echo area" (replace-regexp-in-string "[ \t\n]*$" "" ;; get text of current outline entry - (buffer-substring-no-properties - (save-excursion (outline-previous-heading) (point)) - (save-excursion (outline-next-heading) (point))))))) + (cond + ;; when at heading of entry + ((looking-at outline-regexp) + (buffer-substring-no-properties + (point) + (save-excursion (outline-next-heading) (point)))) + ;; when within entry + (t (buffer-substring-no-properties + (save-excursion (outline-previous-heading) (point)) + (save-excursion (outline-next-heading) (point))))))))) (defun khoj--get-current-paragraph-text () "Get text in current paragraph at point."