From max@openchat.com Fri Aug 1 09:47:07 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-5.6 required=4.0 tests=AWL,BAYES_00, MURPHY_DRUGS_REL8,RCVD_IN_DNSWL_MED autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 1 Aug 2008 16:47:08 +0000 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m71Gl4ZW028086 for ; Fri, 1 Aug 2008 09:47:05 -0700 Received: from mx10.gnu.org ([199.232.76.166]:60407) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1KOxlX-0002bn-SY for emacs-pretest-bug@gnu.org; Fri, 01 Aug 2008 12:46:08 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1KOxmM-0006kI-Oo for emacs-pretest-bug@gnu.org; Fri, 01 Aug 2008 12:47:02 -0400 Received: from p84-72.acedsl.com ([66.114.84.72]:17975 helo=momoland.openchat.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KOxmL-0006jc-UZ for emacs-pretest-bug@gnu.org; Fri, 01 Aug 2008 12:46:58 -0400 Received: from momoland.openchat.com (localhost [127.0.0.1]) by momoland.openchat.com (Postfix) with ESMTP id 83E50F45674C for ; Fri, 1 Aug 2008 12:22:52 -0400 (EDT) Date: Fri, 01 Aug 2008 12:22:52 -0400 Message-ID: <874p64wvqb.wl%max@openchat.com> From: Max Mikhanosha To: emacs-pretest-bug@gnu.org Subject: Forward: Buffer being killed not current in kill-buffer-hook References: <8763r1obx6.wl%max@openchat.com> User-Agent: Wanderlust/2.15.3 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.0.51 (x86_64-unknown-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Fri_Aug__1_12:22:52_2008-1" X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-Greylist: delayed 1442 seconds by postgrey-1.27 at monty-python; Fri, 01 Aug 2008 12:46:55 EDT --Multipart_Fri_Aug__1_12:22:52_2008-1 Content-Type: text/plain; charset=US-ASCII I posted this to emacs-dev, but there was no response. This is still happenning to me with latest CVS build. --Multipart_Fri_Aug__1_12:22:52_2008-1 Content-Type: message/rfc822 Date: Sat, 19 Jul 2008 16:29:25 -0400 Message-ID: <8763r1obx6.wl%max@openchat.com> From: Max Mikhanosha To: emacs-devel@gnu.org Subject: Buffer being killed not current in kill-buffer-hook User-Agent: Wanderlust/2.15.3 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.0.51 (x86_64-unknown-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII When using multi-tty emacsclient, the following piece of code demostrates the problem: DISPLAY is unset, CVS Emacs started with --no-init-file (require 'server) (progn (setq server-name "test") (server-start)) (defun print-current-buffer () (message "current-buffer=%s" (current-buffer))) (add-hook 'kill-buffer-hook 'print-current-buffer) Now from a different screen session, connect with emacsclient like so: "lib-src/emacsclient -c -s test foo". New tty frame will be created. Immeditely kill the buffer, it will ask "Buffer has existing clients" say "yes". emacsclient will disconnect from a server. In the *Messages* buffer on the server frame: When done with a buffer, type C-x # (No files need saving) current-buffer=*scratch* All the code that uses kill-buffer-hook rightfully assumes that the buffer being killed will be current buffer when called, as that is what is stated in the kill-buffer-hook documentation. For example saveplace does not work because of this.. ERC leaves a channel if unrelated buffer is killed on a different terminal, etc. I had fixed this with the following patch, altho I don't know enough about server.el logic to figure out if what it does is ok? Seems to have fixed the bug and not broke anything else: Index: lisp/server.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/server.el,v retrieving revision 1.166 diff -u -b -r1.166 server.el --- lisp/server.el 6 May 2008 07:57:49 -0000 1.166 +++ lisp/server.el 19 Jul 2008 20:28:26 -0000 @@ -1084,7 +1084,8 @@ ;; tell it that it is done, and forget it entirely. (unless buffers (server-log "Close" proc) - (server-delete-client proc))))) + (save-current-buffer + (server-delete-client proc)))))) (when (and (bufferp buffer) (buffer-name buffer)) ;; We may or may not kill this buffer; ;; if we do, do not call server-buffer-done recursively --Multipart_Fri_Aug__1_12:22:52_2008-1-- From cyd@stupidchicken.com Wed Sep 24 13:13:52 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-3.8 required=4.0 tests=AWL,BAYES_00, MURPHY_DRUGS_REL8 autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 640-done) by emacsbugs.donarmstrong.com; 24 Sep 2008 20:13:52 +0000 Received: from cyd.mit.edu (CYD.MIT.EDU [18.115.2.24]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m8OKDnDP022299 for <640-done@emacsbugs.donarmstrong.com>; Wed, 24 Sep 2008 13:13:50 -0700 Received: by cyd.mit.edu (Postfix, from userid 1000) id 6A75D57E189; Wed, 24 Sep 2008 16:14:17 -0400 (EDT) From: Chong Yidong To: Max Mikhanosha Cc: 640-done@debbugs.gnu.org Subject: Re: Buffer being killed not current in kill-buffer-hook Date: Wed, 24 Sep 2008 16:14:17 -0400 Message-ID: <8763oluwrq.fsf@cyd.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > I posted this to emacs-dev, but there was no response. This is still > happenning to me with latest CVS build. Sorry for the delay. I've just checked in a slightly more conservative version of you patch (since I'm not sure it's correct to apply save-current-buffer in all situations). Thanks for the report and the patch. From unknown Mon Aug 11 18:16:30 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: $requester Subject: Internal Control Message-Id: bug archived. Date: Thu, 23 Oct 2008 14:24:03 +0000 User-Agent: Fakemail v42.6.9 # A New Hope # A log time ago, in a galaxy far, far away # something happened. # # Magically this resulted in the following # action being taken, but this fake control # message doesn't tell you why it happened # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator