X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-history.el;h=25b8e7e6c57b514beb10856e83ffcf8abf03d781;hb=bf2df5d4bf0f70c7f102eb924e352f83d46f3fa4;hp=aece8294c803697ade61aa19a3477ca08ace6d07;hpb=b548b4a448ec0f207c010ec7e449f818f3b77a02;p=elisp%2Friece.git diff --git a/lisp/riece-history.el b/lisp/riece-history.el index aece829..25b8e7e 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 @@ -18,11 +18,13 @@ ;; 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: +;; 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: @@ -33,12 +35,13 @@ (require 'riece-options) (require 'riece-globals) -(require 'riece-highlight) (require 'riece-identity) +(require 'riece-signal) (require 'ring) +(require 'riece-highlight) (defgroup riece-history nil - "Channel history" + "Manage history of channel shifting." :tag "History" :prefix "riece-" :group 'riece) @@ -61,8 +64,21 @@ :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) +(defconst riece-history-description + "Manage history of channel shifting.") + (defun riece-guess-channel-from-history () (let ((length (ring-length riece-channel-history)) (index 0) @@ -72,32 +88,48 @@ index (1+ index))) (nreverse result))) -(defun riece-history-format-channel-list-line (index channel) - (if (and (not (ring-empty-p riece-channel-history)) - (riece-identity-equal channel (ring-ref riece-channel-history 0))) +(defun riece-history-format-identity-for-channel-list-buffer (index identity) + (if (and (get 'riece-history 'riece-addon-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 channel) - "\n"))) + (riece-format-identity identity)))) + +(defun riece-history-format-identity-for-channel-list-indicator (index + identity) + (if (and (get 'riece-history 'riece-addon-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)) + ;; 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-modeline-history-face))))) ;;; (defun riece-history-requires () ;;; (if (memq 'riece-guess riece-addons) ;;; '(riece-guess))) +(defun riece-history-after-switch-to-channel-functions (last) + (if (and (get 'riece-history 'riece-addon-enabled) last + (not (riece-identity-equal last riece-current-channel))) + (ring-insert riece-channel-history last))) + +(defun riece-history-requires () + (if (memq 'riece-highlight riece-addons) + '(riece-highlight))) + (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 - (not (riece-identity-equal last riece-current-channel))) - (ring-insert riece-channel-history last)))) - (add-hook 'riece-format-channel-list-line-functions - 'riece-history-format-channel-list-line) + 'riece-history-after-switch-to-channel-functions) + (add-hook 'riece-format-identity-for-channel-list-buffer-functions + 'riece-history-format-identity-for-channel-list-buffer) + (add-hook 'riece-format-identity-for-channel-list-indicator-functions + 'riece-history-format-identity-for-channel-list-indicator) (if (memq 'riece-highlight riece-addons) (setq riece-channel-list-mark-face-alist (cons '(?+ . riece-channel-list-history-face) @@ -107,7 +139,26 @@ ;;; 'riece-guess-channel-from-history)) ) +(defun riece-history-uninstall () + (remove-hook 'riece-after-switch-to-channel-functions + 'riece-history-after-switch-to-channel-functions) + (remove-hook 'riece-format-identity-for-channel-list-buffer-functions + 'riece-history-format-identity-for-channel-list-buffer) + (remove-hook 'riece-format-identity-for-channel-list-indicator-functions + 'riece-history-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))) + +(defun riece-history-enable () + (setq riece-channel-history + (make-ring riece-channel-history-length)) + (riece-emit-signal 'channel-list-changed)) + +(defun riece-history-disable () + (setq riece-channel-history nil) + (riece-emit-signal 'channel-list-changed)) + (provide 'riece-history) ;;; riece-history.el ends here -