From: ueno Date: Mon, 23 Jun 2003 04:53:26 +0000 (+0000) Subject: * riece-handle.el (riece-handle-join-message): Don't call X-Git-Tag: strict-naming-mergepoint~8 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=03f7203a4ac7c63a15038bc9cba050396afb25fa;p=elisp%2Friece.git * 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6afb132..680f097 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,33 @@ +2003-06-23 Daiki Ueno + + * 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 * riece-display.el (riece-inhibit-update-buffers): New variable. diff --git a/lisp/riece-commands.el b/lisp/riece-commands.el index cafdf3c..9a04b89 100644 --- a/lisp/riece-commands.el +++ b/lisp/riece-commands.el @@ -37,8 +37,9 @@ (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 @@ -439,7 +440,8 @@ (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))) diff --git a/lisp/riece-display.el b/lisp/riece-display.el index 2ed58fb..db6804f 100644 --- a/lisp/riece-display.el +++ b/lisp/riece-display.el @@ -47,9 +47,9 @@ 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)) @@ -102,35 +102,38 @@ Typically, this variable is bound to a let form.") (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) @@ -138,24 +141,28 @@ Typically, this variable is bound to a let form.") (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 @@ -248,6 +255,8 @@ Typically, this variable is bound to a let form.") (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) @@ -255,7 +264,9 @@ Typically, this variable is bound to a let form.") (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) @@ -279,7 +290,9 @@ Typically, this variable is bound to a let form.") (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. @@ -293,8 +306,7 @@ Typically, this variable is bound to a let form.") (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)) diff --git a/lisp/riece-filter.el b/lisp/riece-filter.el index 1631146..f468dd9 100644 --- a/lisp/riece-filter.el +++ b/lisp/riece-filter.el @@ -152,8 +152,7 @@ (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)) diff --git a/lisp/riece-globals.el b/lisp/riece-globals.el index cb0c5eb..99f2bb6 100644 --- a/lisp/riece-globals.el +++ b/lisp/riece-globals.el @@ -32,6 +32,8 @@ "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.") @@ -92,17 +94,6 @@ Local to the server buffers.") "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. diff --git a/lisp/riece-handle.el b/lisp/riece-handle.el index 6aa2adc..b9ad13d 100644 --- a/lisp/riece-handle.el +++ b/lisp/riece-handle.el @@ -118,8 +118,6 @@ 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" @@ -147,7 +145,8 @@ ;; 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)) @@ -185,7 +184,8 @@ (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))) @@ -221,8 +221,9 @@ (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) @@ -264,7 +265,8 @@ (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)) diff --git a/lisp/riece-identity.el b/lisp/riece-identity.el index f56e62c..081d3c3 100644 --- a/lisp/riece-identity.el +++ b/lisp/riece-identity.el @@ -147,7 +147,8 @@ RFC2812, 2.2 \"Character codes\" says: (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 @@ -155,7 +156,7 @@ RFC2812, 2.2 \"Character codes\" says: (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)) diff --git a/lisp/riece-naming.el b/lisp/riece-naming.el index 709abea..4b4970f 100644 --- a/lisp/riece-naming.el +++ b/lisp/riece-naming.el @@ -30,23 +30,34 @@ (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) @@ -68,6 +79,12 @@ 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))) diff --git a/lisp/riece-unread.el b/lisp/riece-unread.el index 8a856e2..cb7670d 100644 --- a/lisp/riece-unread.el +++ b/lisp/riece-unread.el @@ -42,36 +42,30 @@ (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) diff --git a/lisp/riece.el b/lisp/riece.el index 7357bdd..8a5cd0b 100644 --- a/lisp/riece.el +++ b/lisp/riece.el @@ -312,10 +312,8 @@ All normal editing commands are turned off. 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 "-" @@ -363,6 +361,7 @@ Instead, these commands are available: 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 @@ -379,6 +378,7 @@ Instead, these commands are available: \\{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