riece-switch-to-channel.
(riece-handle-part-message): Don't decode message if it is empty.
(riece-handle-kick-message): Ditto.
(riece-handle-quit-message): Ditto.
(riece-handle-kill-message): Ditto.
* riece-commands.el (riece-command-part): Show the current channel
as default candidate.
* riece-identity.el (riece-completing-read-identity): Accept
optional 5th argument `initial'.
* riece-unread.el (riece-unread-update-channel-list-buffer):
Simplified.
* riece-filter.el (riece-sentinel): Don't bind
riece-inhibit-update-buffers.
* riece-display.el (riece-redisplay-buffer): New variable.
(riece-inhibit-update-buffers): Abolish.
(riece-update-channel-list-buffer): Memorize
encoded identity as text property on each line.
* riece.el (riece-channel-list-mode): Make riece-redisplay-buffer
buffer local.
(riece-user-list-mode): Ditto.
+2003-06-23 Daiki Ueno <ueno@unixuser.org>
+
+ * riece-handle.el (riece-handle-join-message): Don't call
+ riece-switch-to-channel.
+ (riece-handle-part-message): Don't decode message if it is empty.
+ (riece-handle-kick-message): Ditto.
+ (riece-handle-quit-message): Ditto.
+ (riece-handle-kill-message): Ditto.
+
+ * riece-commands.el (riece-command-part): Show the current channel
+ as default candidate.
+
+ * riece-identity.el (riece-completing-read-identity): Accept
+ optional 5th argument `initial'.
+
+ * riece-unread.el (riece-unread-update-channel-list-buffer):
+ Simplified.
+
+ * riece-filter.el (riece-sentinel): Don't bind
+ riece-inhibit-update-buffers.
+
+ * riece-display.el (riece-redisplay-buffer): New variable.
+ (riece-inhibit-update-buffers): Abolish.
+ (riece-update-channel-list-buffer): Memorize
+ encoded identity as text property on each line.
+
+ * riece.el (riece-channel-list-mode): Make riece-redisplay-buffer
+ buffer local.
+ (riece-user-list-mode): Ditto.
+
2003-06-22 Daiki Ueno <ueno@unixuser.org>
* riece-display.el (riece-inhibit-update-buffers): New variable.
(defun riece-command-switch-to-channel (channel)
(interactive (list (riece-completing-read-identity
"Channel/User: " riece-current-channels nil t)))
- (riece-switch-to-channel channel)
- (riece-redisplay-buffers))
+ (unless (equal channel riece-current-channels)
+ (riece-switch-to-channel channel)
+ (riece-redisplay-buffers)))
(defun riece-command-switch-to-channel-by-number (number)
(interactive
(let ((completion-ignore-case t)
(target
(riece-completing-read-identity
- "Channel/User: " riece-current-channels))
+ "Channel/User: " riece-current-channels nil nil
+ (cons (riece-decode-identity riece-current-channel) 0)))
message)
(if (and current-prefix-arg
(riece-channel-p (riece-identity-prefix target)))
riece-update-short-channel-indicator
riece-update-channel-list-indicator))
-(defvar riece-inhibit-update-buffers nil
- "Non-nil means disregard update request of buffers.
-Typically, this variable is bound to a let form.")
+(defvar riece-redisplay-buffer nil
+ "Non-nil means the buffer needs to be updated.
+Local to the buffers.")
(defun riece-configure-windows ()
(let ((buffer (window-buffer))
(get-buffer-window riece-command-buffer)))))
(defun riece-set-window-points ()
- (if (and riece-user-list-buffer
- (get-buffer-window riece-user-list-buffer))
+ (if (get-buffer-window riece-user-list-buffer)
(with-current-buffer riece-user-list-buffer
(unless (riece-frozen riece-user-list-buffer)
(set-window-start (get-buffer-window riece-user-list-buffer)
(point-min)))))
- (if (and riece-channel-list-buffer
- (get-buffer-window riece-channel-list-buffer))
+ (if (get-buffer-window riece-channel-list-buffer)
(with-current-buffer riece-channel-list-buffer
(unless (riece-frozen riece-channel-list-buffer)
(set-window-start (get-buffer-window riece-channel-list-buffer)
(point-min))))))
(defun riece-update-user-list-buffer ()
- (if (and riece-user-list-buffer
- (get-buffer riece-user-list-buffer)
- riece-current-channel
- (riece-channel-p (riece-identity-prefix riece-current-channel)))
- (save-excursion
- (set-buffer (process-buffer (riece-server-process
- (riece-identity-server
- riece-current-channel))))
- (let* ((inhibit-read-only t)
- buffer-read-only
- (channel (riece-identity-prefix riece-current-channel))
- (users (riece-channel-get-users channel))
- (operators (riece-channel-get-operators channel))
- (speakers (riece-channel-get-speakers channel)))
- (set-buffer riece-user-list-buffer)
+ (save-excursion
+ (set-buffer riece-user-list-buffer)
+ (when (and riece-redisplay-buffer
+ riece-current-channel
+ (riece-channel-p (riece-identity-prefix riece-current-channel)))
+ (let (users operators speakers)
+ (with-current-buffer (process-buffer (riece-server-process
+ (riece-identity-server
+ riece-current-channel)))
+ (setq users
+ (riece-channel-get-users
+ (riece-identity-prefix riece-current-channel))
+ operators
+ (riece-channel-get-operators
+ (riece-identity-prefix riece-current-channel))
+ speakers
+ (riece-channel-get-speakers
+ (riece-identity-prefix riece-current-channel))))
+ (let ((inhibit-read-only t)
+ buffer-read-only)
(erase-buffer)
(while users
(if (member (car users) operators)
(if (member (car users) speakers)
(insert "+" (car users) "\n")
(insert " " (car users) "\n")))
- (setq users (cdr users)))))))
+ (setq users (cdr users)))))
+ (setq riece-redisplay-buffer nil))))
(defun riece-update-channel-list-buffer ()
- (if (and riece-channel-list-buffer
- (get-buffer riece-channel-list-buffer))
- (save-excursion
- (set-buffer riece-channel-list-buffer)
- (let ((inhibit-read-only t)
- buffer-read-only
- (index 1)
- (channels riece-current-channels))
- (erase-buffer)
- (while channels
- (if (car channels)
+ (save-excursion
+ (set-buffer riece-channel-list-buffer)
+ (when riece-redisplay-buffer
+ (let ((inhibit-read-only t)
+ buffer-read-only
+ (index 1)
+ (channels riece-current-channels))
+ (erase-buffer)
+ (while channels
+ (if (car channels)
+ (let ((point (point)))
(insert (format "%2d: %s\n" index
- (riece-decode-identity (car channels)))))
- (setq index (1+ index)
- channels (cdr channels)))))))
+ (riece-decode-identity (car channels))))
+ (put-text-property point (point) 'riece-identity
+ (car channels))))
+ (setq index (1+ index)
+ channels (cdr channels))))
+ (setq riece-redisplay-buffer nil))))
(defun riece-update-channel-indicator ()
(setq riece-channel-indicator
(defun riece-switch-to-channel (identity)
(setq riece-last-channel riece-current-channel
riece-current-channel identity)
+ (with-current-buffer riece-user-list-buffer
+ (setq riece-redisplay-buffer t))
(run-hooks 'riece-channel-switch-hook))
(defun riece-join-channel (identity)
(setq riece-current-channels
(riece-identity-assign-binding identity riece-current-channels
riece-default-channel-binding))
- (riece-channel-buffer-create identity)))
+ (riece-channel-buffer-create identity)
+ (with-current-buffer riece-channel-list-buffer
+ (setq riece-redisplay-buffer t))))
(defun riece-switch-to-nearest-channel (pointer)
(let ((start riece-current-channels)
(if pointer
(setcar pointer nil))
(if (riece-identity-equal identity riece-current-channel)
- (riece-switch-to-nearest-channel pointer))))
+ (riece-switch-to-nearest-channel pointer))
+ (with-current-buffer riece-channel-list-buffer
+ (setq riece-redisplay-buffer t))))
(defun riece-configure-windows-predicate ()
;; The current channel is changed, and some buffers are visible.
(setq buffers (cdr buffers))))))))
(defun riece-redisplay-buffers (&optional force)
- (unless riece-inhibit-update-buffers
- (riece-update-buffers))
+ (riece-update-buffers)
(if (or force
(funcall riece-configure-windows-predicate))
(funcall riece-configure-windows-function))
(substring status 0 (1- (length status))))
(message "Connection to \"%s\" closed: %s"
server-name (substring status 0 (1- (length status))))))
- (let ((channels riece-current-channels)
- (riece-inhibit-update-buffers t))
+ (let ((channels riece-current-channels))
(while channels
(if (and (car channels)
(equal (riece-identity-server (car channels))
"The channel you currently have joined.")
(defvar riece-current-channels nil
"The channels you have currently joined.")
+(defvar riece-last-channel nil
+ "The channel you had joined the last time.")
(defvar riece-save-variables-are-dirty nil
"Non nil if the variables in `riece-saved-forms' are changed.")
"Coding system for process I/O.
Local to the server buffers.")
-;;; Variables local to the command buffer:
-(defvar riece-default-channel-candidate nil
- "A channel name used as completion candidate.
-Local to the command buffer.")
-(defvar riece-last-channel nil
- "The channel you joined the last time.")
-(defvar riece-command-buffer-mode 'channel
- "Command buffer mode.
-Possible values are `chat' and `channel'.
-Local to the command buffer.")
-
;;; Variables local to the channel buffers:
(defvar riece-freeze nil
"If t, channel window is not scrolled.
riece-server-name))
(buffer (get-buffer (riece-channel-buffer-name
channel-identity))))
- (if (riece-identity-equal-no-server user riece-real-nickname)
- (riece-switch-to-channel channel-identity))
(riece-insert-change
buffer
(format "%s (%s) has joined %s\n"
;; RFC2812 3.2.2 doesn't recommend server to send part
;; messages which contain multiple targets.
(channels (split-string (car parameters) ","))
- (message (riece-decode-coding-string (nth 1 parameters)))
+ (message (if (nth 1 parameters)
+ (riece-decode-coding-string (nth 1 parameters))))
(user-identity (riece-make-identity user riece-server-name)))
(while channels
(riece-naming-assert-part user (car channels))
(parameters (riece-split-parameters string))
(channel (car parameters))
(user (nth 1 parameters))
- (message (riece-decode-coding-string (nth 2 parameters)))
+ (message (if (nth 2 parameters)
+ (riece-decode-coding-string (nth 2 parameters))))
(kicker-identity (riece-make-identity kicker riece-server-name))
(channel-identity (riece-make-identity channel riece-server-name))
(user-identity (riece-make-identity user riece-server-name)))
(let* ((user (riece-prefix-nickname prefix))
(channels (copy-sequence (riece-user-get-channels user)))
(pointer channels)
- (message (riece-decode-coding-string
- (car (riece-split-parameters string))))
+ (parameters (riece-split-parameters string))
+ (message (if (car parameters)
+ (riece-decode-coding-string (car parameters))))
(user-identity (riece-make-identity user riece-server-name)))
;; If you are talking with the user, quit it.
(if (riece-identity-member user-identity riece-current-channels)
(let* ((killer (riece-prefix-nickname prefix))
(parameters (riece-split-parameters string))
(user (car parameters))
- (message (riece-decode-coding-string (nth 1 parameters)))
+ (message (if (nth 1 parameters)
+ (riece-decode-coding-string (nth 1 parameters))))
(channels (copy-sequence (riece-user-get-channels user)))
(killer-identity (riece-make-identity killer riece-server-name))
(user-identity (riece-make-identity user riece-server-name))
(riece-make-identity (riece-encode-coding-string prefix) server))))
(defun riece-completing-read-identity (prompt channels
- &optional predicate must-match)
+ &optional predicate must-match
+ initial)
(let* ((decoded
(completing-read
prompt
(list (riece-decode-identity channel)))
(delq nil (copy-sequence (or channels
riece-current-channels))))
- predicate must-match))
+ predicate must-match initial))
(encoded
(riece-encode-identity decoded)))
(if (and (not (string-match "[ ,]" decoded))
(require 'riece-display)
(defun riece-naming-assert-join (user-name channel-name)
- (when (riece-identity-equal-no-server user-name riece-real-nickname)
- (riece-join-channel (riece-make-identity channel-name riece-server-name))
- (riece-update-buffers))
(riece-user-toggle-channel user-name channel-name t)
- (riece-channel-toggle-user channel-name user-name t))
+ (riece-channel-toggle-user channel-name user-name t)
+ (if (riece-identity-equal-no-server user-name riece-real-nickname)
+ (let ((channel-identity (riece-make-identity channel-name
+ riece-server-name)))
+ (riece-join-channel channel-identity)
+ (riece-switch-to-channel channel-identity))
+ (if (and riece-current-channel
+ (riece-identity-equal (riece-make-identity channel-name
+ riece-server-name)
+ riece-current-channel))
+ (with-current-buffer riece-user-list-buffer
+ (setq riece-redisplay-buffer t)))))
(defun riece-naming-assert-part (user-name channel-name)
+ (riece-user-toggle-channel user-name channel-name nil)
+ (riece-channel-toggle-user channel-name user-name nil)
+ (riece-channel-toggle-operator channel-name user-name nil)
+ (riece-channel-toggle-speaker channel-name user-name nil)
(if (riece-identity-equal-no-server user-name riece-real-nickname)
- (progn
- (riece-part-channel (riece-make-identity channel-name
- riece-server-name))
- (riece-update-buffers)
- (riece-forget-channel channel-name))
- (riece-user-toggle-channel user-name channel-name nil)
- (riece-channel-toggle-user channel-name user-name nil)
- (riece-channel-toggle-operator channel-name user-name nil)
- (riece-channel-toggle-speaker channel-name user-name nil)))
+ (riece-part-channel (riece-make-identity channel-name
+ riece-server-name))
+ (if (and riece-current-channel
+ (riece-identity-equal (riece-make-identity channel-name
+ riece-server-name)
+ riece-current-channel))
+ (with-current-buffer riece-user-list-buffer
+ (setq riece-redisplay-buffer t)))))
(defun riece-naming-assert-rename (old-name new-name)
(if (riece-identity-equal-no-server old-name riece-real-nickname)
pointer (member old-name users))
(if pointer
(setcar pointer new-name))
+ (if (and riece-current-channel
+ (riece-identity-equal (riece-make-identity channel-name
+ riece-server-name)
+ riece-current-channel))
+ (with-current-buffer riece-user-list-buffer
+ (setq riece-redisplay-buffer t)))
(setq channels (cdr channels)))
(riece-rename-user old-name new-name)))
(delete (riece-message-target message) riece-unread-channels))
(add-to-list 'riece-unread-channels
(riece-message-target message))
- (unless riece-inhibit-update-buffers
- (riece-unread-update-channel-list-buffer))))
+ (riece-unread-update-channel-list-buffer)))
(defun riece-unread-channel-switch-hook ()
(setq riece-unread-channels
(delete riece-current-channel
riece-unread-channels))
- (unless riece-inhibit-update-buffers
- (riece-unread-update-channel-list-buffer)))
+ (riece-unread-update-channel-list-buffer))
(defun riece-unread-update-channel-list-buffer ()
- (if riece-channel-list-buffer-mode
- (save-excursion
- (set-buffer riece-channel-list-buffer)
- (let ((inhibit-read-only t)
- buffer-read-only)
- (goto-char (point-min))
- (while (not (eobp))
- (if (looking-at "\\( ?[0-9]+:\\)\\([ !]\\)\\(.+\\)")
- (let ((channel (match-string 3)))
- (replace-match
- (concat "\\1"
- (if (member (save-match-data
- (riece-encode-identity channel))
- riece-unread-channels)
- "!"
- " ")
- "\\3"))))
- (forward-line))))))
-
+ (save-excursion
+ (set-buffer riece-channel-list-buffer)
+ (let ((inhibit-read-only t)
+ buffer-read-only)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (if (looking-at "\\( ?[0-9]+:\\)[ !]")
+ (let ((channel (get-text-property (match-end 0) 'riece-identity)))
+ (replace-match
+ (concat "\\1"
+ (if (member channel riece-unread-channels)
+ "!"
+ " ")))))
+ (forward-line)))))
+
(defun riece-unread-switch-to-channel ()
(interactive)
(if (car riece-unread-channels)
Instead, these commands are available:
\\{riece-dialogue-mode-map}"
(kill-all-local-variables)
-
(make-local-variable 'riece-freeze)
(make-local-variable 'tab-stop-list)
-
(setq riece-freeze riece-default-freeze
riece-away-indicator "-"
riece-operator-indicator "-"
All normal editing commands are turned off."
(kill-all-local-variables)
(buffer-disable-undo)
+ (make-local-variable 'riece-redisplay-buffer)
(setq major-mode 'riece-channel-list-mode
mode-name "Channels"
mode-line-buffer-identification
\\{riece-user-list-mode-map}"
(kill-all-local-variables)
(buffer-disable-undo)
+ (make-local-variable 'riece-redisplay-buffer)
(setq major-mode 'riece-user-list-mode
mode-name "User list"
mode-line-buffer-identification