From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Giorgos Keramidas Newsgroups: gmane.emacs.devel Subject: Avoiding loss of rcirc messages from the on disk log Date: Sat, 31 Oct 2009 05:19:06 +0200 Message-ID: <87bpjol07p.fsf@kobe.laptop> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1256959220 13102 80.91.229.12 (31 Oct 2009 03:20:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 31 Oct 2009 03:20:20 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 31 04:20:13 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N44Vg-0007Kr-EZ for ged-emacs-devel@m.gmane.org; Sat, 31 Oct 2009 04:20:12 +0100 Original-Received: from localhost ([127.0.0.1]:45517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N44Vf-0007e1-U9 for ged-emacs-devel@m.gmane.org; Fri, 30 Oct 2009 23:20:11 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N44Uo-00078O-A1 for emacs-devel@gnu.org; Fri, 30 Oct 2009 23:19:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N44Uj-00075x-Ih for emacs-devel@gnu.org; Fri, 30 Oct 2009 23:19:17 -0400 Original-Received: from [199.232.76.173] (port=43709 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N44Uj-00075u-BX for emacs-devel@gnu.org; Fri, 30 Oct 2009 23:19:13 -0400 Original-Received: from poseidon.ceid.upatras.gr ([150.140.141.169]:33567) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N44Ui-0007K1-RO for emacs-devel@gnu.org; Fri, 30 Oct 2009 23:19:13 -0400 Original-Received: from mail.ceid.upatras.gr (unknown [10.1.0.143]) by poseidon.ceid.upatras.gr (Postfix) with ESMTP id 53ACBEB46E7 for ; Sat, 31 Oct 2009 05:19:09 +0200 (EET) Original-Received: from localhost (europa.ceid.upatras.gr [127.0.0.1]) by mail.ceid.upatras.gr (Postfix) with ESMTP id 326A1451B2 for ; Sat, 31 Oct 2009 05:19:09 +0200 (EET) X-Virus-Scanned: amavisd-new at ceid.upatras.gr Original-Received: from mail.ceid.upatras.gr ([127.0.0.1]) by localhost (europa.ceid.upatras.gr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3VY8YHdpNUtX for ; Sat, 31 Oct 2009 05:19:09 +0200 (EET) Original-Received: from kobe.laptop (adsl26-237.kln.forthnet.gr [77.49.153.237]) by mail.ceid.upatras.gr (Postfix) with ESMTP id DDB08450C6 for ; Sat, 31 Oct 2009 05:19:08 +0200 (EET) Original-Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id n9V3J7Qv060824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 31 Oct 2009 05:19:07 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Original-Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id n9V3J6VL060823; Sat, 31 Oct 2009 05:19:06 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (berkeley-unix) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:116490 Archived-At: 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'. I have now bound `C-c L' locally to a function that explicitly calls `rcirc-log-write': (defun keramida/rcirc-log-write () "A command-wrapper for the `rcirc-log-write' function. This wrapper may be bound to a key, so that `rcirc-log-write' can be called from any IRC buffer to immediately save any pending messages on disk." (interactive) (if (null rcirc-log-alist) (message "No IRC messages to save") (when rcirc-log-directory (rcirc-log-write) (message "IRC messages saved in %s" rcirc-log-directory)))) (defun keramida/rcirc-setup-keys () "Set up some custom keys that I find useful in rcirc buffers." (local-set-key (kbd "C-c L") 'keramida/rcirc-log-write)) (add-hook 'rcirc-mode-hook 'keramida/rcirc-setup-keys) This is ok for now, but it seems slightly ugly. Looking at the source code of rcirc, I see that it adds its own `rcirc-kill-buffer-hook' to the `kill-buffer-hook'. This calls `rcirc-clean-up-buffer', but there is no call to `rcirc-log-write' in the rcirc buffer cleanup function. Would it be a good idea to install the following change to `rcirc.el' so that all log messages are flushed to disk when an rcirc buffer is killed? ------------------------------------------------------------------------ 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 @@ -984,6 +984,8 @@ 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 () ------------------------------------------------------------------------