Subject: Re: bug#18510: 24.4.50; ERC doesn't update mode line frequently enough

From: Stefan Monnier <[email-masked]>
Date: Fri, 19 Sep 2014 14:37:07 -0400

>> I've worked around it locally by advising erc-update-mode-line to call
>> (force-mode-line-update t).
> That's not a workaround, that's a fix.

Hmm... not sure what that was about, sorry.  Of course, the
(force-mode-line-update t) should only be called when changing
a variable that's visible in the global mode-line-format.

Does the patch below work?
[ I assume the problem is also present in 24.3.93.  ]

        Stefan

=== modified file 'lisp/erc/erc-track.el'
--- lisp/erc/erc-track.el	2014-02-10 01:34:22 +0000
+++ lisp/erc/erc-track.el	2014-09-19 18:34:57 +0000
@@ -767,8 +765,7 @@
 		  (erc-modified-channels-remove-buffer buffer))))
 	    erc-modified-channels-alist)
       (when removed-channel
-	(erc-modified-channels-display)
-	(force-mode-line-update t)))
+	(erc-modified-channels-display)))
     (remove-hook 'post-command-hook 'erc-modified-channels-update)))
 
 (defvar erc-track-mouse-face (if (featurep 'xemacs)
@@ -825,9 +822,10 @@
 	((eq 'importance erc-track-switch-direction)
 	 (erc-track-sort-by-importance)))
   (run-hooks 'erc-track-list-changed-hook)
-  (unless (eq erc-track-position-in-mode-line nil)
-  (if (null erc-modified-channels-alist)
-      (setq erc-modified-channels-object (erc-modified-channels-object nil))
+  (when erc-track-position-in-mode-line
+    (let* ((oldobject erc-modified-channels-object)
+	   (strings
+	    (when erc-modified-channels-alist
     ;; erc-modified-channels-alist contains all the data we need.  To
     ;; better understand what is going on, we split things up into
     ;; four lists: BUFFERS, COUNTS, SHORT-NAMES, and FACES.  These
@@ -858,10 +856,11 @@
 	      buffers (cdr buffers)
 	      counts (cdr counts)
 	      faces (cdr faces)))
-      (when (featurep 'xemacs)
-	(erc-modified-channels-object nil))
-      (setq erc-modified-channels-object
-	    (erc-modified-channels-object strings))))))
+		strings)))
+	   (newobject (erc-modified-channels-object strings)))
+      (unless (equal oldobject newobject)
+	(setq erc-modified-channels-object newobject)
+	(force-mode-line-update t)))))
 
 (defun erc-modified-channels-remove-buffer (buffer)
   "Remove BUFFER from `erc-modified-channels-alist'."