Subject: Re: bug#58928: 29.0.50; overlays in org-mode are disrupted after call `org-capture`

From: Matt Armstrong <[email-masked]>
Date: Tue, 01 Nov 2022 16:25:22 -0700

I've created a simpler repro that demonstrates how inserts/deletes in an
indirect buffer does not update positions for overlays its base buffer.

This function creates a temp buffer with some text and one overlay, then
an indirect buffer against it.  Editing text in the indirect buffer
fails to update overlay positions in the base buffer.

(defun repro58928 ()
  (interactive)
  (with-current-buffer (get-buffer-create "*b58928*")
    (erase-buffer)
    (delete-all-overlays)
    (insert "My dog has fleas,\nlots and lots of fleas!\n")
    (let ((overlay (make-overlay 18 (point-max))))
      (overlay-put overlay 'face 'match))
    (pop-to-buffer (current-buffer))
    (ignore-errors
      (kill-buffer "*INDIRECT-b58928*"))
    (let ((indirect (make-indirect-buffer (current-buffer)
					  "*INDIRECT-b58928*")))
      (with-current-buffer indirect
	(goto-char (point-min)))
      (pop-to-buffer indirect))))

I'm not sure where the bug is, but the good news is that the regression
test will be easy to express in lisp.