1 ;;; riece-history.el --- channel history management add-on
2 ;; Copyright (C) 1998-2003 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Keywords: IRC, riece
7 ;; This file is part of Riece.
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
26 ;; To use, add the following line to your ~/.riece/init.el:
27 ;; (add-to-list 'riece-addons 'riece-history)
33 (defgroup riece-history nil
39 (defcustom riece-channel-history-length 3
40 "Length of riece-channel-history."
42 :group 'riece-history)
44 (defvar riece-channel-history nil)
46 (defun riece-guess-channel-from-history ()
47 (let ((length (ring-length riece-channel-history))
50 (while (< index length)
51 (setq result (cons (ring-ref riece-channel-history index) result)
55 (defun riece-history-requires ()
56 (if (memq 'riece-guess riece-addons)
59 (defun riece-history-insinuate ()
60 (add-hook 'riece-startup-hook
62 (setq riece-channel-history
63 (make-ring riece-channel-history-length))))
64 (add-hook 'riece-exit-hook
66 (setq riece-channel-history nil)))
67 (add-hook 'riece-after-switch-to-channel-functions
69 (ring-insert riece-channel-history last)))
70 (if (memq 'riece-guess riece-addons)
71 (add-hook 'riece-guess-channel-try-functions
72 'riece-guess-channel-from-history)))
74 (provide 'riece-history)
76 ;;; riece-history.el ends here