X-Git-Url: http://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-unread.el;h=5ba652f948ab6f8d18084ac3f4e4fcb4fc665aea;hp=af09f29be7932bdd6b858824ece85088fcea72e0;hb=128fd61defd46adee3734539563d4d815bfca7cf;hpb=7aacdad9d2d5ecc858552476a80c81f5dc5490d5 diff --git a/lisp/riece-unread.el b/lisp/riece-unread.el index af09f29..5ba652f 100644 --- a/lisp/riece-unread.el +++ b/lisp/riece-unread.el @@ -27,19 +27,43 @@ ;; "unread messages". ;; To use, add the following line to your ~/.riece/init.el: -;; (add-to-list 'riece-addons 'riece-unread t) +;; (add-to-list 'riece-addons 'riece-unread) ;;; Code: -(eval-when-compile (require 'riece-message)) +(require 'riece-message) +(require 'riece-commands) + +(eval-when-compile (require 'riece-highlight)) + +(defgroup riece-unread nil + "Mark unread channels" + :tag "Unread" + :prefix "riece-" + :group 'riece) + +(defcustom riece-channel-list-unread-face 'riece-channel-list-unread-face + "Face used for displaying unread channels." + :type 'face + :group 'riece-highlight-faces) + +(defface riece-channel-list-unread-face + '((((class color) + (background dark)) + (:foreground "orange")) + (((class color) + (background light)) + (:foreground "firebrick")) + (t + (:bold t))) + "Face used for displaying unread channels." + :group 'riece-highlight-faces) (defvar riece-unread-channels nil) (defun riece-unread-display-message-function (message) (unless (or (riece-message-own-p message) - (and (equal (riece-message-target message) riece-current-channel) - (eq (window-buffer (selected-window)) - (get-buffer riece-command-buffer)))) + (equal (riece-message-target message) riece-current-channel)) (setq riece-unread-channels (delete (riece-message-target message) riece-unread-channels)) (add-to-list 'riece-unread-channels @@ -60,13 +84,14 @@ buffer-read-only) (goto-char (point-min)) (while (not (eobp)) - (if (looking-at "\\( ?[0-9]+:\\)\\([ !]\\)\\(.+\\)") - (let ((channel (match-string 3))) + (if (looking-at "\\( ?[0-9]+:\\)\\(.\\)\\(.+\\)") + (let ((channel (save-match-data + (riece-parse-identity (match-string 3))))) (replace-match (concat "\\1" (if (member channel riece-unread-channels) "!" - " ") + "\\2") "\\3")))) (forward-line)))))) @@ -80,19 +105,27 @@ (defvar riece-dialogue-mode-map) (defvar riece-channel-list-mode-map) +(defun riece-unread-requires () + (if (memq 'riece-highlight riece-addons) + '(riece-highlight))) + (defun riece-unread-insinuate () (add-hook 'riece-after-display-message-functions 'riece-unread-display-message-function) (add-hook 'riece-channel-switch-hook 'riece-unread-channel-switch-hook) - (add-hook 'riece-update-buffers-hook - 'riece-unread-update-channel-list-buffer) + (add-hook 'riece-update-buffer-functions + 'riece-unread-update-channel-list-buffer t) (define-key riece-command-mode-map "\C-c\C-u" 'riece-unread-switch-to-channel) (define-key riece-dialogue-mode-map "u" 'riece-unread-switch-to-channel) (define-key riece-channel-list-mode-map - "u" 'riece-unread-switch-to-channel)) + "u" 'riece-unread-switch-to-channel) + (if (memq 'riece-highlight riece-addons) + (setq riece-channel-list-mark-face-alist + (cons '(?! . riece-channel-list-unread-face) + riece-channel-list-mark-face-alist)))) (provide 'riece-unread)