X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-commands.el;h=039543d7aa0c1ed6b309a4403c273dd11d06f7ee;hp=401678a9561e122f63efb1764226f75b93871db6;hb=9f6396c152d5235237321945ce81a9883b01d609;hpb=85fa0be0b53e8d76b02dc47c9cae0136d134d5b1 diff --git a/lisp/riece-commands.el b/lisp/riece-commands.el index 401678a..039543d 100644 --- a/lisp/riece-commands.el +++ b/lisp/riece-commands.el @@ -38,7 +38,7 @@ (defun riece-command-switch-to-channel (channel) (interactive (list (riece-completing-read-identity "Channel/User: " riece-current-channels nil t))) - (unless (equal channel riece-current-channels) + (unless (equal channel riece-current-channel) (riece-switch-to-channel channel) (riece-redisplay-buffers))) @@ -117,7 +117,8 @@ "Select a layout-name from all current available layouts and change the layout to the selected layout-name." (interactive (list (completing-read "Layout: " riece-layout-alist))) - (setq riece-layout name) + (setq riece-layout name + riece-save-variables-are-dirty t) (riece-command-configure-windows)) (defun riece-command-toggle-channel-buffer-mode () @@ -144,24 +145,29 @@ 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 - (list (read-from-minibuffer - "Topic: " (cons (or (riece-with-server-buffer - (riece-identity-server riece-current-channel) - (riece-channel-get-topic - (riece-identity-prefix - riece-current-channel))) - "") - 0)))) + (progn + (riece-check-channel-commands-are-usable t) + (list (read-from-minibuffer + "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))) @@ -169,28 +175,24 @@ the layout to the selected layout-name." (defun riece-command-invite (user) (interactive (let ((completion-ignore-case t)) - (unless (and riece-current-channel - (riece-channel-p (riece-identity-prefix - riece-current-channel))) - (error "Not on a channel")) - (list (completing-read + (riece-check-channel-commands-are-usable t) + (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 (let ((completion-ignore-case t)) - (unless (and riece-current-channel - (riece-channel-p (riece-identity-prefix - riece-current-channel))) - (error "Not on a channel")) + (riece-check-channel-commands-are-usable t) (list (completing-read "User: " - (mapcar #'list (riece-channel-get-users - riece-current-channel))) + (riece-with-server-buffer + (riece-identity-server riece-current-channel) + (riece-channel-get-users (riece-identity-prefix + riece-current-channel)))) (if current-prefix-arg (read-string "Message: "))))) (riece-send-string @@ -210,7 +212,7 @@ the layout to the selected layout-name." (if (and riece-current-channel (riece-channel-p (riece-identity-prefix riece-current-channel))) - (cons (riece-format-identity riece-current-channel t) + (cons (riece-identity-prefix riece-current-channel) 0)))))) (if (or (not (equal pattern "")) (yes-or-no-p "Really want to query NAMES without argument? ")) @@ -224,7 +226,7 @@ the layout to the selected layout-name." (if (and riece-current-channel (riece-channel-p (riece-identity-prefix riece-current-channel))) - (cons (riece-format-identity riece-current-channel t) + (cons (riece-identity-prefix riece-current-channel) 0)))))) (if (or (not (equal pattern "")) (yes-or-no-p "Really want to query WHO without argument? ")) @@ -238,7 +240,7 @@ the layout to the selected layout-name." (if (and riece-current-channel (riece-channel-p (riece-identity-prefix riece-current-channel))) - (cons (riece-format-identity riece-current-channel t) + (cons (riece-identity-prefix riece-current-channel) 0)))))) (if (or (not (equal pattern "")) (yes-or-no-p "Really want to query LIST without argument? ")) @@ -251,6 +253,7 @@ the layout to the selected layout-name." (if current-prefix-arg (riece-completing-read-identity "Channel/User: " riece-current-channels) + (riece-check-channel-commands-are-usable t) riece-current-channel)) (riece-overriding-server-name (riece-identity-server channel)) (riece-temp-minibuffer-message @@ -272,30 +275,21 @@ the layout to the selected layout-name." (defun riece-command-set-operators (users &optional arg) (interactive - (let ((operators - (riece-with-server-buffer - (riece-identity-server riece-current-channel) - (riece-channel-get-operators - (riece-identity-prefix riece-current-channel)))) - (completion-ignore-case t) - users) - (if current-prefix-arg - (setq users (riece-completing-read-multiple - "Users" - (mapcar #'list operators))) - (setq users (riece-completing-read-multiple - "Users" - (delq nil (mapcar - (lambda (user) - (unless (member user operators) - (list user))) - (riece-with-server-buffer - (riece-identity-server - riece-current-channel) - (riece-channel-get-users - (riece-identity-prefix - riece-current-channel)))))))) - (list users current-prefix-arg))) + (progn + (riece-check-channel-commands-are-usable t) + (let ((completion-ignore-case t)) + (list (riece-completing-read-multiple + "Users" + (riece-with-server-buffer + (riece-identity-server riece-current-channel) + (riece-channel-get-users (riece-identity-prefix + riece-current-channel))) + (if current-prefix-arg + (lambda (user) + (memq ?o (cdr user))) + (lambda (user) + (not (memq ?o (cdr user)))))) + current-prefix-arg)))) (let (group) (while users (setq group (cons (car users) group) @@ -313,30 +307,21 @@ the layout to the selected layout-name." (defun riece-command-set-speakers (users &optional arg) (interactive - (let ((speakers - (riece-with-server-buffer - (riece-identity-server riece-current-channel) - (riece-channel-get-speakers - (riece-identity-prefix riece-current-channel)))) - (completion-ignore-case t) - users) - (if current-prefix-arg - (setq users (riece-completing-read-multiple - "Users" - (mapcar #'list speakers))) - (setq users (riece-completing-read-multiple - "Users" - (delq nil (mapcar - (lambda (user) - (unless (member user speakers) - (list user))) - (riece-with-server-buffer - (riece-identity-server - riece-current-channel) - (riece-channel-get-users - (riece-identity-prefix - riece-current-channel)))))))) - (list users current-prefix-arg))) + (progn + (riece-check-channel-commands-are-usable t) + (let ((completion-ignore-case t)) + (list (riece-completing-read-multiple + "Users" + (riece-with-server-buffer + (riece-identity-server riece-current-channel) + (riece-channel-get-users (riece-identity-prefix + riece-current-channel))) + (if current-prefix-arg + (lambda (user) + (memq ?v (cdr user))) + (lambda (user) + (not (memq ?v (cdr user)))))) + current-prefix-arg)))) (let (group) (while users (setq group (cons (car users) group) @@ -356,9 +341,7 @@ the layout to the selected layout-name." "Send MESSAGE to the current channel." (if (equal message "") (error "No text to send")) - (unless riece-current-channel - (error (substitute-command-keys - "Type \\[riece-command-join] to join a channel"))) + (riece-check-channel-commands-are-usable) (if notice (progn (riece-send-string @@ -396,6 +379,23 @@ the layout to the selected layout-name." (let ((next-line-add-newlines t)) (next-line 1))) +(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 + "User: " + (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" (riece-identity-prefix user) text)) + (riece-display-message + (riece-make-message (riece-current-nickname) user text nil t))) + (let ((next-line-add-newlines t)) + (next-line 1))) + (defun riece-command-join-channel (target key) (let ((process (riece-server-process (riece-identity-server target)))) (unless process @@ -421,8 +421,14 @@ the layout to the selected layout-name." (interactive (let* ((completion-ignore-case t) (target - (riece-completing-read-identity - "Channel/User: " riece-current-channels)) + (if riece-join-channel-candidate + (let ((default (riece-format-identity + riece-join-channel-candidate))) + (riece-completing-read-identity + (format "Channel/User (default %s): " default) + riece-current-channels nil nil nil nil default)) + (riece-completing-read-identity + "Channel/User: " riece-current-channels))) key) (if (and current-prefix-arg (riece-channel-p (riece-identity-prefix target))) @@ -439,9 +445,6 @@ the layout to the selected layout-name." (defun riece-command-part-channel (target message) (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 message (format "PART %s :%s\r\n" @@ -452,16 +455,20 @@ the layout to the selected layout-name." (defun riece-command-part (target &optional message) (interactive - (let* ((completion-ignore-case t) - (target - (riece-completing-read-identity - "Channel/User: " riece-current-channels nil nil - (cons (riece-format-identity riece-current-channel) 0))) - message) - (if (and current-prefix-arg - (riece-channel-p (riece-identity-prefix target))) - (setq message (read-string "Message: "))) - (list target message))) + (progn + (riece-check-channel-commands-are-usable) + (let* ((completion-ignore-case t) + (target + (riece-completing-read-identity + (format "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: "))) + (list target message)))) (if (riece-identity-member target riece-current-channels) (if (riece-channel-p (riece-identity-prefix target)) (riece-command-part-channel target message) @@ -523,7 +530,10 @@ the layout to the selected layout-name." (defun riece-command-toggle-away (&optional message) "Mark yourself as being away." (interactive - (if (and (not (riece-user-get-away (riece-current-nickname))) + (if (and (not (riece-with-server-buffer (riece-identity-server + (riece-current-nickname)) + (riece-user-get-away (riece-identity-prefix + (riece-current-nickname))))) (or (null riece-away-message) current-prefix-arg)) (let ((message (read-string "Away message: "))) @@ -572,10 +582,10 @@ If prefix argument ARG is non-nil, toggle frozen status." (read-string "Message: ") (or riece-quit-message (riece-extended-version)))) - (process-list riece-process-list)) - (while process-list - (riece-quit-server-process (car process-list) message) - (setq process-list (cdr process-list)))))) + (alist riece-server-process-alist)) + (while alist + (riece-quit-server-process (cdr (car alist)) message) + (setq alist (cdr alist)))))) (defun riece-command-raw (command) "Enter raw IRC command, which is sent to the server." @@ -613,13 +623,7 @@ If prefix argument ARG is non-nil, toggle frozen status." (defun riece-command-close-server (server-name &optional message) (interactive - (list (completing-read - "Server: " - (mapcar - (lambda (process) - (with-current-buffer (process-buffer process) - (list riece-server-name))) - riece-process-list)) + (list (completing-read "Server: " riece-server-process-alist) (if current-prefix-arg (read-string "Message: ") (or riece-quit-message @@ -629,13 +633,7 @@ If prefix argument ARG is non-nil, toggle frozen status." (defun riece-command-universal-server-name-argument () (interactive) (let* ((riece-overriding-server-name - (completing-read - "Server: " - (mapcar - (lambda (process) - (with-current-buffer (process-buffer process) - (list riece-server-name))) - riece-process-list))) + (completing-read "Server: " riece-server-process-alist)) (command (key-binding (read-key-sequence (format "Command to execute on \"%s\":"