(defun foo-bar (bound) (let (beg end) (and (re-search-forward "\\(\\(?:\\(?:Fri\\|Mon\\|S\\(?:atur\\|un\\)\\|\\(?:T\\(?:hur\\|ue\\)\\|Wedne\\)s\\)day\\)\ , \\(?:A\\(?:pril\\|ugust\\)\\|December\\|February\\|J\\(?:anuary\\|u\\(?:ly\\|ne\\)\\)\ \\|Ma\\(?:rch\\|y\\)\\|\\(?:Novem\\|Octo\\|Septem\\)ber\\) [0-9]+, -?[0-9]+\n\\)\\(=+\n\\)?" bound t) (or (and (> (match-end 0) (match-end 1)) (setq beg (match-beginning 0)) (setq end (match-end 0))) (and (= (match-end 1) bound) (setq beg (match-beginning 0)) (save-excursion (save-match-data (and (looking-at "=+\n") (setq end (match-end 0))))))) (and beg end (or (put-text-property beg end 'font-lock-multiline t) t))))) (setq foo-font-lock-keywords '((foo-bar 1 'font-lock-keyword-face))) (defun foo-mode-after-change (start end old-len) (save-excursion (goto-char start) (beginning-of-line) (when (eq (char-after) ?\=)) (let* ((buffer-undo-list t) (inhibit-read-only t) (inhibit-point-motion-hooks t) (inhibit-modification-hooks t) deactivate-mark buffer-file-name buffer-file-truename) (put-text-property (line-beginning-position 0) (line-beginning-position) 'fontified nil)))) (define-derived-mode foo-mode fundamental-mode "foo" (set (make-local-variable 'font-lock-defaults) '(foo-font-lock-keywords t)) (set (make-local-variable 'font-lock-multiline) t) (add-hook 'after-change-functions 'foo-mode-after-change nil t))