bnbeckwith / wc-mode

Wordcount minor mode for Emacs
68 stars 11 forks source link

Fix idle timer management logic #17

Closed jgkamat closed 3 years ago

jgkamat commented 3 years ago

Previously, a buffer local variable was set with a global idle timer. This caused the following bugs:

  1. If the first buffer to open wc-mode (assuming loading wc-mode is deferred) is closed, wc-mode would no longer update in any buffer.
  2. The logic for wc mode would run on every `current-buffer', causing slowdowns even after wc-mode is disabled.

The simple fix for both of these is to run a single global idle timer which only runs on wc-mode buffers, instead of many buffer local timers. However, if the user types in many wc-mode buffers, only the latest one will update. However, I'm mostly interested in fixing the performance issue and the bug where wc-mode will completely break, so I'll keep this simple for now.

jgkamat commented 3 years ago

@bnbeckwith any chance I could get a review on this at some point?