;;; Code:
-(eval-when-compile (require 'riece-inlines))
-
(require 'riece-channel)
(require 'riece-complete)
(require 'riece-display)
;;; Channel movement:
(defun riece-command-switch-to-channel (channel)
- (interactive
- (list (completing-read "Channel/User: "
- (mapcar #'list riece-current-channels)
- nil t)))
+ (interactive (list (riece-completing-read-identity
+ "Channel/User: " riece-current-channels nil t)))
(riece-switch-to-channel channel)
(riece-command-configure-windows))
"Select the next channel."
(interactive)
(when (> (length riece-current-channels) 1)
- (let ((pointer (cdr (string-list-member-ignore-case
+ (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!")))))
"Select the previous channel."
(interactive)
(when (> (length riece-current-channels) 1)
- (let ((pointer (string-list-member-ignore-case
+ (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)))
- (if (car start)
- (setq channel (car start)))
+ (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-topic (topic)
(interactive
(list (read-from-minibuffer
- "Topic: " (cons (or (riece-channel-get-topic
- riece-current-channel)
+ "Topic: " (cons (or (riece-with-identity-buffer riece-current-channel
+ (riece-channel-get-topic
+ (riece-identity-prefix
+ riece-current-channel)))
"")
0))))
(riece-send-string (format "TOPIC %s :%s\r\n"
(interactive
(let ((completion-ignore-case t))
(unless (and riece-current-channel
- (riece-channel-p riece-current-channel))
+ (riece-channel-p (riece-identity-prefix
+ riece-current-channel)))
(error "Not on a channel"))
(list (completing-read
"User: "
(interactive
(let ((completion-ignore-case t))
(unless (and riece-current-channel
- (riece-channel-p riece-current-channel))
+ (riece-channel-p (riece-identity-prefix
+ riece-current-channel)))
(error "Not on a channel"))
(list (completing-read
"User: "
(list (read-from-minibuffer
"Pattern: "
(if (and riece-current-channel
- (riece-channel-p riece-current-channel))
- (cons (riece-identity-prefix riece-current-channel)
+ (riece-channel-p (riece-identity-prefix
+ riece-current-channel)))
+ (cons (riece-decode-identity riece-current-channel t)
0))))))
(if (or (not (equal pattern ""))
(yes-or-no-p "Really want to query NAMES without argument? "))
(list (read-from-minibuffer
"Pattern: "
(if (and riece-current-channel
- (riece-channel-p riece-current-channel))
- (cons (riece-identity-prefix riece-current-channel)
+ (riece-channel-p (riece-identity-prefix
+ riece-current-channel)))
+ (cons (riece-decode-identity riece-current-channel t)
0))))))
(if (or (not (equal pattern ""))
(yes-or-no-p "Really want to query WHO without argument? "))
(list (read-from-minibuffer
"Pattern: "
(if (and riece-current-channel
- (riece-channel-p riece-current-channel))
- (cons (riece-identity-prefix riece-current-channel)
+ (riece-channel-p (riece-identity-prefix
+ riece-current-channel)))
+ (cons (riece-decode-identity riece-current-channel t)
0))))))
(if (or (not (equal pattern ""))
(yes-or-no-p "Really want to query LIST without argument? "))
(let* ((completion-ignore-case t)
(channel
(if current-prefix-arg
- (completing-read
- "Channel/User: "
- (mapcar #'list riece-current-channels))
+ (riece-completing-read-identity
+ "Channel/User: " riece-current-channels)
riece-current-channel))
(riece-overriding-server-name (riece-identity-server channel))
(riece-temp-minibuffer-message
(concat "[Available modes: "
- (riece-with-server-buffer
- (if (and (riece-channel-p channel)
- riece-supported-channel-modes)
- (apply #'string riece-supported-channel-modes)
- (if (and (not (riece-channel-p channel))
- riece-supported-user-modes)
- (apply #'string riece-supported-user-modes))))
+ (riece-with-server-buffer (riece-identity-server channel)
+ (if (riece-channel-p (riece-identity-prefix channel))
+ (if riece-supported-channel-modes
+ (apply #'string riece-supported-channel-modes))
+ (if riece-supported-user-modes
+ (apply #'string riece-supported-user-modes))))
"]")))
(list channel
(read-from-minibuffer
- (concat (riece-concat-modes channel "Mode (? for help)") ": ")
+ (concat (riece-concat-channel-modes
+ channel "Mode (? for help)") ": ")
nil riece-minibuffer-map))))
(riece-send-string (format "MODE %s :%s\r\n" channel change)))
(defun riece-command-set-operators (users &optional arg)
(interactive
- (let ((operators (riece-channel-get-operators riece-current-channel))
+ (let ((operators
+ (riece-with-identity-buffer riece-current-channel
+ (riece-channel-get-operators
+ (riece-identity-prefix riece-current-channel))))
(completion-ignore-case t)
users)
(if current-prefix-arg
(mapcar #'list operators)))
(setq users (riece-completing-read-multiple
"Users"
- (delq nil (mapcar (lambda (user)
- (unless (member user operators)
- (list user)))
- (riece-channel-get-users
- riece-current-channel))))))
+ (delq nil (mapcar
+ (lambda (user)
+ (unless (member user operators)
+ (list user)))
+ (riece-with-identity-buffer
+ riece-current-channel
+ (riece-channel-get-users
+ (riece-identity-prefix
+ riece-current-channel))))))))
(list users current-prefix-arg)))
(let (group)
(while users
(defun riece-command-set-speakers (users &optional arg)
(interactive
- (let ((speakers (riece-channel-get-speakers riece-current-channel))
+ (let ((speakers
+ (riece-with-identity-buffer riece-current-channel
+ (riece-channel-get-speakers
+ (riece-identity-prefix riece-current-channel))))
(completion-ignore-case t)
users)
(if current-prefix-arg
(mapcar #'list speakers)))
(setq users (riece-completing-read-multiple
"Users"
- (delq nil (mapcar (lambda (user)
- (unless (member user speakers)
- (list user)))
- (riece-channel-get-users
- riece-current-channel))))))
+ (delq nil (mapcar
+ (lambda (user)
+ (unless (member user speakers)
+ (list user)))
+ (riece-with-identity-buffer
+ riece-current-channel
+ (riece-channel-get-users
+ (riece-identity-prefix
+ riece-current-channel))))))))
(list users current-prefix-arg)))
(let (group)
(while users
(next-line 1)))
(defun riece-command-join-channel (target key)
- (let ((server-name (riece-identity-server target))
- process)
- (if server-name
- (setq process (cdr (assoc server-name riece-server-process-alist)))
- (setq process riece-server-process))
+ (let ((process (riece-server-process (riece-identity-server target))))
(unless process
(error "%s" (substitute-command-keys
"Type \\[riece-command-open-server] to open server.")))
(interactive
(let ((completion-ignore-case t)
(target
- (completing-read "Channel/User: "
- (mapcar #'list riece-current-channels)))
+ (riece-completing-read-identity
+ "Channel/User: " riece-current-channels))
key)
(if (and current-prefix-arg
(riece-channel-p target))
(let ((pointer (riece-identity-member target riece-current-channels)))
(if pointer
(riece-command-switch-to-channel (car pointer))
- (if (riece-channel-p target)
+ (if (riece-channel-p (riece-identity-prefix target))
(riece-command-join-channel target key)
(riece-command-join-partner target)))))
(defun riece-command-part-channel (target message)
- (let ((server-name (riece-identity-server target))
- process)
- (if server-name
- (setq process (cdr (assoc server-name riece-server-process-alist)))
- (setq process riece-server-process))
+ (let ((process (riece-server-process (riece-identity-server target))))
(unless process
(error "%s" (substitute-command-keys
"Type \\[riece-command-open-server] to open server.")))
(interactive
(let ((completion-ignore-case t)
(target
- (completing-read "Channel/User: "
- (mapcar #'list riece-current-channels)
- nil t (cons riece-current-channel 0)))
+ (riece-completing-read-identity
+ "Channel/User: " riece-current-channels))
message)
(if (and current-prefix-arg
- (riece-channel-p target))
+ (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 target)
+ (if (riece-channel-p (riece-identity-prefix target))
(riece-command-part-channel target message)
(riece-part-channel target)
(riece-redisplay-buffers))
(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
"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."
(if arg
(read-string "Message: ")
(or riece-quit-message
- (riece-extended-version)))))
- (riece-close-all-server message))))
+ (riece-extended-version))))
+ (process-list riece-process-list))
+ (while process-list
+ (riece-process-send-string (car process-list)
+ (if message
+ (format "QUIT :%s\r\n" message)
+ "QUIT\r\n"))
+ (setq process-list (cdr process-list))))))
(defun riece-command-raw (command)
"Enter raw IRC command, which is sent to the server."
(defun riece-command-open-server (server-name)
(interactive
(list (completing-read "Server: " riece-server-alist)))
- (if (assoc server-name riece-server-process-alist)
- (error "%s already opened" server-name)
- (riece-open-server
- (riece-server-name-to-server server-name)
- server-name)))
+ (if (riece-server-process server-name)
+ (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
- (list (completing-read "Server: " riece-server-process-alist)
+ (list (completing-read
+ "Server: "
+ (mapcar
+ (lambda (process)
+ (with-current-buffer (process-buffer process)
+ riece-server-name))
+ riece-process-list))
(if current-prefix-arg
(read-string "Message: ")
(or riece-quit-message
(riece-extended-version)))))
- (riece-close-server server-name message))
+ (riece-process-send-string (riece-server-process server-name)
+ (if message
+ (format "QUIT :%s\r\n" message)
+ "QUIT\r\n")))
(defun riece-command-universal-server-name-argument ()
(interactive)
(let* ((riece-overriding-server-name
- (completing-read "Server: "
- riece-server-process-alist))
+ (completing-read
+ "Server: "
+ (mapcar
+ (lambda (process)
+ (with-current-buffer (process-buffer process)
+ riece-server-name))
+ riece-process-list)))
(command
(key-binding (read-key-sequence
(format "Command to execute on \"%s\":"