org-side-tree icon indicating copy to clipboard operation
org-side-tree copied to clipboard

Error "Invalid search bound (wrong side of point)"

Open nohzafk opened this issue 1 year ago • 9 comments

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

  1. Open an Org-mode file.
  2. Invoke the function org-side-tree.
  3. Observe the error message: "Invalid search bound (wrong side of point)".
  4. In some cases, the side window may open successfully.
  5. Modify the Org file (e.g., add or edit headings, src blocks).
  6. 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-text is responsible for the error, especially when beg and end positions 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.

nohzafk avatar May 31 '24 10:05 nohzafk

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

localauthor avatar May 31 '24 10:05 localauthor

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.

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?

localauthor avatar May 31 '24 10:05 localauthor

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.

localauthor avatar May 31 '24 11:05 localauthor

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

nohzafk avatar May 31 '24 18:05 nohzafk

Just pushed a change, let me know if it helps

localauthor avatar Jun 01 '24 10:06 localauthor

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.

image

nohzafk avatar Jun 01 '24 11:06 nohzafk

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.

nohzafk avatar Jun 01 '24 11:06 nohzafk

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.

sjLambda avatar Jul 26 '24 20:07 sjLambda

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.

bitozoid avatar Jul 04 '25 10:07 bitozoid