@@ -252,8 +252,13 @@ The data is consist of ROLE and CONTENT."
252252 (let-alist message
253253 (goto-char (point-max ))
254254 (let* ((start (point ))
255+ (is-user (string= (chatgpt-user) .role))
255256 (role (format " <%s >: " .role))
256- (content (chatgpt--render-markdown .content)))
257+ ; ; XXX: If messages from user, don't try to render to markdown!
258+ ; ; else, messages from OpenAI will most likely going to be
259+ ; ; markdown so we render it!
260+ (content (if is-user .content
261+ (chatgpt--render-markdown .content))))
257262 (add-face-text-property 0 (length role) 'chatgpt-user nil role)
258263 (insert role " " content)
259264 (insert " \n\n " )
@@ -329,7 +334,6 @@ The data is consist of ROLE and CONTENT."
329334(defun chatgpt-input-send ()
330335 " Send the input."
331336 (interactive )
332- (user-error " fuk" )
333337 (cond
334338 ((not (eq major-mode #'chatgpt-input-mode )) ) ; does nothing
335339 (chatgpt-requesting-p
@@ -409,8 +413,18 @@ The data is consist of ROLE and CONTENT."
409413; ;; Entry
410414
411415(defun chatgpt-mode--kill-buffer-hook ()
412- " "
416+ " Kill buffer hook."
417+ (let ((instance chatgpt-instances))
418+ (when (get-buffer chatgpt-input-buffer-name)
419+ (with-current-buffer chatgpt-input-buffer-name
420+ ; ; kill input if it's the right session
421+ (when (equal instance chatgpt-instances)
422+ (kill-this-buffer ))))))
423+
424+ (defun chatgpt-header-line ()
425+ " The display for header line."
413426 ; ; TODO: ..
427+ " "
414428 )
415429
416430(defvar chatgpt-mode-map
@@ -426,7 +440,8 @@ The data is consist of ROLE and CONTENT."
426440\\ <chatgpt-mode-map>"
427441 (setq-local buffer-read-only t )
428442 (font-lock-mode -1 )
429- (add-hook 'kill-buffer-hook #'chatgpt-mode--kill-buffer-hook nil t ))
443+ (add-hook 'kill-buffer-hook #'chatgpt-mode--kill-buffer-hook nil t )
444+ (setq-local header-line-format `((:eval (chatgpt-header-line)))))
430445
431446(defun chatgpt-register-instance (index buffer-or-name )
432447 " Register BUFFER-OR-NAME with INDEX as an instance.
0 commit comments