Error "Invalid search bound (wrong side of point)"
When invoking the function org-side-tree, an error "Invalid search bound (wrong side of point)" is frequently encountered. As a result, the side window fails to open. On occasions where the side window does open, modifying the file often reproduces the error, causing instability.
Steps to Reproduce
- Open an Org-mode file.
- Invoke the function
org-side-tree. - Observe the error message: "Invalid search bound (wrong side of point)".
- In some cases, the side window may open successfully.
- Modify the Org file (e.g., add or edit headings, src blocks).
- Note that the error may reoccur, causing inconsistent behavior with the side window.
Debug Information
- The error is thrown inside the function
org-side-tree-get-headings. - In the code segment:
(while (re-search-forward heading-regexp nil t) (let* ((beg (line-beginning-position)) (end (line-end-position)) (heading (or (and (and org-side-tree-add-overlays (derived-mode-p 'org-mode)) (org-side-tree-overlays-to-text beg end)) (org-side-tree-buffer-substring beg end)))) - The function
org-side-tree-overlays-to-textis responsible for the error, especially whenbegandendpositions include a src block.
Environment
- Org-mode version: doom emacs
- Emacs version: emacs-plus@29
- Operating System: MacOS
Additional Information
The error seems to be related to the presence of src blocks within the beg and end positions passed to the function org-side-tree-overlays-to-text.
Thanks for the detailed report. I cannot reproduce it, so could you provide more details about the file that raises the error? Or could you share a file that I could use to try to reproduce the issue (with sensitive info taken out, of course)?
Additional Information
The error seems to be related to the presence of src blocks within the
begandendpositions passed to the functionorg-side-tree-overlays-to-text.
This part doesn't make sense to me.
The beg and end positions should be the beginning and end of a heading. So it shouldn't be possible for there to be a src block between beg and end.
Have you modified outline-regexp in some way?
I think I see the problem. Does the error occur when all headlines are unfolded?
I don't know how to fix this yet, but I would suggest setting org-side-tree-add-overlays to nil for the time being.
yes, i think the error occur when all headlines are expanded. Sometimes the beg is at the heading, sometimes the beg is at the first line of heading (which is a src block)
I will give it a try setting org-side-tree-add-overlays to nil later
Just pushed a change, let me know if it helps
Thanks! I've tested it. With the latest commit, the side tree can be opened.
However, if I turn on the debugger using M-x toggle-debug-on-error, the error still pops up after I click the heading on the org-side-tree buffer. This time, it doesn't affect usage. So i think i just turn off the debugger is OK, the error message is for your reference.
Here is the screenshot. The "beg" point reported at the error message is actually at the next line of the heading.
also i found out that if the org-side-tree window is opend at the right side, the error still happens and the window won't open. situation of left side is described above.
I get the same error behavior except that my setup is a linux, emacs is the latest compilation from master branch of the trunk with native compilation turned on, and the org files are both small and large. I've not noticed any difference in the folded/unfolded state. Sometimes the side window opens but is empty.
In my case, Doom Emacs and Emacs 30.1, it seems that I need not to be on a header. Otherwise it fails with this error.