(riece-get-users-on-server): Use it.
* riece-ctcp.el (riece-ctcp-completing-read-identity): Abolish.
(riece-command-ctcp-version): Use riece-completing-read-identity
and riece-get-identities-on-server.
(riece-command-ctcp-ping): Ditto.
(riece-command-ctcp-clientinfo): Ditto.
(riece-command-ctcp-action): Ditto.
* riece-commands.el (riece-command-finger): Pass the current
server name to riece-get-users-on-server; use
riece-completing-read-identity.
(riece-command-invite): Ditto.
(riece-command-enter-message-to-user): Ditto.
* riece-000.el (riece-handle-001-message): Register myself with
riece-obarray.
+2003-10-22 Daiki Ueno <ueno@unixuser.org>
+
+ * riece-misc.el (riece-get-identities-on-server): New function.
+ (riece-get-users-on-server): Use it.
+
+ * riece-ctcp.el (riece-ctcp-completing-read-identity): Abolish.
+ (riece-command-ctcp-version): Use riece-completing-read-identity
+ and riece-get-identities-on-server.
+ (riece-command-ctcp-ping): Ditto.
+ (riece-command-ctcp-clientinfo): Ditto.
+ (riece-command-ctcp-action): Ditto.
+
+ * riece-commands.el (riece-command-finger): Pass the current
+ server name to riece-get-users-on-server; use
+ riece-completing-read-identity.
+ (riece-command-invite): Ditto.
+ (riece-command-enter-message-to-user): Ditto.
+
+ * riece-000.el (riece-handle-001-message): Register myself with
+ riece-obarray.
+
2003-10-21 Daiki Ueno <ueno@unixuser.org>
* riece-ctcp.el (riece-ctcp-completing-read-identity): New
(setq riece-real-server-name prefix
riece-real-nickname name
riece-real-userhost nil)
+ ;; Before sending USERHOST, register myself with riece-obarray
+ ;; because it may take some time.
+ (riece-get-user name)
(riece-send-string (format "USERHOST %s\r\n" riece-real-nickname))
(riece-insert-info
(list riece-dialogue-buffer riece-others-buffer)
(defun riece-command-finger (user &optional recurse)
(interactive
(let* ((completion-ignore-case t)
- (user (completing-read
+ (user (riece-completing-read-identity
"User: "
- (mapcar #'list (riece-get-users-on-server)))))
+ (riece-get-users-on-server (riece-current-server-name)))))
(list user current-prefix-arg)))
(if recurse
- (riece-send-string (format "WHOIS %s %s\r\n" user user))
- (riece-send-string (format "WHOIS %s\r\n" user))))
+ (riece-send-string (format "WHOIS %s %s\r\n"
+ (riece-identity-prefix user)
+ (riece-identity-prefix user)))
+ (riece-send-string (format "WHOIS %s\r\n" (riece-identity-prefix user)))))
(defun riece-command-topic (topic)
(interactive
(interactive
(let ((completion-ignore-case t))
(riece-check-channel-commands-are-usable t)
- (list (completing-read
+ (list (riece-completing-read-identity
"User: "
- (mapcar #'list (riece-get-users-on-server))))))
+ (riece-get-users-on-server (riece-current-server-name))))))
(riece-send-string (format "INVITE %s %s\r\n"
- user (riece-identity-prefix
- riece-current-channel))))
+ (riece-identity-prefix user)
+ (riece-identity-prefix riece-current-channel))))
(defun riece-command-kick (user &optional message)
(interactive
"Send the current line to USER."
(interactive
(let ((completion-ignore-case t))
- (list (completing-read
+ (list (riece-completing-read-identity
"User: "
- (mapcar #'list (riece-get-users-on-server))))))
+ (riece-get-users-on-server (riece-current-server-name))))))
(let ((text (buffer-substring
(riece-line-beginning-position)
(riece-line-end-position))))
(riece-send-string
- (format "PRIVMSG %s :%s\r\n" user text))
+ (format "PRIVMSG %s :%s\r\n" (riece-identity-prefix user) text))
(riece-display-message
- (riece-make-message (riece-current-nickname)
- (riece-make-identity user (riece-current-server-name))
- text nil t)))
+ (riece-make-message (riece-current-nickname) user text nil t)))
(let ((next-line-add-newlines t))
(next-line 1)))
string))
"\n")))
-(defun riece-ctcp-completing-read-identity ()
- (riece-completing-read-identity
- "Channel/User: "
- (let ((server-name (riece-current-server-name)))
- (append (mapcar
- (lambda (user)
- (riece-make-identity user server-name))
- (riece-get-users-on-server))
- riece-current-channels))))
-
-(defun riece-command-ctcp-version (user)
+(defun riece-command-ctcp-version (target)
(interactive
- (list (riece-ctcp-completing-read-identity)))
- (riece-send-string (format "PRIVMSG %s :\1VERSION\1\r\n" user)))
+ (list (riece-completing-read-identity
+ "Channel/User: "
+ (apply #'nconc
+ (mapcar (lambda (entry)
+ (riece-get-identities-on-server (car entry)))
+ riece-server-process-alist)))))
+ (riece-send-string (format "PRIVMSG %s :\1VERSION\1\r\n"
+ (riece-identity-prefix target))))
-(defun riece-command-ctcp-ping (user)
+(defun riece-command-ctcp-ping (target)
(interactive
- (list (riece-ctcp-completing-read-identity)))
- (riece-send-string (format "PRIVMSG %s :\1PING\1\r\n" user))
+ (list (riece-completing-read-identity
+ "Channel/User: "
+ (apply #'nconc
+ (mapcar (lambda (entry)
+ (riece-get-identities-on-server (car entry)))
+ riece-server-process-alist)))))
+ (riece-send-string (format "PRIVMSG %s :\1PING\1\r\n"
+ (riece-identity-prefix target)))
(setq riece-ctcp-ping-time (current-time)))
-(defun riece-command-ctcp-clientinfo (user)
+(defun riece-command-ctcp-clientinfo (target)
(interactive
- (list (riece-ctcp-completing-read-identity)))
- (riece-send-string (format "PRIVMSG %s :\1CLIENTINFO\1\r\n" user)))
+ (list (riece-completing-read-identity
+ "Channel/User: "
+ (apply #'nconc
+ (mapcar (lambda (entry)
+ (riece-get-identities-on-server (car entry)))
+ riece-server-process-alist)))))
+ (riece-send-string (format "PRIVMSG %s :\1CLIENTINFO\1\r\n"
+ (riece-identity-prefix target))))
-(defun riece-command-ctcp-action (channel action)
+(defun riece-command-ctcp-action (target action)
(interactive
(list (if current-prefix-arg
- (riece-ctcp-completing-read-identity)
+ (riece-completing-read-identity
+ "Channel/User: "
+ (apply #'nconc
+ (mapcar (lambda (entry)
+ (riece-get-identities-on-server (car entry)))
+ riece-server-process-alist)))
riece-current-channel)
(read-string "Action: ")))
(if (equal action "")
(error "No action"))
(riece-send-string (format "PRIVMSG %s :\1ACTION %s\1\r\n"
- (riece-identity-prefix channel)
+ (riece-identity-prefix target)
action))
- (let ((buffer (riece-channel-buffer channel)))
+ (let ((buffer (riece-channel-buffer target)))
(riece-insert-change
buffer
(concat (riece-identity-prefix (riece-current-nickname)) " " action "\n"))
\(i.e. it matches `riece-channel-regexp')"
(string-match (concat "^" riece-channel-regexp) string))
+(defun riece-user-p (string)
+ "Return t if STRING is a user.
+\(i.e. it matches `riece-user-regexp')"
+ (string-match (concat "^" riece-user-regexp) string))
+
(defun riece-current-nickname ()
"Return the current nickname."
(riece-with-server-buffer (riece-current-server-name)
(substring user-at-host 1)
user-at-host))
-(defun riece-get-users-on-server ()
- (riece-with-server-buffer (riece-current-server-name)
- (let (users)
+(defun riece-get-users-on-server (server-name)
+ (delq nil (mapcar (lambda (identity)
+ (if (riece-user-p (riece-identity-prefix identity))
+ identity))
+ (riece-get-identities-on-server server-name))))
+
+(defun riece-get-identities-on-server (server-name)
+ (riece-with-server-buffer server-name
+ (let (identities)
(mapatoms
(lambda (atom)
- (unless (riece-channel-p (symbol-name atom))
- (setq users (cons (symbol-name atom) users))))
+ (setq identities
+ (cons (riece-make-identity (symbol-name atom) server-name)
+ identities)))
riece-obarray)
- (if (member riece-real-nickname users)
- users
- (cons riece-real-nickname users)))))
+ identities)))
(defun riece-check-channel-commands-are-usable (&optional channel)
(unless riece-current-channel