unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Giorgos Keramidas <keramida@ceid.upatras.gr>
To: emacs-devel@gnu.org
Subject: Avoiding loss of rcirc messages from the on disk log
Date: Sat, 31 Oct 2009 05:19:06 +0200	[thread overview]
Message-ID: <87bpjol07p.fsf@kobe.laptop> (raw)

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





                 reply	other threads:[~2009-10-31  3:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bpjol07p.fsf@kobe.laptop \
    --to=keramida@ceid.upatras.gr \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).