Subject: Re: bug#52097: 28.0.50; Regression - posn-at-point returns wrong result if overlay is present

From: Daniel Mendler <[email-masked]>
Date: Thu, 25 Nov 2021 12:23:02 +0100

>> 1. emacs -Q
>> 2. Create new buffer bug.el
>> 3. Activate flymake-mode (for the overlay)
>> 4. Enter "  invalid-ident" (note the spaces at the beginning)
>> 5. Wait until the flymake overlay appears
> 
> The overlay doesn't seem to appear for me, for some reason.

I am using emacs -Q. I just recompiled the current emacs-28 branch.
After some time flymake should underline the invalid identifier.

> Could you please post a recipe that doesn't require Flymake?
Try this command:

(defun posn-bug ()
  (interactive)
  (let ((buffer (get-buffer-create "*bug*")))
    (with-current-buffer buffer
      (erase-buffer)
      (pop-to-buffer buffer)
      (goto-char (point-min))
      (insert "  word")
      (let ((ov (make-overlay 3 7)))
        (overlay-put ov 'before-string
          #("!" 0 1 (display (left-fringe exclamation-mark error))))
        (message "Reported positions %S %S %S %S %S %S %S"
                 (posn-x-y (posn-at-point 1))
                 (posn-x-y (posn-at-point 2))
                 (posn-x-y (posn-at-point 3))
                 (posn-x-y (posn-at-point 4))
                 (posn-x-y (posn-at-point 5))
                 (posn-x-y (posn-at-point 6))
                 (posn-x-y (posn-at-point 7)))))))