Skip to content

Commit d34aa0f

Browse files
committed
Highlight role
1 parent ebd4018 commit d34aa0f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

chatgpt.el

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@
8080
(defvar-local chatgpt--display-pointer 0
8181
"Display pointer.")
8282

83+
(defface chatgpt-user
84+
'((t :inherit font-lock-builtin-face))
85+
"Face used for user."
86+
:group 'chatgpt)
87+
8388
;;
8489
;;; Util
8590

@@ -220,10 +225,11 @@ The data is consist of ROLE and CONTENT."
220225
(let ((message (elt chatgpt-chat-history chatgpt--display-pointer)))
221226
(let-alist message
222227
(goto-char (point-max))
223-
(let ((start (point))
224-
(content (chatgpt--render-markdown .content))
225-
(is-user (string= (chatgpt-user) .role)))
226-
(insert "<" .role ">: " content)
228+
(let* ((start (point))
229+
(role (format "<%s>:" .role))
230+
(content (chatgpt--render-markdown .content)))
231+
(add-face-text-property 0 (length role) 'chatgpt-user nil role)
232+
(insert role " " content)
227233
(insert "\n\n")
228234
(chatgpt--fill-region start (point)))))
229235
(cl-incf chatgpt--display-pointer)))

0 commit comments

Comments
 (0)