orgmode icon indicating copy to clipboard operation
orgmode copied to clipboard

Narrow/Widen to subtree

Open focusaurus opened this issue 2 years ago • 12 comments

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

focusaurus avatar Jan 10 '22 00:01 focusaurus

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.

kristijanhusak avatar Jan 13 '22 21:01 kristijanhusak

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.

focusaurus avatar Jan 14 '22 11:01 focusaurus

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

joshpetit avatar Jan 19 '22 18:01 joshpetit

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 avatar Jan 19 '22 20:01 kristijanhusak

@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.

joshpetit avatar Jan 19 '22 23:01 joshpetit

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 avatar Jan 20 '22 16:01 focusaurus

@focusaurus Could you send a video of an example of how narrow tree works?

joshpetit avatar Jan 20 '22 16:01 joshpetit

@joshpetit sure maybe this will help https://d.pr/v/JvdtId

focusaurus avatar Jan 20 '22 17:01 focusaurus

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.

joshpetit avatar Jan 20 '22 17:01 joshpetit

Just an FYI I'll be busy over the next week but won't forget this haha. It's on my queue.

joshpetit avatar Jan 25 '22 14:01 joshpetit

I don't think it's any blocker so take your time :)

kristijanhusak avatar Jan 25 '22 14:01 kristijanhusak

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.

joshpetit avatar Feb 16 '22 15:02 joshpetit