From 6b94e1137ca4c8c1204b7562d54427a893cc5560 Mon Sep 17 00:00:00 2001 From: ueno Date: Mon, 2 Jun 2003 16:57:32 +0000 Subject: [PATCH] Fix for status indicators. * riece.el (riece-command-mode): Don't set riece-freeze-indicator. (riece-dialogue-mode): Call riece-update-status-indicators. (riece-channel-mode): Add riece-operator-indicator to mode-line-buffer-identification. * riece-user.el (riece-make-user): New attribute `operator'. (riece-user-operator): New function. (riece-user-set-operator): New function. (riece-user-toggle-away): New function. (riece-user-toggle-operator): New function. * riece-misc.el (riece-own-frozen): Revive. * riece-message.el (riece-display-message): Reset riece-freeze if riece-freeze == 'own && (riece-message-own-p message). * riece-globals.el (riece-own-freeze): Abolish; use riece-freeze. (riece-operator-indicator): New variable. * riece-display.el (riece-update-status-indicators): New function. (riece-update-buffer-functions): Add it. * riece-commands.el (riece-command-toggle-freeze): Don't call riece-freeze. (riece-command-toggle-own-freeze): Don't call riece-own-freeze. * riece-300.el (riece-handle-302-message): Use riece-user-toggle-away instead of riece-user-set-away. (riece-handle-301-message): Ditto. (riece-handle-305-message): Ditto. (riece-handle-306-message): Ditto. (riece-handle-352-message): Ditto. --- lisp/ChangeLog | 28 ++++++++++++++++++++++++++++ lisp/riece-300.el | 36 +++++++++++++++++------------------- lisp/riece-commands.el | 28 ++++++++++++++++++++-------- lisp/riece-display.el | 24 ++++++++++++++++++++++++ lisp/riece-globals.el | 7 +++---- lisp/riece-message.el | 27 +++++++++++++++++---------- lisp/riece-misc.el | 15 ++++----------- lisp/riece-options.el | 7 +------ lisp/riece-user.el | 24 ++++++++++++++++++++++-- lisp/riece.el | 18 +++++++----------- 10 files changed, 143 insertions(+), 71 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 321b330..92fd4f1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,31 @@ +2003-06-02 Daiki Ueno + + * riece.el (riece-command-mode): Don't set riece-freeze-indicator. + (riece-dialogue-mode): Call riece-update-status-indicators. + (riece-channel-mode): Add riece-operator-indicator to + mode-line-buffer-identification. + * riece-user.el (riece-make-user): New attribute `operator'. + (riece-user-operator): New function. + (riece-user-set-operator): New function. + (riece-user-toggle-away): New function. + (riece-user-toggle-operator): New function. + * riece-misc.el (riece-own-frozen): Revive. + * riece-message.el (riece-display-message): Reset riece-freeze if + riece-freeze == 'own && (riece-message-own-p message). + * riece-globals.el (riece-own-freeze): Abolish; use riece-freeze. + (riece-operator-indicator): New variable. + * riece-display.el (riece-update-status-indicators): New function. + (riece-update-buffer-functions): Add it. + * riece-commands.el (riece-command-toggle-freeze): Don't call + riece-freeze. + (riece-command-toggle-own-freeze): Don't call riece-own-freeze. + * riece-300.el (riece-handle-302-message): Use + riece-user-toggle-away instead of riece-user-set-away. + (riece-handle-301-message): Ditto. + (riece-handle-305-message): Ditto. + (riece-handle-306-message): Ditto. + (riece-handle-352-message): Ditto. + 2003-06-02 Yoichi NAKAYAMA * riece-commands.el (riece-command-next-channel): Circularly diff --git a/lisp/riece-300.el b/lisp/riece-300.el index 77ed5cb..839d7b9 100644 --- a/lisp/riece-300.el +++ b/lisp/riece-300.el @@ -46,23 +46,25 @@ "\\)\\(\\*\\)?=\\([-+]\\)\\([^ ]+\\)") (car replies)) (let ((user (match-string 1 (car replies))) - (away (eq (match-string 3 (car replies)) ?-))) + (away (eq (match-string 3 (car replies)) ?-)) + (user-at-host (match-string 4 (car replies))) + (operator (not (null (match-beginning 2))))) + (riece-user-toggle-away user away) + (riece-user-toggle-operator user operator) (riece-insert-info (list riece-dialogue-buffer riece-others-buffer) (concat (riece-concat-server-name (format "%s is (%s) [%s, %s]" user - (riece-strip-user-at-host - (match-string 4 (car replies))) - (if (match-beginning 2) + (riece-strip-user-at-host user-at-host) + (if operator "operator" "not operator") (if away "away" "not away"))) - "\n")) - (riece-user-set-away (riece-get-user user) away))) + "\n")))) (setq replies (cdr replies))))) (defun riece-handle-303-message (prefix number name string) @@ -76,26 +78,21 @@ (when (string-match (concat "^\\(" riece-user-regexp "\\) :") string) - (let ((user (match-string 1 string))) - (riece-user-set-away (riece-get-user user) t) + (let ((user (match-string 1 string)) + (message (substring string (match-end 0)))) + (riece-user-toggle-away user t) (riece-insert-info (list riece-dialogue-buffer riece-others-buffer) (concat (riece-concat-server-name - (format "%s is away: %s" - user - (substring string (match-end 0)))) + (format "%s is away: %s" user message)) "\n"))))) (defun riece-handle-305-message (prefix number name string) - (riece-user-set-away (riece-get-user riece-real-nickname) nil) - (setq riece-away-indicator "-") - (force-mode-line-update t)) + (riece-user-toggle-away riece-real-nickname nil)) (defun riece-handle-306-message (prefix number name string) - (riece-user-set-away (riece-get-user riece-real-nickname) t) - (setq riece-away-indicator "A") - (force-mode-line-update t)) + (riece-user-toggle-away riece-real-nickname t)) (defun riece-handle-311-message (prefix number name string) (if (string-match @@ -282,7 +279,7 @@ (server (match-string 4 string)) (nick (match-string 5 string)) (away (equal (match-string 6 string) "G")) - (operator (match-string 7 string)) + (operator (not (null (match-beginning 7)))) (flag (match-string 8 string)) (hops (match-string 9 string)) (name (substring string (match-end 0))) @@ -290,7 +287,8 @@ (riece-make-identity channel) riece-channel-buffer-alist)))) (riece-naming-assert-join nick channel) - (riece-user-set-away (riece-get-user user) away) + (riece-user-toggle-away user away) + (riece-user-toggle-operator user operator) (riece-insert-info buffer (format "%10s = %s (%s) [%s, %s, %s hops, on %s]\n" diff --git a/lisp/riece-commands.el b/lisp/riece-commands.el index 28b0d39..b237282 100644 --- a/lisp/riece-commands.el +++ b/lisp/riece-commands.el @@ -513,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." diff --git a/lisp/riece-display.el b/lisp/riece-display.el index bd6f0e2..ee9c090 100644 --- a/lisp/riece-display.el +++ b/lisp/riece-display.el @@ -31,6 +31,7 @@ (defvar riece-update-buffer-functions '(riece-user-list-update-buffer riece-channel-list-update-buffer + riece-update-status-indicators riece-update-channel-indicator riece-update-channel-list-indicator)) @@ -177,6 +178,29 @@ ","))) (setq riece-channel-list-indicator "No channel"))) +(defun riece-update-status-indicators () + (riece-with-server-buffer + (setq riece-away-indicator + (if (and riece-real-nickname + (riece-user-get-away riece-real-nickname)) + "A" + "-")) + (setq riece-operator-indicator + (if (and riece-real-nickname + (riece-user-get-operator riece-real-nickname)) + "O" + "-"))) + (setq riece-freeze-indicator + (with-current-buffer (if (and riece-channel-buffer-mode + riece-channel-buffer) + riece-channel-buffer + riece-dialogue-buffer) + (if (eq riece-freeze 'own) + "f" + (if riece-freeze + "F" + "-"))))) + (defun riece-update-buffers () (run-hooks 'riece-update-buffer-functions) (force-mode-line-update t) diff --git a/lisp/riece-globals.el b/lisp/riece-globals.el index c7b74c7..fbba31b 100644 --- a/lisp/riece-globals.el +++ b/lisp/riece-globals.el @@ -107,10 +107,8 @@ Local to the command buffer.") ;;; Variables local to the channel buffers: (defvar riece-freeze nil - "If non-nil, channel window is not scrolled. -Local to the channel buffers.") -(defvar riece-own-freeze nil - "If non-nil, channel window is not scrolled until you input. + "If t, channel window is not scrolled. +If 'own, channel window is not scrolled until you speak. Local to the channel buffers.") ;;; Modeline indicators: @@ -120,6 +118,7 @@ Local to the channel buffers.") "The current joined channels, \"pretty-printed.\".") (defvar riece-away-indicator "-") +(defvar riece-operator-indicator "-") (defvar riece-freeze-indicator nil) (defvar riece-own-freeze-indicator nil) diff --git a/lisp/riece-message.el b/lisp/riece-message.el index 2bef9f6..ae3c7ba 100644 --- a/lisp/riece-message.el +++ b/lisp/riece-message.el @@ -135,16 +135,23 @@ Normally they are *Dialogue* and/or *Others*." (defun riece-display-message (message) "Display MESSAGE object." - (let* ((open-bracket - (funcall riece-message-make-open-bracket-function message)) - (close-bracket - (funcall riece-message-make-close-bracket-function message)) - (name - (funcall riece-message-make-name-function message)) - (global-name - (funcall riece-message-make-global-name-function message)) - (buffer (riece-message-buffer message)) - (parent-buffers (riece-message-parent-buffers message buffer))) + (let ((open-bracket + (funcall riece-message-make-open-bracket-function message)) + (close-bracket + (funcall riece-message-make-close-bracket-function message)) + (name + (funcall riece-message-make-name-function message)) + (global-name + (funcall riece-message-make-global-name-function message)) + (buffer (riece-message-buffer message)) + parent-buffers) + (when (and buffer + (riece-message-own-p message) + (riece-own-frozen buffer)) + (with-current-buffer buffer + (setq riece-freeze nil)) + (riece-update-status-indicators)) + (setq parent-buffers (riece-message-parent-buffers message buffer)) (riece-insert buffer (concat open-bracket name close-bracket " " (riece-message-text message) "\n")) diff --git a/lisp/riece-misc.el b/lisp/riece-misc.el index b269572..bc68892 100644 --- a/lisp/riece-misc.el +++ b/lisp/riece-misc.el @@ -72,20 +72,13 @@ (defun riece-insert-info (buffer message) (riece-insert buffer (concat riece-info-prefix message))) -(defun riece-freeze (buffer &optional arg) - (with-current-buffer buffer - (setq riece-freeze (if arg (< 0 arg) (not riece-freeze)) - riece-freeze-indicator (if riece-freeze "F" "-")) - (force-mode-line-update))) - (defun riece-frozen (buffer) - (with-current-buffer buffer riece-freeze)) + (with-current-buffer buffer + riece-freeze)) -(defun riece-own-freeze (buffer &optional arg) +(defun riece-own-frozen (buffer) (with-current-buffer buffer - (setq riece-own-freeze (if arg (< 0 arg) (not riece-own-freeze)) - riece-own-freeze-indicator (if riece-own-freeze "M" "-")) - (force-mode-line-update))) + (eq riece-freeze 'own))) (defun riece-process-send-string (process string) (with-current-buffer (process-buffer process) diff --git a/lisp/riece-options.el b/lisp/riece-options.el index c9d000d..aa86dbb 100644 --- a/lisp/riece-options.el +++ b/lisp/riece-options.el @@ -208,12 +208,7 @@ way is to put Riece variables on .emacs or file loaded from there." :group 'riece-looks) (defcustom riece-default-freeze nil - "If non nil, channel buffer local freeze flag is on at starting." - :type 'boolean - :group 'riece-looks) - -(defcustom riece-default-own-freeze nil - "If non nil, channel buffer local own freeze flag is on at starting." + "Channel buffer local freeze flag is on at starting." :type 'boolean :group 'riece-looks) diff --git a/lisp/riece-user.el b/lisp/riece-user.el index f74f770..197d765 100644 --- a/lisp/riece-user.el +++ b/lisp/riece-user.el @@ -59,11 +59,11 @@ (makunbound symbol) (unintern (symbol-name symbol) riece-obarray)))))) -(defun riece-make-user (&optional channels user-at-host modes away) +(defun riece-make-user (&optional channels user-at-host modes away operator) "Make an instance of user object. Arguments are appropriate to joined channels, user-at-host, mode, and away status, respectively." - (vector channels user-at-host modes away)) + (vector channels user-at-host modes away operator)) (defun riece-get-user (name) (riece-with-server-buffer @@ -90,6 +90,10 @@ away status, respectively." "Return t, if USER has been marked as away." (aref user 3)) +(defun riece-user-operator (user) + "Return t, if USER has operator privilege." + (aref user 4)) + (defun riece-user-set-channels (user value) "Set the joined channels of USER to VALUE." (aset user 0 value)) @@ -106,6 +110,10 @@ away status, respectively." "Set the away status of USER to VALUE." (aset user 3 value)) +(defun riece-user-set-operator (user value) + "Set the operator status of USER to VALUE." + (aset user 4 value)) + (defun riece-user-get-channels (&optional name) (riece-user-channels (riece-get-user (or name riece-real-nickname)))) @@ -122,6 +130,10 @@ away status, respectively." (riece-user-away (riece-get-user (or name riece-real-nickname)))) +(defun riece-user-get-operator (&optional name) + (riece-user-operator + (riece-get-user (or name riece-real-nickname)))) + (defun riece-user-toggle-channel (name channel flag) "Add or remove the joined channel of user." (let* ((user (riece-get-user (or name (riece-current-nickname)))) @@ -142,6 +154,14 @@ away status, respectively." (if (memq mode modes) (riece-user-set-modes user (delq mode modes)))))) +(defun riece-user-toggle-away (name flag) + (riece-user-set-away + (riece-get-user (or name (riece-current-nickname))) flag)) + +(defun riece-user-toggle-operator (name flag) + (riece-user-set-operator + (riece-get-user (or name (riece-current-nickname))) flag)) + (provide 'riece-user) ;;; riece-user.el ends here diff --git a/lisp/riece.el b/lisp/riece.el index f4ef821..ac3c37d 100644 --- a/lisp/riece.el +++ b/lisp/riece.el @@ -288,11 +288,8 @@ For a list of the generic commands type \\[riece-command-generic] ? RET. (interactive) (kill-all-local-variables) - (setq riece-freeze riece-default-freeze - riece-freeze-indicator (if riece-freeze "F" "-") - riece-own-freeze riece-default-own-freeze - riece-own-freeze-indicator (if riece-own-freeze "M" "-") - riece-away-indicator "-" + (setq riece-away-indicator "-" + riece-operator-indicator "-" major-mode 'riece-command-mode mode-name "Commands" mode-line-buffer-identification @@ -300,6 +297,7 @@ For a list of the generic commands type \\[riece-command-generic] ? RET. '("Riece: " mode-line-modified riece-away-indicator + riece-operator-indicator "-- " riece-current-channel " " riece-real-nickname))) (riece-simplify-mode-line-format) (use-local-map riece-command-mode-map) @@ -322,16 +320,11 @@ Instead, these commands are available: (kill-all-local-variables) (make-local-variable 'riece-freeze) - (make-local-variable 'riece-freeze-indicator) - (make-local-variable 'riece-own-freeze) - (make-local-variable 'riece-own-freeze-indicator) (make-local-variable 'tab-stop-list) (setq riece-freeze riece-default-freeze - riece-freeze-indicator (if riece-freeze "F" "-") - riece-own-freeze riece-default-own-freeze - riece-own-freeze-indicator (if riece-own-freeze "M" "-") riece-away-indicator "-" + riece-operator-indicator "-" major-mode 'riece-dialogue-mode mode-name "Dialogue" mode-line-buffer-identification @@ -339,11 +332,13 @@ Instead, these commands are available: '("Riece: " mode-line-modified riece-away-indicator + riece-operator-indicator riece-freeze-indicator riece-own-freeze-indicator " " riece-channel-list-indicator " ")) buffer-read-only t tab-stop-list riece-tab-stop-list) + (riece-update-status-indicators) (riece-simplify-mode-line-format) (use-local-map riece-dialogue-mode-map) (buffer-disable-undo) @@ -367,6 +362,7 @@ Instead, these commands are available: '("Riece: " mode-line-modified riece-away-indicator + riece-operator-indicator riece-freeze-indicator riece-own-freeze-indicator " " -- 1.7.10.4