Fixed.
[riece] / lisp / riece-button.el
index 9d85a14..27e4a73 100644 (file)
@@ -19,8 +19,8 @@
 
 ;; 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.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -48,8 +48,6 @@
     ["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.")
 
@@ -63,7 +61,7 @@
     ;; wid-edit (XEmacs only).
     (if (boundp 'help-echo-owns-message)
        (setq help-echo-owns-message t))
-    (format "%S: switch to %s; down-mouse-3: more options"
+    (format (riece-mcat "%S: switch to %s; down-mouse-3: more options")
            (aref riece-mouse-2 0)
            ;; XEmacs will get a single widget arg; Emacs 21 will get
            ;; window, overlay, position.
@@ -80,7 +78,8 @@ This function is used as a callback for a channel button."
     (if (riece-identity-member channel riece-current-channels)
        (riece-command-switch-to-channel channel)
       (message "%s" (substitute-command-keys
-                    "Type \\[riece-command-join] to join the channel")))))
+                    (riece-mcat
+                     "Type \\[riece-command-join] to join the channel"))))))
 
 (defun riece-identity-button-click (event)
   "Call widget-button-click and select the last selected window."
@@ -206,7 +205,7 @@ This function is used as a callback for a channel button."
 
 (defvar riece-identity-button-map)
 (defun riece-button-add-identity-button (start end)
-  (if riece-button-enabled
+  (if (get 'riece-button 'riece-addon-enabled)
       (riece-scan-property-region
        'riece-identity
        start end
@@ -247,12 +246,6 @@ This function is used as a callback for a channel button."
        (riece-make-identity-button-map)))
 
 (defun riece-button-insinuate ()
-  (add-hook 'riece-channel-list-mode-hook
-           'riece-button-channel-list-mode-hook)
-  (add-hook 'riece-user-list-mode-hook
-           'riece-button-user-list-mode-hook)
-  (add-hook 'riece-dialogue-mode-hook
-           'riece-button-dialogue-mode-hook)
   (save-excursion
     (when riece-channel-list-buffer
       (set-buffer riece-channel-list-buffer)
@@ -267,6 +260,12 @@ This function is used as a callback for a channel button."
                'riece-dialogue-mode)
            (riece-button-dialogue-mode-hook))
        (setq buffers (cdr buffers)))))
+  (add-hook 'riece-channel-list-mode-hook
+           'riece-button-channel-list-mode-hook)
+  (add-hook 'riece-user-list-mode-hook
+           'riece-button-user-list-mode-hook)
+  (add-hook 'riece-dialogue-mode-hook
+           'riece-button-dialogue-mode-hook)
   (add-hook 'riece-after-insert-functions 'riece-button-add-identity-button))
 
 (defun riece-button-uninstall ()
@@ -275,7 +274,7 @@ This function is used as a callback for a channel button."
       (while buffers
        (set-buffer (car buffers))
        (remove-hook 'riece-update-buffer-functions
-                    'riece-button-update-buffer)
+                    'riece-button-update-buffer t)
        (if (local-variable-p 'riece-identity-button-map
                              (car buffers))
            (kill-local-variable 'riece-identity-button-map))
@@ -290,7 +289,6 @@ This function is used as a callback for a channel button."
               'riece-button-add-identity-button))
 
 (defun riece-button-enable ()
-  (setq riece-button-enabled t)
   (let ((pointer riece-buffer-list))
     (while pointer
       (with-current-buffer (car pointer)
@@ -303,7 +301,6 @@ This function is used as a callback for a channel button."
     (riece-emit-signal 'channel-list-changed)))
 
 (defun riece-button-disable ()
-  (setq riece-button-enabled nil)
   (save-excursion
     (let ((pointer riece-buffer-list))
       (while pointer