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., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, 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 (defconst riece-guess-description
45 "Guess the next channel, using multiple methods.")
47 (defvar riece-current-channels)
49 (defun riece-guess-candidates ()
50 "Build candidate list.
51 This function calls \\[riece-guess-channel-try-functions] in turn and
53 (let ((functions riece-guess-channel-try-functions)
60 (unless (riece-identity-member
63 (funcall (car functions)))))
64 functions (cdr functions)))
71 (not (riece-identity-member
74 riece-current-channels))))
77 (defvar riece-guess-candidates nil)
79 (defun riece-command-guess-switch-to-channel ()
80 "Try to switch to the channel where the user is interested in."
82 (unless (and (eq last-command this-command)
83 riece-guess-candidates)
84 (setq riece-guess-candidates (riece-guess-candidates)))
85 (unless riece-guess-candidates
87 (riece-command-switch-to-channel
88 (prog1 (car riece-guess-candidates)
89 (setq riece-guess-candidates (cdr riece-guess-candidates)))))
91 (defvar riece-command-mode-map)
92 (defvar riece-dialogue-mode-map)
93 (defvar riece-channel-list-mode-map)
95 (defun riece-guess-insinuate ()
98 (defun riece-guess-enable ()
99 (define-key riece-command-mode-map
100 "\C-cg" 'riece-command-guess-switch-to-channel)
101 (define-key riece-dialogue-mode-map
102 "g" 'riece-command-guess-switch-to-channel)
103 (define-key riece-channel-list-mode-map
104 "g" 'riece-command-guess-switch-to-channel))
106 (defun riece-guess-disable ()
107 (define-key riece-command-mode-map
109 (define-key riece-dialogue-mode-map
111 (define-key riece-channel-list-mode-map
114 (provide 'riece-guess)
116 ;;; riece-guess.el ends here