mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 19:03:01 +01:00
Set query as heading of notes search results in Emacs Org buffer
This commit is contained in:
parent
150593c776
commit
5db08c5293
1 changed files with 4 additions and 3 deletions
|
@ -45,13 +45,14 @@
|
||||||
:group 'semantic-search
|
:group 'semantic-search
|
||||||
:type 'integer)
|
:type 'integer)
|
||||||
|
|
||||||
(defun semantic-search--extract-entries-as-org (json-response)
|
(defun semantic-search--extract-entries-as-org (json-response query)
|
||||||
"Convert json response from API to org-mode entries"
|
"Convert json response from API to org-mode entries"
|
||||||
;; remove leading (, ) or SPC from extracted entries string
|
;; remove leading (, ) or SPC from extracted entries string
|
||||||
(replace-regexp-in-string
|
(replace-regexp-in-string
|
||||||
"^[\(\) ]" ""
|
"^[\(\) ]" ""
|
||||||
;; extract entries from response as single string and convert to entries
|
;; extract entries from response as single string and convert to entries
|
||||||
(format "%s"
|
(format "* %s\n%s"
|
||||||
|
query
|
||||||
(mapcar
|
(mapcar
|
||||||
(lambda (args) (format "%s" (cdr (assoc 'Entry args))))
|
(lambda (args) (format "%s" (cdr (assoc 'Entry args))))
|
||||||
json-response))))
|
json-response))))
|
||||||
|
@ -110,7 +111,7 @@
|
||||||
(json-response (json-parse-buffer :object-type 'alist)))
|
(json-response (json-parse-buffer :object-type 'alist)))
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(insert
|
(insert
|
||||||
(cond ((or (equal search-type "notes") (equal search-type "music")) (semantic-search--extract-entries-as-org json-response))
|
(cond ((or (equal search-type "notes") (equal search-type "music")) (semantic-search--extract-entries-as-org json-response query))
|
||||||
((equal search-type "ledger") (semantic-search--extract-entries-as-ledger json-response))
|
((equal search-type "ledger") (semantic-search--extract-entries-as-ledger json-response))
|
||||||
((equal search-type "image") (semantic-search--extract-entries-as-images json-response query))
|
((equal search-type "image") (semantic-search--extract-entries-as-images json-response query))
|
||||||
(t (format "%s" json-response)))))
|
(t (format "%s" json-response)))))
|
||||||
|
|
Loading…
Reference in a new issue