X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-highlight.el;h=6b3dbb53b58552c86883fd3130b75c44a43a5e24;hp=ff65be5d2fee5c501acd204e4d6e750493f41d6e;hb=2b559fc272a39d2dd115a59357eaeafc58374441;hpb=e447920d6ebe73786cbaa0e5896f04bb0423dd5d diff --git a/lisp/riece-highlight.el b/lisp/riece-highlight.el index ff65be5..6b3dbb5 100644 --- a/lisp/riece-highlight.el +++ b/lisp/riece-highlight.el @@ -27,16 +27,18 @@ (require 'riece-globals) (require 'riece-options) ;riece-channel-list-buffer-mode (require 'riece-identity) ;riece-format-identity +(require 'riece-misc) (require 'font-lock) +(require 'derived) (defgroup riece-highlight nil - "Highlight your IRC buffer" + "Highlight IRC buffers" :tag "Highlight" :prefix "riece-" :group 'riece) (defgroup riece-highlight-faces nil - "Faces for highlight your IRC buffer" + "Faces for highlight IRC buffers" :tag "Faces" :prefix "riece-highlight-" :group 'riece-highlight) @@ -148,7 +150,7 @@ ".*\\)$") (list 1 (intern (format "riece-dialogue-%s-face" line)) t t))) '(change notice wallops error info)) - (list (list "(from [^)]+)$" 0 riece-dialogue-server-face t))) + '((riece-highlight-server-match 0 riece-dialogue-server-face t))) "Default expressions to highlight in riece-dialogue-mode." :type '(repeat (list string)) :group 'riece-highlight) @@ -187,33 +189,43 @@ :type '(repeat (list string)) :group 'riece-highlight) +(unless (riece-facep 'riece-modeline-current-face) + (make-face 'riece-modeline-current-face + "Face used for displaying the current channel in modeline.") + (if (featurep 'xemacs) + (set-face-parent 'riece-modeline-current-face 'modeline)) + (set-face-foreground 'riece-modeline-current-face + (face-foreground 'riece-channel-list-current-face))) + (defvar riece-highlight-enabled nil) -(defvar font-lock-support-mode) +(defconst riece-highlight-description + "Highlight IRC buffers") + +(defun riece-highlight-server-match (limit) + (and (re-search-forward "(from [^)]+)$" limit t) + (get-text-property (match-beginning 0) 'riece-server-name))) + (defun riece-highlight-setup-dialogue () (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(riece-dialogue-font-lock-keywords t)) - (make-local-variable 'font-lock-verbose) - (setq font-lock-verbose nil) - (when (boundp 'font-lock-support-mode) - (make-local-variable 'font-lock-support-mode) - (setq font-lock-support-mode nil)) - (make-local-hook 'font-lock-mode-hook) - (setq font-lock-mode-hook nil) + ;; In XEmacs, auto-initialization of font-lock is not affective + ;; when buffer-file-name is not set. + (font-lock-set-defaults) (make-local-hook 'after-change-functions) (add-hook 'after-change-functions - 'riece-highlight-hide-prefix nil 'local)) + 'riece-highlight-hide-prefix nil 'local) + (if riece-highlight-enabled + (font-lock-mode 1))) (defun riece-highlight-setup-channel-list () (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(riece-channel-list-font-lock-keywords t)) - (make-local-variable 'font-lock-verbose) - (setq font-lock-verbose nil) - (when (boundp 'font-lock-support-mode) - (make-local-variable 'font-lock-support-mode) - (setq font-lock-support-mode nil)) - (make-local-hook 'font-lock-mode-hook) - (setq font-lock-mode-hook nil)) + ;; In XEmacs, auto-initialization of font-lock is not affective + ;; when buffer-file-name is not set. + (font-lock-set-defaults) + (if riece-highlight-enabled + (font-lock-mode 1))) (defun riece-highlight-hide-prefix (start end length) (save-excursion @@ -243,7 +255,7 @@ string (replace-match "%%" nil nil string))) (list (format "%d:" index) (riece-propertize-modeline-string - string 'face 'riece-channel-list-current-face))))) + string 'face 'riece-modeline-current-face))))) (defun riece-highlight-insinuate () (put 'riece-channel-mode 'font-lock-defaults @@ -287,7 +299,7 @@ major-mode)) '(riece-dialogue-mode riece-channel-list-mode)) (with-current-buffer (car buffers) - (font-lock-mode -1))) + (font-lock-mode 0))) (setq buffers (cdr buffers)))) (setq riece-highlight-enabled nil))