closes window on buffer close
This commit is contained in:
parent
309fa4ec99
commit
865918293a
|
|
@ -11,10 +11,13 @@
|
||||||
|
|
||||||
(require 'ellama)
|
(require 'ellama)
|
||||||
|
|
||||||
|
(defvar ellama-capture-buffer-name "*Ellama Input*"
|
||||||
|
"Name of the buffer used for Ellama input capture.")
|
||||||
|
|
||||||
(defun ellama-capture ()
|
(defun ellama-capture ()
|
||||||
"Create a temporary pop-up buffer for Ellama input."
|
"Create a temporary pop-up buffer for Ellama input with context-adding capabilities."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((buf (get-buffer-create "*Ellama Input*")))
|
(let ((buf (get-buffer-create ellama-capture-buffer-name)))
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(text-mode)
|
(text-mode)
|
||||||
|
|
@ -23,23 +26,29 @@
|
||||||
(local-set-key (kbd "C-c C-k") 'ellama-capture-abort)
|
(local-set-key (kbd "C-c C-k") 'ellama-capture-abort)
|
||||||
(local-set-key (kbd "C-c f") 'ellama-context-add-file)
|
(local-set-key (kbd "C-c f") 'ellama-context-add-file)
|
||||||
(local-set-key (kbd "C-c i") 'ellama-context-add-info-node)
|
(local-set-key (kbd "C-c i") 'ellama-context-add-info-node)
|
||||||
(setq header-line-format
|
(setq header-line-format
|
||||||
(substitute-command-keys
|
(substitute-command-keys
|
||||||
"(ellama-capture) C-c C-c: send, C-c C-k: abort, C-c f: add file, C-c i: add info node")))
|
"C-c C-c: send, C-c C-k: abort, C-c f: add file, C-c i: add info node")))
|
||||||
(pop-to-buffer buf)
|
(let ((display-buffer-alist
|
||||||
|
`(((lambda (buffer-name _) (equal buffer-name ,ellama-capture-buffer-name))
|
||||||
|
(display-buffer-in-side-window)
|
||||||
|
(side . bottom)
|
||||||
|
(slot . 0)
|
||||||
|
(window-height . 0.3)))))
|
||||||
|
(pop-to-buffer buf))
|
||||||
(message "Type your message, then use the commands shown in the header line")))
|
(message "Type your message, then use the commands shown in the header line")))
|
||||||
|
|
||||||
(defun ellama-capture-finalize ()
|
(defun ellama-capture-finalize ()
|
||||||
"Send the content of the Ellama input buffer to Ellama and kill the buffer."
|
"Send the content of the Ellama input buffer to Ellama and close the window."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((content (buffer-string)))
|
(let ((content (buffer-string)))
|
||||||
(kill-buffer (current-buffer))
|
(quit-window t)
|
||||||
(ellama-chat content)))
|
(ellama-chat content)))
|
||||||
|
|
||||||
(defun ellama-capture-abort ()
|
(defun ellama-capture-abort ()
|
||||||
"Kill the Ellama input buffer without sending its content."
|
"Kill the Ellama input buffer without sending its content."
|
||||||
(interactive)
|
(interactive)
|
||||||
(kill-buffer (current-buffer))
|
(quit-window t)
|
||||||
(message "Ellama input aborted"))
|
(message "Ellama input aborted"))
|
||||||
|
|
||||||
(global-set-key (kbd "C-x A e SPC") #'ellama-capture)
|
(global-set-key (kbd "C-x A e SPC") #'ellama-capture)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue