Index: ChangeLog
===================================================================
RCS file: /project/slime/cvsroot/slime/ChangeLog,v
retrieving revision 1.1581
diff -u -p -r1.1581 ChangeLog
--- ChangeLog	2 Nov 2008 12:05:24 -0000	1.1581
+++ ChangeLog	19 Nov 2008 14:34:35 -0000
@@ -1,3 +1,13 @@
+2008-11-19  Gábor Melis  <mega@retes.hu>
+
+	* slime.el (slime-compute-modeline-connection-state): Return the
+	number of outstanding requests if connected.
+	(slime-update-all-modelines): Renamed from slime-update-modelines,
+	loops through all slime buffers.
+	(slime-restart-or-init-modeline-update-timer): New function.
+	(slime-dispatch-event): Arrange for modelines to be updated on
+	:EMACS-REX and :RETURN.
+
 2008-11-02  Helmut Eller  <heller@common-lisp.net>
 
 	* slime.el (slime-popup-buffer-quit): Always delete windows and
Index: slime.el
===================================================================
RCS file: /project/slime/cvsroot/slime/slime.el,v
retrieving revision 1.1060
diff -u -p -r1.1060 slime.el
--- slime.el	2 Nov 2008 12:05:24 -0000	1.1060
+++ slime.el	19 Nov 2008 14:34:49 -0000
@@ -481,8 +481,11 @@ The string is periodically updated by an
 (defun slime-compute-modeline-connection-state ()
   (let ((new-state (slime-compute-connection-state (slime-current-connection))))
     (if (eq new-state :connected)
-        nil ; normal case, so don't display anything in the mode line.
-        (slime-connection-state-as-string new-state))))
+        (let ((n (length (slime-rex-continuations))))
+          (if (= n 0)
+              nil
+            n))
+      (slime-connection-state-as-string new-state))))
 
 (defun slime-compute-modeline-string (conn state pkg)
   (concat (when (or conn pkg)             "[")
@@ -506,18 +509,28 @@ The string is periodically updated by an
       (setq slime-modeline-connection-name new-conn)
       (setq slime-modeline-connection-state new-state)
       (setq slime-modeline-string
-            (slime-compute-modeline-string new-conn new-state new-pkg))
-      (force-mode-line-update t))))
+            (slime-compute-modeline-string new-conn new-state new-pkg)))))
 
 (defun slime-shall-we-update-modeline-p ()
   (and slime-extended-modeline 
        (or slime-mode slime-popup-buffer-mode)))
 
-(defun slime-update-modeline ()
-  (when (slime-shall-we-update-modeline-p)
-    (slime-update-modeline-string)))
+(defun slime-update-all-modelines ()
+  (dolist (buffer (buffer-list))
+    (with-current-buffer buffer
+      (when (slime-shall-we-update-modeline-p)
+        (slime-update-modeline-string)
+        (force-mode-line-update t)))))
+
+(defvar slime-modeline-update-timer nil)
+
+(defun slime-restart-or-init-modeline-update-timer ()
+  (when slime-modeline-update-timer
+    (cancel-timer slime-modeline-update-timer))
+  (setq slime-modeline-update-timer
+        (run-with-idle-timer 0.2 0.2 'slime-update-all-modelines)))
 
-(run-with-idle-timer 0.2 0.2 'slime-update-modeline)
+(slime-restart-or-init-modeline-update-timer)
 
 ;; Setup the mode-line to say when we're in slime-mode, which
 ;; connection is active, and which CL package we think the current
@@ -2373,11 +2386,19 @@ Debugged requests are ignored."
              (slime-display-oneliner "; pipelined request... %S" form))
            (let ((id (incf (slime-continuation-counter))))
              (push (cons id continuation) (slime-rex-continuations))
+             ;; Minimize flashing of modeline due to short lived
+             ;; requests such as those of autodoc.
+             (slime-restart-or-init-modeline-update-timer)
              (slime-send `(:emacs-rex ,form ,package ,thread ,id))))
           ((:return value id)
            (let ((rec (assq id (slime-rex-continuations))))
              (cond (rec (setf (slime-rex-continuations)
                               (remove rec (slime-rex-continuations)))
+                        ;; Must do this ourselves since emacs may have
+                        ;; been idling long enough that
+                        ;; SLIME-MODELINE-UPDATE-TIMER is not going to
+                        ;; trigger by itself.
+                        (slime-update-all-modelines)
                         (funcall (cdr rec) value))
                    (t
                     (error "Unexpected reply: %S %S" id value)))))
