X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-commands.el;h=5241a68cb57919b64358ed84c54722fe78769179;hb=84b8ce91229a773f610737a9b6f36ff1aeb2d097;hp=3436926d05ac6f344fe24059f47054574f83bb19;hpb=68f27a170336e4cf4a7e43d18a476c026affa79a;p=elisp%2Friece.git diff --git a/lisp/riece-commands.el b/lisp/riece-commands.el index 3436926..5241a68 100644 --- a/lisp/riece-commands.el +++ b/lisp/riece-commands.el @@ -19,8 +19,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Code: @@ -32,6 +32,7 @@ (require 'riece-misc) (require 'riece-identity) (require 'riece-message) +(require 'riece-mcat) (autoload 'derived-mode-class "derived") @@ -112,8 +113,23 @@ (defun riece-command-configure-windows () (interactive) + "Reconfigure windows with the current layout." (riece-redisplay-buffers t)) +(defun riece-command-suspend-resume () + (interactive) + "Save or restore the current window configuration." + (let ((entry (assq 'riece-window-configuration (frame-parameters)))) + (modify-frame-parameters (selected-frame) + (list (cons 'riece-window-configuration + (current-window-configuration)))) + (if (cdr entry) + (set-window-configuration (cdr entry)) + (delete-other-windows)) + (message + (substitute-command-keys + "\\[riece-command-suspend-resume] to get back the last windows")))) + (defun riece-command-change-layout (name) "Select a layout-name from all current available layouts and change the layout to the selected layout-name." @@ -129,6 +145,13 @@ the layout to the selected layout-name." riece-save-variables-are-dirty t) (riece-command-configure-windows)) +(defun riece-command-toggle-others-buffer-mode () + (interactive) + (setq riece-others-buffer-mode + (not riece-others-buffer-mode) + riece-save-variables-are-dirty t) + (riece-command-configure-windows)) + (defun riece-command-toggle-user-list-buffer-mode () (interactive) (setq riece-user-list-buffer-mode @@ -172,7 +195,8 @@ the layout to the selected layout-name." 0))))) (riece-send-string (format "TOPIC %s :%s\r\n" (riece-identity-prefix riece-current-channel) - topic))) + topic) + riece-current-channel)) (defun riece-command-invite (user) (interactive @@ -182,7 +206,7 @@ the layout to the selected layout-name." "Invite user: " (riece-get-users-on-server (riece-current-server-name)) nil nil nil nil nil t)))) - (riece-send-string (format "INVITE %s %s\r\n" + (riece-send-string (format "INVITE %s :%s\r\n" (riece-identity-prefix user) (riece-identity-prefix riece-current-channel)))) @@ -205,7 +229,8 @@ the layout to the selected layout-name." user message) (format "KICK %s %s\r\n" (riece-identity-prefix riece-current-channel) - user)))) + user)) + riece-current-channel)) (defun riece-command-names (pattern) (interactive @@ -278,7 +303,7 @@ the layout to the selected layout-name." (if (equal change "") (riece-send-string (format "MODE %s\r\n" (riece-identity-prefix channel))) - (riece-send-string (format "MODE %s :%s\r\n" + (riece-send-string (format "MODE %s %s\r\n" (riece-identity-prefix channel) change)))) @@ -354,6 +379,7 @@ the layout to the selected layout-name." (defun riece-command-send-message (message notice) "Send MESSAGE to the current channel." + (run-hooks 'riece-command-send-message-hook) (if (equal message "") (error "No text to send")) (riece-check-channel-commands-are-usable) @@ -362,14 +388,16 @@ the layout to the selected layout-name." (riece-send-string (format "NOTICE %s :%s\r\n" (riece-identity-prefix riece-current-channel) - message)) + message) + riece-current-channel) (riece-display-message (riece-make-message (riece-current-nickname) riece-current-channel message 'notice t))) (riece-send-string (format "PRIVMSG %s :%s\r\n" (riece-identity-prefix riece-current-channel) - message)) + message) + riece-current-channel) (riece-display-message (riece-make-message (riece-current-nickname) riece-current-channel message nil t)))) @@ -397,33 +425,35 @@ the layout to the selected layout-name." (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 - "Message to user: " - (riece-get-users-on-server (riece-current-server-name)) - nil nil nil nil nil t)))) + (if (and (bolp) (eolp)) + (error "No text to send") + (let ((completion-ignore-case t)) + (list (riece-completing-read-identity + "Message to user: " + (riece-get-users-on-server (riece-current-server-name)) + nil nil nil nil nil t))))) (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)) + (format "PRIVMSG %s :%s\r\n" (riece-identity-prefix user) text) + user) (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 - (error "%s" (substitute-command-keys - "Type \\[riece-command-open-server] to open server."))) - (riece-process-send-string process - (if key - (format "JOIN %s :%s\r\n" - (riece-identity-prefix target) - key) - (format "JOIN %s\r\n" - (riece-identity-prefix target)))))) + (unless (riece-server-opened (riece-identity-server target)) + (error "%s" (substitute-command-keys + "Type \\[riece-command-open-server] to open server."))) + (riece-send-string (if key + (format "JOIN %s :%s\r\n" + (riece-identity-prefix target) + key) + (format "JOIN %s\r\n" + (riece-identity-prefix target))) + target)) (defun riece-command-join-partner (target) (let ((pointer (riece-identity-member target riece-current-channels))) @@ -432,43 +462,38 @@ the layout to the selected layout-name." (riece-join-channel target) (riece-switch-to-channel target)))) -(defun riece-command-join (target &optional key) +(defun riece-command-join (target) (interactive - (let* ((completion-ignore-case t) - (target - (if riece-join-channel-candidate - (let ((default (riece-format-identity - riece-join-channel-candidate))) - (riece-completing-read-identity - (format "Join channel/user (default %s): " default) - (riece-get-identities-on-server (riece-current-server-name)) - nil nil nil nil default)) - (riece-completing-read-identity - "Join channel/user: " - (riece-get-identities-on-server (riece-current-server-name))))) - key) - (if (and current-prefix-arg - (riece-channel-p (riece-identity-prefix target))) - (setq key - (riece-read-passwd (format "Key for %s: " - (riece-format-identity target))))) - (list target key))) + (let ((completion-ignore-case t)) + (list + (if riece-join-channel-candidate + (let ((default (riece-format-identity + riece-join-channel-candidate))) + (riece-completing-read-identity + (format "Join channel/user (default %s): " default) + (riece-get-identities-on-server (riece-current-server-name)) + nil nil nil nil default)) + (riece-completing-read-identity + "Join channel/user: " + (riece-get-identities-on-server (riece-current-server-name))))))) (let ((pointer (riece-identity-member target riece-current-channels))) (if pointer (riece-command-switch-to-channel (car pointer)) (if (riece-channel-p (riece-identity-prefix target)) - (riece-command-join-channel target key) + (riece-command-join-channel target nil) (riece-command-join-partner target))))) (defun riece-command-part-channel (target message) - (let ((process (riece-server-process (riece-identity-server target)))) - (riece-process-send-string process - (if message - (format "PART %s :%s\r\n" - (riece-identity-prefix target) - message) - (format "PART %s\r\n" - (riece-identity-prefix target)))))) + (unless (riece-server-opened (riece-identity-server target)) + (error "%s" (substitute-command-keys + "Type \\[riece-command-open-server] to open server."))) + (riece-send-string (if message + (format "PART %s :%s\r\n" + (riece-identity-prefix target) + message) + (format "PART %s\r\n" + (riece-identity-prefix target))) + target)) (defun riece-command-part (target &optional message) (interactive @@ -481,10 +506,10 @@ the layout to the selected layout-name." (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: "))) + (message + (if current-prefix-arg + (read-string "Message: ") + riece-part-message))) (list target message)))) (if (riece-identity-member target riece-current-channels) (if (riece-channel-p (riece-identity-prefix target)) @@ -609,11 +634,11 @@ If prefix argument ARG is non-nil, toggle frozen status." (progn (message "No server process") (ding)) - (if (y-or-n-p "Really quit IRC? ") + (if (y-or-n-p (riece-mcat "Really quit IRC? ")) (let ((message (if arg (read-string "Message: ") - riece-quit-message)) + riece-quit-message)) (alist riece-server-process-alist)) (while alist (riece-quit-server-process (cdr (car alist)) message) @@ -624,8 +649,23 @@ If prefix argument ARG is non-nil, toggle frozen status." (interactive "sIRC command: ") (riece-send-string (concat command "\r\n"))) +(defun riece-command-beginning-of-buffer () + "Scroll channel buffer to the beginning." + (interactive) + (let (buffer window) + (setq buffer (if riece-channel-buffer-mode + riece-channel-buffer + riece-dialogue-buffer)) + (or (setq window (get-buffer-window buffer)) + (setq window (get-buffer-window riece-dialogue-buffer) + buffer riece-dialogue-buffer)) + (when window + (save-selected-window + (select-window window) + (goto-char (point-min)))))) + (defun riece-command-end-of-buffer () - "Get end of the dialogue buffer." + "Scroll channel buffer to the end." (interactive) (let (buffer window) (setq buffer (if riece-channel-buffer-mode @@ -652,7 +692,7 @@ If prefix argument ARG is non-nil, toggle frozen status." (list (riece-format-identity user t))) (riece-get-users-on-server (riece-current-server-name)))) - (current (current-word)) + (current (or (current-word) "")) (completion (try-completion current table)) (all (all-completions current table))) (if (eq completion t) @@ -662,6 +702,7 @@ If prefix argument ARG is non-nil, toggle frozen status." (if (equal current completion) (with-output-to-temp-buffer "*Help*" (display-completion-list all)) + (re-search-forward "\\>" nil t) (delete-region (point) (- (point) (length current))) (insert completion)))))) @@ -680,7 +721,10 @@ If prefix argument ARG is non-nil, toggle frozen status." (if current-prefix-arg (read-string "Message: ") riece-quit-message))) - (riece-quit-server-process (riece-server-process server-name) message)) + (let ((process (riece-server-process server-name))) + (unless process + (error "%s is not opened" server-name)) + (riece-quit-server-process process message))) (defun riece-command-universal-server-name-argument () (interactive) @@ -693,6 +737,15 @@ If prefix argument ARG is non-nil, toggle frozen status." (message "") (call-interactively command))) +(eval-when-compile + (autoload 'riece-save-variables-files "riece")) +(defun riece-command-save-variables () + "Save `riece-variables-file'." + (interactive) + (if (or riece-save-variables-are-dirty + (y-or-n-p "No changes made. Save anyway? ")) + (riece-save-variables-files))) + (provide 'riece-commands) ;;; riece-commands.el ends here