Get current paragraph text when point at start of paragraph in khoj.el

Previously if cursor was at start of current paragraph, it would get
text for the current and next paragraph, instead of just the current one
This commit is contained in:
Debanjum Singh Solanky 2023-01-23 18:02:47 -03:00
parent a0b03c8bb1
commit 07e9e4ecc3

View file

@ -417,10 +417,16 @@ Use `which-key` if available, else display simple message in echo area"
;; trim trailing whitespaces from text
(replace-regexp-in-string
"[ \t\n]*$" ""
;; get text of current entry
(buffer-substring-no-properties
(save-excursion (backward-paragraph) (point))
(save-excursion (forward-paragraph) (point)))))))
(cond
;; when at beginning of a middle paragraph
((and (looking-at paragraph-start) (not (equal (point) (point-min))))
(buffer-substring-no-properties
(save-excursion (backward-paragraph) (point))
(point)))
;; else
(t (buffer-substring-no-properties
(save-excursion (backward-paragraph) (point))
(save-excursion (forward-paragraph) (point)))))))))
(defun khoj--find-similar (&optional content-type)
"Find items of CONTENT-TYPE in khoj index similar to text surrounding point."