From: ueno Date: Tue, 26 Aug 2003 06:35:06 +0000 (+0000) Subject: * riece-highlight.el (riece-channel-list-mark-current-channel): X-Git-Tag: riece-0_1_1~11 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=8513ec2a461335ebfd91299cfa8c4897497a1459;p=elisp%2Friece.git * riece-highlight.el (riece-channel-list-mark-current-channel): New function. * riece-display.el (riece-channel-list-changed): New variable. (riece-update-channel-list-buffer): Check riece-channel-list-changed. (riece-update-channel-list-indicator): Ditto. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 79a6b03..30e444c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,14 @@ 2003-08-26 Daiki Ueno + * riece-highlight.el (riece-channel-list-mark-current-channel): + New function. + + * riece-display.el (riece-channel-list-changed): New variable. + (riece-update-channel-list-buffer): Check riece-channel-list-changed. + (riece-update-channel-list-indicator): Ditto. + +2003-08-26 Daiki Ueno + * riece-options.el (riece-addons): Enable riece-unread by default. * riece-highlight.el (riece-channel-list-current-face): New variable. diff --git a/lisp/riece-display.el b/lisp/riece-display.el index 2f22561..e72fe27 100644 --- a/lisp/riece-display.el +++ b/lisp/riece-display.el @@ -37,6 +37,8 @@ riece-update-short-channel-indicator riece-update-channel-list-indicator)) +(defvar riece-channel-list-changed nil) + (defun riece-update-user-list-buffer () (save-excursion (set-buffer riece-user-list-buffer) @@ -67,27 +69,24 @@ (setq users (cdr users)))))))) (defun riece-update-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) - (let ((point (point))) - (insert (format "%2d:%c%s\n" index - (if (riece-identity-equal - (car channels) - riece-current-channel) - ?* - ?\ ) - (riece-format-identity (car channels)))) - (put-text-property point (point) 'riece-identity - (car channels)))) - (setq index (1+ index) - channels (cdr channels)))))) + (if riece-channel-list-changed + (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) + (let ((point (point))) + (insert (format "%2d: %s\n" index + (riece-format-identity (car channels)))) + (put-text-property point (point) 'riece-identity + (car channels)))) + (setq index (1+ index) + channels (cdr channels)))) + (setq riece-channel-list-changed nil)))) (defun riece-update-channel-indicator () (setq riece-channel-indicator @@ -108,23 +107,25 @@ "None"))) (defun riece-update-channel-list-indicator () - (if (and riece-current-channels - ;; There is at least one channel. - (delq nil (copy-sequence riece-current-channels))) - (let ((index 1)) - (setq riece-channel-list-indicator - (mapconcat - #'identity - (delq nil - (mapcar - (lambda (channel) - (prog1 (if channel - (format "%d:%s" index - (riece-format-identity channel))) - (setq index (1+ index)))) - riece-current-channels)) - ","))) - (setq riece-channel-list-indicator "No channel"))) + (if riece-channel-list-changed + (if (and riece-current-channels + ;; There is at least one channel. + (delq nil (copy-sequence riece-current-channels))) + (let ((index 1)) + (setq riece-channel-list-indicator + (mapconcat + #'identity + (delq nil + (mapcar + (lambda (channel) + (prog1 + (if channel + (format "%d:%s" index + (riece-format-identity channel))) + (setq index (1+ index)))) + riece-current-channels)) + ","))) + (setq riece-channel-list-indicator "No channel")))) (defun riece-update-status-indicators () (if riece-current-channel @@ -193,7 +194,8 @@ (if channel (riece-parse-identity channel))) riece-default-channel-binding))) - (riece-channel-buffer-create identity))) + (riece-channel-buffer-create identity) + (setq riece-channel-list-changed t))) (defun riece-switch-to-nearest-channel (pointer) (let ((start riece-current-channels) @@ -217,7 +219,8 @@ (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)) + (setq riece-channel-list-changed t))) (defun riece-redisplay-buffers (&optional force) (riece-update-buffers) diff --git a/lisp/riece-highlight.el b/lisp/riece-highlight.el index a01575f..f6a50f3 100644 --- a/lisp/riece-highlight.el +++ b/lisp/riece-highlight.el @@ -255,6 +255,24 @@ (if (looking-at riece-prefix-regexp) (put-text-property (match-beginning 1) (match-end 1) 'invisible t)))) +(defun riece-channel-list-mark-current-channel () + (if (and riece-channel-list-buffer-mode + riece-current-channel) + (save-excursion + (set-buffer riece-channel-list-buffer) + (let ((inhibit-read-only t) + buffer-read-only) + (goto-char (point-min)) + (if (re-search-forward "^\\( ?[0-9]+:\\)\\*" nil t) + (replace-match "\\1 ")) + (goto-char (point-min)) + (if (re-search-forward + (concat + "^\\( ?[0-9]+:\\).\\(" + (regexp-quote (riece-format-identity riece-current-channel)) + "\\)$") nil t) + (replace-match "\\1*\\2")))))) + (defun riece-channel-list-turn-on-font-lock () (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(riece-channel-list-font-lock-keywords t)) @@ -278,6 +296,8 @@ 'riece-dialogue-schedule-turn-on-font-lock) (put 'riece-channel-list-mode 'font-lock-defaults '(riece-channel-list-font-lock-keywords t)) + (add-hook 'riece-channel-switch-hook + 'riece-channel-list-mark-current-channel) (add-hook 'riece-after-load-startup-hook 'riece-channel-list-schedule-turn-on-font-lock))