Originally sent to bug-gnu-emacs but was asked to file as an Org bug:
--text follows this line--
- 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
In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2025-01-07 built on piano Repository revision: 4bf0f6655142b9e216325d051943b7b7ca4d2cd7 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Linux Mint 21.3
Important settings: value of $LC_MONETARY: sv_SE.UTF-8 value of $LC_NUMERIC: sv_SE.UTF-8 value of $LC_TIME: en_GB.UTF-8 value of $LANG: C.UTF-8 locale-coding-system: utf-8-unix
Major mode: Org
Minor modes in effect: tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t minibuffer-regexp-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t