X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Friece-history.el;h=aece8294c803697ade61aa19a3477ca08ace6d07;hb=c29e67d9775fc091a53a59d8fb315ef2e05bd46b;hp=435c9faff832e8e19de1c616909311cfa2c2b163;hpb=c9e176be5079fdd2c81e0d3a2c4ee0d2d8cf5e17;p=riece diff --git a/lisp/riece-history.el b/lisp/riece-history.el index 435c9fa..aece829 100644 --- a/lisp/riece-history.el +++ b/lisp/riece-history.el @@ -23,11 +23,18 @@ ;;; Commentary: -;; To use, add the following line to your ~/.riece/init.el: -;; (add-to-list 'riece-addons 'riece-history) +;; You can check recently visited channels via `C-c g' in the commands +;; buffer, by adding the following lines to ~/.riece/init.el: + +;; (add-hook 'riece-guess-channel-try-functions +;; 'riece-guess-channel-from-history) ;;; Code: +(require 'riece-options) +(require 'riece-globals) +(require 'riece-highlight) +(require 'riece-identity) (require 'ring) (defgroup riece-history nil @@ -41,6 +48,19 @@ :type 'integer :group 'riece-history) +(defface riece-channel-list-history-face + '((((class color) + (background dark)) + (:foreground "PaleTurquoise")) + (((class color) + (background light)) + (:foreground "SeaGreen3")) + (t + (:bold t))) + "Face used for displaying history channels." + :group 'riece-highlight-faces) +(defvar riece-channel-list-history-face 'riece-channel-list-history-face) + (defvar riece-channel-history nil) (defun riece-guess-channel-from-history () @@ -52,9 +72,16 @@ index (1+ index))) (nreverse result))) -(defun riece-history-requires () - (if (memq 'riece-guess riece-addons) - '(riece-guess))) +(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))) + (concat (format "%2d:+" index) + (riece-format-identity channel) + "\n"))) + +;;; (defun riece-history-requires () +;;; (if (memq 'riece-guess riece-addons) +;;; '(riece-guess))) (defun riece-history-insinuate () (add-hook 'riece-startup-hook @@ -66,10 +93,19 @@ (setq riece-channel-history nil))) (add-hook 'riece-after-switch-to-channel-functions (lambda (last) - (ring-insert riece-channel-history last))) - (if (memq 'riece-guess riece-addons) - (add-hook 'riece-guess-channel-try-functions - 'riece-guess-channel-from-history))) + (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) + (if (memq 'riece-highlight riece-addons) + (setq riece-channel-list-mark-face-alist + (cons '(?+ . riece-channel-list-history-face) + riece-channel-list-mark-face-alist))) +;;; (if (memq 'riece-guess riece-addons) +;;; (add-hook 'riece-guess-channel-try-functions +;;; 'riece-guess-channel-from-history)) + ) (provide 'riece-history)