From: ueno Date: Sun, 14 Mar 2004 01:39:30 +0000 (+0000) Subject: * riece-display.el (riece-display-connect-signals): Update X-Git-Tag: riece-0_2_2~15 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2698182f06e6c6b36412cddce8d6d2c6cb25c965;p=elisp%2Friece.git * 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. --- diff --git a/lisp/COMPILE b/lisp/COMPILE index de49d00..be964cf 100644 --- a/lisp/COMPILE +++ b/lisp/COMPILE @@ -11,6 +11,7 @@ riece-coding riece-complete + riece-mode ;; riece-identity -+-> riece-channel ;; +-> riece-user riece-identity diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e85fe98..7ffb53a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,33 @@ +2004-03-14 Daiki Ueno + + * 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 * riece-ctcp.el: "Error occurred in XXX" -> "Error in XXX". diff --git a/lisp/Makefile.am b/lisp/Makefile.am index 108ec38..8a7d4b8 100644 --- a/lisp/Makefile.am +++ b/lisp/Makefile.am @@ -3,7 +3,7 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \ 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 \ diff --git a/lisp/riece-300.el b/lisp/riece-300.el index 034e9c0..21ca896 100644 --- a/lisp/riece-300.el +++ b/lisp/riece-300.el @@ -289,16 +289,9 @@ (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))) diff --git a/lisp/riece-channel.el b/lisp/riece-channel.el index 1f0c293..da4b75d 100644 --- a/lisp/riece-channel.el +++ b/lisp/riece-channel.el @@ -27,6 +27,7 @@ (require 'riece-options) (require 'riece-globals) (require 'riece-identity) +(require 'riece-mode) ;;; Channel object: (defun riece-find-channel (name) @@ -147,12 +148,13 @@ respectively." (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." diff --git a/lisp/riece-display.el b/lisp/riece-display.el index c78d9e7..253ae75 100644 --- a/lisp/riece-display.el +++ b/lisp/riece-display.el @@ -188,7 +188,7 @@ Local to the buffer in `riece-buffer-list'.") (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 diff --git a/lisp/riece-handle.el b/lisp/riece-handle.el index e83fbe5..f08270d 100644 --- a/lisp/riece-handle.el +++ b/lisp/riece-handle.el @@ -29,6 +29,7 @@ (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)) @@ -344,68 +345,6 @@ 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)) @@ -414,7 +353,8 @@ (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 diff --git a/lisp/riece-misc.el b/lisp/riece-misc.el index 0a68bb1..ded59d1 100644 --- a/lisp/riece-misc.el +++ b/lisp/riece-misc.el @@ -31,6 +31,7 @@ (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))) @@ -143,7 +144,16 @@ (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) diff --git a/lisp/riece-mode.el b/lisp/riece-mode.el new file mode 100644 index 0000000..4a77940 --- /dev/null +++ b/lisp/riece-mode.el @@ -0,0 +1,72 @@ +;;; riece-mode.el --- functions for manipulating channel/user modes +;; Copyright (C) 1998-2003 Daiki Ueno + +;; Author: Daiki Ueno +;; 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 diff --git a/lisp/riece-naming.el b/lisp/riece-naming.el index 4aa774d..dd5ad10 100644 --- a/lisp/riece-naming.el +++ b/lisp/riece-naming.el @@ -88,6 +88,49 @@ 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 diff --git a/lisp/riece-user.el b/lisp/riece-user.el index e42c825..8a3f974 100644 --- a/lisp/riece-user.el +++ b/lisp/riece-user.el @@ -24,6 +24,7 @@ ;;; Code: (require 'riece-identity) +(require 'riece-mode) ;;; User object: (defun riece-find-user (name) @@ -134,11 +135,12 @@ away status, respectively." (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)