Subject: Re: bug#11088: 24.0.94; minor mode cannot be cleanly turned off in idle timer

From: Stefan Monnier <[email-masked]>
Date: Sun, 25 Mar 2012 14:28:21 -0400

> 1. emacs -q -l t.el
> 2. C-c w
> 3. let emacs idle for more than 2 seconds
> 4. type `l'

> You should still see the message "hello world" printed, which is odd
> since I expect the minor mode turned off by now.

> (defvar test-mode-map
>   (let ((map (make-sparse-keymap)))
>     (define-key map "l" (lambda () (interactive) (message "Hello World")))
>     map))

> (define-minor-mode test-mode ""
>   :global t
>   (if test-mode
>       (run-with-idle-timer 2 nil 'test-mode -1)))

> (global-set-key "\C-cw" 'test-mode)

It's a known problem: the set of active keymaps is computed before Emacs
starts waiting for the next key-sequence and is not recomputed after
running idle timers and process filters.

        Stefan