emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mysterious buffer switching


From: David Kastrup
Subject: Re: Mysterious buffer switching
Date: Sun, 27 Feb 2005 20:01:01 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

"Chong Yidong" <address@hidden> writes:

> Do `emacs -Q', turn on global-font-lock-mode, and visit a long file --
> say, `.emacs'. Now go back to the `*scratch*' buffer and evaluate the
> following:
>
> (defun check-buffer ()
>   (if (not (eq (current-buffer) my-buffer))
>       (message "Foo: %s" (buffer-name (current-buffer)))))
>
> (setq my-buffer (current-buffer))
> (run-with-timer 0.1 0.1 'check-buffer)
>
> Wait for around five seconds. You will see:
>
> Foo: .emacs
>
> You need to have font-lock enabled, and there has to be a long fontified
> buffer lurking around somewhere. My guess is that the font-lock engine is
> doing stuff while waiting for input, which causes current-buffer to be
> different when the timer calls the function.
>
> This has the unfortunate consequence of breaking Pong.

Which would be the fault of whatever Pong is.  run-with-timer does not
guarantee you any particular buffer.  You can always make do with

(run-with-timer 0.1 0.1 `(lambda () (with-current-buffer
  ,(current-buffer) (whateverfunction))))


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

[Prev in Thread] Current Thread [Next in Thread]