From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Problem with splash screen and emacsclient Date: Sun, 19 Nov 2006 20:33:55 -0500 Message-ID: References: <4560CF07.5060406@student.lu.se> <4560D1A7.4030405@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1163986462 15116 80.91.229.2 (20 Nov 2006 01:34:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 20 Nov 2006 01:34:22 +0000 (UTC) Cc: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 20 02:34:20 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Gly35-00082E-BO for ged-emacs-devel@m.gmane.org; Mon, 20 Nov 2006 02:34:15 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gly34-0006qJ-Dd for ged-emacs-devel@m.gmane.org; Sun, 19 Nov 2006 20:34:14 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gly2o-0006nr-3x for emacs-devel@gnu.org; Sun, 19 Nov 2006 20:33:58 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gly2m-0006lv-EW for emacs-devel@gnu.org; Sun, 19 Nov 2006 20:33:56 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gly2l-0006ln-V1 for emacs-devel@gnu.org; Sun, 19 Nov 2006 20:33:55 -0500 Original-Received: from [209.226.175.97] (helo=tomts40-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Gly2l-0000Yx-PD for emacs-devel@gnu.org; Sun, 19 Nov 2006 20:33:55 -0500 Original-Received: from pastel.home ([70.55.143.67]) by tomts40-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20061120013354.NVOB3449.tomts40-srv.bellnexxia.net@pastel.home> for ; Sun, 19 Nov 2006 20:33:54 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 3977F8630; Sun, 19 Nov 2006 20:33:55 -0500 (EST) Original-To: Lennart Borgman In-Reply-To: <4560D1A7.4030405@student.lu.se> (Lennart Borgman's message of "Sun\, 19 Nov 2006 22\:50\:31 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.90 (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 Xref: news.gmane.org gmane.emacs.devel:62519 Archived-At: >> If Emacs is showing the splash screen and you open a file with emacsclient >> then Emacs shows that it is in some kind of recursive edit mode. The mode >> line may look like this >> >> >> --\-- emacsclient.c Top L1 CVS:1.91 [(C/l)] ---------------- >> >> Some commands does not work until the splash screens times out. The [] >> disappears then from the mode line. (You can use M-x top-level to get out >> of this state before time out.) >> >> It seems like emacs server should remove the splash screen just as normal >> input events does. But how should that be done? The function showing the >> splash screen is doing a (sit-for 120). Similar problem happen if you use emacsclient when Emacs is in the minibuffer. It's even worse when used on multiple displays since you may be stuck with an active minibuffer in one display to which you currently don't have access. I use the patch below for that purpose. I believe it should address your problem as well. Stefan --- orig/lisp/server.el +++ mod/lisp/server.el @@ -382,6 +397,13 @@ ;; nothing if there is one (for multiple Emacs sessions)? (server-start (not server-mode))) +(defun server-add-hook-once (hook function &optional append local) + "Same as `add-hook', but FUN is only run once. +Also contrary to `add-hook', this is not idempotent." + (let ((code (list 'lambda))) + (setcdr code `(() (,function) (remove-hook ',hook ',code ',local))) + (add-hook hook code append local))) + (defun* server-process-filter (proc string) "Process a request from the server to edit some files. PROC is the server process. Format of STRING is \"PATH PATH PATH... \\n\"." @@ -403,6 +425,15 @@ (when prev (setq string (concat prev string)) (process-put proc :previous-string nil))) + (when (> (recursion-depth) 0) + ;; We're inside a minibuffer already, so if the emacs-client is trying + ;; to open a frame on a new display, we might end up with an unusable + ;; frame because input from that display will be blocked (until exiting + ;; the minibuffer). Better exit this minibuffer right away. + (process-put proc :previous-string string) + (server-add-hook-once 'post-command-hook + `(lambda () (server-process-filter ',proc ""))) + (top-level)) ;; If the input is multiple lines, ;; process each line individually. (while (string-match "\n" string)