* riece-button.el (riece-button-requires): Abolish.
[riece] / lisp / riece-button.el
index cba6fd3..f9f2188 100644 (file)
@@ -113,75 +113,63 @@ This function is used as a callback for a channel button."
 
 (defun riece-user-button-set-operators ()
   (interactive)
-  (let (group)
+  (let (group users)
     (if (riece-region-active-p)
        (save-excursion
-         (riece-button-map-identity-region
+         (riece-scan-property-region
+          'riece-identity
           (region-beginning) (region-end)
           (lambda (start end)
             (setq group (cons (get-text-property start 'riece-identity)
                               group)))))
       (setq group (list (get-text-property (point) 'riece-identity))))
+    (setq users (riece-with-server-buffer
+                   (riece-identity-server riece-current-channel)
+                 (riece-channel-get-users (riece-identity-prefix
+                                           riece-current-channel))))
     (if (setq group
              (delq nil
                    (mapcar
                     (lambda (identity)
-                      (riece-with-server-buffer (riece-identity-server
-                                                 riece-current-channel)
-                        (if (and (member
-                                  (riece-identity-prefix identity)
-                                  (riece-channel-get-users
-                                   (riece-identity-prefix
-                                    riece-current-channel)))
-                                 (not (member
-                                       (riece-identity-prefix identity)
-                                       (riece-channel-get-operators
-                                        (riece-identity-prefix
-                                         riece-current-channel)))))
-                            identity)))
+                      (unless (memq ?o (cdr (riece-identity-assoc
+                                             (riece-identity-prefix identity)
+                                             users
+                                             t)))
+                        identity))
                     group)))
        (riece-command-set-operators (mapcar #'riece-identity-prefix group)))))
 
 (defun riece-user-button-set-speakers ()
   (interactive)
-  (let (group)
+  (let (group users)
     (if (riece-region-active-p)
        (save-excursion
-         (riece-button-map-identity-region
+         (riece-scan-property-region
+          'riece-identity
           (region-beginning) (region-end)
           (lambda (start end)
             (setq group (cons (get-text-property start 'riece-identity)
                               group)))))
       (setq group (list (get-text-property (point) 'riece-identity))))
+    (setq users (riece-with-server-buffer
+                   (riece-identity-server riece-current-channel)
+                 (riece-channel-get-users (riece-identity-prefix
+                                           riece-current-channel))))
     (if (setq group
              (delq nil
                    (mapcar
                     (lambda (identity)
-                      (riece-with-server-buffer (riece-identity-server
-                                                 riece-current-channel)
-                        (if (and (member
-                                  (riece-identity-prefix identity)
-                                  (riece-channel-get-users
-                                   (riece-identity-prefix
-                                    riece-current-channel)))
-                                 (not (member
-                                       (riece-identity-prefix identity)
-                                       (riece-channel-get-operators
-                                        (riece-identity-prefix
-                                         riece-current-channel))))
-                                 (not (member
-                                       (riece-identity-prefix identity)
-                                       (riece-channel-get-speakers
-                                        (riece-identity-prefix
-                                         riece-current-channel)))))
-                            identity)))
+                      (unless (memq ?v (cdr (riece-identity-assoc
+                                             (riece-identity-prefix identity)
+                                             users
+                                             t)))
+                        identity))
                     group)))
        (riece-command-set-speakers (mapcar #'riece-identity-prefix group)))))
 
 (defun riece-user-button-finger ()
   (interactive)
-  (riece-command-finger
-   (riece-identity-prefix (get-text-property (point) 'riece-identity))))
+  (riece-command-finger (get-text-property (point) 'riece-identity)))
 
 (defun riece-make-identity-button-map ()
   (let ((map (make-sparse-keymap)))
@@ -189,26 +177,10 @@ This function is used as a callback for a channel button."
     (define-key map [down-mouse-3] 'riece-identity-button-popup-menu)
     map))
 
-(defun riece-button-map-identity-region (start end function)
-  (catch 'done
-    (while t
-      ;; Search for the beginning of the button region.
-      (unless (get-text-property start 'riece-identity)
-       (setq start (next-single-property-change start 'riece-identity
-                                                nil end)))
-      (if (= start end)
-         (throw 'done nil))
-      ;; Search for the end of the button region.
-      (let ((button-end (next-single-property-change start 'riece-identity
-                                                    nil end)))
-       (if (= button-end end)
-           (throw 'done nil))
-       (funcall function start button-end)
-       (setq start button-end)))))
-
 (defvar riece-identity-button-map)
 (defun riece-button-add-identity-button (start end)
-  (riece-button-map-identity-region
+  (riece-scan-property-region
+   'riece-identity
    start end
    (lambda (start end)
      (let ((inhibit-read-only t)
@@ -222,9 +194,6 @@ This function is used as a callback for a channel button."
 (defun riece-button-update-buffer ()
   (riece-button-add-identity-button (point-min) (point-max)))
 
-(defun riece-button-requires ()
-  '(riece-highlight))
-
 (defvar riece-channel-list-mode-map)
 (defvar riece-user-list-mode-map)
 (defvar riece-dialogue-mode-map)