alphapapa / org-sidebar

A helpful sidebar for Org mode
GNU General Public License v3.0
527 stars 16 forks source link

Sidebar tree opens subtrees in most recently opened window #49

Open glvno opened 3 years ago

glvno commented 3 years ago

Context: Spacemacs frame with four windows open:

  1. org-sidebar-tree of example.org
  2. example.org
  3. arbitrary or empty buffer
  4. arbitrary or empty buffer

I switch to window 1, navigate to the headline I want to open as a subtree, and hit RET.

Expected behavior: Subtree opens in window 2 (i.e., the window that contains the full example.org buffer).

Actual behavior: Subtree opens in window 4.

After messing around with it, I think the subtree will always open in the most recently opened window. And this appears to be the behavior no matter when or from what window org-sidebar-tree is run.

It would make sense to open the subtree in the most recently opened window displaying an empty buffer, but if it's going to replace a non-empty buffer, it seems like it would make the most sense to replace the full example.org tree. My use case is probably on the unusual side, however, so I wouldn't be surprised if the current behavior was chosen deliberately for reasons that aren't relevant to my use case.

Thank you for all your hard work on this wonderful package!

alphapapa commented 3 years ago

Please see the relevant code here: https://github.com/alphapapa/org-sidebar/blob/67fe1b5c6c879e14d34c34eec2190e9719046b6c/org-sidebar.el#L305 As well, you might want to review the Emacs manual section on "side windows."

If it seems useful, we could try to make this behavior more customizeable.