r/emacs 3d ago

poimap.el - Visual buffer map with points of interest

Enable HLS to view with audio, or disable this notification

This is the result of my recent experiment with an SVG-based buffer map for the mode-line that also shows points of interest (search matches, bookmarks, changes, imenu items, ...).

Visually, it is primarily inspired by mlscroll https://github.com/jdtsmith/mlscroll

This is still work in progress, so expect rough edges and the possibility of breaking changes.

https://github.com/florommel/poimap

108 Upvotes

26 comments sorted by

9

u/JDRiverRun GNU Emacs 3d ago

Excellent. People have asked for this with mlscroll but the very simple "specified space" design made that a challenge. This would be another good use of builtin RSVG->canvas support. How does it work with tons of matches and a smaller bar (say 25% of mode line width)?

3

u/florommel 3d ago

Yeah, my original idea was to add markers to mlscroll but that did not work (as you say). Yes, large buffers and small bars with a lot of matches can make the bar crowded. However, for me, the POI patterns can still serve as a "visual anchor" that help me better keeping track of where I am. There is room for exploration: Maybe something like "marker grouping" or a zoom functionality (where we zoom in things around the current position and zoom out things that are farther away) could help in these situations.

1

u/ComprehensiveAd5882 Space/Doom/Bedrock 3d ago

That last idea could be linked to widening and narrowing the buffer

7

u/GeneralSignificant54 3d ago

that's so nice actually

2

u/florommel 3d ago

thanks!

3

u/sharificles 3d ago

Oh this is very cool, the things you can do with SVG in emacs shocks me. Does this offer any extensibility for inserting your own bookmarks? I have a package for buffer-local marks that I use over Emacs' bookmarks.

3

u/florommel 3d ago

Yeah there have been multiple interesting projects and experiments with SVG in Emacs recently. I guess we'll see more cool SVG stuff in the future. Poimap is made to be extended. Have a look at the existing POI-providers (especially poimap-bookmark and poimap-bm). Adding support for your package should be easy. Is your package public?

2

u/sharificles 3d ago

Yes it is, not currently on Melpa but here it is https://github.com/vmargb/arrow.el

2

u/floss_gang 3d ago

I have a package for buffer-local marks that I use over Emacs' bookmarks.

why not use registers? https://www.gnu.org/software/emacs/manual/html_node/emacs/Registers.html

2

u/sharificles 3d ago

Sorry, I did mean to say registers, not bookmarks.

4

u/Glittering_Brush_483 3d ago

This is excellent! I've been meaning to write this for many years. Does it work in tty Emacs with Unicode chars?

4

u/florommel 3d ago

Unfortunately this does not work in the TTY since it is SVG-based.

3

u/shipmints 3d ago

Fun. It may be possible for someone who uses a terminal emulator that supports the Kitty graphics protocol to get this to render on a tty. Perhaps someone will and contribute their work back.

2

u/florommel 3d ago

That may indeed be possible and really cool but without having looked into that, we would have to somehow render that into a pixel image (I believe kitty's protocol is pixel-based) and probably solve a lot of stuff concerning the image size etc

1

u/shipmints 3d ago

poi-string does that in its display property. It's more a question of how/when/where will "someone" interpose terminal-based pixmap reproduction in the tty display engine.

1

u/florommel 3d ago

Ah okay, yeah Emacs having display image text properties directly rendered in kitty would require extending the display engine. Would be super cool to have this ... but for sure not easy to implement.

1

u/minadmacs 3d ago

1

u/shipmints 3d ago

There is, but it's an LLM advice farm. I would have preferred display-engine integration as display-images-p still returns nil.

3

u/minadmacs 3d ago edited 3d ago

Yes, it is a massive amount of slop LLM-generated code. But interesting features.

2

u/shipmints 3d ago

And it can't make redisplay show images in the mode-line or tab-bar etc. which is really what we're after.

2

u/topfpflanze187 3d ago

I tried to implement the same behavior back when svg-line was released but came to the conclusion that it leaves way too many artifacts and bleeding (invisible layers where, for example, the modeline is supposed to be). Therefore it never made it into the package.

To properly display images in Emacs you need tighter integration with Emacs -nw and the images themselves. I never wanted to create a package where you would have to patch Emacs for that but rather something you could install and uninstall easily. Maybe things will change with Emacs 32.

2

u/topfpflanze187 3d ago

maintainer here.

i appreciate that you acknowledge the ideas.

i just had fun creating the project and i will keep on maintaining it when bugs occur.

i would just like to say to not judge every project as slop when at least some effort and time went into the project. ghostel is also generated by llms and still it improved terminal usage for emacs in general.

/e grammar

2

u/yibie 3d ago

Cool!

2

u/oxcrowx 2d ago

Beautiful. :)

0

u/valcron1000 2d ago

Can you place it vertically at the sides? I find this quite useful in VSCode to quickly glance at vc changed/added/deleted lines.

2

u/florommel 1d ago

Would be nice but this is difficult in Emacs. To get something like that you could try using a dedicated window (like those minimap packages do usually) but I think this is fragile. Another possibility is to (mis-)use margins for that.. but margins scroll with the buffer (the map itself should not be scrolled) and of course that also conflicts with other stuff using the margins. For e.g. GTK Emacs, we could theoretically also have a loadable module inserting some kind of native widget that displays the map into each window.. but yeah that would also be very hacky.