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

[IMPROVEMENT] Toggle bullet on folded versus unfolded headline state - ▶ to ▼ #22

Open
wakatara opened this issue Jan 5, 2021 · 14 comments
Assignees
Labels
enhancement New feature or request

Comments

@wakatara
Copy link

wakatara commented Jan 5, 2021

I am currently using org-superstar (thank you) but am looking to make the UX on using it with org-mode a bit more like the toggles that you see in the popular program/web application Notion.

Basically, I want to have folded headlines bulleted with a "▶" and then when I tab to unfold the headline have the bullet change to be a "▼" ( a transition animation might be kinda nice, but hardly necessary. =] ).

If there is a way to do this already in superstar, and I just didn't figure it out, I apologize, but it seemed a nice effect to have as well as possibly being a cleaner mechanic than straight up bullets in some regard.

thanks!
Daryl.

@wakatara wakatara added the enhancement New feature or request label Jan 5, 2021
@integral-dw
Copy link
Owner

integral-dw commented Jan 9, 2021

Hi @wakatara, that's a pretty nifty idea! I'll have to think about it, though I may not manage to do so properly before February.

@wakatara
Copy link
Author

Well, I am using the right triangle now to demarcate the first two levels (as I did mess around with Notion over the holidays) and the toggle feature there is very nice (which is basically just org-mode folding and unfolding but with a nice vidual indicator. Also, while I'm thinking about it, this would also remove the need for the org-mode end of line ellipsis I currently use as well (which happens to be a down triangle... :-/ ).

And I am sure I can hold my breath till February. Thanks for all your work on this library! Makes the UX in org-mode much much nicer. Makes a big difference.

@wakatara
Copy link
Author

Actually, an even better think here would be to also allow the bullet to be optional or distinct if there was information in the fold.

So, for example, have a simple hidden or missing bullet if it's simply a headline but then display a ▶ if there is actual content folded into the headline (and then, of course, the down arrow ▼ once unfolded... =]

@integral-dw
Copy link
Owner

I finally have more time on my hands to look into this a little more. I looked a bit into the options and I'm afraid that the solution for this is the same that allows for example creating even more interactive elements in Org that can hide away information. It's a project I have put on hold for a while but wanna pick up again soon. The core technical issue to overcome with it is twofold:

On the one hand, you can have text in an Emacs buffer hold such metadata (like "do I belong to a folded entry?") effortlessly, but keeping this metadata up to date requires a lot of moving parts in real time. Essentially each time the user executes a command and changes the buffer some bookkeeping will need to be done. This is the job of a mode that wants to achieve this.

On the other hand, making Emacs visualize that metadata ("ah, this bullet belongs to a folded entry, hence I ought to display it as..") is also rather simple. This task is deferred to font-lock, which handles everything from syntax highlighting to Superstar making Org look nice. However, font-locking can be quite expensive, hence font-lock does not just constantly update the buffer but tries to only change bits it "has to".

And that's the problem, really: Keeping these two independent processes in sync, and I'm working on an entire mode dedicated to nothing but keeping these two things in sync. I have not yet found a solution for this that can't be confused by simple operations, however (like cutting out large chunks of a buffer etc). My next plan towards this goal is to first write down and explain what I am doing over there and talk to the Emacs upstream to gain a deeper understanding of "real-time" font-lock. Sorry for the rant, but after discovering that this leads down the same rabbit hole as #20 I thought it was necessary to mention this at least somewhere.

To get back to your initial request, there may be a way to do this specific thing with a nice hack involving orders of magnitude less complexity, so I'll see if I can come up with something over the weekend. If not, it is only an even bigger incentive to get the org-menu-mode engine to run without race conditions and other timing nonsense.

@integral-dw integral-dw self-assigned this Feb 5, 2021
@wakatara
Copy link
Author

wakatara commented Feb 6, 2021

Wow, that is much more complex than I thought it would be (so, out of curiosity, how does the org-mode ellipsis symbol know to appear on fold and unfold then?). Thank you for even considering it.

I think your entire mode sounds very interesting and have to admit I selfishly want it since I'd also like better TeX rendering than org-mode currently support in-buffer.

In any case, certainly interested to see what you come up with. I have to admit to only have messed around with font-lock over the Xmas holidays when I wanted to make my emacs experience a lot closer to something like Notion, so really interested in seeing the results.

@integral-dw
Copy link
Owner

integral-dw commented Feb 11, 2021

Yeah, sadly it's a bit hairy.

so, out of curiosity, how does the org-mode ellipsis symbol know to appear on fold and unfold then?

Org mode uses overlays for that, which are rather convenient, but as far as I'm aware can cause slowdown if used extensively. I usually restrict myself to using text properties exclusively, especially since my modes would easily double/triple the amount of overlays in the worst case.
(EDIT: I have consulted the info node again, and yes, excessive use of overlays is discouraged.
Good to know where I got that from. 😅 )

Anyway, I'll work on a more coherent update on the matter on the other repo, though I will likely first have to do some Font Lock research...

@andersjohansson
Copy link
Contributor

This would definitely be a cool feature! (maybe something for upstream org even). BTW, @integral-dw, if you are not aware of @yantar92's work on reimplementing the org folding mechanism with text properties instead of overlays, you should take a look at that. May be some overlap or inspiration for org-superstar: https://github.com/yantar92/org

@integral-dw
Copy link
Owner

Oh, that IS news to me! I'll have a look in the near future :)

@andersjohansson
Copy link
Contributor

I have been using the org-fold branch for a few weeks and found that it speeds up my large org files. Hopefully it will be ready for merging soon.

@wakatara
Copy link
Author

wakatara commented Mar 12, 2022

@andersjohansson
What does org-fold do precisely? (and have you seem origami? I use that to help with folding in super-org-agenda. It is great.).

@wakatara
Copy link
Author

@integral-dw

Hola! Was just wondering if you ever got a chance to look into those overlays. (the interesting thing is most apps that use a web rendering (notion, workflowy, etc et) and lists now do the "▶" to "▼" swivel thing now. It is actually a suprisingly nice dynamic.

Anyhow, was just wondering as I was back in org-mode again... =]

@yantar92
Copy link

yantar92 commented Mar 12, 2022 via email

@integral-dw
Copy link
Owner

Hi everyone,
sorry I've been so quiet. I've been out of commission last year and am slowly working through the issues again.
The org-fold patch in principle may allow me to implement that feature quite neatly, actually. I'll need to do some housekeeping in the Issue tracker but I'm just letting you know it's on my mind, thank you for your patience!

@andersjohansson
Copy link
Contributor

By the way, outline-mode got these kinds of toggles in Emacs 29. I haven’t looked into the implementation, and whether it can be used for org (which has recently split with outline-mode). But looks promising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants