emacs-devel
[Top][All Lists]
Advanced

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

Re: diary font-lock issue


From: Glenn Morris
Subject: Re: diary font-lock issue
Date: Tue, 16 May 2006 13:56:39 -0400
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Hi Martin, thanks for the response.


martin rudalics wrote:

> `foo-font-lock-keywords' will fail to find a match when the end of
> `font-lock-fontify-region' is positioned as indicated above.

> As soon as `font-lock-extend-region' has undergone its final revision
> you should be able to replace the after-change-hook by writing an
> appropriate `font-lock-extend-region-function'.  If
> `font-lock-extend-region' will be regularly called by say
> `font-lock-default-fontify-region', you will have to simply check
> whether the first character to be fontified is an "=" and you may use
> your original code practically unchanged.
>

> (defun foo-bar (bound)
[...]
> (setq foo-font-lock-keywords
>       '((foo-bar 1 'font-lock-keyword-face)))

Just looking at this quickly, it looks to be doing the same job as the
regexp I originally quoted, but using a function instead to do the
match. Setting font-lock-multiline to t in the buffer means that it
gets added as a property to all fontified regions, so yours is more
elegant (only adding the property where needed), but the two ought to
be equivalent, right?

> (defun foo-mode-after-change (start end old-len)

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

This all seems very complex. According to:

<http://lists.gnu.org/archive/html/emacs-devel/2006-04/msg00881.html>

"the font-lock-multiline property should be enough in all cases to
make it unnecessary to use an after-change-function hook."

That's a long thread, but AFAICS, it seems that for simple keyword
fontification, setting font-lock-multiline for the buffer ought to be
enough.

(Though later on I find:

<http://lists.gnu.org/archive/html/emacs-devel/2006-04/msg01130.html>

    > (i) The matching of keywords which span line breaks;
    ... setting the font-lock-multiline variable... won't reliably
    take care of (i)

which confuses me.)


I'm also confused as to why the initial fontification is not working
as it should. There are no "changes" involved in this instance.
(Indeed, the fancy diary buffer is not something one edits, so this is
about as simple as multiline font-lockign can get.)





reply via email to

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