* riece-commands.el (riece-command-enter-message): Fix behavior at last line of buffer.
[riece] / lisp / riece-commands.el
index 3436926..1f47339 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.
 
 ;;; Code:
 
 (require 'riece-misc)
 (require 'riece-identity)
 (require 'riece-message)
-
-(autoload 'derived-mode-class "derived")
+(require 'riece-mcat)
 
 ;;; Channel movement:
 (defun riece-command-switch-to-channel (channel)
   (interactive (list (riece-completing-read-identity
-                     "Switch to channel/user: "
+                     (riece-mcat "Switch to channel/user: ")
                      riece-current-channels nil t)))
   (unless (equal channel riece-current-channel)
     (riece-switch-to-channel channel)))
@@ -48,7 +47,7 @@
    (let ((command-name (symbol-name this-command)))
      (if (string-match "[0-9]+$" command-name)
         (list (string-to-number (match-string 0 command-name)))
-       (list (string-to-number (read-string "Switch to number: "))))))
+       (list (string-to-number (read-string (riece-mcat "Switch to number: ")))))))
   (let ((channel (nth (1- number) riece-current-channels)))
     (if channel
        (riece-command-switch-to-channel channel)
 
 (defun riece-command-configure-windows ()
   (interactive)
+  "Reconfigure windows with the current layout."
   (riece-redisplay-buffers t))
 
+(defun riece-command-suspend-resume ()
+  (interactive)
+  "Save or restore the current window configuration."
+  (let ((entry (assq 'riece-window-configuration (frame-parameters))))
+    (modify-frame-parameters (selected-frame)
+                            (list (cons 'riece-window-configuration
+                                        (current-window-configuration))))
+    (if (cdr entry)
+       (set-window-configuration (cdr entry))
+      (delete-other-windows))
+    (message
+     (substitute-command-keys
+      "\\[riece-command-suspend-resume] to get back the last windows"))))
+
 (defun riece-command-change-layout (name)
   "Select a layout-name from all current available layouts and change
 the layout to the selected layout-name."
-  (interactive (list (completing-read "Change layout: " riece-layout-alist)))
+  (interactive (list (completing-read (riece-mcat "Change layout: ")
+                                     riece-layout-alist)))
   (setq riece-layout name
        riece-save-variables-are-dirty t)
   (riece-command-configure-windows))
@@ -129,6 +144,13 @@ the layout to the selected layout-name."
        riece-save-variables-are-dirty t)
   (riece-command-configure-windows))
 
+(defun riece-command-toggle-others-buffer-mode ()
+  (interactive)
+  (setq riece-others-buffer-mode
+       (not riece-others-buffer-mode)
+       riece-save-variables-are-dirty t)
+  (riece-command-configure-windows))
+
 (defun riece-command-toggle-user-list-buffer-mode ()
   (interactive)
   (setq riece-user-list-buffer-mode
@@ -147,7 +169,7 @@ the layout to the selected layout-name."
   (interactive
    (let* ((completion-ignore-case t)
          (user (riece-completing-read-identity
-                "Finger user: "
+                (riece-mcat "Finger user: ")
                 (riece-get-users-on-server (riece-current-server-name))
                 nil nil nil nil nil t)))
      (list user current-prefix-arg)))
@@ -162,27 +184,29 @@ the layout to the selected layout-name."
    (progn
      (riece-check-channel-commands-are-usable t)
      (list (read-from-minibuffer
-           "Set 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-mcat "Set 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)))
+                            topic)
+                    riece-current-channel))
 
 (defun riece-command-invite (user)
   (interactive
    (let ((completion-ignore-case t))
      (riece-check-channel-commands-are-usable t)
      (list (riece-completing-read-identity
-           "Invite user: "
+           (riece-mcat "Invite user: ")
            (riece-get-users-on-server (riece-current-server-name))
            nil nil nil nil nil t))))
-  (riece-send-string (format "INVITE %s %s\r\n"
+  (riece-send-string (format "INVITE %s :%s\r\n"
                             (riece-identity-prefix user)
                             (riece-identity-prefix riece-current-channel))))
 
@@ -191,7 +215,7 @@ the layout to the selected layout-name."
    (let ((completion-ignore-case t))
      (riece-check-channel-commands-are-usable t)
      (list (completing-read
-           "Kick user: "
+           (riece-mcat "Kick user: ")
            (riece-with-server-buffer
                (riece-identity-server riece-current-channel)
              (riece-channel-get-users (riece-identity-prefix
@@ -205,48 +229,83 @@ the layout to the selected layout-name."
               user message)
      (format "KICK %s %s\r\n"
             (riece-identity-prefix riece-current-channel)
-            user))))
+            user))
+   riece-current-channel))
+
+(defun riece-command-kick-with-ban (user pattern &optional message)
+  (interactive
+   (let ((completion-ignore-case t)
+        user)
+     (riece-check-channel-commands-are-usable t)
+     (riece-with-server-buffer (riece-identity-server riece-current-channel)
+       (setq user (completing-read
+                  (riece-mcat "Kick user: ")
+                  (riece-channel-get-users (riece-identity-prefix
+                                            riece-current-channel))))
+       (list
+       user
+       (read-from-minibuffer
+        (riece-mcat "Ban pattern: ")
+        (concat user "!" (riece-user-get-user-at-host user)))
+       (if current-prefix-arg
+           (read-string "Message: "))))))
+  (riece-send-string (format "MODE %s :+b %s\r\n"
+                            (riece-identity-prefix riece-current-channel)
+                            pattern)
+                    riece-current-channel)
+  (riece-send-string
+   (if message
+       (format "KICK %s %s :%s\r\n"
+              (riece-identity-prefix riece-current-channel)
+              user message)
+     (format "KICK %s %s\r\n"
+            (riece-identity-prefix riece-current-channel)
+            user))
+   riece-current-channel))
 
 (defun riece-command-names (pattern)
   (interactive
    (let ((completion-ignore-case t))
      (list (read-from-minibuffer
-           "NAMES pattern: "
+           (riece-mcat "NAMES pattern: ")
            (if (and riece-current-channel
                     (riece-channel-p (riece-identity-prefix
                                       riece-current-channel)))
                (cons (riece-identity-prefix riece-current-channel)
                      0))))))
   (if (or (not (equal pattern ""))
-         (yes-or-no-p "Really want to query NAMES without argument? "))
+         (yes-or-no-p (riece-mcat
+                       "Really want to query NAMES without argument? ")))
       (riece-send-string (format "NAMES %s\r\n" pattern))))
 
 (defun riece-command-who (pattern)
   (interactive
    (let ((completion-ignore-case t))
      (list (read-from-minibuffer
-           "WHO pattern: "
+           (riece-mcat "WHO pattern: ")
            (if (and riece-current-channel
                     (riece-channel-p (riece-identity-prefix
                                       riece-current-channel)))
                (cons (riece-identity-prefix riece-current-channel)
                      0))))))
   (if (or (not (equal pattern ""))
-         (yes-or-no-p "Really want to query WHO without argument? "))
+         (yes-or-no-p (riece-mcat
+                       "Really want to query WHO without argument? ")))
       (riece-send-string (format "WHO %s\r\n" pattern))))
 
 (defun riece-command-list (pattern)
   (interactive
    (let ((completion-ignore-case t))
      (list (read-from-minibuffer
-           "LIST pattern: "
+           (riece-mcat "LIST pattern: ")
            (if (and riece-current-channel
                     (riece-channel-p (riece-identity-prefix
                                       riece-current-channel)))
                (cons (riece-identity-prefix riece-current-channel)
                      0))))))
   (if (or (not (equal pattern ""))
-         (yes-or-no-p "Really want to query LIST without argument? "))
+         (yes-or-no-p (riece-mcat
+                       "Really want to query LIST without argument? ")))
       (riece-send-string (format "LIST %s\r\n" pattern))))
 
 (defun riece-command-change-mode (channel change)
@@ -255,14 +314,14 @@ the layout to the selected layout-name."
          (channel
           (if current-prefix-arg
               (riece-completing-read-identity
-               "Change mode for channel/user: "
+               (riece-mcat "Change mode for channel/user: ")
                (riece-get-identities-on-server (riece-current-server-name))
                nil nil nil nil nil t)
             (riece-check-channel-commands-are-usable t)
             riece-current-channel))
          (riece-overriding-server-name (riece-identity-server channel))
          (riece-temp-minibuffer-message
-          (concat "[Available modes: "
+          (concat (riece-mcat "[Available modes: ")
                   (riece-with-server-buffer (riece-identity-server channel)
                     (if (riece-channel-p (riece-identity-prefix channel))
                         (if riece-supported-channel-modes
@@ -273,12 +332,12 @@ the layout to the selected layout-name."
      (list channel
           (read-from-minibuffer
            (concat (riece-concat-channel-modes
-                    channel "Mode (? for help)") ": ")
+                    channel (riece-mcat "Mode (? for help)")) ": ")
            nil riece-minibuffer-map))))
   (if (equal change "")
       (riece-send-string (format "MODE %s\r\n"
                                 (riece-identity-prefix channel)))
-    (riece-send-string (format "MODE %s :%s\r\n"
+    (riece-send-string (format "MODE %s %s\r\n"
                               (riece-identity-prefix channel)
                               change))))
 
@@ -289,8 +348,8 @@ the layout to the selected layout-name."
      (let ((completion-ignore-case t))
        (list (riece-completing-read-multiple
              (if current-prefix-arg
-                 "Unset +o for users"
-               "Set +o for users")
+                 (riece-mcat "Unset +o for users")
+               (riece-mcat "Set +o for users"))
              (riece-with-server-buffer
                  (riece-identity-server riece-current-channel)
                (riece-channel-get-users (riece-identity-prefix
@@ -324,8 +383,8 @@ the layout to the selected layout-name."
      (let ((completion-ignore-case t))
        (list (riece-completing-read-multiple
              (if current-prefix-arg
-                 "Unset +v for users"
-               "Set +v for users")
+                 (riece-mcat "Unset +v for users")
+               (riece-mcat "Set +v for users"))
              (riece-with-server-buffer
                  (riece-identity-server riece-current-channel)
                (riece-channel-get-users (riece-identity-prefix
@@ -354,22 +413,25 @@ the layout to the selected layout-name."
 
 (defun riece-command-send-message (message notice)
   "Send MESSAGE to the current channel."
+  (run-hooks 'riece-command-send-message-hook)
   (if (equal message "")
-      (error "No text to send"))
+      (error (riece-mcat "No text to send")))
   (riece-check-channel-commands-are-usable)
   (if notice
       (progn
        (riece-send-string
         (format "NOTICE %s :%s\r\n"
                 (riece-identity-prefix riece-current-channel)
-                message))
+                message)
+        riece-current-channel)
        (riece-display-message
         (riece-make-message (riece-current-nickname) riece-current-channel
                             message 'notice t)))
     (riece-send-string
      (format "PRIVMSG %s :%s\r\n"
             (riece-identity-prefix riece-current-channel)
-            message))
+            message)
+     riece-current-channel)
     (riece-display-message
      (riece-make-message (riece-current-nickname) riece-current-channel
                         message nil t))))
@@ -381,8 +443,10 @@ the layout to the selected layout-name."
                               (riece-line-beginning-position)
                               (riece-line-end-position))
                              nil)
-  (let ((next-line-add-newlines t))
-    (next-line 1)))
+  (forward-line 1)
+  (when (eobp)
+    (insert "\n")))
+
 
 (defun riece-command-enter-message-as-notice ()
   "Send the current line to the current channel as NOTICE."
@@ -391,39 +455,43 @@ the layout to the selected layout-name."
                               (riece-line-beginning-position)
                               (riece-line-end-position))
                              t)
-  (let ((next-line-add-newlines t))
-    (next-line 1)))
+  (forward-line 1)
+  (when (eobp)
+    (insert "\n")))
 
 (defun riece-command-enter-message-to-user (user)
   "Send the current line to USER."
   (interactive
-   (let ((completion-ignore-case t))
-     (list (riece-completing-read-identity
-           "Message to user: "
-           (riece-get-users-on-server (riece-current-server-name))
-           nil nil nil nil nil t))))
+   (if (and (bolp) (eolp))
+       (error "No text to send")
+     (let ((completion-ignore-case t))
+       (list (riece-completing-read-identity
+             (riece-mcat "Message to user: ")
+             (riece-get-users-on-server (riece-current-server-name))
+             nil nil nil nil nil t)))))
   (let ((text (buffer-substring
               (riece-line-beginning-position)
               (riece-line-end-position))))
     (riece-send-string
-     (format "PRIVMSG %s :%s\r\n" (riece-identity-prefix user) text))
+     (format "PRIVMSG %s :%s\r\n" (riece-identity-prefix user) text)
+     user)
     (riece-display-message
      (riece-make-message (riece-current-nickname) user text nil t)))
-  (let ((next-line-add-newlines t))
-    (next-line 1)))
+  (forward-line 1)
+  (when (eobp)
+    (insert "\n")))
 
 (defun riece-command-join-channel (target key)
-  (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 key
-                                  (format "JOIN %s :%s\r\n"
-                                          (riece-identity-prefix target)
-                                          key)
-                                (format "JOIN %s\r\n"
-                                        (riece-identity-prefix target))))))
+  (unless (riece-server-opened (riece-identity-server target))
+    (error "%s" (substitute-command-keys
+                "Type \\[riece-command-open-server] to open server.")))
+  (riece-send-string (if key
+                        (format "JOIN %s :%s\r\n"
+                                (riece-identity-prefix target)
+                                key)
+                      (format "JOIN %s\r\n"
+                              (riece-identity-prefix target)))
+                    target))
 
 (defun riece-command-join-partner (target)
   (let ((pointer (riece-identity-member target riece-current-channels)))
@@ -432,43 +500,38 @@ the layout to the selected layout-name."
       (riece-join-channel target)
       (riece-switch-to-channel target))))
 
