
;---------------------------------------------------------------------------
; Provide highlighting of a wdiff buffer.
;
; Mark Allman (mallman@icir.org)
;
; Call 'allman-wdiff-fontify-buffer' to highlight the additions and 
; removals in wdiff output contained in the current buffer.  (I do this 
; as part of generating the wdiff from various VCS).
;---------------------------------------------------------------------------

(provide 'allman-wdiff)

(defvar allman-wdiff-add-font
  (make-face 'allman-wdiff-add-font))
(set-face-foreground 'allman-wdiff-add-font "yellow")
(make-face-bold 'allman-wdiff-add-font)

(defvar allman-wdiff-remove-font
  (make-face 'allman-wdiff-remove-font))
(set-face-foreground 'allman-wdiff-remove-font "white")
(make-face-bold 'allman-wdiff-remove-font)

(defun allman-wdiff-fontify-buffer ()
  (interactive)
  (setq font-lock-multiline t)
  (font-lock-add-keywords
   nil
   '(("[{]\\+\\([^+]\\|\\+[^}]\\)*\\+[}]" . 'allman-wdiff-add-font)
     ("\\[\\-\\([^-]\\|\\-[^]]\\)*\\-\\]" . 'allman-wdiff-remove-font)))
  (font-lock-fontify-buffer))
