X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-commands.el;h=580e77a1fd52b6cdd92744f15f3c363cebbe60b0;hp=55c0f2392d163d4520d8ee7110264fe9cce58071;hb=33c39589a38c10fbb4d54f09d6d2be1301f439f0;hpb=b9d6ae0d8aa0c6459bf6cccb8604ce4ff31bf66b diff --git a/lisp/riece-commands.el b/lisp/riece-commands.el index 55c0f23..580e77a 100644 --- a/lisp/riece-commands.el +++ b/lisp/riece-commands.el @@ -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 () @@ -154,14 +155,17 @@ the layout to the selected layout-name." (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,10 +173,7 @@ 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")) + (riece-check-channel-commands-are-usable t) (list (completing-read "User: " (mapcar #'list (riece-get-users-on-server)))))) @@ -183,10 +184,7 @@ the layout to the selected layout-name." (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 @@ -213,7 +211,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? ")) @@ -227,7 +225,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? ")) @@ -241,7 +239,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? ")) @@ -254,6 +252,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 @@ -275,30 +274,32 @@ 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 + (progn + (riece-check-channel-commands-are-usable t) + (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" - (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))) + (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)))) (let (group) (while users (setq group (cons (car users) group) @@ -316,30 +317,32 @@ 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 + (progn + (riece-check-channel-commands-are-usable t) + (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" - (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))) + (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)))) (let (group) (while users (setq group (cons (car users) group) @@ -359,9 +362,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 @@ -399,6 +400,25 @@ 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 (completing-read + "User: " + (mapcar #'list (riece-get-users-on-server)))))) + (let ((text (buffer-substring + (riece-line-beginning-position) + (riece-line-end-position)))) + (riece-send-string + (format "PRIVMSG %s :%s\r\n" user text)) + (riece-display-message + (riece-make-message (riece-current-nickname) + (riece-make-identity user (riece-current-server-name)) + 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 @@ -448,9 +468,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" @@ -461,18 +478,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 - (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))) + (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) @@ -534,7 +553,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: "))) @@ -583,10 +605,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." @@ -624,13 +646,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 @@ -640,13 +656,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\":"