-(defun riece-command-join (target &optional key)
+(defun riece-command-join (target)
   (interactive
-   (let* ((completion-ignore-case t)
-         (target
-          (if riece-join-channel-candidate
-              (let ((default (riece-format-identity
-                              riece-join-channel-candidate)))
-                (riece-completing-read-identity
-                 (format "Join channel/user (default %s): " default)
-                 (riece-get-identities-on-server (riece-current-server-name))
-                 nil nil nil nil default))
-            (riece-completing-read-identity
-             "Join channel/user: "
-             (riece-get-identities-on-server (riece-current-server-name)))))
-         key)
-     (if (and current-prefix-arg
-             (riece-channel-p (riece-identity-prefix target)))
-        (setq key
-              (riece-read-passwd (format "Key for %s: "
-                                         (riece-format-identity target)))))
-     (list target key)))
+   (let ((completion-ignore-case t))
+     (list
+      (if riece-join-channel-candidate
+         (let ((default (riece-format-identity
+                         riece-join-channel-candidate)))
+           (riece-completing-read-identity
+            (format (riece-mcat "Join channel/user (default %s): ") default)
+            (riece-get-identities-on-server (riece-current-server-name))
+            nil nil nil nil default))
+       (riece-completing-read-identity
+        (riece-mcat "Join channel/user: ")
+        (riece-get-identities-on-server (riece-current-server-name)))))))
   (let ((pointer (riece-identity-member target riece-current-channels)))
     (if pointer
        (riece-command-switch-to-channel (car pointer))
       (if (riece-channel-p (riece-identity-prefix target))
-         (riece-command-join-channel target key)
+         (riece-command-join-channel target nil)
        (riece-command-join-partner target)))))
 
 (defun riece-command-part-channel (target message)
-  (let ((process (riece-server-process (riece-identity-server target))))
-    (riece-process-send-string process
-                              (if message
-                                  (format "PART %s :%s\r\n"
-                                          (riece-identity-prefix target)
-                                          message)
-                                (format "PART %s\r\n"
-                                        (riece-identity-prefix target))))))
+  (unless (riece-server-opened (riece-identity-server target))
+    (error "%s" (substitute-command-keys
+                "Type \\[riece-command-open-server] to open server.")))
+  (riece-send-string (if message
+                        (format "PART %s :%s\r\n"
+                                (riece-identity-prefix target)
+                                message)
+                      (format "PART %s\r\n"
+                              (riece-identity-prefix target)))
+                    target))
 
 (defun riece-command-part (target &optional message)
   (interactive
@@ -477,14 +540,14 @@ the layout to the selected layout-name."
      (let* ((completion-ignore-case t)
            (target
             (riece-completing-read-identity
-             (format "Part from channel/user (default %s): "
+             (format (riece-mcat "Part from 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: ")))
+           (message
+            (if current-prefix-arg
+                (read-string (riece-mcat "Message: "))
+              riece-part-message)))
        (list target message))))
   (if (riece-identity-member target riece-current-channels)
       (if (riece-channel-p (riece-identity-prefix target))
@@ -509,7 +572,7 @@ the layout to the selected layout-name."
            (let ((other-window-scroll-buffer buffer))
              (scroll-other-window-down lines))
          (beginning-of-buffer
-          (message "Beginning of buffer"))))))
+          (message (riece-mcat "Beginning of buffer")))))))
 
 (defun riece-command-scroll-up (lines)
   "Scroll LINES up dialogue buffer from command buffer."
@@ -523,7 +586,7 @@ the layout to the selected layout-name."
            (let ((other-window-scroll-buffer buffer))
              (scroll-other-window lines))
          (end-of-buffer
-          (message "End of buffer"))))))
+          (message (riece-mcat "End of buffer")))))))
 
 (defun riece-command-user-list-scroll-down (lines)
   "Scroll LINES down user list buffer from command buffer."
@@ -533,7 +596,7 @@ the layout to the selected layout-name."
          (let ((other-window-scroll-buffer riece-user-list-buffer))
            (scroll-other-window-down lines))
        (beginning-of-buffer
-        (message "Beginning of buffer")))))
+        (message (riece-mcat "Beginning of buffer"))))))
 
 (defun riece-command-user-list-scroll-up (lines)
   "Scroll LINES up user list buffer from command buffer."
@@ -543,7 +606,7 @@ the layout to the selected layout-name."
          (let ((other-window-scroll-buffer riece-user-list-buffer))
            (scroll-other-window lines))
        (end-of-buffer
-        (message "End of buffer")))))
+        (message (riece-mcat "End of buffer"))))))
 
 (defun riece-command-toggle-away (&optional message)
   "Mark yourself as being away."
@@ -554,7 +617,8 @@ the layout to the selected layout-name."
                                         (riece-current-nickname)))))
            current-prefix-arg)
        (list (read-from-minibuffer
-             "Away message: " (cons (or riece-away-message "") 0)))))
+             (riece-mcat "Away message: ") (cons (or riece-away-message "")
+                                                 0)))))
   (if (riece-with-server-buffer (riece-identity-server
                                 (riece-current-nickname))
        (riece-user-get-away (riece-identity-prefix
@@ -567,8 +631,7 @@ the layout to the selected layout-name."
   "Prevent automatic scrolling of the dialogue window.
 If prefix argument ARG is non-nil, toggle frozen status."
   (interactive "P")
-  (with-current-buffer (if (eq (derived-mode-class major-mode)
-                              'riece-dialogue-mode)
+  (with-current-buffer (if (riece-derived-mode-p 'riece-dialogue-mode)
                           (current-buffer)
                         (if (and riece-channel-buffer-mode
                                  riece-channel-buffer)
@@ -585,8 +648,7 @@ If prefix argument ARG is non-nil, toggle frozen status."
 The difference from `riece-command-freeze' is that your messages are hidden.
 If prefix argument ARG is non-nil, toggle frozen status."
   (interactive "P")
-  (with-current-buffer (if (eq (derived-mode-class major-mode)
-                              'riece-dialogue-mode)
+  (with-current-buffer (if (riece-derived-mode-p 'riece-dialogue-mode)
                           (current-buffer)
                         (if (and riece-channel-buffer-mode
                                  riece-channel-buffer)
@@ -607,13 +669,13 @@ If prefix argument ARG is non-nil, toggle frozen status."
   (interactive "P")
   (if (null riece-server-process-alist)
       (progn
-       (message "No server process")
+       (message (riece-mcat "No server process"))
        (ding))
-    (if (y-or-n-p "Really quit IRC? ")
+    (if (y-or-n-p (riece-mcat "Really quit IRC? "))
        (let ((message
               (if arg
-                  (read-string "Message: ")
-              riece-quit-message))
+                  (read-string (riece-mcat "Message: "))
+                riece-quit-message))
              (alist riece-server-process-alist))
          (while alist
            (riece-quit-server-process (cdr (car alist)) message)
@@ -624,8 +686,23 @@ If prefix argument ARG is non-nil, toggle frozen status."
   (interactive "sIRC command: ")
   (riece-send-string (concat command "\r\n")))
 
+(defun riece-command-beginning-of-buffer ()
+  "Scroll channel buffer to the beginning."
+  (interactive)
+  (let (buffer window)
+    (setq buffer (if riece-channel-buffer-mode
+                    riece-channel-buffer
+                  riece-dialogue-buffer))
+    (or (setq window (get-buffer-window buffer))
+       (setq window (get-buffer-window riece-dialogue-buffer)
+             buffer riece-dialogue-buffer))
+    (when window
+      (save-selected-window
+       (select-window window)
+       (goto-char (point-min))))))
+
 (defun riece-command-end-of-buffer ()
-  "Get end of the dialogue buffer."
+  "Scroll channel buffer to the end."
   (interactive)
   (let (buffer window)
     (setq buffer (if riece-channel-buffer-mode
@@ -652,22 +729,23 @@ If prefix argument ARG is non-nil, toggle frozen status."
                          (list (riece-format-identity user t)))
                        (riece-get-users-on-server
                         (riece-current-server-name))))
-        (current (current-word))
+        (current (or (current-word) ""))
         (completion (try-completion current table))
         (all (all-completions current table)))
     (if (eq completion t)
        nil
       (if (null completion)
-         (message "Can't find completion for \"%s\"" current)
+         (message (riece-mcat "Can't find completion for \"%s\"") current)
        (if (equal current completion)
            (with-output-to-temp-buffer "*Help*"
              (display-completion-list all))
+         (re-search-forward "\\>" nil t)
          (delete-region (point) (- (point) (length current)))
          (insert completion))))))
 
 (defun riece-command-open-server (server-name)
   (interactive
-   (list (completing-read "Open server: " riece-server-alist)))
+   (list (completing-read (riece-mcat "Open server: ") riece-server-alist)))
   (if (riece-server-process server-name)
       (error "%s is already opened" server-name))
   (riece-open-server
@@ -676,23 +754,36 @@ If prefix argument ARG is non-nil, toggle frozen status."
 
 (defun riece-command-close-server (server-name &optional message)
   (interactive
-   (list (completing-read "Close server: " riece-server-process-alist)
+   (list (completing-read (riece-mcat "Close server: ")
+                         riece-server-process-alist)
         (if current-prefix-arg
-            (read-string "Message: ")
+            (read-string (riece-mcat "Message: "))
           riece-quit-message)))
-  (riece-quit-server-process (riece-server-process server-name) message))
+  (let ((process (riece-server-process server-name)))
+    (unless process
+      (error "%s is not opened" server-name))
+    (riece-quit-server-process process message)))
 
 (defun riece-command-universal-server-name-argument ()
   (interactive)
   (let* ((riece-overriding-server-name
-         (completing-read "Server: " riece-server-process-alist))
+         (completing-read (riece-mcat "Server: ") riece-server-process-alist))
         (command
          (key-binding (read-key-sequence
-                       (format "Command to execute on \"%s\":"
+                       (format (riece-mcat "Command to execute on \"%s\":")
                                riece-overriding-server-name)))))
     (message "")
     (call-interactively command)))
 
+(eval-when-compile
+  (autoload 'riece-save-variables-files "riece"))
+(defun riece-command-save-variables ()
+  "Save `riece-variables-file'."
+  (interactive)
+  (if (or riece-save-variables-are-dirty
+         (y-or-n-p (riece-mcat "No changes made.  Save anyway? ")))
+      (riece-save-variables-files)))
+
 (provide 'riece-commands)
 
 ;;; riece-commands.el ends here