X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-commands.el;h=7f9f654503b14cd6bb77b556b201bc71d5907055;hb=5fd1fc530e3aed912d077d115f54b55563497d8f;hp=004490f2e8e94782188f33141406a0670708bb2f;hpb=c6029b2eae0018343a829fc745b71fd8d068d966;p=elisp%2Friece.git diff --git a/lisp/riece-commands.el b/lisp/riece-commands.el index 004490f..7f9f654 100644 --- a/lisp/riece-commands.el +++ b/lisp/riece-commands.el @@ -73,21 +73,41 @@ "Select the next channel." (interactive) (when (> (length riece-current-channels) 1) - (let ((channels (copy-sequence riece-current-channels))) - (setcdr (last channels) channels) ;make a circular link - (riece-command-switch-to-channel - (nth 1 (string-list-member-ignore-case - riece-current-channel channels)))))) + (let ((pointer (cdr (riece-identity-member-no-server + riece-current-channel + riece-current-channels)))) + (while (and pointer + (null (car pointer))) + (setq pointer (cdr pointer))) + (when (null pointer) + (setq pointer riece-current-channels) + (while (and pointer + (null (car pointer))) + (setq pointer (cdr pointer)))) + (if (car pointer) + (riece-command-switch-to-channel (car pointer)) + (error "No such channel!"))))) (defun riece-command-previous-channel () "Select the previous channel." (interactive) (when (> (length riece-current-channels) 1) - (let ((channels (nreverse (copy-sequence riece-current-channels)))) - (setcdr (last channels) channels) ;make a circular link - (riece-command-switch-to-channel - (nth 1 (string-list-member-ignore-case - riece-current-channel channels)))))) + (let ((pointer (riece-identity-member-no-server + riece-current-channel + riece-current-channels)) + (start riece-current-channels) + channel) + (while (and start (not (eq start pointer))) + (setq channel (car start)) + (setq start (cdr start))) + (when (null channel) + (setq start (copy-sequence riece-current-channels)) + (setq start (delq nil start)) + (and (> (length start) 1) + (setq channel (nth (1- (length start)) start)))) + (if channel + (riece-command-switch-to-channel channel) + (error "No such channel!"))))) (defun riece-command-select-command-buffer () "Select the command buffer." @@ -103,19 +123,22 @@ (defun riece-command-toggle-channel-buffer-mode () (interactive) (setq riece-channel-buffer-mode - (not riece-channel-buffer-mode)) + (not riece-channel-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 - (not riece-user-list-buffer-mode)) + (not riece-user-list-buffer-mode) + riece-save-variables-are-dirty t) (riece-command-configure-windows)) (defun riece-command-toggle-channel-list-buffer-mode () (interactive) (setq riece-channel-list-buffer-mode - (not riece-channel-list-buffer-mode)) + (not riece-channel-list-buffer-mode) + riece-save-variables-are-dirty t) (riece-command-configure-windows)) (defun riece-command-finger (user &optional recurse) @@ -361,7 +384,7 @@ (riece-identity-prefix target)))))) (defun riece-command-join-partner (target) - (let ((pointer (riece-identity-member target riece-current-channels))) + (let ((pointer (riece-identity-member-safe target riece-current-channels))) (if pointer (riece-command-switch-to-channel (car pointer)) (riece-join-channel target) @@ -380,7 +403,7 @@ (setq key (riece-read-passwd (format "Key for %s: " target)))) (list target key))) - (let ((pointer (riece-identity-member target riece-current-channels))) + (let ((pointer (riece-identity-member-safe target riece-current-channels))) (if pointer (riece-command-switch-to-channel (car pointer)) (if (riece-channel-p target) @@ -416,7 +439,7 @@ (riece-channel-p target)) (setq message (read-string "Message: "))) (list target message))) - (if (riece-identity-member target riece-current-channels) + (if (riece-identity-member-safe target riece-current-channels) (if (riece-channel-p target) (riece-command-part-channel target message) (riece-part-channel target) @@ -477,7 +500,9 @@ (defun riece-command-toggle-away (&optional message) "Mark yourself as being away." (interactive - (if current-prefix-arg + (if (and (not (riece-user-get-away (riece-current-nickname))) + (or (null riece-away-message) + current-prefix-arg)) (let ((message (read-string "Away message: "))) (list message)))) (if message @@ -488,20 +513,32 @@ "Prevent automatic scrolling of the dialogue window. If prefix argument ARG is non-nil, toggle frozen status." (interactive "P") - (riece-freeze (if riece-channel-buffer-mode - riece-channel-buffer - riece-dialogue-buffer) - (if arg (prefix-numeric-value arg)))) + (with-current-buffer (if (and riece-channel-buffer-mode + riece-channel-buffer) + riece-channel-buffer + riece-dialogue-buffer) + (setq riece-freeze (if arg + (< 0 (prefix-numeric-value arg)) + (not riece-freeze)))) + (riece-update-status-indicators) + (force-mode-line-update t)) (defun riece-command-toggle-own-freeze (&optional arg) "Prevent automatic scrolling of the dialogue window. The difference from `riece-command-freeze' is that your messages are hidden. If prefix argument ARG is non-nil, toggle frozen status." (interactive "P") - (riece-own-freeze (if riece-channel-buffer-mode - riece-channel-buffer - riece-dialogue-buffer) - (if arg (prefix-numeric-value arg)))) + (with-current-buffer (if (and riece-channel-buffer-mode + riece-channel-buffer) + riece-channel-buffer + riece-dialogue-buffer) + (if (if arg + (< 0 (prefix-numeric-value arg)) + (not (eq riece-freeze 'own))) + (setq riece-freeze 'own) + (setq riece-freeze nil))) + (riece-update-status-indicators) + (force-mode-line-update t)) (defun riece-command-quit (&optional arg) "Quit IRC." @@ -542,14 +579,11 @@ If prefix argument ARG is non-nil, toggle frozen status." (defun riece-command-open-server (server-name) (interactive (list (completing-read "Server: " riece-server-alist))) - (let ((process (riece-start-server - (riece-server-name-to-server server-name) - server-name))) - (with-current-buffer (process-buffer process) - (setq riece-server-name server-name)) - (setq riece-server-process-alist - (cons (cons server-name process) - riece-server-process-alist)))) + (if (assoc server-name riece-server-process-alist) + (error "%s is already opened" server-name) + (riece-open-server + (riece-server-name-to-server server-name) + server-name))) (defun riece-command-close-server (server-name &optional message) (interactive