From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Max Mikhanosha Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#640: Forward: Buffer being killed not current in kill-buffer-hook Date: Fri, 01 Aug 2008 12:22:52 -0400 Message-ID: <874p64wvqb.wl%max@openchat.com> References: <8763r1obx6.wl%max@openchat.com> Reply-To: Max Mikhanosha , 640@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org 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-Trace: ger.gmane.org 1217610508 28616 80.91.229.12 (1 Aug 2008 17:08:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Aug 2008 17:08:28 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 01 19:09:18 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KOy7r-00063p-6v for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Aug 2008 19:09:11 +0200 Original-Received: from localhost ([127.0.0.1]:37862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KOy6w-0005ro-HI for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Aug 2008 13:08:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KOy6A-00057O-2x for bug-gnu-emacs@gnu.org; Fri, 01 Aug 2008 13:07:26 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KOy68-00055i-RD for bug-gnu-emacs@gnu.org; Fri, 01 Aug 2008 13:07:25 -0400 Original-Received: from [199.232.76.173] (port=54558 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KOy68-00054f-5I for bug-gnu-emacs@gnu.org; Fri, 01 Aug 2008 13:07:24 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:45056) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KOy67-00016y-Mj for bug-gnu-emacs@gnu.org; Fri, 01 Aug 2008 13:07:24 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m71H7L3W001643; Fri, 1 Aug 2008 10:07:21 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m71Gt4JP029622; Fri, 1 Aug 2008 09:55:04 -0700 X-Loop: don@donarmstrong.com Resent-From: Max Mikhanosha Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 01 Aug 2008 16:55:04 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 640 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.121760922828092 (code B ref -1); Fri, 01 Aug 2008 16:55:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 1 Aug 2008 16:47:08 +0000 Original-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 Original-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 Original-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 Original-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 Original-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) User-Agent: Wanderlust/2.15.3 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 =?UTF-8?Q?(Shij=C5=8D)?= APEL/10.6 Emacs/22.0.51 (x86_64-unknown-linux-gnu) MULE/5.0 (SAKAKI) 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 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Fri, 01 Aug 2008 13:07:25 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:18960 gmane.emacs.pretest.bugs:22785 Archived-At: --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--