Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a variable to hide body of the TOC after inserting new contents #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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.

None yet

2 participants