From: ueno Date: Wed, 22 Oct 2003 02:10:03 +0000 (+0000) Subject: * riece-misc.el (riece-get-identities-on-server): New function. X-Git-Tag: riece-0_1_5~23 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94f6984b02b3c6eee79a969ededb44da0da1041c;p=elisp%2Friece.git * 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 298790f..b897296 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,24 @@ +2003-10-22 Daiki Ueno + + * 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 * riece-ctcp.el (riece-ctcp-completing-read-identity): New diff --git a/lisp/riece-000.el b/lisp/riece-000.el index 2900106..12e2d37 100644 --- a/lisp/riece-000.el +++ b/lisp/riece-000.el @@ -43,6 +43,9 @@ (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) diff --git a/lisp/riece-commands.el b/lisp/riece-commands.el index 580e77a..0d42b6c 100644 --- a/lisp/riece-commands.el +++ b/lisp/riece-commands.el @@ -145,13 +145,15 @@ the layout to the selected layout-name." (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 @@ -174,12 +176,12 @@ the layout to the selected layout-name." (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 @@ -404,18 +406,16 @@ the layout to the selected layout-name." "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))) diff --git a/lisp/riece-ctcp.el b/lisp/riece-ctcp.el index 9406b12..0ffce09 100644 --- a/lisp/riece-ctcp.el +++ b/lisp/riece-ctcp.el @@ -251,44 +251,57 @@ 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")) diff --git a/lisp/riece-misc.el b/lisp/riece-misc.el index c20d3ad..e3ff301 100644 --- a/lisp/riece-misc.el +++ b/lisp/riece-misc.el @@ -105,6 +105,11 @@ \(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) @@ -180,17 +185,22 @@ (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