X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Friece-unread.el;h=c07c84082ee9902ff52cc022a069175135e49686;hb=39a549aa5e223951c0046b6757ff9f57b91c475f;hp=e35c0e3ac21912049a3de55bf62b1d90364a0d8a;hpb=8bb0858f2815a32b2cd471fbdfbda2e86e82eb07;p=riece diff --git a/lisp/riece-unread.el b/lisp/riece-unread.el index e35c0e3..c07c840 100644 --- a/lisp/riece-unread.el +++ b/lisp/riece-unread.el @@ -18,8 +18,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. ;;; Commentary: @@ -38,8 +38,7 @@ (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." @@ -70,13 +69,11 @@ (defvar riece-unread-channels nil) -(defvar riece-unread-enabled nil) - (defconst riece-unread-description "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)))) @@ -88,20 +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 (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)) @@ -131,6 +128,9 @@ (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)) @@ -153,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) @@ -162,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 () @@ -173,8 +189,7 @@ "u" nil) (define-key riece-channel-list-mode-map "u" nil) - (setq riece-unread-channels nil - riece-unread-enabled nil) + (setq riece-unread-channels nil) (riece-emit-signal 'channel-list-changed)) (provide 'riece-unread)