On 09/11/2021 18:46, Ihor Radchenko wrote:
Max Nikulin writes:
`org-store-link' under some conditions may pick a link to wrong heading.
Emacs-26.3, Org main~1.
I can reproduce, though not exactly following your steps.
Can you try the attached patch?
With equivalent patch (attached one has additional differences in spaces
around) my particular case works. I have no idea which additional
scenarios it may affect. I did not test the patch extensively. I faced
the issue while I was preparing a patch to fix storing double #CUSTOM_ID
links.
P.S. I am puzzled that `org-element-at-point' returns paragraph even
when patch is not applied. After such call `org-store-link' does what I
expect. However "after undo" erroneous state survives emacs restart,
thanks to org-persist, I believe.