riece-long-channel-indicator on 'channel-modes-changed signal.
* riece-naming.el (riece-naming-assert-channel-modes): New
function renamed from riece-handle-channel-modes.
* riece-misc.el: Require 'riece-mode.
(riece-concat-channel-modes): Display mode parameter.
* riece-channel.el: Require 'riece-mode.
(riece-channel-toggle-mode): Store mode "objects" instead of mode
"flags".
* riece-user.el: Require 'riece-mode.
(riece-user-toggle-mode): Store mode "objects" instead of mode
"flags".
* riece-handle.el: Require 'riece-mode.
(riece-handle-mode-message): Use riece-parse-mode.
(riece-parse-mode): Moved to riece-mode.el.
(riece-handle-channel-modes): Moved to riece-naming.el.
* riece-300.el: Require 'riece-mode.
(riece-handle-324-message): Use riece-parse-mode.
* riece-mode.el: New file.
* Makefile.am (EXTRA_DIST): Add riece-mode.el.
* COMPILE (riece-modules): Add riece-mode.
riece-coding
riece-complete
+ riece-mode
;; riece-identity -+-> riece-channel
;; +-> riece-user
riece-identity
+2004-03-14 Daiki Ueno <ueno@unixuser.org>
+
+ * riece-display.el (riece-display-connect-signals): Update
+ riece-long-channel-indicator on 'channel-modes-changed signal.
+
+ * riece-naming.el (riece-naming-assert-channel-modes): New
+ function renamed from riece-handle-channel-modes.
+
+ * riece-misc.el: Require 'riece-mode.
+ (riece-concat-channel-modes): Display mode parameter.
+
+ * riece-channel.el: Require 'riece-mode.
+ (riece-channel-toggle-mode): Store mode "objects" instead of mode
+ "flags".
+ * riece-user.el: Require 'riece-mode.
+ (riece-user-toggle-mode): Store mode "objects" instead of mode
+ "flags".
+
+ * riece-handle.el: Require 'riece-mode.
+ (riece-handle-mode-message): Use riece-parse-mode.
+ (riece-parse-mode): Moved to riece-mode.el.
+ (riece-handle-channel-modes): Moved to riece-naming.el.
+
+ * riece-300.el: Require 'riece-mode.
+ (riece-handle-324-message): Use riece-parse-mode.
+
+ * riece-mode.el: New file.
+ * Makefile.am (EXTRA_DIST): Add riece-mode.el.
+ * COMPILE (riece-modules): Add riece-mode.
+
2004-03-13 Daiki Ueno <ueno@unixuser.org>
* riece-ctcp.el: "Error occurred in XXX" -> "Error in XXX".
riece-channel.el riece-coding.el riece-commands.el riece-compat.el \
riece-complete.el riece-display.el riece-emacs.el riece-filter.el \
riece-globals.el riece-handle.el riece-highlight.el riece-identity.el \
- riece-message.el riece-misc.el riece-naming.el \
+ riece-message.el riece-misc.el riece-mode.el riece-naming.el \
riece-options.el riece-server.el riece-signal.el riece-user.el \
riece-version.el riece-xemacs.el riece.el \
riece-ctcp.el riece-url.el riece-unread.el \
(defun riece-handle-324-message (prefix number name string)
(if (string-match "^\\([^ ]+\\) \\([^ ]+\\) " string)
(let* ((channel (match-string 1 string))
- (mode-string (substring string (match-beginning 2)))
- (modes (string-to-list (match-string 2 string)))
- (toggle (car modes)))
- (setq modes (cdr modes))
- (while modes
- (riece-channel-toggle-mode channel (car modes) (eq toggle ?+))
- (setq modes (cdr modes)))
- (riece-emit-signal 'channel-modes-changed
- (riece-make-identity channel riece-server-name)
- modes (eq toggle ?+))
+ (mode-string (match-string 2 string)))
+ (riece-naming-assert-channel-modes channel
+ (riece-parse-modes mode-string))
(let* ((channel-identity (riece-make-identity channel
riece-server-name))
(buffer (riece-channel-buffer channel-identity)))
(require 'riece-options)
(require 'riece-globals)
(require 'riece-identity)
+(require 'riece-mode)
;;; Channel object:
(defun riece-find-channel (name)
(defun riece-channel-toggle-mode (name mode flag)
"Add or remove channel MODE of channel."
(let* ((channel (riece-get-channel name))
- (modes (riece-channel-modes channel)))
+ (modes (riece-channel-modes channel))
+ (old (riece-mode-assoc (riece-mode-flag mode) modes)))
(if flag
- (unless (memq mode modes)
+ (unless old
(riece-channel-set-modes channel (cons mode modes)))
- (if (memq mode modes)
- (riece-channel-set-modes channel (delq mode modes))))))
+ (if old
+ (riece-channel-set-modes channel (delq old modes))))))
(defun riece-channel-toggle-banned (name pattern flag)
"Add or remove banned PATTERN of channel."
(riece-connect-signal
'channel-modes-changed
(lambda (signal handback)
- (riece-update-status-indicators)
+ (riece-update-long-channel-indicator)
(force-mode-line-update t))
(lambda (signal)
(and riece-current-channel
(require 'riece-channel)
(require 'riece-naming)
(require 'riece-signal)
+(require 'riece-mode)
(defun riece-handle-nick-message (prefix string)
(let* ((old (riece-prefix-nickname prefix))
topic))
"\n")))))
-(defun riece-parse-modes (string)
- (let ((start 0)
- result)
- (while (and (string-match "[-+]\\([^ ]*\\) *" string start)
- (= (match-beginning 0) start))
- (let ((toggle (eq (aref string 0) ?+))
- (modes (string-to-list (match-string 1 string))))
- (setq start (match-end 0))
- (while modes
- (if (and (string-match "\\([^-+][^ ]*\\) *" string start)
- (= (match-beginning 0) start))
- (setq start (match-end 0)
- result (cons (list (car modes) toggle
- (match-string 1 string))
- result))
- (setq result (cons (list (car modes) toggle)
- result)))
- (setq modes (cdr modes)))))
- (nreverse result)))
-
-(defun riece-handle-channel-modes (channel modes)
- (while modes
- (cond
- ((eq (car (car modes)) ?o)
- (riece-channel-toggle-operator channel
- (nth 2 (car modes))
- (nth 1 (car modes)))
- (riece-emit-signal 'channel-operators-changed
- (riece-make-identity channel
- riece-server-name)
- (riece-make-identity (nth 2 (car modes))
- riece-server-name)
- (nth 1 (car modes))))
- ((eq (car (car modes)) ?v)
- (riece-channel-toggle-speaker channel
- (nth 2 (car modes))
- (nth 1 (car modes)))
- (riece-emit-signal 'channel-speakers-changed
- (riece-make-identity channel
- riece-server-name)
- (riece-make-identity (nth 2 (car modes))
- riece-server-name)
- (nth 1 (car modes))))
- ((eq (car (car modes)) ?b)
- (riece-channel-toggle-banned channel
- (nth 2 (car modes))
- (nth 1 (car modes))))
- ((eq (car (car modes)) ?e)
- (riece-channel-toggle-uninvited channel
- (nth 2 (car modes))
- (nth 1 (car modes))))
- ((eq (car (car modes)) ?I)
- (riece-channel-toggle-invited channel
- (nth 2 (car modes))
- (nth 1 (car modes))))
- (t
- (apply #'riece-channel-toggle-mode channel (car modes))))
- (setq modes (cdr modes)))
- (riece-emit-signal 'channel-modes-changed
- (riece-make-identity channel
- riece-server-name)))
-
(defun riece-handle-mode-message (prefix string)
(let* ((user (riece-prefix-nickname prefix))
(user-identity (riece-make-identity user riece-server-name))
(setq channel (match-string 1 string)
string (substring string (match-end 0)))
(if (string-match (concat "^" riece-channel-regexp "$") channel)
- (riece-handle-channel-modes channel (riece-parse-modes string)))
+ (riece-naming-assert-channel-modes channel
+ (riece-parse-modes string)))
(let* ((channel-identity (riece-make-identity channel riece-server-name))
(buffer (riece-channel-buffer channel-identity)))
(riece-insert-change
(require 'riece-channel)
(require 'riece-server)
(require 'riece-user)
+(require 'riece-mode)
(defun riece-get-buffer-create (name &optional init-major-mode)
(let ((buffer (get-buffer name)))
(riece-with-server-buffer (riece-identity-server target)
(let ((modes (riece-channel-get-modes (riece-identity-prefix target))))
(if modes
- (concat string " [" (apply #'string modes) "]")
+ (concat string " ["
+ (mapconcat
+ (lambda (mode)
+ (if (riece-mode-parameter mode)
+ (format "%c(%s)"
+ (riece-mode-flag mode)
+ (riece-mode-parameter mode))
+ (char-to-string (riece-mode-flag mode))))
+ modes "")
+ "]")
string))))
(defun riece-concat-message (string message)
--- /dev/null
+;;; riece-mode.el --- functions for manipulating channel/user modes
+;; Copyright (C) 1998-2003 Daiki Ueno
+
+;; Author: Daiki Ueno <ueno@unixuser.org>
+;; Created: 1998-09-28
+;; Keywords: IRC, riece
+
+;; This file is part of Riece.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Code:
+
+(defun riece-parse-modes (string)
+ (let ((start 0)
+ result)
+ (while (and (string-match "[-+]\\([^ ]*\\) *" string start)
+ (= (match-beginning 0) start))
+ (let ((toggle (eq (aref string 0) ?+))
+ (modes (string-to-list (match-string 1 string))))
+ (setq start (match-end 0))
+ (while modes
+ (if (and (string-match "\\([^-+][^ ]*\\) *" string start)
+ (= (match-beginning 0) start))
+ (setq start (match-end 0)
+ result (cons (list (riece-make-mode
+ (car modes) (match-string 1 string))
+ toggle)
+ result))
+ (setq result (cons (list (riece-make-mode (car modes))
+ toggle)
+ result)))
+ (setq modes (cdr modes)))))
+ (nreverse result)))
+
+(defun riece-mode-assoc (flag modes)
+ "Return a mode object matched with FLAG in MODES."
+ (catch 'found
+ (while modes
+ (if (eq flag (riece-mode-flag (car modes)))
+ (throw 'found (car modes)))
+ (setq modes (cdr modes)))))
+
+(defun riece-make-mode (flag &optional parameter)
+ "Make an instance of mode object.
+Arguments are appropriate to the flag and the parameter."
+ (vector flag parameter))
+
+(defun riece-mode-flag (mode)
+ "Return the flag of MODE."
+ (aref mode 0))
+
+(defun riece-mode-parameter (mode)
+ "Return the parameter of MODE."
+ (aref mode 1))
+
+(provide 'riece-mode)
+
+;;; riece-mode.el ends here
\ No newline at end of file
users (cdr users)))
(riece-emit-signal 'user-list-changed channel-identity)))
+(defun riece-naming-assert-channel-modes (channel modes)
+ (while modes
+ (cond
+ ((eq (riece-mode-flag (car (car modes))) ?o)
+ (riece-channel-toggle-operator channel
+ (riece-mode-parameter (car (car modes)))
+ (nth 1 (car modes)))
+ (riece-emit-signal 'channel-operators-changed
+ (riece-make-identity channel
+ riece-server-name)
+ (riece-make-identity (riece-mode-parameter
+ (car (car modes)))
+ riece-server-name)
+ (nth 1 (car modes))))
+ ((eq (riece-mode-flag (car (car modes))) ?v)
+ (riece-channel-toggle-speaker channel
+ (riece-mode-parameter (car (car modes)))
+ (nth 1 (car modes)))
+ (riece-emit-signal 'channel-speakers-changed
+ (riece-make-identity channel
+ riece-server-name)
+ (riece-make-identity (riece-mode-parameter
+ (car (car modes)))
+ riece-server-name)
+ (nth 1 (car modes))))
+ ((eq (riece-mode-flag (car (car modes))) ?b)
+ (riece-channel-toggle-banned channel
+ (riece-mode-parameter (car (car modes)))
+ (nth 1 (car modes))))
+ ((eq (riece-mode-flag (car (car modes))) ?e)
+ (riece-channel-toggle-uninvited channel
+ (riece-mode-parameter (car (car modes)))
+ (nth 1 (car modes))))
+ ((eq (riece-mode-flag (car (car modes))) ?I)
+ (riece-channel-toggle-invited channel
+ (riece-mode-parameter (car (car modes)))
+ (nth 1 (car modes))))
+ (t
+ (apply #'riece-channel-toggle-mode channel (car modes))))
+ (setq modes (cdr modes)))
+ (riece-emit-signal 'channel-modes-changed
+ (riece-make-identity channel riece-server-name)))
+
(provide 'riece-naming)
;;; riece-naming.el ends here
;;; Code:
(require 'riece-identity)
+(require 'riece-mode)
;;; User object:
(defun riece-find-user (name)
(defun riece-user-toggle-mode (name mode flag)
"Add or remove user MODE of user."
(let* ((user (riece-get-user name))
- (modes (riece-user-modes user)))
+ (modes (riece-user-modes user))
+ (old (riece-mode-assoc (riece-mode-flag mode) modes)))
(if flag
- (unless (memq mode modes)
+ (unless old
(riece-user-set-modes user (cons mode modes)))
- (if (memq mode modes)
+ (if old
(riece-user-set-modes user (delq mode modes))))))
(defun riece-user-toggle-away (name flag)