title: Emacs -- creating / deleting a `buffer-local` repeating idle-timer
body: <p>I have a minor-mode that uses a repeating idle-timer:</p>
  
  <pre><code>(timer-activate-when-idle
      (run-with-idle-timer 0.2 t 'function-name))
  </code></pre>
  
  <p>I am trying to figure out the best way to handle the same minor-mode being active in more than one buffer, and how to cancel the timer when killing the buffer or deactivating the minor-mode without affecting other buffers.</p>
  
  <p>My preferred way to handle this, if it is even possible, would be to create a <em>buffer-local</em> idle-timer and assign it a unique name / identification for purposes of canceling.  If this method is within the realm of possibility, then an example would be greatly appreciated.</p>
  
  <p>My least preferred method to handle this would be to loop through all open buffers to ascertain whether this particular minor-mode is active in any of them, and if not, then cancel the timer.  In other words, there would be one timer that services all buffers.</p>
  
  <p>Any other ideas on how to handle this situation would be greatly appreciated.</p>
  
  <p>[NOTE:  I realize that I can put in a condition that prevents the timer from taking any action (e.g., if not minor-mode xyz), however, I like to be tidy and clean-up after myself when there is no longer a need for a particular timer.]</p>