* liece-channel.el (liece-channel-change): Run
[elisp/liece.git] / lisp / liece-commands.el
index c4439eb..86ab774 100644 (file)
@@ -666,29 +666,30 @@ If argument ARG is non-nil message will be encrypted with KEY."
          (liece-next-line 1))
       (liece-message (_ "No text to send")))))
 
-(defun liece-command-names (&optional channel)
-  "List the nicknames of the current IRC users on given CHANNEL.
+(defun liece-command-names (&optional expr)
+  "List the nicknames of the current IRC users on given EXPR.
 With an Control-U as argument, only the current channel is listed.
 With - as argument, list all channels."
   (interactive
    (if (or current-prefix-arg (null liece-current-channel))
        (if (eq current-prefix-arg '-)
           (list current-prefix-arg))
-     (let ((completion-ignore-case t) channel)
-       (setq channel (liece-minibuffer-completing-default-read
+     (let ((completion-ignore-case t) expr)
+       (setq expr (liece-minibuffer-completing-default-read
                      (_ "Names on channel: ")
                      liece-channel-alist nil nil liece-current-channel))
-       (unless (string-equal "" channel)
-        (list channel)))))
-  (cond
-   ((not channel)
-    (liece-send "NAMES %s"
-               (liece-channel-real liece-current-channel)))
-   ((and (eq channel '-)
-        (y-or-n-p (_ "Do you really query NAMES without argument?")))
-    (liece-send "NAMES"))
-   (t
-    (liece-send "NAMES %s" (liece-channel-real channel)))))
+       (unless (string-equal "" expr)
+        (list expr)))))
+  (when (or (and (eq expr '-)
+                (y-or-n-p
+                 (_ "Do you really query NAMES without argument?")))
+           (not (or expr
+                    (if liece-current-channel
+                        (setq expr (liece-channel-real
+                                    liece-current-channel))))))
+    (setq expr ""))
+  (when expr
+    (liece-send "NAMES %s" expr)))
 
 (defun liece-command-nickname (nick)
   "Set your nickname to NICK."
@@ -712,15 +713,17 @@ With - as argument, list all users."
                   (append liece-channel-alist liece-nick-alist)))
        (unless (string-equal "" expr)
         (list expr)))))
-  (cond
-   ((not expr)
-    (liece-send "WHO %s" (liece-channel-real liece-current-channel)))
-   ((and (eq expr '-)
-        (y-or-n-p (_ "Do you really query WHO without argument?")))
-    (liece-send "WHO"))
-   (t
+  (when (or (and (eq expr '-)
+                (y-or-n-p
+                 (_ "Do you really query WHO without argument?")))
+           (not (or expr
+                    (if liece-current-channel
+                        (setq expr (liece-channel-real
+                                    liece-current-channel))))))
+    (setq expr ""))
+  (when expr
     (liece-send "WHO %s" expr)
-    (setq liece-who-expression expr))))
+    (setq liece-who-expression expr)))
 
 (defun liece-command-finger (finger-nick-var &optional server)
   "Get information about a specific user FINGER-NICK-VAR.