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 ;; You can check recently visited channels via `C-c g' in the commands
27 ;; buffer, by adding the following lines to ~/.riece/init.el:
29 ;; (add-hook 'riece-guess-channel-try-functions
30 ;; 'riece-guess-channel-from-history)
36 (defgroup riece-history nil
42 (defcustom riece-channel-history-length 3
43 "Length of riece-channel-history."
45 :group 'riece-history)
47 (defface riece-channel-list-history-face
50 (:foreground "PaleTurquoise"))
53 (:foreground "SeaGreen3"))
56 "Face used for displaying history channels."
57 :group 'riece-highlight-faces)
58 (defvar riece-channel-list-history-face 'riece-channel-list-history-face)
60 (defvar riece-channel-history nil)
62 (defun riece-guess-channel-from-history ()
63 (let ((length (ring-length riece-channel-history))
66 (while (< index length)
67 (setq result (cons (ring-ref riece-channel-history index) result)
71 (defun riece-history-format-channel-list-line (index channel)
72 (if (and (not (ring-empty-p riece-channel-history))
73 (riece-identity-equal channel (ring-ref riece-channel-history 0)))
74 (concat (format "%2d:+" index)
75 (riece-format-identity channel)
78 ;;; (defun riece-history-requires ()
79 ;;; (if (memq 'riece-guess riece-addons)
82 (defun riece-history-insinuate ()
83 (add-hook 'riece-startup-hook
85 (setq riece-channel-history
86 (make-ring riece-channel-history-length))))
87 (add-hook 'riece-exit-hook
89 (setq riece-channel-history nil)))
90 (add-hook 'riece-after-switch-to-channel-functions
92 (unless (riece-identity-equal last riece-current-channel)
93 (ring-insert riece-channel-history last))))
94 (add-hook 'riece-format-channel-list-line-functions
95 'riece-history-format-channel-list-line)
96 (if (memq 'riece-highlight riece-addons)
97 (setq riece-channel-list-mark-face-alist
98 (cons '(?+ . riece-channel-list-history-face)
99 riece-channel-list-mark-face-alist)))
100 ;;; (if (memq 'riece-guess riece-addons)
101 ;;; (add-hook 'riece-guess-channel-try-functions
102 ;;; 'riece-guess-channel-from-history))
105 (provide 'riece-history)
107 ;;; riece-history.el ends here