wolray / symbol-overlay

Highlight symbols with keymap-enabled overlays
344 stars 42 forks source link

Use a single shared timer for all buffers #78

Closed mattbeshara closed 2 years ago

mattbeshara commented 3 years ago

Hi there, this PR causes all buffers using Symbol Overlay mode to share a single timer, rather than creating a separate timer for each buffer the mode is active in. In my testing it doesn't seem to have any effect other than reducing the number of active timers in timer-idle-list (potentially by a large number if, like me, you have a ton of buffers open all the time, most of them using this mode).

mattbeshara commented 2 years ago

Hi, I've just rebased this PR so it merges cleanly. I've been using this for months without any issues, and it's a huge performance improvement in cases where the user has a large number of buffers open with Symbol Overlay enabled. Is there any interest in merging this?

purcell commented 2 years ago

Yeah, let's go for it. It'll probably look broken for people who install the new version without restarting emacs, because the timer var will be "stuck" as buffer-local until then, but I think this is a desirable change. Thanks.

mattbeshara commented 2 years ago

Cool, thank you! And yes, I recall when I was first playing around with this change that I encountered something of a limitation in Elisp: you can't un-make a variable buffer local. As you say though, restarting Emacs to load the new code from scratch sorts it out.