1 ;;; riece-guess.el --- guess the next channel, using multiple methods
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-guess)
31 (require 'riece-identity)
32 (require 'riece-commands)
34 (defgroup riece-guess nil
35 "Guess the next channel"
40 (defcustom riece-guess-channel-try-functions
41 '(riece-default-guess-channel)
42 "Functions which returns a list of channels the user wants to switch."
43 :type '(repeat function)
46 (defvar riece-current-channels)
47 (defun riece-default-guess-channel ()
48 (delq nil (copy-sequence riece-current-channels)))
50 (defun riece-guess-candidates ()
51 (let ((functions riece-guess-channel-try-functions)
58 (if (riece-identity-member channel candidates)
61 (funcall (car functions)))))
62 functions (cdr functions)))
65 (defvar riece-guess-candidates nil)
67 (defun riece-command-guess-switch-to-channel ()
68 "Try to switch to the channel where the user is interested in."
70 (unless (eq last-command this-command)
71 (setq riece-guess-candidates (riece-guess-candidates)))
72 (unless riece-guess-candidates
74 (riece-command-switch-to-channel
75 (prog1 (car riece-guess-candidates)
76 (setq riece-guess-candidates (cdr riece-guess-candidates)))))
78 (defvar riece-command-mode-map)
79 (defvar riece-dialogue-mode-map)
80 (defvar riece-channel-list-mode-map)
82 (defun riece-guess-insinuate ()
83 (define-key riece-command-mode-map
84 "\C-cg" 'riece-command-guess-switch-to-channel)
85 (define-key riece-dialogue-mode-map
86 "g" 'riece-command-guess-switch-to-channel)
87 (define-key riece-channel-list-mode-map
88 "g" 'riece-command-guess-switch-to-channel))
90 (provide 'riece-guess)
92 ;;; riece-guess.el ends here