orgmode
orgmode copied to clipboard
Narrow/Widen to subtree
Does this feature exist in Emacs orgmode core?
Yes
Orgmode link
I don't see a lot of documentation around this but the source org-narrow-to-subtree function declaration is here. I learned about this through spacemacs and the orgmode layer they have there.
Feature value
It lets me hide everything except my current focus. I also use this heavily in workflowy.
Additional context
No response
I don't think there's an easy way to achieve this in Neovim in a same way Emacs Orgmode does. It hides all the other lines and leaves only the current subtree visible. Neovim can't do that. We could maybe open the current subtree in another window and save it in original window once it's closed.
Oh that's a bummer. It seems strange that we can do collapse/expand but not show/hide. I don't understand the details of the limitation.
@kristijanhusak I like this idea of creating a buffer that you can edit and then will be saved afterwards. I may try and working on this feature if you think it's valuable, but some clarification and help would be appreciated
- The entire tree (all the way to the top
*
) should be put into the buffer? - Would it make sense to not allow people to save if the original buffer has been modified since they open up the narrow view? If so is there a way to do this with the vim api?
The entire tree (all the way to the top * ) should be put into the buffer?
I think it's only current headline, but I'll double check how Emacs Orgmode behaves
Would it make sense to not allow people to save if the original buffer has been modified since they open up the narrow view? If so is there a way to do this with the vim api?
I think you should follow the same path that levouh took here, since the features are similar: https://github.com/nvim-orgmode/orgmode/pull/151
@kristijanhusak Ok cool it's pretty much a copy of that feature haha. It'll be some good practice haven't done something like this.
Just note for my use case I often spend all day in a narrow tree on the task I'm doing that day, so I need to write the buffer frequently without needing to close a window or go back to the full wide tree.
@focusaurus Could you send a video of an example of how narrow tree works?
@joshpetit sure maybe this will help https://d.pr/v/JvdtId
Alright seems good so @kristijanhusak I'll implement it to:
- Open the current headline and its children in a new buffer
- Act just like #151 does.
Just an FYI I'll be busy over the next week but won't forget this haha. It's on my queue.
I don't think it's any blocker so take your time :)
Update: I looked into the implementation of the other feature, and noticed that my experience with lua and the neovim api is very very small 😅. I don't see myself working on this anytime soon so if someone else wants to pick this up that'll be awesome.