Skip to content

Conversation

@KaratasFurkan
Copy link

When the table of contents is long, it bothers to expand it every time on update. Thus, I create a variable to hide/collapse body of the table of contents after updating its contents.

@snosov1
Copy link
Owner

snosov1 commented Jul 9, 2020

Hey, @KaratasFurkan !

I see where you're coming from, but I'm afraid things are not that simple =) Please, see #9 for reference. The saving of show/hide state for the tree in Org seems to be unreasonably complicated to a point where it's better to stay out of it.

If we apply your fix, then

  1. The opened TOC heading will be closing upon change (that can be unexpected)
  2. Item 1 can somewhat be tolerated with explanation "Well, what did you think when you set this insert-silently variable to t?", but you will find that some of your other previously opened subheadings will close as well in areas unrelated to TOC or your current position (try it!). That I don't think can be tolerated.

Back in the day I've just decided to drop it - the undesired unfolding only happens when a heading is added (which, I presume, shouldn't be too often). This seems like the least evil.

That said, if you feel adventurous - you can try to implement it "properly", but mind that there's a lot of caveats down the road (some of them are listed in the aforementioned discussion).

@KaratasFurkan
Copy link
Author

Hi, thanks for responding very quick.

I think "The opened TOC heading will be closing upon change" can be tolerated too but i did not realize the second item. Maybe I got too excited to send a pull request 😄. I agree that it can't be tolerated.

I will update if I find a proper way to implement it.

@KaratasFurkan
Copy link
Author

I changed the outline-hide-body function to outline-hide-entry. Apparently, outline-hide-body hides all body lines in buffer. This solves the second item.

you will find that some of your other previously opened subheadings will close as well in areas unrelated to TOC or your current position (try it!). That I don't think can be tolerated.

I take a quick look the conversation you mentioned, it seems it is difficult to remember folding state. I am okay with "always fold TOC after update".

If you are okay too, I may change the variable name to be more clear about "always fold regardless state".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants