Merge signal-slot branch.
authorDaiki Ueno <ueno@unixuser.org>
Sun, 7 Mar 2004 23:16:48 +0000 (23:16 +0000)
committerDaiki Ueno <ueno@unixuser.org>
Sun, 7 Mar 2004 23:16:48 +0000 (23:16 +0000)
21 files changed:
doc/riece-ja.texi
lisp/COMPILE
lisp/ChangeLog
lisp/Makefile.am
lisp/riece-300.el
lisp/riece-commands.el
lisp/riece-ctcp.el
lisp/riece-display.el
lisp/riece-emacs.el
lisp/riece-filter.el
lisp/riece-handle.el
lisp/riece-highlight.el
lisp/riece-history.el
lisp/riece-message.el
lisp/riece-naming.el
lisp/riece-ndcc.el
lisp/riece-signal.el [new file with mode: 0644]
lisp/riece-unread.el
lisp/riece-xemacs.el
lisp/riece-xface.el
lisp/riece.el

index a43f04e..53a4ef0 100644 (file)
@@ -192,7 +192,7 @@ Riece \e$B$O@_Dj%U%!%$%k$rJQ?t\e(B @code{riece-directory} \e$B$G;X<($5$l$k%G%#%l%/%
 * Connecting to multiple servers::  \e$BJ#?t$N%5!<%P$K$D$J$0$K$O\e(B
 @end menu
 
-@node Windows, Commands, Basic usage, Basic usage
+@node Windows, Indicators, Basic usage, Basic usage
 @section Windows
 
 \e$B%G%U%)%k%H$N@_Dj$G$O!"%A%c%s%M%k$KF~$k$H!"2<$N?^$K<($9$h$&$J8^$D$N%&%#%s\e(B
@@ -237,7 +237,7 @@ Riece \e$B$O@_Dj%U%!%$%k$rJQ?t\e(B @code{riece-directory} \e$B$G;X<($5$l$k%G%#%l%/%
 \e$B%"%6!<%:%P%C%U%!\e(B (@samp{*Others*})\e$B!#8=:_$N%A%c%s%M%k0J30$N2qOC$,N.$l$^$9!#\e(B
 @end enumerate
 
-@node Indicators
+@node Indicators, Commands, Windows, Basic usage
 @section Indicators
 
 \e$B%3%^%s%I%P%C%U%!$d%A%c%s%M%k%P%C%U%!$N%b!<%I%i%$%s$N:8C<$K$O!"\e(B
@@ -262,7 +262,7 @@ Riece: --- ueno #Liece [n]
 \e$B$P\e(B @samp{f})
 @end enumerate
 
-@node Commands, Connecting to multiple servers, Windows, Basic usage
+@node Commands, Connecting to multiple servers, Indicators, Basic usage
 @section Commands
 
 \e$BJ8>O$rF~NO$7$?%P%C%U%!$O!"%3%^%s%I%P%C%U%!$H8F$P$l!"%3%^%s%I%P%C%U%!$+$i\e(B
@@ -373,10 +373,12 @@ Riece \e$B$N%P!<%8%g%s$rI=<($7$^$9!#A0CV0z?t\e(B (@kbd{C-u}) \e$B$rM?$($k$H!"$h$j>\
 \e$B%f!<%6%j%9%H%P%C%U%!$NI=<(!&HsI=<($r@Z$jBX$($^$9\e(B(@code{riece-command-toggle-user-list-buffer-mode})
 @item C-c C-t f
 @findex riece-command-toggle-freeze
-\e$B%A%c%s%M%k%P%C%U%!!"$^$?$O%@%$%"%m%0%P%C%U%!$N%9%/%m!<%k$r6X;_$7$^$9\e(B(@code{riece-command-toggle-freeze})
+\e$B%A%c%s%M%k%P%C%U%!!"$^$?$O%@%$%"%m%0%P%C%U%!$rE`7k\e(B(\e$B%9%/%m!<%k$r6X;_\e(B)\e$B$7$^\e(B
+\e$B$9\e(B(@code{riece-command-toggle-freeze})
 @item C-c C-t o
 @findex riece-command-toggle-own-freeze
-\e$B%A%c%s%M%k%P%C%U%!!"$^$?$O%@%$%"%m%0%P%C%U%!$N%9%/%m!<%k$r!"<+J,$,H/8@$9$k$^$G6X;_$7$^$9\e(B(@code{riece-command-toggle-own-freeze})
+\e$B%A%c%s%M%k%P%C%U%!!"$^$?$O%@%$%"%m%0%P%C%U%!$r!"<+J,$,H/8@$9$k$^$GE`7k$7\e(B
+\e$B$^$9\e(B(@code{riece-command-toggle-own-freeze})
 @item C-c C-t a
 @findex riece-command-toggle-away
 \e$B<+J,$NN%@J>uBV$r@Z$jBX$($^$9\e(B(@code{riece-command-toggle-away})
@@ -617,6 +619,7 @@ Riece \e$B$K$O!"%O%s%I%i%U%C%/$H8F$P$l$kFC<l$J%U%C%/$,$"$j$^$9!#$3$l$i$O\e(B IRC
 * Debugging::                   
 * Modules::                     
 * Namespace management::        
+* Signals::                     
 @end menu
 
 @node CVS, Debugging, Development, Development
@@ -684,6 +687,8 @@ channel object \e$B4XO"$NDj5A\e(B
 @item riece-user
 user object \e$B4XO"$NDj5A\e(B 
 
+@item riece-signal
+\e$B%7%0%J%k\e(B(@xref{Signals})\e$B4IM}\e(B
 @item riece-misc
 \e$B;(B?$J4X?t$NDj5A\e(B(\e$B%$%s%i%$%s4X?t$r=|$/\e(B) 
 @item riece-display
@@ -734,7 +739,7 @@ DCC (Direct Client to Client protocol) \e$B$K$h$k%U%!%$%kE>Aw\e(B (Emacs 21.3 \e$B$
 @code{make-network-connection} \e$B$K$h$k<BAu\e(B)
 @end table
 
-@node Namespace management,  , Modules, Development
+@node Namespace management, Signals, Modules, Development
 @section Namespace management
 
 Riece \e$B$OJ#?t$N%5!<%P$KF1;~$K@\B3$9$k$?$a!"%5!<%PKh$KJL!9$NL>A06u4V$r4IM}\e(B
@@ -870,6 +875,88 @@ AWAY \e$BCf$+$I$&$+\e(B
 \e$B%f!<%6$NL>A0$,JQ99$5$l$?$3$H$rI=L@$7$^$9\e(B 
 @end defun
 
+@node Signals,  , Namespace management, Development
+@section Signals
+
+\e$B2hLL$N:FIA2h$r8zN(NI$/9T$&$?$a$K!"%$%Y%s%H$HIA2hBP>]$N%*%V%8%'%/%H\e(B(\e$B%P%C\e(B
+\e$B%U%!$d!"%b!<%I%i%$%s$N0u\e(B @pxref{Indicators})\e$B$r7k$SIU$1$k%a%+%K%:%`$rMQ0U\e(B
+\e$B$7$F$$$^$9!#\e(B
+
+\e$B2?$i$+$N%$%Y%s%H$,H/@8$9$k$H!"%7%0%J%k$,Aw=P$5$l$^$9!#%7%0%J%k$N35G0$O!"\e(B
+Qt \e$B$d\e(B GTK+ \e$B$H$$$C$?\e(B GUI \e$B%D!<%k%-%C%H$KMQ0U$5$l$F$$$k$b$N$HF1MM$G$9!#\e(B
+
+\e$B%7%0%J%k$rAw=P$9$k$K$O!"\e(B@samp{riece-emit-signal} \e$B$r;H$$$^$9!#\e(B
+
+@defun riece-emit-signal signal-name &rest args
+@var{signal-name} \e$B$G;X<($5$l$k%7%0%J%k$r!"0z?t\e(B @var{args} \e$B$H$H$b$KAw=P$7$^$9\e(B
+@end defun
+
+\e$B%7%0%J%k$K1~Ez$9$k$K$O!"\e(B@samp{riece-connect-signal} \e$B$r;H$$$^$9!#\e(B
+
+@defun riece-connect-signal signal-name slot-function &optional filter-function handback
+@var{signal-name} \e$B$G;X<($5$l$k%7%0%J%k$K1~Ez$9$k4X?t\e(B @var{slot-function} 
+\e$B$r7k$SIU$1$^$9!#\e(B@var{slot-function} \e$B$K;XDj$5$l$?4X?t$O\e(B 2 \e$B$D$N0z?t$r<h$j$^\e(B
+\e$B$9!#Bh\e(B1\e$B$N0z?t$O$O%7%0%J%k$rI=$7$^$9!#$^$?!"Bh\e(B2\e$B$N0z?t$H$7$F!"\e(B
+@var{handback} \e$B0z?t$KM?$($i$l$?%*%V%8%'%/%H$,$=$N$^$^EO$5$l$^$9!#\e(B
+
+@var{filter-function} \e$B$O!"<u?.$7$?%7%0%J%k$K1~Ez$9$Y$-$+$I$&$+$rH=Dj$9$k\e(B
+\e$B4X?t$G$9!#$3$N4X?t$O0z?t$H$7$F%7%0%J%k%*%V%8%'%/%H$r<u$1<h$j!"\e(B@samp{nil}
+\e$B$^$?$O\e(B @samp{t} \e$B$rJV$9$3$H$,4|BT$5$l$^$9!#JV$jCM$,\e(B @samp{nil} \e$B$N>l9g$K$O!"\e(B
+@var{slot-function} \e$B$,8F$P$l$k$3$H$O$"$j$^$;$s!#\e(B
+@end defun
+
+\e$B%7%0%J%k%*%V%8%'%/%H$K%"%/%;%9$9$k$K$O!"0J2<$N4X?t$r;H$$$^$9!#\e(B
+
+@defun riece-signal-name
+\e$B%7%0%J%k$NL>A0\e(B(\e$B%7%s%\%k\e(B)\e$B$rJV$7$^$9!#\e(B
+@end defun
+
+@defun riece-signal-args
+\e$B%7%0%J%kAw=P;~$KM?$($i$l$?0z?t$rJV$7$^$9!#\e(B
+@end defun
+
+\e$B8=:_!"0J2<$N%7%0%J%k$,I8=`$GEPO?$5$l$F$$$^$9!'\e(B
+
+@table @samp
+@item channel-list-changed
+\e$B;22C$7$F$$$k%A%c%s%M%k$N0lMw$NJQ2=\e(B
+@item user-list-changed
+\e$B%A%c%s%M%k$N;22C<T0lMw$NJQ2=\e(B
+(\e$B0z?t$O%A%c%s%M%k$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item channel-switched
+\e$B8=:_$N%A%c%s%M%k$r0\F0\e(B
+@item user-joined-channel
+\e$B%f!<%6$,%A%c%s%M%k$K;22C\e(B
+(\e$B0z?t$O!"%f!<%6$*$h$S%A%c%s%M%k$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item user-left-channel
+\e$B%f!<%6$,%A%c%s%M%k$+$iN%C&\e(B
+(\e$B0z?t$O!"%f!<%6$*$h$S%A%c%s%M%k$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item user-renamed
+\e$B%f!<%6$,L>A0$rJQ99\e(B
+(\e$B0z?t$O!"0JA0$H8=:_$NL>A0$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item user-away-changed
+\e$B%f!<%6$NN%@J>uBV$NJQ2=\e(B
+(\e$B0z?t$O!"%f!<%6$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item user-operator-changed
+\e$B%f!<%6$N%*%Z%l!<%?>uBV$NJQ2=\e(B
+(\e$B0z?t$O!"%f!<%6$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item channel-topic-changed
+\e$B%A%c%s%M%k$N%H%T%C%/$NJQ2=\e(B
+(\e$B0z?t$O!"%A%c%s%M%k$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item channel-modes-changed
+\e$B%A%c%s%M%k$N%b!<%I$NJQ2=\e(B
+(\e$B0z?t$O!"%A%c%s%M%k$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item channel-operators-changed
+\e$B%A%c%s%M%k$G%*%Z%l!<%?8"8B$r;}$D%f!<%6$N0lMw$NJQ2=\e(B
+(\e$B0z?t$O!"%A%c%s%M%k$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item channel-speakers-changed
+\e$B%A%c%s%M%k$GH/8@8"$r;}$D%f!<%6$N0lMw$NJQ2=\e(B
+(\e$B0z?t$O!"%A%c%s%M%k$KAjEv$9$k\e(B @samp{riece-identity} \e$B%*%V%8%'%/%H\e(B)
+@item buffer-freeze-changed
+\e$B%P%C%U%!$NE`7k>uBV$NJQ2=\e(B
+(\e$B0z?t$O%P%C%U%!\e(B)
+@end table
+
 @node Index, Function Index, Development, Top
 @chapter Index
 @printindex cp
index f9abd24..de49d00 100644 (file)
@@ -18,6 +18,8 @@
                riece-user
 
                riece-misc
+               riece-signal
+
                ;; riece-layout ---> riece-display
                riece-layout
                riece-display
index 43dd8f7..fa5b7dc 100644 (file)
@@ -1,3 +1,249 @@
+2004-03-07  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-display.el: Rename some signals.
+
+       * riece-commands.el (riece-command-set-operators): Reverse user-list.
+       (riece-command-set-speakers): Ditto.
+
+2004-03-07  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-unread.el
+       (riece-unread-format-identity-for-channel-list-indicator): Escape
+       % -> %%; use riece-propertize-modeline-string.
+
+       * riece-history.el
+       (riece-history-format-identity-for-channel-list-indicator): Escape
+       % -> %%; use riece-propertize-modeline-string.
+
+       * riece-highlight.el
+       (riece-highlight-format-identity-for-channel-list-indicator):
+       Escape % -> %%; use riece-propertize-modeline-string.
+
+       * riece-display.el
+       (riece-format-identity-for-channel-list-indicator): Escape % ->
+       %%.
+       (riece-update-channel-list-indicator): Rewrite.
+
+       * riece-emacs.el (riece-propertize-modeline-string): New function.
+       * riece-xemacs.el (riece-propertize-modeline-string): New function.
+
+2004-03-07  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-unread.el
+       (riece-unread-format-identity-for-channel-list-indicator): New
+       function.
+       (riece-unread-insinuate): Setup
+       riece-format-identity-for-channel-list-indicator-functions.
+
+       * riece-history.el
+       (riece-history-format-identity-for-channel-list-buffer): New
+       function.
+       (riece-history-insinuate): Setup
+       riece-format-identity-for-channel-list-indicator-functions.
+
+       * riece-highlight.el
+       (riece-highlight-format-identity-for-channel-list-indicator): New
+       function.
+       (riece-highlight-insinuate): Setup
+       riece-format-identity-for-channel-list-indicator-functions.
+
+       * riece-display.el
+       (riece-format-identity-for-channel-list-buffer): Rename from
+       riece-format-channel-list-line.
+       (riece-format-identity-for-channel-list-indicator): New function.
+       (riece-update-channel-list-indicator): Use it.
+
+2004-03-07  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-handle.el (riece-parse-modes): Make sure that mode params
+       are started at the beginning of the mode string.
+       (riece-handle-channel-modes): Fixed arguments passed to
+       riece-channel-toggle-*.
+
+2004-03-06  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-xface.el (riece-xface-insinuate): Set
+       'riece-update-buffer-functions local to the user-list buffer.
+
+       * riece-unread.el: Require 'riece-signal instead of
+       'riece-display.
+       (riece-unread-after-display-message-function): Emit
+       'riece-update-buffer signal instead of
+       'riece-unread-channel-list-update signal.
+
+       * riece-ndcc.el: Don't require 'riece-display.
+
+       * riece-naming.el: Require 'riece-signal instead of
+       'riece-display.
+       (riece-naming-assert-rename): Don't rename buffer.
+
+       * riece-history.el (riece-history-format-channel-list-line): Don't
+       append "\n".
+
+       * riece-handle.el: Require 'riece-signal instead of
+       'riece-display.
+       (riece-parse-modes): Rename from riece-parse-channel-modes; don't
+       update channel modes.
+       (riece-handle-channel-modes): New function which processes the
+       result of riece-parse-modes.
+       (riece-handle-mode-message): Use it.
+
+       * riece-filter.el: Don't require 'riece-display.
+       * riece-display.el: Require 'riece-signal; connect
+       'riece-update-buffer signal.
+
+       * riece-ctcp.el: Don't require 'riece-display.
+
+       * riece-signal.el: New module splitted from riece-display.el.
+       * Makefile.am (EXTRA_DIST): Add riece-signal.
+       * COMPILE (riece-modules): Add riece-signal.
+
+2004-03-05  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-unread.el (riece-unread-after-display-message-function):
+       Emit 'riece-unread-channel-list-update signal.
+       (riece-unread-insinuate): Connect the signal to the function which
+       updates channel-list buffer.
+
+       * riece-display.el (riece-display-connect-signals): Fix parenthesis.
+
+2004-03-04  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-display.el (riece-emit-signal): Fixed bug that errors
+       during signal filter execution were not caught.
+       (riece-display-connect-signals): Check riece-current-channel is set.
+
+2004-03-01  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-display.el (riece-display-connect-signals): Fixed bug in
+       signal filters.
+
+       * riece-handle.el (riece-handle-mode-message): Don't call
+       riece-parse-channel-modes if channel doesn't match with
+       riece-channel-regexp.
+
+2004-02-28  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-display.el (riece-display-connect-signals): Connect some
+       signals.
+
+       * riece-naming.el (riece-naming-assert-join): Don't change the
+       current channel manually.
+       (riece-naming-assert-part): Ditto.
+       (riece-naming-assert-rename): Ditto.
+       (riece-naming-assert-channel-users): Ditto.
+
+2004-02-27  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-display.el (riece-emit-signal): Create signal object
+       internally.
+
+       * riece-message.el (riece-display-message-1): Emit
+       'riece-buffer-toggle-freeze signal.
+
+       * riece-commands.el (riece-command-toggle-freeze): Emit
+       'riece-buffer-toggle-freeze signal; don't update status indicators
+       manually.
+       (riece-command-toggle-own-freeze): Ditto.
+       
+       * riece-naming.el (riece-naming-assert-join): Rename signal 'join
+       -> 'riece-naming-assert-join.
+       (riece-naming-assert-part): Rename signal 'part ->
+       'riece-naming-assert-part.
+       (riece-naming-assert-rename): Rename signal 'rename ->
+       'riece-naming-assert-rename.
+       (riece-naming-assert-channel-users): Rename from
+       riece-naming-assert-users; rename signal 'users ->
+       'riece-naming-assert-channel-users.
+
+       * riece-handle.el (riece-handle-topic-message): Emit
+       'riece-channel-set-topic signal.
+       (riece-parse-channel-modes): Emit 'riece-channel-toggle-operator,
+       'riece-channel-toggle-speaker, and 'riece-channel-toggle-modes signals.
+
+       * riece-display.el (riece-display-connect-signals): Rename some
+       signals; connect more signals.
+
+       * riece-300.el (riece-handle-302-message): Emit
+       'riece-user-toggle-away, and 'riece-user-toggle-operator signals;
+       don't update status indicators manually.
+       (riece-handle-301-message): Emit 'riece-user-toggle-away signal;
+       don't update status indicators manually.
+       (riece-handle-305-message): Ditto.
+       (riece-handle-306-message): Ditto.
+       (riece-handle-353-message): Follow the name change of
+       riece-naming-assert-users.
+       (riece-handle-324-message): Emit 'riece-channel-toggle-modes
+       signal; don't update status indicators manually.
+       (riece-handle-set-topic): Emit 'riece-channel-set-topic signal;
+       don't update channel indicator manually.
+       (riece-handle-352-message): Emit 'riece-user-toggle-away, and
+       'riece-user-toggle-operator signals; don't update status
+       indicators manually.
+
+2004-02-27  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-display.el (riece-connect-signal): Create slot object
+       internally.
+
+2004-02-27  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece.el (riece): Setup signal slots.
+
+       * riece-unread.el (riece-unread-after-display-message-function):
+       Don't call riece-redisplay-buffers.
+
+       * riece-naming.el (riece-naming-assert-names): New function.
+       (riece-naming-assert-join): Emit 'join signal.
+       (riece-naming-assert-part): Emit 'part signal.
+       (riece-naming-assert-rename): Emit 'rename signal.
+
+       * riece-message.el (riece-message-buffer): Don't call
+       riece-redisplay-buffers.
+
+       * riece-handle.el (riece-handle-nick-message): Don't call
+       riece-redisplay-buffers.
+       (riece-handle-join-message): Ditto.
+       (riece-handle-part-message): Ditto.
+       (riece-handle-kick-message): Ditto.
+       (riece-handle-kill-message): Ditto.
+       (riece-handle-topic-message): Ditto.
+       (riece-parse-channel-modes): Ditto.
+
+       * riece-display.el (riece-update-user-list-buffer): Use
+       riece-with-server-buffer.
+       (riece-emit-signal): Notify if signal filter fails.
+       (riece-display-connect-signals): New function.
+       (riece-update-user-list-buffer): Don't switch to user-list buffer.
+       (riece-update-channel-list-buffer): Don't switch to channel-list
+       buffer.
+       (riece-switch-to-channel): Emit 'switch-to-channel signal.
+       (riece-switch-to-nearest-channel): Ditto.
+
+       * riece-commands.el (riece-command-switch-to-channel): Don't call
+       riece-redisplay-buffers.
+       (riece-command-join-partner): Ditto.
+       (riece-command-part): Ditto.
+
+       * riece-300.el (riece-handle-353-message): Save match data before
+       calling riece-naming-assert-names; don't call riece-redisplay-buffers.
+       (riece-handle-322-message): Don't call riece-redisplay-buffers.
+
+2004-02-26  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-display.el: Introduce Qt like "signal-slot" abstraction
+       for routing display events.
+       (riece-signal-slot-obarray): New variable.
+       (riece-make-slot): New function.
+       (riece-slot-function): New function.
+       (riece-slot-filter): New function.
+       (riece-slot-handback): New function.
+       (riece-make-signal): New function.
+       (riece-signal-name): New function.
+       (riece-signal-args): New function.
+       (riece-connect-signal): New function.
+       (riece-emit-signal): New function.
+
 2004-02-19  Daiki Ueno  <ueno@unixuser.org>
 
        * riece-300.el (riece-handle-353-message): Add 'riece-identity
index b0ced27..108ec38 100644 (file)
@@ -4,8 +4,8 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \
        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-options.el riece-server.el riece-user.el riece-version.el \
-       riece-xemacs.el riece.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 \
        riece-ndcc.el riece-rdcc.el riece-log.el riece-mini.el \
        riece-doctor.el riece-alias.el riece-layout.el riece-skk-kakutei.el \
index cb22cf8..034e9c0 100644 (file)
            (if operator
                (setq status (cons "operator" status)))
            (riece-user-toggle-away user away)
+           (riece-emit-signal 'user-away-changed
+                              (riece-make-identity user riece-server-name)
+                              away)
            (riece-user-toggle-operator user operator)
+           (riece-emit-signal 'user-operator-changed
+                              (riece-make-identity user riece-server-name)
+                              operator)
            (riece-insert-info
             (list riece-dialogue-buffer riece-others-buffer)
             (concat
@@ -65,9 +71,7 @@
                         t)
                        (riece-strip-user-at-host user-at-host))))
              "\n"))))
-      (setq replies (cdr replies)))
-  (riece-update-status-indicators)
-  (force-mode-line-update t)))
+      (setq replies (cdr replies)))))
 
 (defun riece-handle-303-message (prefix number name string)
   (riece-insert-info
@@ -89,6 +93,9 @@
       (let ((user (match-string 1 string))
            (message (substring string (match-end 0))))
        (riece-user-toggle-away user t)
+       (riece-emit-signal 'user-away-changed
+                          (riece-make-identity user riece-server-name)
+                          t)
        (riece-insert-info
         (list riece-dialogue-buffer riece-others-buffer)
         (concat
                    (riece-make-identity user riece-server-name)
                    t)
                   message))
-         "\n"))))
-  (riece-update-status-indicators)
-  (force-mode-line-update t))
+         "\n")))))
 
 (defun riece-handle-305-message (prefix number name string)
   (riece-user-toggle-away riece-real-nickname nil)
-  (riece-update-status-indicators)
-  (force-mode-line-update t))
+  (riece-emit-signal 'user-away-changed
+                     (riece-make-identity riece-real-nickname
+                                          riece-server-name)
+                     nil))
 
 (defun riece-handle-306-message (prefix number name string)
   (riece-user-toggle-away riece-real-nickname t)
-  (riece-update-status-indicators)
-  (force-mode-line-update t))
+  (riece-emit-signal 'user-away-changed
+                    (riece-make-identity riece-real-nickname
+                                         riece-server-name)
+                    t))
 
 (defun riece-handle-311-message (prefix number name string)
   (if (string-match
   "RPL_NAMREPLY        \"<channel> :[[@|+]<nick> [[@|+]<nick> [...]]]\"."
   (if (string-match "^[=\*@] *\\([^ ]+\\) +:" string)
       (let ((channel (match-string 1 string))
-           (start 0))
+           (start 0)
+           user users)
        (setq string (substring string (match-end 0)))
        (while (string-match
                (concat "\\([@+]\\)?\\(" riece-user-regexp "\\) *")
                             (riece-make-identity (match-string 2 string)
                                                  riece-server-name)
                             string)
-         (setq start (match-end 0))
-         (if (match-beginning 1)
-             (if (eq (aref string (match-beginning 1)) ?@)
-                 (progn
-                   (riece-naming-assert-join
-                    (match-string 2 string) channel)
-                   (riece-channel-toggle-operator
-                    channel (match-string 2 string) t))
-               (if (eq (aref string (match-beginning 1)) ?+)
-                   (progn
-                     (riece-naming-assert-join
-                      (match-string 2 string) channel)
-                     (riece-channel-toggle-speaker
-                      channel (match-string 2 string) t))))
-           (riece-naming-assert-join (match-string 2 string) channel)))
+         (setq start (match-end 0)
+               user (if (match-beginning 1)
+                        (if (eq (aref string (match-beginning 1)) ?@)
+                            (list (match-string 2 string) ?o)
+                          (if (eq (aref string (match-beginning 1)) ?+)
+                              (list (match-string 2 string) ?v)))
+                      (list (match-string 2 string)))
+               users (cons user users)))
+       (riece-naming-assert-channel-users (nreverse users) channel)
        (let* ((channel-identity (riece-make-identity channel
                                                      riece-server-name))
               (buffer (riece-channel-buffer channel-identity)))
            (riece-concat-server-name
             (format "Users on %s: %s"
                     (riece-format-identity channel-identity t) string))
-           "\n")))
-       (riece-redisplay-buffers))))
+           "\n"))))))
 
 (defun riece-handle-322-message (prefix number name string)
   (if (string-match "^\\([^ ]+\\) \\([0-9]+\\) :" string)
        (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 ?+))
        (let* ((channel-identity (riece-make-identity channel
                                                      riece-server-name))
               (buffer (riece-channel-buffer channel-identity)))
             (format "Mode for %s: %s"
                     (riece-format-identity channel-identity t)
                     mode-string))
-           "\n")))
-       (riece-update-channel-indicator)
-       (force-mode-line-update t))))
+           "\n"))))))
 
 (defun riece-handle-set-topic (prefix number name string remove)
   (if (string-match "^\\([^ ]+\\) :" string)
        (if remove
            (riece-channel-set-topic (riece-get-channel channel) nil)
          (riece-channel-set-topic (riece-get-channel channel) message)
-       (riece-insert-info buffer (concat "Topic: " message "\n"))
-       (riece-insert-info
-        (if (and riece-channel-buffer-mode
-                 (not (eq buffer riece-channel-buffer)))
-            (list riece-dialogue-buffer riece-others-buffer)
-          riece-dialogue-buffer)
-        (concat
-         (riece-concat-server-name
-          (format "Topic for %s: %s"
-                  (riece-format-identity channel-identity t)
-                  message))
-         "\n"))
-       (riece-update-channel-indicator)))))
+         (riece-insert-info buffer (concat "Topic: " message "\n"))
+         (riece-insert-info
+          (if (and riece-channel-buffer-mode
+                   (not (eq buffer riece-channel-buffer)))
+              (list riece-dialogue-buffer riece-others-buffer)
+            riece-dialogue-buffer)
+          (concat
+           (riece-concat-server-name
+            (format "Topic for %s: %s"
+                    (riece-format-identity channel-identity t)
+                    message))
+           "\n")))
+       (riece-emit-signal 'channel-topic-changed
+                           channel-identity
+                           (unless remove
+                             message)))))
 
 (defun riece-handle-331-message (prefix number name string)
   (riece-handle-set-topic prefix number name string t))
            (setq status (nreverse status)))
        (riece-naming-assert-join nick channel)
        (riece-user-toggle-away user away)
+       (riece-emit-signal 'user-away-changed
+                          (riece-make-identity user riece-server-name)
+                          away)
        (riece-user-toggle-operator user operator)
+       (riece-emit-signal 'user-operator-changed
+                          (riece-make-identity user riece-server-name)
+                          operator)
        (riece-insert-info buffer (concat (riece-concat-user-status
                                           status info)
                                          "\n"))
              t)
             " "
             info)))
-         "\n"))
-       (riece-redisplay-buffers))))
+         "\n")))))
 
 (defun riece-handle-315-message (prefix number name string))
 (defun riece-handle-318-message (prefix number name string))
index 890e2e8..214ac1c 100644 (file)
@@ -38,8 +38,7 @@
   (interactive (list (riece-completing-read-identity
                      "Channel/User: " riece-current-channels nil t)))
   (unless (equal channel riece-current-channel)
-    (riece-switch-to-channel channel)
-    (riece-redisplay-buffers)))
+    (riece-switch-to-channel channel)))
 
 (defun riece-command-switch-to-channel-by-number (number)
   (interactive
@@ -303,7 +302,7 @@ the layout to the selected layout-name."
                     ?-
                   ?+)
                 (make-string (length group) ?o)
-                (mapconcat #'identity group " ")))
+                (mapconcat #'identity (nreverse group) " ")))
        (setq group nil)))))
 
 (defun riece-command-set-speakers (users &optional arg)
@@ -336,7 +335,7 @@ the layout to the selected layout-name."
                     ?-
                   ?+)
                 (make-string (length group) ?v)
-                (mapconcat #'identity group " ")))
+                (mapconcat #'identity (nreverse group) " ")))
        (setq group nil)))))
 
 (defun riece-command-send-message (message notice)
@@ -416,8 +415,7 @@ the layout to the selected layout-name."
     (if pointer
        (riece-command-switch-to-channel (car pointer))
       (riece-join-channel target)
-      (riece-switch-to-channel target)
-      (riece-redisplay-buffers))))
+      (riece-switch-to-channel target))))
 
 (defun riece-command-join (target &optional key)
   (interactive
@@ -476,8 +474,7 @@ the layout to the selected layout-name."
   (if (riece-identity-member target riece-current-channels)
       (if (riece-channel-p (riece-identity-prefix target))
          (riece-command-part-channel target message)
-       (riece-part-channel target)
-       (riece-redisplay-buffers))
+       (riece-part-channel target))
     (error "You are not talking with %s" target)))
 
 (defun riece-command-change-nickname (nickname)
@@ -561,9 +558,9 @@ If prefix argument ARG is non-nil, toggle frozen status."
                         riece-dialogue-buffer)
     (setq riece-freeze (if arg
                           (< 0 (prefix-numeric-value arg))
-                        (not riece-freeze))))
-  (riece-update-status-indicators)
-  (force-mode-line-update t))
+                        (not riece-freeze)))
+    (riece-emit-signal 'buffer-freeze-changed
+                      (current-buffer) riece-freeze)))
 
 (defun riece-command-toggle-own-freeze (&optional arg)
   "Prevent automatic scrolling of the dialogue window.
@@ -579,8 +576,8 @@ If prefix argument ARG is non-nil, toggle frozen status."
          (not (eq riece-freeze 'own)))
        (setq riece-freeze 'own)
       (setq riece-freeze nil)))
-  (riece-update-status-indicators)
-  (force-mode-line-update t))
+  (riece-emit-signal 'buffer-freeze-changed
+                    (current-buffer) riece-freeze))
 
 (eval-when-compile
   (autoload 'riece-exit "riece"))
index 8baad1d..37061bc 100644 (file)
@@ -26,7 +26,6 @@
 
 (require 'riece-version)
 (require 'riece-misc)
-(require 'riece-display)
 (require 'riece-highlight)
 
 (defface riece-ctcp-action-face
index f675e99..c78d9e7 100644 (file)
@@ -28,6 +28,7 @@
 (require 'riece-channel)
 (require 'riece-misc)
 (require 'riece-layout)
+(require 'riece-signal)
 
 (defvar riece-channel-buffer-format "*Channel:%s*"
   "Format of channel message buffer.")
@@ -45,15 +46,183 @@ Local to the buffer in `riece-buffer-list'.")
     riece-update-channel-list-indicator)
   "Functions to update modeline indicators.")
 
+(defun riece-display-connect-signals ()
+  (riece-connect-signal
+   'channel-list-changed
+   (lambda (signal handback)
+     (save-excursion
+       (set-buffer riece-channel-list-buffer)
+       (run-hooks 'riece-update-buffer-functions))
+     (riece-update-channel-list-indicator)))
+  (riece-connect-signal
+   'user-list-changed
+   (lambda (signal handback)
+     (save-excursion
+       (set-buffer riece-user-list-buffer)
+       (run-hooks 'riece-update-buffer-functions)))
+   (lambda (signal)
+     (and riece-current-channel
+         (riece-identity-equal (car (riece-signal-args signal))
+                               riece-current-channel))))
+  (riece-connect-signal
+   'channel-switched
+   (lambda (signal handback)
+     (riece-update-status-indicators)
+     (riece-update-channel-indicator)
+     (riece-update-long-channel-indicator)
+     (force-mode-line-update t)
+     (riece-emit-signal 'channel-list-changed)
+     (riece-emit-signal 'user-list-changed riece-current-channel)
+     (save-excursion
+       (riece-redraw-layout))))
+  (riece-connect-signal
+   'user-joined-channel
+   (lambda (signal handback)
+     (riece-emit-signal 'user-list-changed riece-current-channel))
+   (lambda (signal)
+     (and riece-current-channel
+         (riece-identity-equal (nth 1 (riece-signal-args signal))
+                               riece-current-channel)
+         (not (riece-identity-equal (car (riece-signal-args signal))
+                                    (riece-current-nickname))))))
+  (riece-connect-signal
+   'user-joined-channel
+   (lambda (signal handback)
+     (riece-join-channel (nth 1 (riece-signal-args signal)))
+     (riece-switch-to-channel (nth 1 (riece-signal-args signal)))
+     (setq riece-join-channel-candidate nil))
+   (lambda (signal)
+     (riece-identity-equal (car (riece-signal-args signal))
+                          (riece-current-nickname))))
+  (riece-connect-signal
+   'user-left-channel
+   (lambda (signal handback)
+     (riece-emit-signal 'user-list-changed riece-current-channel))
+   (lambda (signal)
+     (and riece-current-channel
+         (riece-identity-equal (nth 1 (riece-signal-args signal))
+                               riece-current-channel)
+         (not (riece-identity-equal (car (riece-signal-args signal))
+                                    (riece-current-nickname))))))
+  (riece-connect-signal
+   'user-left-channel
+   (lambda (signal handback)
+     (riece-part-channel (nth 1 (riece-signal-args signal))))
+   (lambda (signal)
+     (riece-identity-equal (car (riece-signal-args signal))
+                          (riece-current-nickname))))
+  (riece-connect-signal
+   'user-renamed
+   (lambda (signal handback)
+     (riece-emit-signal 'user-list-changed riece-current-channel))
+   (lambda (signal)
+     (and riece-current-channel
+         (equal (riece-identity-server (nth 1 (riece-signal-args signal)))
+                (riece-identity-server riece-current-channel))
+         (riece-with-server-buffer (riece-identity-server
+                                    riece-current-channel)
+           (riece-identity-assoc
+            (riece-identity-prefix (nth 1 (riece-signal-args signal)))
+            (riece-channel-get-users (riece-identity-prefix
+                                      riece-current-channel))
+            t)))))
+  (riece-connect-signal
+   'user-renamed
+   (lambda (signal handback)
+     (riece-update-status-indicators)
+     (riece-update-channel-indicator)
+     (force-mode-line-update t))
+   (lambda (signal)
+     (riece-identity-equal (nth 1 (riece-signal-args signal))
+                          (riece-current-nickname))))
+  (riece-connect-signal
+   'user-renamed
+   (lambda (signal handback)
+     (riece-switch-to-channel (nth 1 (riece-signal-args signal))))
+   (lambda (signal)
+     (and riece-current-channel
+         (riece-identity-equal (car (riece-signal-args signal))
+                               riece-current-channel))))
+  (riece-connect-signal
+   'user-renamed
+   (lambda (signal handback)
+     (let* ((old-identity (car (riece-signal-args signal)))
+           (new-identity (nth 1 (riece-signal-args signal)))
+           (pointer (riece-identity-member old-identity
+                                           riece-current-channels)))
+       ;; Rename the channel buffer.
+       (when pointer
+        (setcar pointer new-identity)
+        (with-current-buffer (riece-channel-buffer old-identity)
+          (rename-buffer (riece-channel-buffer-name new-identity) t)
+          (setq riece-channel-buffer-alist
+                (cons (cons new-identity (current-buffer))
+                      (delq (riece-identity-assoc old-identity
+                                                  riece-channel-buffer-alist)
+                            riece-channel-buffer-alist))))))))
+  (riece-connect-signal
+   'user-away-changed
+   (lambda (signal handback)
+     (riece-update-status-indicators)
+     (force-mode-line-update t))
+   (lambda (signal)
+     (riece-identity-equal (car (riece-signal-args signal))
+                          (riece-current-nickname))))
+  (riece-connect-signal
+   'user-operator-changed
+   (lambda (signal handback)
+     (riece-update-status-indicators)
+     (force-mode-line-update t))
+   (lambda (signal)
+     (riece-identity-equal (car (riece-signal-args signal))
+                          (riece-current-nickname))))
+  (riece-connect-signal
+   'channel-topic-changed
+   (lambda (signal handback)
+     (riece-update-long-channel-indicator)
+     (force-mode-line-update t))
+   (lambda (signal)
+     (and riece-current-channel
+         (riece-identity-equal (car (riece-signal-args signal))
+                               riece-current-channel))))
+  (riece-connect-signal
+   'channel-modes-changed
+   (lambda (signal handback)
+     (riece-update-status-indicators)
+     (force-mode-line-update t))
+   (lambda (signal)
+     (and riece-current-channel
+         (riece-identity-equal (car (riece-signal-args signal))
+                               riece-current-channel))))
+  (riece-connect-signal
+   'channel-operators-changed
+   (lambda (signal handback)
+     (riece-emit-signal 'user-list-changed riece-current-channel))
+   (lambda (signal)
+     (and riece-current-channel
+         (riece-identity-equal (car (riece-signal-args signal))
+                               riece-current-channel))))
+  (riece-connect-signal
+   'channel-speakers-changed
+   (lambda (signal handback)
+     (riece-emit-signal 'user-list-changed riece-current-channel))
+   (lambda (signal)
+     (and riece-current-channel
+         (riece-identity-equal (car (riece-signal-args signal))
+                               riece-current-channel))))
+  (riece-connect-signal
+   'buffer-freeze-changed
+   (lambda (signal handback)
+     (riece-update-status-indicators)
+     (force-mode-line-update t))))
+
 (defun riece-update-user-list-buffer ()
   (save-excursion
-    (set-buffer riece-user-list-buffer)
     (if (and riece-current-channel
             (riece-channel-p (riece-identity-prefix riece-current-channel)))
        (let* ((users
-               (with-current-buffer (process-buffer (riece-server-process
-                                                     (riece-identity-server
-                                                      riece-current-channel)))
+               (riece-with-server-buffer (riece-identity-server
+                                          riece-current-channel)
                  (riece-channel-get-users (riece-identity-prefix
                                            riece-current-channel))))
               (inhibit-read-only t)
@@ -74,9 +243,17 @@ Local to the buffer in `riece-buffer-list'.")
                    "\n")
            (setq users (cdr users)))))))
 
+(defun riece-format-identity-for-channel-list-buffer (index identity)
+  (or (run-hook-with-args-until-success
+       'riece-format-identity-for-channel-list-buffer-functions index identity)
+      (concat (format "%2d:%c" index
+                     (if (riece-identity-equal identity riece-current-channel)
+                         ?*
+                       ? ))
+             (riece-format-identity identity))))
+
 (defun riece-update-channel-list-buffer ()
   (save-excursion
-    (set-buffer riece-channel-list-buffer)
     (let ((inhibit-read-only t)
          buffer-read-only
          (index 1)
@@ -85,21 +262,12 @@ Local to the buffer in `riece-buffer-list'.")
       (riece-kill-all-overlays)
       (while channels
        (if (car channels)
-           (insert (riece-format-channel-list-line
-                    index (car channels))))
+           (insert (riece-format-identity-for-channel-list-buffer
+                    index (car channels))
+                   "\n"))
        (setq index (1+ index)
              channels (cdr channels))))))
 
-(defun riece-format-channel-list-line (index channel)
-  (or (run-hook-with-args-until-success
-       'riece-format-channel-list-line-functions index channel)
-      (concat (format "%2d:%c" index
-                     (if (riece-identity-equal channel riece-current-channel)
-                         ?*
-                       ? ))
-             (riece-format-identity channel)
-             "\n")))
-
 (defun riece-update-channel-indicator ()
   (setq riece-channel-indicator
        (if riece-current-channel
@@ -118,24 +286,40 @@ Local to the buffer in `riece-buffer-list'.")
              (riece-format-identity riece-current-channel))
          "None")))
 
+(defun riece-format-identity-for-channel-list-indicator (index identity)
+  (or (run-hook-with-args-until-success
+       'riece-format-identity-for-channel-list-indicator-functions
+       index identity)
+      (let ((string (riece-format-identity identity))
+           (start 0))
+       ;; Escape % -> %%.
+       (while (string-match "%" string start)
+         (setq start (1+ (match-end 0))
+               string (replace-match "%%" nil nil string)))
+       (format "%d:%s" index string))))
+
 (defun riece-update-channel-list-indicator ()
   (if (and riece-current-channels
           ;; There is at least one channel.
           (delq nil (copy-sequence riece-current-channels)))
-      (let ((index 1))
+      (let ((index 1)
+           pointer)
        (setq riece-channel-list-indicator
-             (mapconcat
-              #'identity
-              (delq nil
-                    (mapcar
-                     (lambda (channel)
-                       (prog1
-                           (if channel
-                               (format "%d:%s" index
-                                       (riece-format-identity channel)))
-                         (setq index (1+ index))))
-                     riece-current-channels))
-              ",")))
+             (delq
+              nil
+              (mapcar
+               (lambda (channel)
+                 (prog1
+                     (if channel
+                         (riece-format-identity-for-channel-list-indicator
+                          index channel))
+                   (setq index (1+ index))))
+               riece-current-channels))
+             pointer riece-channel-list-indicator)
+       (while pointer
+         (if (cdr pointer)
+             (setcdr pointer (cons "," (cdr pointer))))
+         (setq pointer (cdr (cdr pointer)))))
     (setq riece-channel-list-indicator "No channel")))
 
 (defun riece-update-status-indicators ()
@@ -211,7 +395,8 @@ Local to the buffer in `riece-buffer-list'.")
   (let ((last riece-current-channel))
     (setq riece-current-channel identity
          riece-channel-buffer (riece-channel-buffer riece-current-channel))
-    (run-hook-with-args 'riece-after-switch-to-channel-functions last)))
+    (run-hook-with-args 'riece-after-switch-to-channel-functions last)
+    (riece-emit-signal 'channel-switched)))
 
 (defun riece-join-channel (identity)
   (unless (riece-identity-member identity riece-current-channels)
@@ -241,7 +426,8 @@ Local to the buffer in `riece-buffer-list'.")
        (riece-switch-to-channel identity)
       (let ((last riece-current-channel))
        (run-hook-with-args 'riece-after-switch-to-channel-functions last)
-       (setq riece-current-channel nil)))))
+       (setq riece-current-channel nil)
+       (riece-emit-signal 'channel-switched)))))
 
 (defun riece-part-channel (identity)
   (let ((pointer (riece-identity-member identity riece-current-channels)))
index 0e49815..ea6be0a 100644 (file)
 
 (defalias 'riece-match-string-no-properties 'match-string-no-properties)
 
+(defun riece-propertize-modeline-string (string &rest properties)
+  (add-text-properties string properties)
+  string)
+
 (provide 'riece-emacs)
 
 ;;; riece-emacs.el ends here
index f522c48..f888921 100644 (file)
@@ -28,7 +28,6 @@
 (require 'riece-misc)
 (require 'riece-server)                        ;riece-close-server
 (require 'riece-identity)
-(require 'riece-display)
 
 (defun riece-handle-numeric-reply (prefix number name string)
   (let ((base-number (* (/ number 100) 100))
index edb916d..e83fbe5 100644 (file)
@@ -28,7 +28,7 @@
 (require 'riece-message)
 (require 'riece-channel)
 (require 'riece-naming)
-(require 'riece-display)
+(require 'riece-signal)
 
 (defun riece-handle-nick-message (prefix string)
   (let* ((old (riece-prefix-nickname prefix))
@@ -60,8 +60,7 @@
                           (format "%s -> %s"
                                 (riece-format-identity old-identity t)
                                 (riece-format-identity new-identity t)))
-                         "\n"))
-    (riece-redisplay-buffers)))
+                         "\n"))))
 
 (defun riece-handle-privmsg-message (prefix string)
   (let* ((user (riece-prefix-nickname prefix))
                   (riece-user-get-user-at-host user)
                   (riece-format-identity channel-identity t)))
          "\n")))
-      (setq channels (cdr channels)))
-    (riece-redisplay-buffers)))
+      (setq channels (cdr channels)))))
 
 (defun riece-handle-part-message (prefix string)
   (let* ((user (riece-prefix-nickname prefix))
                    (riece-format-identity channel-identity t))
            message))
          "\n")))
-      (setq channels (cdr channels)))
-    (riece-redisplay-buffers)))
+      (setq channels (cdr channels)))))
 
 (defun riece-handle-kick-message (prefix string)
   (let* ((kicker (riece-prefix-nickname prefix))
                 (riece-format-identity user-identity t)
                 (riece-format-identity channel-identity t))
          message))
-       "\n")))
-    (riece-redisplay-buffers)))
+       "\n")))))
 
 (defun riece-handle-quit-message (prefix string)
   (let* ((user (riece-prefix-nickname prefix))
          (format "%s has left IRC"
                  (riece-format-identity user-identity t))
          message))
-       "\n"))))
-  (riece-redisplay-buffers))
+       "\n")))))
 
 (defun riece-handle-kill-message (prefix string)
   (let* ((killer (riece-prefix-nickname prefix))
                 (riece-format-identity killer-identity t)
                 (riece-format-identity user-identity t))
          message))
-       "\n")))
-    (riece-redisplay-buffers)))
+       "\n")))))
 
 (defun riece-handle-invite-message (prefix string)
   (let* ((user (riece-prefix-nickname prefix))
         (user-identity (riece-make-identity user riece-server-name))
         (channel-identity (riece-make-identity channel riece-server-name)))
     (riece-channel-set-topic (riece-get-channel channel) topic)
+    (riece-emit-signal 'channel-topic-changed
+                      channel-identity topic)
     (let ((buffer (riece-channel-buffer channel-identity)))
       (riece-insert-change
        buffer
                 (riece-format-identity channel-identity t)
                 (riece-format-identity user-identity t)
                 topic))
-       "\n"))
-      (riece-redisplay-buffers))))
+       "\n")))))
 
-(defsubst riece-parse-channel-modes (string channel)
-  (while (string-match "^[-+]\\([^ ]*\\) *" string)
-    (let ((toggle (aref string 0))
-         (modes (string-to-list (match-string 1 string))))
-      (setq string (substring string (match-end 0)))
-      (while modes
-       (if (and (memq (car modes) '(?O ?o ?v ?k ?l ?b ?e ?I))
-                (string-match "\\([^-+][^ ]*\\) *" string))
-           (let ((parameter (match-string 1 string)))
-             (setq string (substring string (match-end 0)))
-             (cond
-              ((eq (car modes) ?o)
-               (riece-channel-toggle-operator channel parameter
-                                              (eq toggle ?+)))
-              ((eq (car modes) ?v)
-               (riece-channel-toggle-speaker channel parameter
-                                             (eq toggle ?+)))
-              ((eq (car modes) ?b)
-               (riece-channel-toggle-banned channel parameter
-                                            (eq toggle ?+)))
-              ((eq (car modes) ?e)
-               (riece-channel-toggle-uninvited channel parameter
-                                               (eq toggle ?+)))
-              ((eq (car modes) ?I)
-               (riece-channel-toggle-invited channel parameter
-                                             (eq toggle ?+)))))
-         (riece-channel-toggle-mode channel (car modes)
-                                    (eq toggle ?+)))
-       (setq modes (cdr modes))))))
+(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))
         channel)
-    (when (string-match "\\([^ ]+\\) *:?" string)
+    (when (string-match "^\\([^ ]+\\) *:?" string)
       (setq channel (match-string 1 string)
            string (substring string (match-end 0)))
-      (riece-parse-channel-modes string channel)
+      (if (string-match (concat "^" riece-channel-regexp "$") channel)
+         (riece-handle-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
                   (riece-format-identity channel-identity t)
                   (riece-format-identity user-identity t)
                   string))
-         "\n"))
-       (riece-redisplay-buffers)))))
+         "\n"))))))
 
 (provide 'riece-handle)
 
index 8eefc61..4803efb 100644 (file)
   (setq font-lock-mode-hook nil)
   (turn-on-font-lock))
 
+(defun riece-highlight-format-identity-for-channel-list-indicator (index
+                                                                  identity)
+  (if (riece-identity-equal identity riece-current-channel)
+      (let ((string (riece-format-identity identity))
+           (start 0)
+           extent)
+       ;; Escape % -> %%.
+       (while (string-match "%" string start)
+         (setq start (1+ (match-end 0))
+               string (replace-match "%%" nil nil string)))
+       (list (format "%d:" index)
+             (riece-propertize-modeline-string
+              string 'face 'riece-channel-list-current-face)))))
+
 (defun riece-highlight-insinuate ()
   (put 'riece-channel-mode 'font-lock-defaults
        '(riece-dialogue-font-lock-keywords t))
   (put 'riece-channel-list-mode 'font-lock-defaults
        '(riece-channel-list-font-lock-keywords t))
   (add-hook 'riece-after-load-startup-hook
-           'riece-channel-list-schedule-turn-on-font-lock))
+           'riece-channel-list-schedule-turn-on-font-lock)
+  (add-hook 'riece-format-identity-for-channel-list-indicator-functions
+           'riece-highlight-format-identity-for-channel-list-indicator))
 
 (provide 'riece-highlight)
 
index aece829..6541feb 100644 (file)
            index (1+ index)))
     (nreverse result)))
 
-(defun riece-history-format-channel-list-line (index channel)
+(defun riece-history-format-identity-for-channel-list-buffer (index identity)
   (if (and (not (ring-empty-p riece-channel-history))
-          (riece-identity-equal channel (ring-ref riece-channel-history 0)))
+          (riece-identity-equal identity (ring-ref riece-channel-history 0)))
       (concat (format "%2d:+" index)
-               (riece-format-identity channel)
-               "\n")))
+             (riece-format-identity identity))))
+
+(defun riece-history-format-identity-for-channel-list-indicator (index
+                                                                identity)
+  (if (and (not (ring-empty-p riece-channel-history))
+          (riece-identity-equal identity (ring-ref riece-channel-history 0)))
+      (let ((string (riece-format-identity identity))
+           (start 0)
+           extent)
+       ;; Escape % -> %%.
+       (while (string-match "%" string start)
+         (setq start (1+ (match-end 0))
+               string (replace-match "%%" nil nil string)))
+       (list (format "%d:" index)
+             (riece-propertize-modeline-string
+              string 'face 'riece-channel-list-history-face)))))
 
 ;;; (defun riece-history-requires ()
 ;;;   (if (memq 'riece-guess riece-addons)
              (if (and last
                       (not (riece-identity-equal last riece-current-channel)))
                  (ring-insert riece-channel-history last))))
-  (add-hook 'riece-format-channel-list-line-functions
-           'riece-history-format-channel-list-line)
+  (add-hook 'riece-format-identity-for-channel-list-buffer-functions
+           'riece-history-format-identity-for-channel-list-buffer)
+  (add-hook 'riece-format-identity-for-channel-list-indicator-functions
+           'riece-history-format-identity-for-channel-list-indicator)
   (if (memq 'riece-highlight riece-addons)
       (setq riece-channel-list-mark-face-alist
            (cons '(?+ . riece-channel-list-history-face)
index c50aa1d..8db0334 100644 (file)
       ;; If you are not joined any channel,
       ;; switch to the target immediately.
       (unless riece-current-channel
-       (riece-switch-to-channel target))
-      (riece-redisplay-buffers))
+       (riece-switch-to-channel target)))
     (riece-channel-buffer target)))
 
 (defun riece-message-parent-buffers (message buffer)
@@ -160,7 +159,7 @@ Normally they are *Dialogue* and/or *Others*."
               (riece-own-frozen buffer))
       (with-current-buffer buffer
        (setq riece-freeze nil))
-      (riece-update-status-indicators))
+      (riece-emit-signal 'buffer-freeze-changed buffer nil))
     (setq parent-buffers (riece-message-parent-buffers message buffer))
     (riece-insert buffer
                  (concat open-bracket name close-bracket
index 7ffedac..97beb25 100644 (file)
 (require 'riece-globals)
 (require 'riece-channel)
 (require 'riece-user)
-(require 'riece-display)
+(require 'riece-signal)
 
 (defun riece-naming-assert-join (user-name channel-name)
   (riece-user-toggle-channel user-name channel-name t)
   (riece-channel-toggle-user channel-name user-name t)
-  (if (riece-identity-equal-no-server user-name riece-real-nickname)
-      (let ((channel-identity (riece-make-identity channel-name
-                                                  riece-server-name)))
-       (riece-join-channel channel-identity)
-       (riece-switch-to-channel channel-identity)
-       (setq riece-join-channel-candidate nil))))
+  (riece-emit-signal 'user-joined-channel
+                    (riece-make-identity user-name
+                                         riece-server-name)
+                    (riece-make-identity channel-name
+                                         riece-server-name)))
 
 (defun riece-naming-assert-part (user-name channel-name)
   (riece-user-toggle-channel user-name channel-name nil)
   (riece-channel-toggle-user channel-name user-name nil)
   (riece-channel-toggle-operator channel-name user-name nil)
   (riece-channel-toggle-speaker channel-name user-name nil)
-  (if (riece-identity-equal-no-server user-name riece-real-nickname)
-      (riece-part-channel (riece-make-identity channel-name
-                                              riece-server-name))))
+  (riece-emit-signal 'user-left-channel
+                    (riece-make-identity user-name
+                                         riece-server-name)
+                    (riece-make-identity channel-name
+                                         riece-server-name)))
 
 (defun riece-naming-assert-rename (old-name new-name)
   (if (riece-identity-equal-no-server old-name riece-real-nickname)
          (setcar user new-name))
       (setq channels (cdr channels)))
     (riece-rename-user old-name new-name))
-  ;; Rename the channel buffer.
-  (let* ((old-identity (riece-make-identity old-name riece-server-name))
-        (new-identity (riece-make-identity new-name riece-server-name))
-        (pointer (riece-identity-member old-identity riece-current-channels)))
-    (when pointer
-      (setcar pointer new-identity)
-      (with-current-buffer (riece-channel-buffer old-identity)
-       (rename-buffer (riece-channel-buffer-name new-identity) t)
-       (setq riece-channel-buffer-alist
-             (cons (cons new-identity (current-buffer))
-                   (delq (riece-identity-assoc old-identity
-                                               riece-channel-buffer-alist)
-                         riece-channel-buffer-alist))))
-      (if (riece-identity-equal old-identity riece-current-channel)
-         (riece-switch-to-channel new-identity)))))
+  (riece-emit-signal 'user-renamed
+                    (riece-make-identity old-name riece-server-name)
+                    (riece-make-identity new-name riece-server-name)))
+
+(defun riece-naming-assert-channel-users (users channel-name)
+  (let ((channel-identity (riece-make-identity channel-name
+                                              riece-server-name))
+       user-identity-list)
+    (while users
+      (riece-user-toggle-channel (car (car users)) channel-name t)
+      (riece-channel-toggle-user channel-name (car (car users)) t)
+      (if (memq ?o (cdr (car users)))
+         (riece-channel-toggle-operator channel-name (car (car users)) t)
+       (if (memq ?v (cdr (car users)))
+           (riece-channel-toggle-speaker channel-name (car (car users)) t)
+         (riece-channel-toggle-operator channel-name (car (car users)) nil)
+         (riece-channel-toggle-speaker channel-name (car (car users)) nil)))
+      (setq user-identity-list
+           (cons (cons (riece-make-identity (car (car users))
+                                            riece-server-name)
+                       (cdr (car users)))
+                 user-identity-list)
+           users (cdr users)))
+    (riece-emit-signal 'user-list-changed
+                      (riece-make-identity channel-name riece-server-name))))
 
 (provide 'riece-naming)
 
index 0466040..10efdc4 100644 (file)
@@ -25,7 +25,6 @@
 
 (require 'riece-globals)
 (require 'riece-options)
-(require 'riece-display)
 
 (require 'calc)
 
diff --git a/lisp/riece-signal.el b/lisp/riece-signal.el
new file mode 100644 (file)
index 0000000..7fedd2f
--- /dev/null
@@ -0,0 +1,109 @@
+;;; riece-signal.el --- "signal-slot" abstraction for routing display events
+;; 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.
+
+;;; Commentary:
+
+;;; This module implements Qt like "signal-slot" abstraction for
+;;; routing display events.
+
+;;; Code:
+
+(defvar riece-signal-slot-obarray
+  (make-vector 31 0))
+
+(defun riece-make-slot (function &optional filter handback)
+  "Make an instance of slot object.
+Arguments are corresponding to callback function, filter function, and
+a handback object, respectively.
+This function is for internal use only."
+  (vector function filter handback))
+
+(defun riece-slot-function (slot)
+  "Return the callback function of SLOT.
+This function is for internal use only."
+  (aref slot 0))
+
+(defun riece-slot-filter (slot)
+  "Return the filter function of SLOT.
+This function is for internal use only."
+  (aref slot 1))
+
+(defun riece-slot-handback (slot)
+  "Return the handback object of SLOT.
+This function is for internal use only."
+  (aref slot 2))
+
+(defun riece-make-signal (name args)
+  "Make an instance of signal object.
+The 1st arguments is the name of the signal and the rest of arguments
+are the data of the signal.
+This function is for internal use only."
+  (vector name args))
+
+(defun riece-signal-name (signal)
+  "Return the name of SIGNAL."
+  (aref signal 0))
+
+(defun riece-signal-args (signal)
+  "Return the data of SIGNAL."
+  (aref signal 1))
+
+(defun riece-connect-signal (signal-name function &optional filter handback)
+  "Add SLOT as a listener of a signal identified by SIGNAL-NAME."
+  (let ((symbol (intern (symbol-name signal-name) riece-signal-slot-obarray)))
+    (set symbol (cons (riece-make-slot function filter handback)
+                     (if (boundp symbol)
+                         (symbol-value symbol))))))
+
+(defun riece-emit-signal (signal-name &rest args)
+  "Emit SIGNAL."
+  (let ((symbol (intern-soft (symbol-name signal-name)
+                            riece-signal-slot-obarray))
+       signal
+       slots)
+    (when symbol
+      (setq signal (riece-make-signal signal-name args)
+           slots (symbol-value symbol))
+      (while slots
+       (condition-case error
+           (if (or (null (riece-slot-filter (car slots)))
+                   (condition-case error
+                       (funcall (riece-slot-filter (car slots)) signal)
+                     (error
+                      (if riece-debug
+                          (message
+                           "Error occurred in signal filter for \"%S\": %S"
+                           signal-name error)))
+                     nil))
+               (funcall (riece-slot-function (car slots))
+                        signal (riece-slot-handback (car slots))))
+         (error
+          (if riece-debug
+              (message "Error occurred in slot function for \"%S\": %S"
+                       signal-name error))))
+       (setq slots (cdr slots))))))
+
+(provide 'riece-signal)
+
+;;; riece-signal.el ends here
index 1356385..b2b2a28 100644 (file)
@@ -35,6 +35,7 @@
 
 (require 'riece-message)
 (require 'riece-commands)
+(require 'riece-signal)
 
 (eval-when-compile (require 'riece-highlight))
 
                                     riece-unread-channels))
     (setq riece-unread-channels
          (cons (riece-message-target message) riece-unread-channels))
-    (riece-redisplay-buffers)))
+    (riece-emit-signal 'channel-list-changed)))
 
 (defun riece-unread-after-switch-to-channel-function (last)
   (setq riece-unread-channels
        (delete riece-current-channel
                riece-unread-channels)))
 
-(defun riece-unread-format-channel-list-line (index channel)
-  (if (riece-identity-member channel riece-unread-channels)
+(defun riece-unread-format-identity-for-channel-list-buffer (index identity)
+  (if (riece-identity-member identity riece-unread-channels)
       (concat (format "%2d:!" index)
-             (riece-format-identity channel)
-             "\n")))
+             (riece-format-identity identity))))
+
+(defun riece-unread-format-identity-for-channel-list-indicator (index identity)
+  (if (riece-identity-member identity riece-unread-channels)
+      (let ((string (riece-format-identity identity))
+           (start 0)
+           extent)
+       ;; Escape % -> %%.
+       (while (string-match "%" string start)
+         (setq start (1+ (match-end 0))
+               string (replace-match "%%" nil nil string)))
+       (list (format "%d:" index)
+             (riece-propertize-modeline-string
+              string 'face 'riece-channel-list-unread-face)))))
 
 (defun riece-unread-switch-to-channel ()
   (interactive)
            'riece-unread-after-display-message-function)
   (add-hook 'riece-after-switch-to-channel-functions
            'riece-unread-after-switch-to-channel-function)
-  (add-hook 'riece-format-channel-list-line-functions
-           'riece-unread-format-channel-list-line)
+  (add-hook 'riece-format-identity-for-channel-list-buffer-functions
+           'riece-unread-format-identity-for-channel-list-buffer)
+  (add-hook 'riece-format-identity-for-channel-list-indicator-functions
+           'riece-unread-format-identity-for-channel-list-indicator)
   (define-key riece-command-mode-map
     "\C-c\C-u" 'riece-unread-switch-to-channel)
   (define-key riece-dialogue-mode-map
index b1d7349..119cabe 100644 (file)
 (defun riece-match-string-no-properties (number &optional string)
   (format "%s" (match-string number string)))
 
+(defun riece-propertize-modeline-string (string &rest properties)
+  (let ((extent (make-extent nil nil)))
+    (set-extent-properties extent properties)
+    (cons extent string)))
+
 (provide 'riece-xemacs)
 
 ;;; riece-xemacs.el ends here
index 8663214..dbb8a27 100644 (file)
 (defvar lsdb-insert-x-face-function)
 
 (defun riece-xface-update-user-list-buffer ()
-  (save-excursion
-    (set-buffer riece-user-list-buffer)
-    (riece-scan-property-region
-     'riece-identity (point-min)(point-max)
-     (lambda (start end)
-       (let ((records (riece-lsdb-lookup-records (get-text-property
-                                                 start 'riece-identity)))
-            xface)
-        (while (and records
-                    (null xface))
-          (setq xface (nth 1 (assq 'x-face (car records)))
-                records (cdr records)))
-        (if (and xface
-                 (not (eq (char-after end) ? )))
-            (let ((inhibit-read-only t)
-                  buffer-read-only)
-              (goto-char end)
-              (insert " ")
-              (funcall lsdb-insert-x-face-function xface))))))))
+  (riece-scan-property-region
+   'riece-identity (point-min)(point-max)
+   (lambda (start end)
+     (let ((records (riece-lsdb-lookup-records (get-text-property
+                                               start 'riece-identity)))
+          xface)
+       (while (and records
+                  (null xface))
+        (setq xface (nth 1 (assq 'x-face (car records)))
+              records (cdr records)))
+       (if (and xface
+               (not (eq (char-after end) ? )))
+          (let ((inhibit-read-only t)
+                buffer-read-only)
+            (goto-char end)
+            (insert " ")
+            (funcall lsdb-insert-x-face-function xface)))))))
 
 (defun riece-xface-requires ()
   '(riece-lsdb))
 
 (defun riece-xface-insinuate ()
-  (add-hook 'riece-update-buffer-functions
-           'riece-xface-update-user-list-buffer t))
+  (add-hook 'riece-startup-hook
+           (lambda ()
+             (with-current-buffer riece-user-list-buffer
+               (add-hook 'riece-update-buffer-functions
+                         'riece-xface-update-user-list-buffer t)))))
 
 (provide 'riece-xface)
 
index 997db0a..a8e101c 100644 (file)
@@ -284,6 +284,7 @@ If optional argument CONFIRM is non-nil, ask which IRC server to connect."
                         (riece-shrink-buffer (car buffers)))
                     (setq buffers (cdr buffers))))))))
     (switch-to-buffer riece-command-buffer)
+    (riece-display-connect-signals)
     (riece-redisplay-buffers)
     (riece-open-server riece-server "")
     (let ((server-list riece-startup-server-list))