From 5db08c529399a17d0889c6778d5964dea79d3efa Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 29 Sep 2021 13:30:15 -0700 Subject: [PATCH] Set query as heading of notes search results in Emacs Org buffer --- src/interface/emacs/semantic-search.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/interface/emacs/semantic-search.el b/src/interface/emacs/semantic-search.el index 8c7ae5bc..0b961262 100644 --- a/src/interface/emacs/semantic-search.el +++ b/src/interface/emacs/semantic-search.el @@ -45,13 +45,14 @@ :group 'semantic-search :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" ;; remove leading (, ) or SPC from extracted entries string (replace-regexp-in-string "^[\(\) ]" "" ;; extract entries from response as single string and convert to entries - (format "%s" + (format "* %s\n%s" + query (mapcar (lambda (args) (format "%s" (cdr (assoc 'Entry args)))) json-response)))) @@ -110,7 +111,7 @@ (json-response (json-parse-buffer :object-type 'alist))) (erase-buffer) (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 "image") (semantic-search--extract-entries-as-images json-response query)) (t (format "%s" json-response)))))