From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.devel Subject: Re: server-buffer-clients and find-file-hook Date: Fri, 21 Dec 2007 02:15:56 +0100 Message-ID: <476B13CC.9030601@gmail.com> References: <4761CD65.8040708@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1198199777 15422 80.91.229.12 (21 Dec 2007 01:16:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Dec 2007 01:16:17 +0000 (UTC) Cc: Emacs Devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 21 02:16:28 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1J5WV0-0001AI-RV for ged-emacs-devel@m.gmane.org; Fri, 21 Dec 2007 02:16:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J5WUh-0003uc-3L for ged-emacs-devel@m.gmane.org; Thu, 20 Dec 2007 20:16:07 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J5WUd-0003sc-P5 for emacs-devel@gnu.org; Thu, 20 Dec 2007 20:16:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J5WUc-0003qy-RB for emacs-devel@gnu.org; Thu, 20 Dec 2007 20:16:03 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J5WUc-0003qk-NR for emacs-devel@gnu.org; Thu, 20 Dec 2007 20:16:02 -0500 Original-Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J5WUc-00027i-6m for emacs-devel@gnu.org; Thu, 20 Dec 2007 20:16:02 -0500 Original-Received: from c83-254-148-228.bredband.comhem.se ([83.254.148.228]:59385 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1J5WUa-0003US-5Y; Fri, 21 Dec 2007 02:16:00 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 In-Reply-To: X-Antivirus: avast! (VPS 071220-0, 2007-12-20), Outbound message X-Antivirus-Status: Clean X-Originating-IP: 83.254.148.228 X-Scan-Result: No virus found in message 1J5WUa-0003US-5Y. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1J5WUa-0003US-5Y fe36e37b0219724fea7119e2be726dd7 X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) 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 Xref: news.gmane.org gmane.emacs.devel:85325 Archived-At: Stefan Monnier wrote: >> server-buffer-clients is nil (Emacs 22) when find-file-hook is run. >> That makes it impossible to test if a buffer has clients at that time. > > Seems difficult to solve this one directly: find-file creates the > buffer, so it first creates the buffer then calls find-file-hook then > returns the buffer to server.el (via find-file-noselect): server.el > doesn't get a chance to set server-buffer-clients early enough. > > Did this used to work differently in earlier versions of Emacs? I do not believe it worked differently. I am using a not-so-very-beatiful work around currently ;-) (defun as-external-is-from-emacsclient () "Return non-nil if buffer has clients waiting, otherwise nil." (or server-buffer-clients ;; Fix-me: The above does not work because of what I think is a ;; bug in Emacs. Work around: (let ((bt (with-output-to-string (backtrace))) ;; Hide the regexp in the backtrace: (hidden-regexp (concat "server-" "visit-file"))) (save-match-data (string-match hidden-regexp bt)))))