X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-unread.el;h=07b910535fc63215ae62b48aed398bdb950b8a20;hp=fecd65f1f043446eb7328702bfa725ea583a139f;hb=6ee663fa3d9fae9b26cf1494676c3f64f849b173;hpb=e181f1a7f1ea36733e4604ffb97814d50c4e2295 diff --git a/lisp/riece-unread.el b/lisp/riece-unread.el index fecd65f..07b9105 100644 --- a/lisp/riece-unread.el +++ b/lisp/riece-unread.el @@ -1,4 +1,4 @@ -;;; riece-unread.el --- "unread message mark" add-on +;;; riece-unread.el --- mark channels where new messages arrived ;; Copyright (C) 1998-2003 Daiki Ueno ;; Author: Daiki Ueno @@ -23,7 +23,9 @@ ;;; Commentary: -;; This add-on marks channels where new messages are arrived. +;; NOTE: This is an add-on module for Riece. + +;; This add-on marks channels where new messages arrived. ;; You can check the unread channels via `C-c g' in the commands ;; buffer, by adding the following lines to ~/.riece/init.el: @@ -36,11 +38,10 @@ (require 'riece-message) (require 'riece-commands) (require 'riece-signal) - -(eval-when-compile (require 'riece-highlight)) +(require 'riece-highlight) (defgroup riece-unread nil - "Mark unread channels" + "Mark unread channels." :tag "Unread" :prefix "riece-" :group 'riece) @@ -58,15 +59,21 @@ :group 'riece-highlight-faces) (defvar riece-channel-list-unread-face 'riece-channel-list-unread-face) -(defvar riece-unread-channels nil) +(unless (riece-facep 'riece-modeline-unread-face) + (make-face 'riece-modeline-unread-face + "Face used for displaying unread channels in modeline.") + (if (featurep 'xemacs) + (set-face-parent 'riece-modeline-unread-face 'modeline)) + (set-face-foreground 'riece-modeline-unread-face + (face-foreground 'riece-channel-list-unread-face))) -(defvar riece-unread-enabled nil) +(defvar riece-unread-channels nil) (defconst riece-unread-description - "Mark channels where \"unread\" messages arrived") + "Mark channels where new messages arrived.") (defun riece-unread-after-display-message-function (message) - (if riece-unread-enabled + (if (get 'riece-unread 'riece-addon-enabled) (let ((target (if (riece-message-private-p message) (riece-message-speaker message) (riece-message-target message)))) @@ -78,19 +85,20 @@ (riece-emit-signal 'channel-list-changed))))) (defun riece-unread-after-switch-to-channel-function (last) - (if riece-unread-enabled + (if (get 'riece-unread 'riece-addon-enabled) (setq riece-unread-channels - (delete riece-current-channel - riece-unread-channels)))) + (delq (car (riece-identity-member riece-current-channel + riece-unread-channels)) + riece-unread-channels)))) (defun riece-unread-format-identity-for-channel-list-buffer (index identity) - (if (and riece-unread-enabled + (if (and (get 'riece-unread 'riece-addon-enabled) (riece-identity-member identity riece-unread-channels)) (concat (format "%2d:!" index) (riece-format-identity identity)))) (defun riece-unread-format-identity-for-channel-list-indicator (index identity) - (if (and riece-unread-enabled + (if (and (get 'riece-unread 'riece-addon-enabled) (riece-identity-member identity riece-unread-channels)) (let ((string (riece-format-identity identity)) (start 0)) @@ -100,7 +108,7 @@ string (replace-match "%%" nil nil string))) (list (format "%d:" index) (riece-propertize-modeline-string - string 'face 'riece-channel-list-unread-face))))) + string 'face 'riece-modeline-unread-face))))) (defun riece-unread-switch-to-channel () (interactive) @@ -114,12 +122,15 @@ (error "No unread channel!"))) (defun riece-guess-channel-from-unread () - riece-unread-channels) + (reverse riece-unread-channels)) (defun riece-unread-requires () (let (requires) (if (memq 'riece-highlight riece-addons) (setq requires (cons 'riece-highlight requires))) + ;; To override riece-history's channel mark in the channel list buffer. + (if (memq 'riece-history riece-addons) + (setq requires (cons 'riece-history requires))) ;;; (if (memq 'riece-guess riece-addons) ;;; (setq requires (cons 'riece-guess requires))) requires)) @@ -142,6 +153,23 @@ ;;; 'riece-guess-channel-from-unread)) ) +(defun riece-unread-uninstall () + (remove-hook 'riece-after-display-message-functions + 'riece-unread-after-display-message-function) + (remove-hook 'riece-after-switch-to-channel-functions + 'riece-unread-after-switch-to-channel-function) + (remove-hook 'riece-format-identity-for-channel-list-buffer-functions + 'riece-unread-format-identity-for-channel-list-buffer) + (remove-hook 'riece-format-identity-for-channel-list-indicator-functions + 'riece-unread-format-identity-for-channel-list-indicator) + (setq riece-channel-list-mark-face-alist + (delq (assq ?! riece-channel-list-mark-face-alist) + riece-channel-list-mark-face-alist)) +;;; (if (memq 'riece-guess riece-addons) +;;; (add-hook 'riece-guess-channel-try-functions +;;; 'riece-guess-channel-from-unread)) + ) + (defvar riece-command-mode-map) (defvar riece-dialogue-mode-map) (defvar riece-channel-list-mode-map) @@ -151,8 +179,7 @@ (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) - (setq riece-unread-enabled t) + "u" 'riece-unread-switch-to-channel) (riece-emit-signal 'channel-list-changed)) (defun riece-unread-disable () @@ -162,7 +189,7 @@ "u" nil) (define-key riece-channel-list-mode-map "u" nil) - (setq riece-unread-enabled nil) + (setq riece-unread-channels nil) (riece-emit-signal 'channel-list-changed)) (provide 'riece-unread)