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 ;; NOTE: This is an add-on module for Riece.
30 (require 'riece-identity)
31 (require 'riece-commands)
33 (defgroup riece-guess nil
34 "Guess the next channel."
39 (defcustom riece-guess-channel-try-functions nil
40 "Functions which returns a list of channels the user wants to switch."
41 :type '(repeat function)
44 (defvar riece-guess-enabled nil)
46 (defconst riece-guess-description
47 "Guess the next channel, using multiple methods.")
49 (defvar riece-current-channels)
51 (defun riece-guess-candidates ()
52 "Build candidate list.
53 This function calls \\[riece-guess-channel-try-functions] in turn and
55 (let ((functions riece-guess-channel-try-functions)
62 (unless (riece-identity-member
65 (funcall (car functions)))))
66 functions (cdr functions)))
73 (not (riece-identity-member
76 riece-current-channels))))
79 (defvar riece-guess-candidates nil)
81 (defun riece-command-guess-switch-to-channel ()
82 "Try to switch to the channel where the user is interested in."
84 (unless (and (eq last-command this-command)
85 riece-guess-candidates)
86 (setq riece-guess-candidates (riece-guess-candidates)))
87 (unless riece-guess-candidates
89 (riece-command-switch-to-channel
90 (prog1 (car riece-guess-candidates)
91 (setq riece-guess-candidates (cdr riece-guess-candidates)))))
93 (defvar riece-command-mode-map)
94 (defvar riece-dialogue-mode-map)
95 (defvar riece-channel-list-mode-map)
97 (defun riece-guess-insinuate ()
100 (defun riece-guess-enable ()
101 (define-key riece-command-mode-map
102 "\C-cg" 'riece-command-guess-switch-to-channel)
103 (define-key riece-dialogue-mode-map
104 "g" 'riece-command-guess-switch-to-channel)
105 (define-key riece-channel-list-mode-map
106 "g" 'riece-command-guess-switch-to-channel)
107 (setq riece-guess-enabled t))
109 (defun riece-guess-disable ()
110 (define-key riece-command-mode-map
112 (define-key riece-dialogue-mode-map
114 (define-key riece-channel-list-mode-map
116 (setq riece-guess-enabled nil))
118 (provide 'riece-guess)
120 ;;; riece-guess.el ends here