Fix interactive spec.
[riece] / lisp / riece-commands.el
index 3439412..f48effa 100644 (file)
@@ -154,14 +154,17 @@ the layout to the selected layout-name."
 
 (defun riece-command-topic (topic)
   (interactive
-   (list (read-from-minibuffer
-         "Topic: " (cons (or (riece-with-server-buffer
-                                 (riece-identity-server riece-current-channel)
-                               (riece-channel-get-topic
-                                (riece-identity-prefix
-                                 riece-current-channel)))
-                             "")
-                         0))))
+   (progn
+     (riece-check-channel-commands-are-usable t)
+     (list (read-from-minibuffer
+           "Topic: " (cons (or (riece-with-server-buffer
+                                   (riece-identity-server
+                                    riece-current-channel)
+                                 (riece-channel-get-topic
+                                  (riece-identity-prefix
+                                   riece-current-channel)))
+                               "")
+                           0)))))
   (riece-send-string (format "TOPIC %s :%s\r\n"
                             (riece-identity-prefix riece-current-channel)
                             topic)))
@@ -169,10 +172,7 @@ the layout to the selected layout-name."
 (defun riece-command-invite (user)
   (interactive
    (let ((completion-ignore-case t))
-     (unless (and riece-current-channel
-                 (riece-channel-p (riece-identity-prefix
-                                   riece-current-channel)))
-       (error "Not on a channel"))
+     (riece-check-channel-commands-are-usable t)
      (list (completing-read
            "User: "
            (mapcar #'list (riece-get-users-on-server))))))
@@ -183,10 +183,7 @@ the layout to the selected layout-name."
 (defun riece-command-kick (user &optional message)
   (interactive
    (let ((completion-ignore-case t))
-     (unless (and riece-current-channel
-                 (riece-channel-p (riece-identity-prefix
-                                   riece-current-channel)))
-       (error "Not on a channel"))
+     (riece-check-channel-commands-are-usable t)
      (list (completing-read
            "User: "
            (mapcar #'list
@@ -254,6 +251,7 @@ the layout to the selected layout-name."
           (if current-prefix-arg
               (riece-completing-read-identity
                "Channel/User: " riece-current-channels)
+            (riece-check-channel-commands-are-usable t)
             riece-current-channel))
          (riece-overriding-server-name (riece-identity-server channel))
          (riece-temp-minibuffer-message
@@ -275,30 +273,32 @@ the layout to the selected layout-name."
 
 (defun riece-command-set-operators (users &optional arg)
   (interactive
-   (let ((operators
-         (riece-with-server-buffer
-             (riece-identity-server riece-current-channel)
-           (riece-channel-get-operators
-            (riece-identity-prefix riece-current-channel))))
-        (completion-ignore-case t)
-        users)
-     (if current-prefix-arg
+   (progn
+     (riece-check-channel-commands-are-usable t)
+     (let ((operators
+           (riece-with-server-buffer
+               (riece-identity-server riece-current-channel)
+             (riece-channel-get-operators
+              (riece-identity-prefix riece-current-channel))))
+          (completion-ignore-case t)
+          users)
+       (if current-prefix-arg
+          (setq users (riece-completing-read-multiple
+                       "Users"
+                       (mapcar #'list operators)))
         (setq users (riece-completing-read-multiple
                      "Users"
-                     (mapcar #'list operators)))
-       (setq users (riece-completing-read-multiple
-                   "Users"
-                   (delq nil (mapcar
-                              (lambda (user)
-                                (unless (member user operators)
-                                  (list user)))
-                              (riece-with-server-buffer
-                                  (riece-identity-server
-                                   riece-current-channel)
-                                (riece-channel-get-users
-                                 (riece-identity-prefix
-                                  riece-current-channel))))))))
-     (list users current-prefix-arg)))
+                     (delq nil (mapcar
+                                (lambda (user)
+                                  (unless (member user operators)
+                                    (list user)))
+                                (riece-with-server-buffer
+                                    (riece-identity-server
+                                     riece-current-channel)
+                                  (riece-channel-get-users
+                                   (riece-identity-prefix
+                                    riece-current-channel))))))))
+       (list users current-prefix-arg))))
   (let (group)
     (while users
       (setq group (cons (car users) group)
@@ -316,30 +316,32 @@ the layout to the selected layout-name."
 
 (defun riece-command-set-speakers (users &optional arg)
   (interactive
-   (let ((speakers
-         (riece-with-server-buffer
-             (riece-identity-server riece-current-channel)
-           (riece-channel-get-speakers
-            (riece-identity-prefix riece-current-channel))))
-        (completion-ignore-case t)
-        users)
-     (if current-prefix-arg
+   (progn
+     (riece-check-channel-commands-are-usable t)
+     (let ((speakers
+           (riece-with-server-buffer
+               (riece-identity-server riece-current-channel)
+             (riece-channel-get-speakers
+              (riece-identity-prefix riece-current-channel))))
+          (completion-ignore-case t)
+          users)
+       (if current-prefix-arg
+          (setq users (riece-completing-read-multiple
+                       "Users"
+                       (mapcar #'list speakers)))
         (setq users (riece-completing-read-multiple
                      "Users"
-                     (mapcar #'list speakers)))
-       (setq users (riece-completing-read-multiple
-                   "Users"
-                   (delq nil (mapcar
-                              (lambda (user)
-                                (unless (member user speakers)
-                                  (list user)))
-                              (riece-with-server-buffer
-                                  (riece-identity-server
-                                   riece-current-channel)
-                                (riece-channel-get-users
-                                 (riece-identity-prefix
-                                  riece-current-channel))))))))
-     (list users current-prefix-arg)))
+                     (delq nil (mapcar
+                                (lambda (user)
+                                  (unless (member user speakers)
+                                    (list user)))
+                                (riece-with-server-buffer
+                                    (riece-identity-server
+                                     riece-current-channel)
+                                  (riece-channel-get-users
+                                   (riece-identity-prefix
+                                    riece-current-channel))))))))
+       (list users current-prefix-arg))))
   (let (group)
     (while users
       (setq group (cons (car users) group)
@@ -359,9 +361,7 @@ the layout to the selected layout-name."
   "Send MESSAGE to the current channel."
   (if (equal message "")
       (error "No text to send"))
-  (unless riece-current-channel
-    (error (substitute-command-keys
-           "Type \\[riece-command-join] to join a channel")))
+  (riece-check-channel-commands-are-usable)
   (if notice
       (progn
        (riece-send-string
@@ -448,9 +448,6 @@ the layout to the selected layout-name."
 
 (defun riece-command-part-channel (target message)
   (let ((process (riece-server-process (riece-identity-server target))))
-    (unless process
-      (error "%s" (substitute-command-keys
-                  "Type \\[riece-command-open-server] to open server.")))
     (riece-process-send-string process
                               (if message
                                   (format "PART %s :%s\r\n"
@@ -461,18 +458,20 @@ the layout to the selected layout-name."
 
 (defun riece-command-part (target &optional message)
   (interactive
-   (let* ((completion-ignore-case t)
-        (target
-         (riece-completing-read-identity
-          (format "Channel/User (default %s): "
-                  (riece-format-identity riece-current-channel))
-          riece-current-channels nil nil nil nil
-          (riece-format-identity riece-current-channel)))
-        message)
-     (if (and current-prefix-arg
-             (riece-channel-p (riece-identity-prefix target)))
-        (setq message (read-string "Message: ")))
-     (list target message)))
+   (progn
+     (riece-check-channel-commands-are-usable)
+     (let* ((completion-ignore-case t)
+           (target
+            (riece-completing-read-identity
+             (format "Channel/User (default %s): "
+                     (riece-format-identity riece-current-channel))
+             riece-current-channels nil nil nil nil
+             (riece-format-identity riece-current-channel)))
+           message)
+       (if (and current-prefix-arg
+               (riece-channel-p (riece-identity-prefix target)))
+          (setq message (read-string "Message: ")))
+       (list target message))))
   (if (riece-identity-member target riece-current-channels)
       (if (riece-channel-p (riece-identity-prefix target))
          (riece-command-part-channel target message)
@@ -637,7 +636,7 @@ If prefix argument ARG is non-nil, toggle frozen status."
 (defun riece-command-universal-server-name-argument ()
   (interactive)
   (let* ((riece-overriding-server-name
-         (completing-read "Server: " riece-server-process-alist)))
+         (completing-read "Server: " riece-server-process-alist))
         (command
          (key-binding (read-key-sequence
                        (format "Command to execute on \"%s\":"