X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Friece-history.el;h=79dd38909861c4df12f78995c6807ae99ef6b352;hb=8bb0858f2815a32b2cd471fbdfbda2e86e82eb07;hp=6541febee5c9e8b288f9169c7d766fbc2875d3dd;hpb=a90da5167ee52cbf7b1320a4c6a4465b8b10075d;p=riece diff --git a/lisp/riece-history.el b/lisp/riece-history.el index 6541feb..79dd389 100644 --- a/lisp/riece-history.el +++ b/lisp/riece-history.el @@ -1,4 +1,4 @@ -;;; riece-history.el --- channel history management add-on +;;; riece-history.el --- manage history of channel shifting ;; Copyright (C) 1998-2003 Daiki Ueno ;; Author: Daiki Ueno @@ -23,6 +23,8 @@ ;;; Commentary: +;; NOTE: This is an add-on module for Riece. + ;; You can check recently visited channels via `C-c g' in the commands ;; buffer, by adding the following lines to ~/.riece/init.el: @@ -35,10 +37,11 @@ (require 'riece-globals) (require 'riece-highlight) (require 'riece-identity) +(require 'riece-signal) (require 'ring) (defgroup riece-history nil - "Channel history" + "Manage history of channel shifting." :tag "History" :prefix "riece-" :group 'riece) @@ -61,8 +64,23 @@ :group 'riece-highlight-faces) (defvar riece-channel-list-history-face 'riece-channel-list-history-face) +(unless (riece-facep 'riece-modeline-history-face) + (make-face 'riece-modeline-history-face + "Face used for displaying history channels in modeline.") + (if (featurep 'xemacs) + (set-face-parent 'riece-modeline-history-face 'modeline)) + (set-face-foreground 'riece-modeline-history-face + (face-foreground 'riece-channel-list-history-face))) + +(defvar riece-modeline-history-face 'riece-modeline-history-face) + (defvar riece-channel-history nil) +(defvar riece-history-enabled nil) + +(defconst riece-history-description + "Manage history of channel shifting.") + (defun riece-guess-channel-from-history () (let ((length (ring-length riece-channel-history)) (index 0) @@ -73,41 +91,35 @@ (nreverse result))) (defun riece-history-format-identity-for-channel-list-buffer (index identity) - (if (and (not (ring-empty-p riece-channel-history)) + (if (and riece-history-enabled + (not (ring-empty-p riece-channel-history)) (riece-identity-equal identity (ring-ref riece-channel-history 0))) (concat (format "%2d:+" index) (riece-format-identity identity)))) (defun riece-history-format-identity-for-channel-list-indicator (index identity) - (if (and (not (ring-empty-p riece-channel-history)) + (if (and riece-history-enabled + (not (ring-empty-p riece-channel-history)) (riece-identity-equal identity (ring-ref riece-channel-history 0))) (let ((string (riece-format-identity identity)) - (start 0) - extent) + (start 0)) ;; Escape % -> %%. (while (string-match "%" string start) (setq start (1+ (match-end 0)) string (replace-match "%%" nil nil string))) (list (format "%d:" index) (riece-propertize-modeline-string - string 'face 'riece-channel-list-history-face))))) + string 'face 'riece-modeline-history-face))))) ;;; (defun riece-history-requires () ;;; (if (memq 'riece-guess riece-addons) ;;; '(riece-guess))) (defun riece-history-insinuate () - (add-hook 'riece-startup-hook - (lambda () - (setq riece-channel-history - (make-ring riece-channel-history-length)))) - (add-hook 'riece-exit-hook - (lambda () - (setq riece-channel-history nil))) (add-hook 'riece-after-switch-to-channel-functions (lambda (last) - (if (and last + (if (and riece-history-enabled last (not (riece-identity-equal last riece-current-channel))) (ring-insert riece-channel-history last)))) (add-hook 'riece-format-identity-for-channel-list-buffer-functions @@ -123,7 +135,17 @@ ;;; 'riece-guess-channel-from-history)) ) +(defun riece-history-enable () + (setq riece-channel-history + (make-ring riece-channel-history-length)) + (setq riece-history-enabled t) + (riece-emit-signal 'channel-list-changed)) + +(defun riece-history-disable () + (setq riece-channel-history nil + riece-history-enabled nil) + (riece-emit-signal 'channel-list-changed)) + (provide 'riece-history) ;;; riece-history.el ends here -