From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: daniel dever Newsgroups: gmane.emacs.bugs Subject: Buffers not deleted correctly with server/emacsclient Date: Fri, 8 Aug 2003 13:50:46 -0400 Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <200308081750.h78HokWu028036@shlc0630.shr.intel.com> NNTP-Posting-Host: deer.gmane.org X-Trace: main.gmane.org 1060395426 28786 80.91.224.253 (9 Aug 2003 02:17:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 9 Aug 2003 02:17:06 +0000 (UTC) Cc: daniel.dever@intel.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 09 04:17:32 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19lJIR-0000Ue-00 for ; Sat, 09 Aug 2003 04:17:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19lJCh-0005V3-HN for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Aug 2003 22:11:35 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19lJ4y-0003ca-Qm for bug-gnu-emacs@gnu.org; Fri, 08 Aug 2003 22:03:36 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19lC57-0005AR-RF for bug-gnu-emacs@gnu.org; Fri, 08 Aug 2003 14:35:49 -0400 Original-Received: from [192.52.57.35] (helo=hermes.hd.intel.com) by monty-python.gnu.org with esmtp (Exim 4.20) id 19lBQ5-0000ia-Kh for bug-gnu-emacs@gnu.org; Fri, 08 Aug 2003 13:52:53 -0400 Original-Received: from petasus.hd.intel.com (petasus.hd.intel.com [10.127.45.3]) by hermes.hd.intel.com (8.11.6p2/8.11.6/d: outer.mc, v 1.66 2003/05/22 21:17:36 rfjohns1 Exp $) with ESMTP id h78HmZe14843 for ; Fri, 8 Aug 2003 17:48:35 GMT Original-Received: from shms.shr.intel.com (shms.shr.intel.com [10.243.68.69]) by petasus.hd.intel.com (8.11.6p2/8.11.6/d: inner.mc, v 1.35 2003/05/22 21:18:01 rfjohns1 Exp $) with ESMTP id h78Hjss20463 for ; Fri, 8 Aug 2003 17:45:54 GMT Original-Received: from shlc0630.shr.intel.com (shlc0630.shr.intel.com [10.243.74.70]) by shms.shr.intel.com (8.12.9/8.12.8/MailSET/Hub) with ESMTP id h78HolUJ020251; Fri, 8 Aug 2003 13:50:47 -0400 (EDT) Original-Received: from shlc0630.shr.intel.com (localhost [127.0.0.1]) by shlc0630.shr.intel.com (8.12.9/8.12.8/MailSET/client) with ESMTP id h78Holmq028039; Fri, 8 Aug 2003 13:50:47 -0400 Original-Received: (from dedever@localhost) by shlc0630.shr.intel.com (8.12.9/8.12.6/Submit) id h78HokWu028036; Fri, 8 Aug 2003 13:50:46 -0400 Original-To: bug-gnu-emacs@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:5512 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:5512 This bug report will be sent to the Free Software Foundation, not to your local site managers! Please write in English, because the Emacs maintainers do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. In GNU Emacs 21.2.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2002-05-27 on s0022 configured using `configure --prefix=/proj/usertools/ia32_linux/' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US locale-coding-system: iso-latin-1 default-enable-multibyte-characters: t Please describe exactly what actions triggered the bug and the precise symptoms of the bug: from shell tcsh on Linux (er, GNU/Linux :-): > setenv EDITOR emacsclient > emacs -q -f server-start & > more phone_listing.txt v [in more] C-x # [in emacs] [Notice that buffer is buried, but _not_ deleted in emacs, as it should be.] The value of server-kill-new-buffers is t. I believe the problem is that server-buffer-done in server.el checks for server-existing-buffer instead of (not server-existing-buffer). I've included a copy of that function with this change made to it. The function now seems to work, but be warned that I haven't spent much effort testing it. Search for DED to locate my change. /Dan Dever daniel.dever@intel.com ------------------------------------------------------------ ;; Here is the documentation for server-kill-new-buffers: ;; ;; Documentation: ;; *Whether to kill buffers when done with them. ;; If non-nil, kill a buffer unless it already existed before editing ;; it with Emacs server. If nil, kill only buffers as specified by ;; `server-temp-file-regexp'. ;; Please note that only buffers are killed that still have a client, ;; i.e. buffers visited which "emacsclient --no-wait" are never killed in ;; this way. ;; ;; You can customize this variable. ;; ;; Defined in `server'. ;; ;; However, the opposite was happening. The buffer was only being deleted ;; if it did already exist. ;; ;; Search for 'DED' to see my change. (defun server-buffer-done (buffer &optional for-killing) "Mark BUFFER as \"done\" for its client(s). This buries the buffer, then returns a list of the form (NEXT-BUFFER KILLED). NEXT-BUFFER is another server buffer, as a suggestion for what to select next, or nil. KILLED is t if we killed BUFFER \(typically, because it was visiting a temp file)." (let ((running (eq (process-status server-process) 'run)) (next-buffer nil) (killed nil) (first t) (old-clients server-clients)) (while old-clients (let ((client (car old-clients))) (or next-buffer (setq next-buffer (nth 1 (memq buffer client)))) (delq buffer client) ;; Delete all dead buffers from CLIENT. (let ((tail client)) (while tail (and (bufferp (car tail)) (null (buffer-name (car tail))) (delq (car tail) client)) (setq tail (cdr tail)))) ;; If client now has no pending buffers, ;; tell it that it is done, and forget it entirely. (if (cdr client) nil (if running (progn ;; Don't send emacsserver two commands in close succession. ;; It cannot handle that. (or first (sit-for 1)) (setq first nil) (send-string server-process (format "Close: %s Done\n" (car client))) (server-log (format "Close: %s Done\n" (car client))))) (setq server-clients (delq client server-clients)))) (setq old-clients (cdr old-clients))) (if (and (bufferp buffer) (buffer-name buffer)) ;; We may or may not kill this buffer; ;; if we do, do not call server-buffer-done recursively ;; from kill-buffer-hook. (let ((server-kill-buffer-running t)) (save-excursion (set-buffer buffer) (setq server-buffer-clients nil) (run-hooks 'server-done-hook)) ;; Notice whether server-done-hook killed the buffer. (if (null (buffer-name buffer)) (setq killed t) ;; Don't bother killing or burying the buffer ;; when we are called from kill-buffer. (unless for-killing (when (and (not killed) server-kill-new-buffers ;; DED: Added the 'not' 8 August 2003 (not (save-excursion (set-buffer buffer) server-existing-buffer))) (setq killed t) (bury-buffer buffer) (kill-buffer buffer)) (unless killed (if (server-temp-file-p buffer) (progn (kill-buffer buffer) (setq killed t)) (bury-buffer buffer))))))) (list next-buffer killed)))