X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-display.el;h=fbead8bdafe20288f3f9bc7cffb179acd1d22a01;hp=25ac9d3c6616151cf05bc7d40d50971a52541780;hb=b51c9730dc2297168743bd6a79b9b359017610e3;hpb=fe7eeb17a3b1cc9b6a5316aebae340cba1ede06d diff --git a/lisp/riece-display.el b/lisp/riece-display.el index 25ac9d3..fbead8b 100644 --- a/lisp/riece-display.el +++ b/lisp/riece-display.el @@ -19,8 +19,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Code: @@ -43,6 +43,7 @@ Local to the buffer in `riece-buffer-list'.") (defvar riece-update-indicator-functions '(riece-update-status-indicators + riece-update-channel-status-indicator riece-update-channel-indicator riece-update-long-channel-indicator riece-update-channel-list-indicator) @@ -70,6 +71,7 @@ Local to the buffer in `riece-buffer-list'.") 'channel-switched (lambda (signal handback) (riece-update-status-indicators) + (riece-update-channel-status-indicator) (riece-update-channel-indicator) (riece-update-long-channel-indicator) (force-mode-line-update t) @@ -123,11 +125,13 @@ Local to the buffer in `riece-buffer-list'.") (riece-identity-server riece-current-channel)) (riece-with-server-buffer (riece-identity-server riece-current-channel) - (riece-identity-assoc - (riece-identity-prefix (nth 1 (riece-signal-args signal))) - (riece-channel-get-users (riece-identity-prefix - riece-current-channel)) - t))))) + (when (riece-channel-p (riece-identity-prefix + riece-current-channel)) + (riece-identity-assoc + (riece-identity-prefix (nth 1 (riece-signal-args signal))) + (riece-channel-get-users (riece-identity-prefix + riece-current-channel)) + t)))))) (riece-connect-signal 'user-renamed (lambda (signal handback) @@ -199,6 +203,7 @@ Local to the buffer in `riece-buffer-list'.") (riece-connect-signal 'channel-operators-changed (lambda (signal handback) + (riece-update-channel-status-indicator) (riece-emit-signal 'user-list-changed riece-current-channel)) (lambda (signal) (and riece-current-channel @@ -207,6 +212,7 @@ Local to the buffer in `riece-buffer-list'.") (riece-connect-signal 'channel-speakers-changed (lambda (signal handback) + (riece-update-channel-status-indicator) (riece-emit-signal 'user-list-changed riece-current-channel)) (lambda (signal) (and riece-current-channel @@ -280,9 +286,9 @@ Local to the buffer in `riece-buffer-list'.") (setq riece-long-channel-indicator (if riece-current-channel (if (riece-channel-p (riece-identity-prefix riece-current-channel)) - (riece-concat-channel-modes + (riece-concat-channel-topic riece-current-channel - (riece-concat-channel-topic + (riece-concat-channel-modes riece-current-channel (riece-format-identity riece-current-channel))) (riece-format-identity riece-current-channel)) @@ -321,24 +327,30 @@ Local to the buffer in `riece-buffer-list'.") (while pointer (if (cdr pointer) (setcdr pointer (cons "," (cdr pointer)))) - (setq pointer (cdr (cdr pointer))))) + (setq pointer (cdr (cdr pointer)))) + (setq riece-channel-list-indicator + (riece-normalize-modeline-string riece-channel-list-indicator))) (setq riece-channel-list-indicator "No channel"))) (defun riece-update-status-indicators () - (if riece-current-channel - (with-current-buffer riece-command-buffer - (riece-with-server-buffer (riece-identity-server riece-current-channel) - (setq riece-away-indicator - (if (and riece-real-nickname - (riece-user-get-away riece-real-nickname)) - "A" - "-") - riece-operator-indicator - (if (and riece-real-nickname - (riece-user-get-operator riece-real-nickname)) - "O" - "-") - riece-user-indicator riece-real-nickname)))) + (let ((server-name (riece-current-server-name))) + (if server-name + (with-current-buffer riece-command-buffer + (riece-with-server-buffer server-name + (setq riece-away-indicator + (if (and riece-real-nickname + (riece-user-get-away riece-real-nickname)) + "A" + "-") + riece-operator-indicator + (if (and riece-real-nickname + (riece-user-get-operator riece-real-nickname)) + "O" + "-") + riece-user-indicator + (riece-format-identity + (riece-make-identity riece-real-nickname riece-server-name) + t)))))) (walk-windows (lambda (window) (with-current-buffer (window-buffer window) @@ -351,13 +363,37 @@ Local to the buffer in `riece-buffer-list'.") "F" "-")))))))) +(defun riece-update-channel-status-indicator () + (if (and riece-current-channel + (riece-channel-p (riece-identity-prefix riece-current-channel))) + (let ((users + (riece-with-server-buffer (riece-identity-server + riece-current-channel) + (riece-channel-get-users (riece-identity-prefix + riece-current-channel)))) + (nickname + (riece-with-server-buffer (riece-identity-server + riece-current-channel) + riece-real-nickname))) + (with-current-buffer riece-command-buffer + (setq riece-channel-status-indicator + (if nickname + (let ((user (cdr (riece-identity-assoc nickname users t)))) + (if (memq ?o user) + "@" + (if (memq ?v user) + "+" + "-"))) + "-")))))) + (defun riece-update-buffers (&optional buffers) (unless buffers (setq buffers riece-buffer-list)) (while buffers - (save-excursion - (set-buffer (car buffers)) - (run-hooks 'riece-update-buffer-functions)) + (if (buffer-live-p (car buffers)) + (save-excursion + (set-buffer (car buffers)) + (run-hooks 'riece-update-buffer-functions))) (setq buffers (cdr buffers))) (run-hooks 'riece-update-indicator-functions) (force-mode-line-update t) @@ -368,7 +404,8 @@ Local to the buffer in `riece-buffer-list'.") (if channels (setq identity (car channels)) (if riece-debug - (message "%S is not a member of riece-current-channels" identity))) + (riece-debug (format "%S is not a member of riece-current-channels" + identity)))) (format riece-channel-buffer-format (riece-format-identity identity)))) (eval-when-compile @@ -392,10 +429,22 @@ Local to the buffer in `riece-buffer-list'.") (current-buffer))) (defun riece-channel-buffer (identity) - (cdr (riece-identity-assoc identity riece-channel-buffer-alist))) + (let ((entry (riece-identity-assoc identity riece-channel-buffer-alist))) + (if entry + (if (buffer-live-p (cdr entry)) + (cdr entry) + (if riece-debug + (riece-debug + (format "riece-channel-buffer: nonexistent buffer: %s" + (riece-format-identity identity)))))))) (defun riece-switch-to-channel (identity) - (let ((last riece-current-channel)) + (let ((last riece-current-channel) + window) + (if (and riece-channel-buffer + (setq window (get-buffer-window riece-channel-buffer))) + (with-current-buffer riece-channel-buffer + (setq riece-channel-buffer-window-point (window-point window)))) (setq riece-current-channel identity riece-channel-buffer (riece-channel-buffer riece-current-channel)) (run-hook-with-args 'riece-after-switch-to-channel-functions last) @@ -434,10 +483,13 @@ Local to the buffer in `riece-buffer-list'.") (defun riece-part-channel (identity) (let ((pointer (riece-identity-member identity riece-current-channels))) - (if pointer - (setcar pointer nil)) + (unless pointer + (error "No such channel!")) + (setcar pointer nil) (if (riece-identity-equal identity riece-current-channel) - (riece-switch-to-nearest-channel pointer)))) + (riece-switch-to-nearest-channel pointer) + (riece-emit-signal 'channel-list-changed)) + (funcall riece-buffer-dispose-function (riece-channel-buffer identity)))) (defun riece-redisplay-buffers (&optional force) (riece-update-buffers)