emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: diary font-lock issue


From: Stefan Monnier
Subject: Re: diary font-lock issue
Date: Wed, 17 May 2006 11:05:38 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> (setq foo-font-lock-keywords
>       
> '(("\\(\\(?: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=+$" . font-lock-keyword-face)))

> (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))

I'd suggest the following 100% untested:

(define-derived-mode foo-mode fundamental-mode
  "foo"
  (set (make-local-variable 'font-lock-defaults)
       '(foo-font-lock-keywords t nil nil nil
         (font-lock-fontify-region-function
          . foo-font-lock-fontify-region-function)
         (font-lock-multiline . t))))

(defun foo-font-lock-fontify-region-function (beg end &optional loudly)
  (goto-char beg)
  (forward-line 0)
  (if (looking-at "=+$") (setq beg (line-beginning-position 0)))
  (goto-char end)
  (unless (bolp) (forward-line 1))
  (if (looking-at "=+$") (setq end (line-beginning-position 2)))
  (font-lock-default-fontify-region beg end loudly))


-- Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]