Subject: bug#4940: Avoiding loss of rcirc messages from the on disk log

From: Chong Yidong <[email-masked]>
Date: Sun, 17 Jan 2010 19:01:33 -0500

Hi Ryan,

Could you review the patch from Giorgos Keramidas?  Thanks.

> The IRC buffers of "rcirc.el" use the auto-save mechanism to push log
> messages on disk.  This is a very good idea, since it avoids hitting the
> disk for every single line of the IRC log.  On busy channels it probably
> saves a *lot* of time that would be spent waiting for messages to be
> saved on disk.

> Unfortunately, it also means that the simple action of killing an rcirc
> buffer may lose some of the messages.  Any messages still on the alist
> `rcirc-log-alist' are still in memory and I've noticed that some of
> these may not be written to the log files in `rcirc-log-directory'.

diff -r e1381fd70a71 lisp/net/rcirc.el
--- a/lisp/net/rcirc.el	Fri Apr 03 03:02:01 2009 +0300
+++ b/lisp/net/rcirc.el	Sat Oct 31 05:12:55 2009 +0200
 <at>  <at>  -984,6 +984,8  <at>  <at>  If ALL is non-nil, update prompts in all
 (defun rcirc-kill-buffer-hook ()
   "Part the channel when killing an rcirc buffer."
   (when (eq major-mode 'rcirc-mode)
+    (when (and rcirc-log-directory rcirc-log-alist)
+      (rcirc-log-write))
     (rcirc-clean-up-buffer "Killed buffer")))
 
 (defun rcirc-change-major-mode-hook ()