From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Mysterious buffer switching Date: Sun, 27 Feb 2005 20:01:01 +0100 Message-ID: References: <2200.220.255.172.231.1109514547.squirrel@www.stupidchicken.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1109531070 13366 80.91.229.2 (27 Feb 2005 19:04:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 27 Feb 2005 19:04:30 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 27 20:04:29 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D5Thp-00041V-Gg for ged-emacs-devel@m.gmane.org; Sun, 27 Feb 2005 20:03:53 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D5U02-0007oP-Ay for ged-emacs-devel@m.gmane.org; Sun, 27 Feb 2005 14:22:42 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D5TzK-0007av-EO for emacs-devel@gnu.org; Sun, 27 Feb 2005 14:21:58 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D5Tz6-0007SZ-2v for emacs-devel@gnu.org; Sun, 27 Feb 2005 14:21:47 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D5Tz2-0007NN-Hw for emacs-devel@gnu.org; Sun, 27 Feb 2005 14:21:40 -0500 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D5Tf4-0003Il-Lf for emacs-devel@gnu.org; Sun, 27 Feb 2005 14:01:02 -0500 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1D5Tf4-0004AQ-7R; Sun, 27 Feb 2005 14:01:02 -0500 Original-To: "Chong Yidong" In-Reply-To: <2200.220.255.172.231.1109514547.squirrel@www.stupidchicken.com> (Chong Yidong's message of "Sun, 27 Feb 2005 09:29:07 -0500 (EST)") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: main.gmane.org gmane.emacs.devel:33874 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:33874 "Chong Yidong" 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