Ignacio Casso San Román <[email protected]> writes:

> ...
>  `org-agenda-with-point-at-orig-entry` and exactly the same happen.
>
>  After some debugging investigation I identified the issue: those
>  macros only set the current buffer and the buffer point, but not
>  the window point.

Elisp code must not set window point in normal circumstances.

> ... If the provided body has an implicit redisplay (and
>  mine did because it used `completing-read`), Emacs can decide that the
>  buffer point and window point are inconsistent and overwrite the
>  buffer point with the window point, so the `goto-char` in those
>  macros is effectively undone.

What if you wrap your completing-read into save-excursion?

>   (org-with-point-at my-marker
>     (redisplay t)
>     (message "Point: %s. Original marker: %s" (point) my-marker))
>  ```

If the problem is that redisplay (or whatever inside the macro) moves
point, it is not a bug in org-with-point-at.

(org-with-point-at my-marker
 (goto-char 1)
 ;; should end up at point = 1
 (some-command-moving-to-char-1)
 ;; is also expected to end up there
 )

So, not a bug.
Canceled.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to