emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with splash screen and emacsclient


From: Stefan Monnier
Subject: Re: Problem with splash screen and emacsclient
Date: Sun, 19 Nov 2006 20:33:55 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.90 (gnu/linux)

>> 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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]