From fdb60a8dcf35e6602fd9c9d9bb9f876c8370b0ee Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 16 Sep 2021 12:28:05 -0700 Subject: [PATCH] Set Query as Heading of Image Search Results Emacs 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 d32de7e4..8c7ae5bc 100644 --- a/src/interface/emacs/semantic-search.el +++ b/src/interface/emacs/semantic-search.el @@ -56,13 +56,14 @@ (lambda (args) (format "%s" (cdr (assoc 'Entry args)))) json-response)))) -(defun semantic-search--extract-entries-as-images (json-response) +(defun semantic-search--extract-entries-as-images (json-response query) "Convert json response from API to org-mode entries with images" ;; remove leading (, ) or SPC from extracted entries string (replace-regexp-in-string "^[\(\) ]" "" ;; extract entries from response as single string and convert to entries - (format "* Results \n%s" + (format "* %s \n%s" + query (mapcar (lambda (args) (format "\n** \n [[%s]]" (cdr (assoc 'Entry args)))) json-response)))) @@ -111,7 +112,7 @@ (insert (cond ((or (equal search-type "notes") (equal search-type "music")) (semantic-search--extract-entries-as-org 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)) + ((equal search-type "image") (semantic-search--extract-entries-as-images json-response query)) (t (format "%s" json-response))))) (cond ((equal search-type "notes") (org-mode)) ((equal search-type "music") (progn (org-mode)