awth13 / org-appear

Toggle visibility of hidden Org mode element parts upon entering and leaving an element
MIT License
375 stars 19 forks source link

Keep current element open after manual stop #39

Closed Kazark closed 2 years ago

Kazark commented 2 years ago

After using the feature added in #38 for a bit, I experimented with this change and decided I liked it better. I may not understand the full context here, so maybe this is not a good change for everyone, but the reason I moved toward it is because I am so heavily dependent on modal editing, that even when I move around a little bit in a link, I habitually hit escape and move with hjkl. So suppose I hit i in order to edit a link. The link opens, and I am happy; but my cursor is on the display text. Okay, that makes sense to me, since that was the part that was visible. So I move my cursor over to where the link is, and make an edit. However, when I go to move my cursor, I habitually ESC from insert mode and start hitting h or b or the like. Without this change, however, as soon as I hit ESC, the link closes again, because I have added the manual stop function to the evil insert state exit hook.

I'm curious what you think. Am I overlooking some important factor here?

awth13 commented 2 years ago

Hi! Thank you for the PR!

This does make sense when editing in Evil mode without using Emacs keybindings. It should not cause any conflicts with the way the package works. However, one issue I can see is that, perhaps, other users -- e.g., those using the hybrid mode in Spacemacs -- would prefer to avoid this lingering toggle. Any thoughts on how to best provide the option to choose whether to keep-open or not? Providing an argument in org-appear-manual-stop seems like a bad idea since normal hooks should not have arguments.

Maybe this "lingering stop" should be a separate function altogether? I realise that this will require extra changes in the Spacemacs configuration.

awth13 commented 2 years ago

Alternatively, it can be a custom variable, something to the effect of org-appear-manual-linger.

Kazark commented 2 years ago

I think the approach that would introduce the least complexity into this package is to add another function that contains the code I deleted there, perhaps org-appear-manual-close. Then we don't need anymore if checks or custom variables, and when you register your hooks you can decide whether to register one or both functions.

However, I'm happy to update this change however you prefer. A custom variable, or a lingering stop function---I'm happy to implement any of those. Just let me know what you want. I wouldn't sweat the Spacemacs configuration; it's easy enough to change, and I doubt it has garnered many (or any) users yet.

awth13 commented 2 years ago

Hi and sorry for not responding earlier.

While I agree that a separate function is the least complexity solution, I don't like it from a UX perspective. The reason is that, if org-appear-manual-stop is not added as a hook, adding org-appear-manual-hide (or close, though hide is more consistent with the naming in the rest of the package) will just do nothing. That is, unless we set org-appear--do-buffer to nil in it as well but, at this point, how does it differ from org-appear-manual-stop?

This means that the user will have to either add both hooks or only org-appear-manual-stop, which is confusing and, in my opinion, makes org-appear-manual-hide redundant. Not to mention that, if Spacemacs or other Emacs distributions wanted to let users customise this behaviour in a convenient way, they would have to define some variable anyway. Thus, I vote for resolving this with a custom variable.

Would you mind adding a custom variable in this PR?

Kazark commented 2 years ago

Yep, I'm happy to do it that way. It may take me a minute to get to it---I'll try to circle back in a few days.

Kazark commented 2 years ago

@awth13 let me know your thoughts on 55637e8 at your convenience. It is nice about this change that Spacemacs would not have to change.

awth13 commented 2 years ago

This is perfect, thank you for your suggestions and contributions!