Add the following comment to add-on modules.
[riece] / lisp / riece-button.el
index a3b915c..6cd9dfe 100644 (file)
@@ -1,4 +1,4 @@
-;;; riece-button.el --- adding buttons in channel buffers
+;;; riece-button.el --- display useful buttons in IRC buffers
 ;; Copyright (C) 1998-2003 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
@@ -24,8 +24,7 @@
 
 ;;; Commentary:
 
-;; To use, add the following line to your ~/.riece/init.el:
-;; (add-to-list 'riece-addons 'riece-button)
+;; NOTE: This is an add-on module for Riece.
 
 ;;; Code:
 
   '("User"
     ["Finger (WHOIS)" riece-user-button-finger]
     ["Start Private Conversation" riece-user-button-join-partner]
-    ["Give Channel Operator Privileges" riece-user-button-set-operators]
-    ["Allow To Speak" riece-user-button-set-speakers])
+    ["Set +o" riece-user-button-set-operators]
+    ["Set +v" riece-user-button-set-speakers])
   "Menu for user buttons.")
 
 (defvar riece-button-enabled nil)
 
 (defconst riece-button-description
-  "Display useful buttons in IRC buffers")
+  "Display useful buttons in IRC buffers.")
 
 (defvar help-echo-owns-message)
 (define-widget 'riece-identity-button 'push-button
@@ -83,9 +82,31 @@ This function is used as a callback for a channel button."
       (message "%s" (substitute-command-keys
                     "Type \\[riece-command-join] to join the channel")))))
 
+(defun riece-identity-button-click (event)
+  "Call widget-button-click and select the last selected window."
+  (interactive "e")                    ;widget-button-click has
+                                       ;interactive spec "@e"
+  (let ((buffer (current-buffer))
+       (point (point))
+       window)
+    (unwind-protect
+       (save-excursion
+         (set-buffer (riece-event-buffer event))
+         (goto-char (riece-event-point event))
+         (widget-button-click event))
+      ;; riece-button-switch-to-identity changes window-configuration
+      ;; so we must select the last selected window by _buffer_.
+      (if (setq window (get-buffer-window buffer))
+         (progn
+           (select-window window)
+           (set-window-point window point))
+       (if riece-debug
+           (riece-debug (format "buffer %s not visible"
+                                (buffer-name buffer))))))))
+
 (defun riece-identity-button-popup-menu (event)
   "Popup the menu for identity buttons."
-  (interactive "@e")
+  (interactive "e")
   (save-excursion
     (set-buffer (riece-event-buffer event))
     (goto-char (riece-event-point event))
@@ -179,6 +200,7 @@ This function is used as a callback for a channel button."
 (defun riece-make-identity-button-map ()
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map (current-local-map))
+    (define-key map [down-mouse-2] 'riece-identity-button-click)
     (define-key map [down-mouse-3] 'riece-identity-button-popup-menu)
     map))