dmg <d...@turingmachine.org> writes:

> while working with org-roam I detected the following bug:
>
> Create an org file with the following info:
>
> * heading
>
> * heading 2
> ...
> You will note that the location of the first heading is off (it is
> reported as starting after the space after the asterisks)

org-map-region gives no promises about the point location.
So, technically, there is no bug.
That said, the docstring is rather ambiguous. It should at least tell
that the function will be called with point at heading line.

> This patch addresses that:
>
> The current logic of org-map-region uses two searches.
>
> In the first, the point is left after the asterisks of the
> heading.
>
> In the subsequent, the point is correctly set before the asterisks
> of the headline (this is one outline-next-heading
>
> Add a call to goto-char to go to the beginning of the match

I think that the proposed change will make sense.
However, we also need to (1) modify the docstring to document the
behavior. (2) Announce in etc/ORG-NEWS.

Could you please update the patch accordingly?

> I tried to run the tests, but they failed in the python async section.
> I was only able to run and pass 301/1260

Could you please provide the details of the failure?

> Subject: [PATCH] Get org-map-region to properly set the point in first heading
>
> The current logic of org-map-region uses two searches.
>
> In the first, the point is left after the asterisks of the
> heading.
>
> In the subsequent, the point is correctly set before the asterisks
> of the headline (this is one outline-next-heading
>
> Add a call to goto-char to go to the beginning of the match

The commit message will need to be adjusted as I described, highlighting
that we are introducing a consistent behavior.
Also, please follow the commit message format, as described in
https://orgmode.org/worg/org-contribute.html#commit-messages 

If you are willing to, it would also be nice to add a couple of test for
org-map-region (there are currently none). That's optional though.

-- 
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