Thank you for answering. If you believe this is an Org problem rather than Emacs, I shall report it as an Org bug. Best regards /Johan Ekenberg Den ons 8 jan. 2025 kl 13:38 skrev Eli Zaretskii : > > From: Johan Ekenberg > > Date: Tue, 7 Jan 2025 21:08:09 +0100 > > > > - Start emacs: 'emacs -Q' > > - Paste this function into the scratch buffer and evaluate it: > > (defun test-org-insertion-fontification () > > (interactive) > > (let* ((chunks > > '("#+begin_src elisp\n" > > "(+ 1 2)" > > "\n#+end_src\n"))) > > (insert "* NOTE: You need to run this with org-mode enabled and > point at end of buffer\n\n") > > (insert "** This code block is fontified correctly\n") > > (insert (car chunks)) > > (dolist (chunk (cdr chunks)) > > (insert chunk)) > > > > (insert "\n** But not this code block\n") > > (insert (car chunks)) > > (dolist (chunk (cdr chunks)) > > (sit-for (/ 10 1000.0)) ; simulate chunks received over network > and streamed into buffer > > ;; The following were also tested one by one instead of the > sit-for line above: > > ;; (redisplay) ; this triggers the bug > > ;; (force-mode-line-update) ; this does not trigger the bug > > ;; (read-event nil nil 0) ; this triggers the bug > > (insert chunk)) > > )) > > - Open an existing or new file/buffer with org-mode enabled (C-x C-f > foo.org) > > - Place point at end of buffer > > - M-x test-org-insertion-fontification > > - Optional: replace the line (sit-for...) with any of the lines below it. > > > > - Additional information: The problem was discovered when receiving > > streamed data responses via the package gptel which is an Emacs LLM > > Client. Here is the reported issue: > > https://github.com/karthink/gptel/issues/550 > > > > - Also replicated on Emacs 29.3 > > Isn't this an Org problem? If so, could you please report this to the > Org bug mailing list? >