Skip to content

Commit ebd4018

Browse files
committed
Render code block
1 parent 144ea68 commit ebd4018

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

chatgpt.el

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ The data is consist of ROLE and CONTENT."
197197
"Render CONTENT in markdown."
198198
(if (featurep 'markdown-mode)
199199
(with-temp-buffer
200-
(delay-mode-hooks (markdown-mode))
201200
(insert content)
202-
(font-lock-ensure)
201+
(delay-mode-hooks (markdown-mode))
202+
(ignore-errors (font-lock-ensure))
203203
(buffer-string))
204204
content))
205205

@@ -238,6 +238,8 @@ The data is consist of ROLE and CONTENT."
238238
(let ((response (read-string "Type response: "))
239239
(user (chatgpt-user))
240240
(instance chatgpt-instance))
241+
(when (string-empty-p response)
242+
(user-error "[INFO] Invalid response or instruction: %s" response))
241243
(chatgpt--add-message user response) ; add user's response
242244
(chatgpt-with-instance instance
243245
(chatgpt--display-messages)) ; display it
@@ -306,7 +308,8 @@ The data is consist of ROLE and CONTENT."
306308
"Major mode for `chatgpt-mode'.
307309
308310
\\<chatgpt-mode-map>"
309-
(setq-local buffer-read-only t))
311+
(setq-local buffer-read-only t)
312+
(font-lock-mode -1))
310313

311314
(defun chatgpt-register-instance (index buffer-or-name)
312315
"Register BUFFER-OR-NAME with INDEX as an instance.

0 commit comments

Comments
 (0)