jdtsmith / mlscroll

Lightweight scrollbar for the Emacs mode line
GNU General Public License v3.0
99 stars 8 forks source link

Search results indicators on scrollbar #19

Open michael-nhat opened 5 months ago

michael-nhat commented 5 months ago

Is it possible to indicate search results on scroll bar? For example, in chromium browser, you can press C-f to see search results as yellow stripes on scrollbar. Could we have a function like make-match-indicator(line) to implement it?

jdtsmith commented 5 months ago

Interesting idea, but I think it would be very complicated to implement given the current draw model. Perhaps a partner mode of some kind, that draws just below the scrollbar?

michael-nhat commented 5 months ago

Thank you for let me know that. Your reccommendation seem tobe possible. I'm noob in emacs lisp but I miss that kind of feature. I did some modifications with this minimap-mode to be able to see search results throught the minimap (while long scrolling). But I also hope the feature you suggested or somethings like that could be implemented. (Please close this if you need)

jdtsmith commented 5 months ago

I will think about how it might be done (these are notes to myself or anyone else who wants to give it a try).

In principle it's "easy" to set a display property for each specified space. Nested display properties don't work correctly in emacs, however, so this makes it much more challenging. When a search is active (also other things? consult-line for example?) you'd need to use an arbitrary number of spaces. You'd also have to decide on a minimum "search indicator" width, and come up with an algorithm to "merge" matches which are too close together to count as separate. Then you'd draw, instead of 3 specified spaces, N specified spaces, and instead of two styles, four possible styling choices: on-bar/off-bar/on-bar-search/off-bar-search. Since bar width depends on lines showing, not chars showing, you now need the line number of each search term, which could be a performance problem; probably would need to turn off line-based bar size indication for this to work well. This is particularly important when much of the buffer is hidden, as if often the case in org-mode.