* riece-commands.el (riece-command-switch-to-channel): Change prompt.
[riece] / lisp / riece-commands.el
1 ;;; riece-commands.el --- commands available in command buffer
2 ;; Copyright (C) 1998-2003 Daiki Ueno
3
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Created: 1998-09-28
6 ;; Keywords: IRC, riece
7
8 ;; This file is part of Riece.
9
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (require 'riece-channel)
28 (require 'riece-complete)
29 (require 'riece-layout)
30 (require 'riece-display)
31 (require 'riece-server)
32 (require 'riece-misc)
33 (require 'riece-identity)
34 (require 'riece-message)
35
36 (autoload 'derived-mode-class "derived")
37
38 ;;; Channel movement:
39 (defun riece-command-switch-to-channel (channel)
40   (interactive (list (riece-completing-read-identity
41                       "Switch to channel/user: "
42                       riece-current-channels nil t)))
43   (unless (equal channel riece-current-channel)
44     (riece-switch-to-channel channel)))
45
46 (defun riece-command-switch-to-channel-by-number (number)
47   (interactive
48    (let ((command-name (symbol-name this-command)))
49      (if (string-match "[0-9]+$" command-name)
50          (list (string-to-number (match-string 0 command-name)))
51        (list (string-to-number (read-string "Switch to number: "))))))
52   (let ((channel (nth (1- number) riece-current-channels)))
53     (if channel
54         (riece-command-switch-to-channel channel)
55       (error "No such number!"))))
56
57 (eval-and-compile
58   (let ((number 1))
59     (while (<= number 20)
60       (defalias (intern (concat "riece-command-switch-to-channel-by-number-"
61                                 (number-to-string number)))
62         'riece-command-switch-to-channel-by-number)
63       (setq number (1+ number)))))
64
65 (defun riece-command-next-channel ()
66   "Select the next channel."
67   (interactive)
68   (when (> (length riece-current-channels) 1)
69     (let ((pointer (cdr (riece-identity-member
70                          riece-current-channel
71                          riece-current-channels))))
72       (while (and pointer
73                   (null (car pointer)))
74         (setq pointer (cdr pointer)))
75       (when (null pointer)
76         (setq pointer riece-current-channels)
77         (while (and pointer
78                     (null (car pointer)))
79           (setq pointer (cdr pointer))))
80       (if (car pointer)
81           (riece-command-switch-to-channel (car pointer))
82         (error "No such channel!")))))
83
84 (defun riece-command-previous-channel ()
85   "Select the previous channel."
86   (interactive)
87   (when (> (length riece-current-channels) 1)
88     (let ((pointer (riece-identity-member
89                     riece-current-channel
90                     riece-current-channels))
91           (start riece-current-channels)
92           channel)
93       (while (and start (not (eq start pointer)))
94         (if (car start)
95             (setq channel (car start)))
96         (setq start (cdr start)))
97       (when (null channel)
98         (setq start (copy-sequence riece-current-channels))
99         (setq start (delq nil start))
100         (and (> (length start) 1)
101              (setq channel (nth (1- (length start)) start))))
102       (if channel
103           (riece-command-switch-to-channel channel)
104         (error "No such channel!")))))
105
106 (defun riece-command-select-command-buffer ()
107   "Select the command buffer."
108   (interactive)
109   (let ((window (get-buffer-window riece-command-buffer)))
110     (if window
111         (select-window window))))
112
113 (defun riece-command-configure-windows ()
114   (interactive)
115   (riece-redisplay-buffers t))
116
117 (defun riece-command-change-layout (name)
118   "Select a layout-name from all current available layouts and change
119 the layout to the selected layout-name."
120   (interactive (list (completing-read "Change layout: " riece-layout-alist)))
121   (setq riece-layout name
122         riece-save-variables-are-dirty t)
123   (riece-command-configure-windows))
124
125 (defun riece-command-toggle-channel-buffer-mode ()
126   (interactive)
127   (setq riece-channel-buffer-mode
128         (not riece-channel-buffer-mode)
129         riece-save-variables-are-dirty t)
130   (riece-command-configure-windows))
131
132 (defun riece-command-toggle-user-list-buffer-mode ()
133   (interactive)
134   (setq riece-user-list-buffer-mode
135         (not riece-user-list-buffer-mode)
136         riece-save-variables-are-dirty t)
137   (riece-command-configure-windows))
138
139 (defun riece-command-toggle-channel-list-buffer-mode ()
140   (interactive)
141   (setq riece-channel-list-buffer-mode
142         (not riece-channel-list-buffer-mode)
143         riece-save-variables-are-dirty t)
144   (riece-command-configure-windows))
145
146 (defun riece-command-finger (user &optional recurse)
147   (interactive
148    (let* ((completion-ignore-case t)
149           (user (riece-completing-read-identity
150                  "Finger user: "
151                  (riece-get-users-on-server (riece-current-server-name)))))
152      (list user current-prefix-arg)))
153   (if recurse
154       (riece-send-string (format "WHOIS %s %s\r\n"
155                                  (riece-identity-prefix user)
156                                  (riece-identity-prefix user)))
157     (riece-send-string (format "WHOIS %s\r\n" (riece-identity-prefix user)))))
158
159 (defun riece-command-topic (topic)
160   (interactive
161    (progn
162      (riece-check-channel-commands-are-usable t)
163      (list (read-from-minibuffer
164             "Set topic: " (cons (or (riece-with-server-buffer
165                                      (riece-identity-server
166                                       riece-current-channel)
167                                      (riece-channel-get-topic
168                                       (riece-identity-prefix
169                                        riece-current-channel)))
170                                     "")
171                                 0)))))
172   (riece-send-string (format "TOPIC %s :%s\r\n"
173                              (riece-identity-prefix riece-current-channel)
174                              topic)))
175
176 (defun riece-command-invite (user)
177   (interactive
178    (let ((completion-ignore-case t))
179      (riece-check-channel-commands-are-usable t)
180      (list (riece-completing-read-identity
181             "Invite user: "
182             (riece-get-users-on-server (riece-current-server-name))))))
183   (riece-send-string (format "INVITE %s %s\r\n"
184                              (riece-identity-prefix user)
185                              (riece-identity-prefix riece-current-channel))))
186
187 (defun riece-command-kick (user &optional message)
188   (interactive
189    (let ((completion-ignore-case t))
190      (riece-check-channel-commands-are-usable t)
191      (list (completing-read
192             "Kick user: "
193             (riece-with-server-buffer
194                 (riece-identity-server riece-current-channel)
195               (riece-channel-get-users (riece-identity-prefix
196                                         riece-current-channel))))
197            (if current-prefix-arg
198                (read-string "Message: ")))))
199   (riece-send-string
200    (if message
201        (format "KICK %s %s :%s\r\n"
202                (riece-identity-prefix riece-current-channel)
203                user message)
204      (format "KICK %s %s\r\n"
205              (riece-identity-prefix riece-current-channel)
206              user))))
207
208 (defun riece-command-names (pattern)
209   (interactive
210    (let ((completion-ignore-case t))
211      (list (read-from-minibuffer
212             "NAMES pattern: "
213             (if (and riece-current-channel
214                      (riece-channel-p (riece-identity-prefix
215                                        riece-current-channel)))
216                 (cons (riece-identity-prefix riece-current-channel)
217                       0))))))
218   (if (or (not (equal pattern ""))
219           (yes-or-no-p "Really want to query NAMES without argument? "))
220       (riece-send-string (format "NAMES %s\r\n" pattern))))
221
222 (defun riece-command-who (pattern)
223   (interactive
224    (let ((completion-ignore-case t))
225      (list (read-from-minibuffer
226             "WHO pattern: "
227             (if (and riece-current-channel
228                      (riece-channel-p (riece-identity-prefix
229                                        riece-current-channel)))
230                 (cons (riece-identity-prefix riece-current-channel)
231                       0))))))
232   (if (or (not (equal pattern ""))
233           (yes-or-no-p "Really want to query WHO without argument? "))
234       (riece-send-string (format "WHO %s\r\n" pattern))))
235
236 (defun riece-command-list (pattern)
237   (interactive
238    (let ((completion-ignore-case t))
239      (list (read-from-minibuffer
240             "LIST pattern: "
241             (if (and riece-current-channel
242                      (riece-channel-p (riece-identity-prefix
243                                        riece-current-channel)))
244                 (cons (riece-identity-prefix riece-current-channel)
245                       0))))))
246   (if (or (not (equal pattern ""))
247           (yes-or-no-p "Really want to query LIST without argument? "))
248       (riece-send-string (format "LIST %s\r\n" pattern))))
249
250 (defun riece-command-change-mode (channel change)
251   (interactive
252    (let* ((completion-ignore-case t)
253           (channel
254            (if current-prefix-arg
255                (riece-completing-read-identity
256                 "Change mode for channel/user: "
257                 (riece-get-identities-on-server (riece-current-server-name)))
258              (riece-check-channel-commands-are-usable t)
259              riece-current-channel))
260           (riece-overriding-server-name (riece-identity-server channel))
261           (riece-temp-minibuffer-message
262            (concat "[Available modes: "
263                    (riece-with-server-buffer (riece-identity-server channel)
264                      (if (riece-channel-p (riece-identity-prefix channel))
265                          (if riece-supported-channel-modes
266                              (apply #'string riece-supported-channel-modes))
267                        (if riece-supported-user-modes
268                            (apply #'string riece-supported-user-modes))))
269                    "]")))
270      (list channel
271            (read-from-minibuffer
272             (concat (riece-concat-channel-modes
273                      channel "Mode (? for help)") ": ")
274             nil riece-minibuffer-map))))
275   (riece-send-string (format "MODE %s :%s\r\n" (riece-identity-prefix channel)
276                              change)))
277
278 (defun riece-command-set-operators (users &optional arg)
279   (interactive
280    (progn
281      (riece-check-channel-commands-are-usable t)
282      (let ((completion-ignore-case t))
283        (list (riece-completing-read-multiple
284               (if current-prefix-arg
285                   "Unset +o for users"
286                 "Set +o for users")
287               (riece-with-server-buffer
288                   (riece-identity-server riece-current-channel)
289                 (riece-channel-get-users (riece-identity-prefix
290                                          riece-current-channel)))
291               (if current-prefix-arg
292                   (lambda (user)
293                     (memq ?o (cdr user)))
294                 (lambda (user)
295                   (not (memq ?o (cdr user))))))
296              current-prefix-arg))))
297   (let (group)
298     (while users
299       (setq group (cons (car users) group)
300             users (cdr users))
301       (when (or (= (length group) 3)
302                 (null users))
303         (riece-send-string
304          (format "MODE %s %c%s %s\r\n"
305                  (riece-identity-prefix riece-current-channel)
306                  (if current-prefix-arg
307                      ?-
308                    ?+)
309                  (make-string (length group) ?o)
310                  (mapconcat #'identity (nreverse group) " ")))
311         (setq group nil)))))
312
313 (defun riece-command-set-speakers (users &optional arg)
314   (interactive
315    (progn
316      (riece-check-channel-commands-are-usable t)
317      (let ((completion-ignore-case t))
318        (list (riece-completing-read-multiple
319               (if current-prefix-arg
320                   "Unset +v for users"
321                 "Set +v for users")
322               (riece-with-server-buffer
323                   (riece-identity-server riece-current-channel)
324                 (riece-channel-get-users (riece-identity-prefix
325                                           riece-current-channel)))
326               (if current-prefix-arg
327                   (lambda (user)
328                     (memq ?v (cdr user)))
329                 (lambda (user)
330                   (not (memq ?v (cdr user))))))
331              current-prefix-arg))))
332   (let (group)
333     (while users
334       (setq group (cons (car users) group)
335             users (cdr users))
336       (when (or (= (length group) 3)
337                 (null users))
338         (riece-send-string
339          (format "MODE %s %c%s %s\r\n"
340                  (riece-identity-prefix riece-current-channel)
341                  (if current-prefix-arg
342                      ?-
343                    ?+)
344                  (make-string (length group) ?v)
345                  (mapconcat #'identity (nreverse group) " ")))
346         (setq group nil)))))
347
348 (defun riece-command-send-message (message notice)
349   "Send MESSAGE to the current channel."
350   (if (equal message "")
351       (error "No text to send"))
352   (riece-check-channel-commands-are-usable)
353   (if notice
354       (progn
355         (riece-send-string
356          (format "NOTICE %s :%s\r\n"
357                  (riece-identity-prefix riece-current-channel)
358                  message))
359         (riece-display-message
360          (riece-make-message (riece-current-nickname) riece-current-channel
361                              message 'notice t)))
362     (riece-send-string
363      (format "PRIVMSG %s :%s\r\n"
364              (riece-identity-prefix riece-current-channel)
365              message))
366     (riece-display-message
367      (riece-make-message (riece-current-nickname) riece-current-channel
368                          message nil t))))
369
370 (defun riece-command-enter-message ()
371   "Send the current line to the current channel."
372   (interactive)
373   (riece-command-send-message (buffer-substring
374                                (riece-line-beginning-position)
375                                (riece-line-end-position))
376                               nil)
377   (let ((next-line-add-newlines t))
378     (next-line 1)))
379
380 (defun riece-command-enter-message-as-notice ()
381   "Send the current line to the current channel as NOTICE."
382   (interactive)
383   (riece-command-send-message (buffer-substring
384                                (riece-line-beginning-position)
385                                (riece-line-end-position))
386                               t)
387   (let ((next-line-add-newlines t))
388     (next-line 1)))
389
390 (defun riece-command-enter-message-to-user (user)
391   "Send the current line to USER."
392   (interactive
393    (let ((completion-ignore-case t))
394      (list (riece-completing-read-identity
395             "Message to user: "
396             (riece-get-users-on-server (riece-current-server-name))))))
397   (let ((text (buffer-substring
398                (riece-line-beginning-position)
399                (riece-line-end-position))))
400     (riece-send-string
401      (format "PRIVMSG %s :%s\r\n" (riece-identity-prefix user) text))
402     (riece-display-message
403      (riece-make-message (riece-current-nickname) user text nil t)))
404   (let ((next-line-add-newlines t))
405     (next-line 1)))
406
407 (defun riece-command-join-channel (target key)
408   (let ((process (riece-server-process (riece-identity-server target))))
409     (unless process
410       (error "%s" (substitute-command-keys
411                    "Type \\[riece-command-open-server] to open server.")))
412     (riece-process-send-string process
413                                (if key
414                                    (format "JOIN %s :%s\r\n"
415                                            (riece-identity-prefix target)
416                                            key)
417                                  (format "JOIN %s\r\n"
418                                          (riece-identity-prefix target))))))
419
420 (defun riece-command-join-partner (target)
421   (let ((pointer (riece-identity-member target riece-current-channels)))
422     (if pointer
423         (riece-command-switch-to-channel (car pointer))
424       (riece-join-channel target)
425       (riece-switch-to-channel target))))
426
427 (defun riece-command-join (target &optional key)
428   (interactive
429    (let* ((completion-ignore-case t)
430           (target
431            (if riece-join-channel-candidate
432                (let ((default (riece-format-identity
433                                riece-join-channel-candidate)))
434                  (riece-completing-read-identity
435                   (format "Join channel/user (default %s): " default)
436                   (riece-get-identities-on-server (riece-current-server-name))
437                   nil nil nil nil default))
438              (riece-completing-read-identity
439               "Join channel/user: "
440               (riece-get-identities-on-server (riece-current-server-name)))))
441           key)
442      (if (and current-prefix-arg
443               (riece-channel-p (riece-identity-prefix target)))
444          (setq key
445                (riece-read-passwd (format "Key for %s: "
446                                           (riece-format-identity target)))))
447      (list target key)))
448   (let ((pointer (riece-identity-member target riece-current-channels)))
449     (if pointer
450         (riece-command-switch-to-channel (car pointer))
451       (if (riece-channel-p (riece-identity-prefix target))
452           (riece-command-join-channel target key)
453         (riece-command-join-partner target)))))
454
455 (defun riece-command-part-channel (target message)
456   (let ((process (riece-server-process (riece-identity-server target))))
457     (riece-process-send-string process
458                                (if message
459                                    (format "PART %s :%s\r\n"
460                                            (riece-identity-prefix target)
461                                            message)
462                                  (format "PART %s\r\n"
463                                          (riece-identity-prefix target))))))
464
465 (defun riece-command-part (target &optional message)
466   (interactive
467    (progn
468      (riece-check-channel-commands-are-usable)
469      (let* ((completion-ignore-case t)
470             (target
471              (riece-completing-read-identity
472               (format "Part from channel/user (default %s): "
473                       (riece-format-identity riece-current-channel))
474               riece-current-channels nil nil nil nil
475               (riece-format-identity riece-current-channel)))
476             message)
477        (if (and current-prefix-arg
478                 (riece-channel-p (riece-identity-prefix target)))
479            (setq message (read-string "Message: ")))
480        (list target message))))
481   (if (riece-identity-member target riece-current-channels)
482       (if (riece-channel-p (riece-identity-prefix target))
483           (riece-command-part-channel target message)
484         (riece-part-channel target))
485     (error "You are not talking with %s" target)))
486
487 (defun riece-command-change-nickname (nickname)
488   "Change your nickname to NICK."
489   (interactive "sEnter your nickname: ")
490   (riece-send-string (format "NICK %s\r\n" nickname)))
491
492 (defun riece-command-scroll-down (lines)
493   "Scroll LINES down dialogue buffer from command buffer."
494   (interactive "P")
495   (let ((buffer (if (and riece-channel-buffer-mode
496                          riece-current-channel)
497                     riece-channel-buffer
498                   riece-dialogue-buffer)))
499     (if (get-buffer-window buffer)
500         (condition-case nil
501             (let ((other-window-scroll-buffer buffer))
502               (scroll-other-window-down lines))
503           (beginning-of-buffer
504            (message "Beginning of buffer"))))))
505
506 (defun riece-command-scroll-up (lines)
507   "Scroll LINES up dialogue buffer from command buffer."
508   (interactive "P")
509   (let ((buffer (if (and riece-channel-buffer-mode
510                          riece-current-channel)
511                     riece-channel-buffer
512                   riece-dialogue-buffer)))
513     (if (get-buffer-window buffer)
514         (condition-case nil
515             (let ((other-window-scroll-buffer buffer))
516               (scroll-other-window lines))
517           (end-of-buffer
518            (message "End of buffer"))))))
519
520 (defun riece-command-user-list-scroll-down (lines)
521   "Scroll LINES down user list buffer from command buffer."
522   (interactive "P")
523   (if (get-buffer-window riece-user-list-buffer)
524       (condition-case nil
525           (let ((other-window-scroll-buffer riece-user-list-buffer))
526             (scroll-other-window-down lines))
527         (beginning-of-buffer
528          (message "Beginning of buffer")))))
529
530 (defun riece-command-user-list-scroll-up (lines)
531   "Scroll LINES up user list buffer from command buffer."
532   (interactive "P")
533   (if (get-buffer-window riece-user-list-buffer)
534       (condition-case nil
535           (let ((other-window-scroll-buffer riece-user-list-buffer))
536             (scroll-other-window lines))
537         (end-of-buffer
538          (message "End of buffer")))))
539
540 (defun riece-command-toggle-away (&optional message)
541   "Mark yourself as being away."
542   (interactive
543    (if (and (not (riece-with-server-buffer (riece-identity-server
544                                             (riece-current-nickname))
545                    (riece-user-get-away (riece-identity-prefix
546                                          (riece-current-nickname)))))
547             current-prefix-arg)
548        (list (read-from-minibuffer
549               "Away message: " (cons (or riece-away-message "") 0)))))
550   (if (riece-with-server-buffer (riece-identity-server
551                                  (riece-current-nickname))
552         (riece-user-get-away (riece-identity-prefix
553                               (riece-current-nickname))))
554       (riece-send-string "AWAY\r\n")
555     (riece-send-string (format "AWAY :%s\r\n" (or message
556                                                   riece-away-message)))))
557
558 (defun riece-command-toggle-freeze (&optional arg)
559   "Prevent automatic scrolling of the dialogue window.
560 If prefix argument ARG is non-nil, toggle frozen status."
561   (interactive "P")
562   (with-current-buffer (if (eq (derived-mode-class major-mode)
563                                'riece-dialogue-mode)
564                            (current-buffer)
565                          (if (and riece-channel-buffer-mode
566                                   riece-channel-buffer)
567                              riece-channel-buffer
568                            riece-dialogue-buffer))
569     (setq riece-freeze (if arg
570                            (< 0 (prefix-numeric-value arg))
571                          (not riece-freeze)))
572     (riece-emit-signal 'buffer-freeze-changed
573                        (current-buffer) riece-freeze)))
574
575 (defun riece-command-toggle-own-freeze (&optional arg)
576   "Prevent automatic scrolling of the dialogue window.
577 The difference from `riece-command-freeze' is that your messages are hidden.
578 If prefix argument ARG is non-nil, toggle frozen status."
579   (interactive "P")
580   (with-current-buffer (if (eq (derived-mode-class major-mode)
581                                'riece-dialogue-mode)
582                            (current-buffer)
583                          (if (and riece-channel-buffer-mode
584                                   riece-channel-buffer)
585                              riece-channel-buffer
586                            riece-dialogue-buffer))
587     (if (if arg
588             (< 0 (prefix-numeric-value arg))
589           (not (eq riece-freeze 'own)))
590         (setq riece-freeze 'own)
591       (setq riece-freeze nil))
592     (riece-emit-signal 'buffer-freeze-changed
593                        (current-buffer) riece-freeze)))
594
595 (eval-when-compile
596   (autoload 'riece-exit "riece"))
597 (defun riece-command-quit (&optional arg)
598   "Quit IRC."
599   (interactive "P")
600   (if (null riece-server-process-alist)
601       (progn
602         (message "No server process")
603         (ding))
604     (if (y-or-n-p "Really quit IRC? ")
605         (let ((message
606                (if arg
607                    (read-string "Message: ")
608                riece-quit-message))
609               (alist riece-server-process-alist))
610           (while alist
611             (riece-quit-server-process (cdr (car alist)) message)
612             (setq alist (cdr alist)))))))
613
614 (defun riece-command-raw (command)
615   "Enter raw IRC command, which is sent to the server."
616   (interactive "sIRC command: ")
617   (riece-send-string (concat command "\r\n")))
618
619 (defun riece-command-end-of-buffer ()
620   "Get end of the dialogue buffer."
621   (interactive)
622   (let (buffer window)
623     (setq buffer (if riece-channel-buffer-mode
624                      riece-channel-buffer
625                    riece-dialogue-buffer))
626     (or (setq window (get-buffer-window buffer))
627         (setq window (get-buffer-window riece-dialogue-buffer)
628               buffer riece-dialogue-buffer))
629     (when window
630       (save-selected-window
631         (select-window window)
632         (goto-char (point-max))))))
633
634 (defun riece-command-copy-region (start end)
635   "Move current region between START and END to `kill-ring'."
636   (interactive "r")
637   (kill-new (buffer-substring-no-properties start end)))
638
639 (defun riece-command-complete-user ()
640   "Complete a user name in the current buffer."
641   (interactive)
642   (let* ((completion-ignore-case t)
643          (table (mapcar (lambda (user)
644                           (list (riece-format-identity user t)))
645                         (riece-get-users-on-server
646                          (riece-current-server-name))))
647          (current (current-word))
648          (completion (try-completion current table))
649          (all (all-completions current table)))
650     (if (eq completion t)
651         nil
652       (if (null completion)
653           (message "Can't find completion for \"%s\"" current)
654         (if (equal current completion)
655             (with-output-to-temp-buffer "*Help*"
656               (display-completion-list all))
657           (delete-region (point) (- (point) (length current)))
658           (insert completion))))))
659   
660 (defun riece-command-open-server (server-name)
661   (interactive
662    (list (completing-read "Open server: " riece-server-alist)))
663   (if (riece-server-process server-name)
664       (error "%s is already opened" server-name))
665   (riece-open-server
666    (riece-server-name-to-server server-name)
667    server-name))
668
669 (defun riece-command-close-server (server-name &optional message)
670   (interactive
671    (list (completing-read "Close server: " riece-server-process-alist)
672          (if current-prefix-arg
673              (read-string "Message: ")
674            riece-quit-message)))
675   (riece-quit-server-process (riece-server-process server-name) message))
676
677 (defun riece-command-universal-server-name-argument ()
678   (interactive)
679   (let* ((riece-overriding-server-name
680           (completing-read "Server: " riece-server-process-alist))
681          (command
682           (key-binding (read-key-sequence
683                         (format "Command to execute on \"%s\":"
684                                 riece-overriding-server-name)))))
685     (message "")
686     (call-interactively command)))
687
688 (provide 'riece-commands)
689
690 ;;; riece-commands.el ends here