From bf2867688e6b691856ff9f547337405c08899c3b Mon Sep 17 00:00:00 2001 From: Benson Chu Date: Sun, 22 Jun 2025 09:33:32 -0500 Subject: [PATCH] Fix bug when buffer is empty --- lisp/self-chat-mode.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lisp/self-chat-mode.el b/lisp/self-chat-mode.el index ea308e3..864549c 100644 --- a/lisp/self-chat-mode.el +++ b/lisp/self-chat-mode.el @@ -29,15 +29,16 @@ (not (= self-chat-num self-chat-last))) (setq self-chat-last2 self-chat-last self-chat-last self-chat-num)) - ;; Are we fixing up an old line, or creating a new one? - (if (save-excursion - (beginning-of-line) - (not (looking-at (rx (+ nonl) ":")))) - (progn - (beginning-of-line) - (kill-line)) - (call-interactively #'newline) - (call-interactively #'newline)) + (unless (and (eobp) (bobp)) + ;; Are we fixing up an old line, or creating a new one? + (if (save-excursion + (beginning-of-line) + (not (looking-at (rx (+ nonl) ":")))) + (progn + (beginning-of-line) + (kill-line)) + (call-interactively #'newline) + (call-interactively #'newline))) (insert "> ")) (defun chat-post ()