Style Khoj chat directly via elisp instead of via in-buffer settings

This commit is contained in:
Debanjum Singh Solanky 2023-03-26 06:03:30 +07:00
parent f6ff7b1beb
commit 4f655d20ae

View file

@ -351,9 +351,7 @@ Render results in BUFFER-NAME using QUERY, CONTENT-TYPE."
(let ((json-response (cdr (assoc 'response (khoj--query-chat-api ""))))) (let ((json-response (cdr (assoc 'response (khoj--query-chat-api "")))))
(with-current-buffer (get-buffer-create buffer-name) (with-current-buffer (get-buffer-create buffer-name)
(erase-buffer) (erase-buffer)
(insert "#+STARTUP: showall hidestars\n") (insert "* Khoj Chat\n")
;; allow sub, superscript text within {} for footnotes
(insert "#+OPTIONS: ^:{}\n")
(thread-last (thread-last
json-response json-response
;; generate chat messages from Khoj Chat API response ;; generate chat messages from Khoj Chat API response
@ -361,21 +359,24 @@ Render results in BUFFER-NAME using QUERY, CONTENT-TYPE."
;; insert chat messages into Khoj Chat Buffer ;; insert chat messages into Khoj Chat Buffer
(mapc #'insert)) (mapc #'insert))
(progn (progn
(org-mode)
(khoj--add-hover-text-to-footnote-refs (point-min)) (khoj--add-hover-text-to-footnote-refs (point-min))
;; render reference footnotes as superscript ;; render reference footnotes as superscript
(setq-local (setq-local
org-startup-folded "showall"
org-hide-leading-stars t
org-use-sub-superscripts '{} org-use-sub-superscripts '{}
org-pretty-entities-include-sub-superscripts t org-pretty-entities-include-sub-superscripts t
org-pretty-entities t) org-pretty-entities t)
(org-set-startup-visibility)
;; create khoj chat shortcut keybindings ;; create khoj chat shortcut keybindings
(use-local-map (copy-keymap org-mode-map)) (use-local-map (copy-keymap org-mode-map))
(local-set-key (kbd "m") #'khoj--chat) (local-set-key (kbd "m") #'khoj--chat)
(local-set-key (kbd "C-x m") #'khoj--chat) (local-set-key (kbd "C-x m") #'khoj--chat)
;; enable appropriate khoj chat major, minor modes ;; enable minor modes for khoj chat
(org-mode)
(visual-line-mode) (visual-line-mode)
(read-only-mode t))))) (read-only-mode t)))))