unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* diary font-lock issue
@ 2006-05-16  7:22 Glenn Morris
  2006-05-16 15:50 ` martin rudalics
  2006-05-17 15:05 ` Stefan Monnier
  0 siblings, 2 replies; 9+ messages in thread
From: Glenn Morris @ 2006-05-16  7:22 UTC (permalink / raw



I'm trying to fix a bug recently reported by Stephen Berman
("Fontification problem with fancy diary") on the pretest-bug list.
I'm stumped, and would appreciate some help from people knowledgeable
about font-lock.

I can simplify the issue to this:


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


sample input file:
-------
Friday, May 5, 2006
===================
9.00 Xxxx Xxxxxx Xxxxx xXxxxxxxxxxxxx
15.20-15.50 Xxxx Xxxxxxxxxxxxxxxxx
17.30-19.00 Xxxx Xxxxxxxxxx
18.00-19.30 Xxxx XXX

Monday, May 8, 2006
===================
8.00 Xxxxxxxx xx Xxxxxxxx Xxxxxxxxxx xxx Xxxxxxxxxxxxx
14.30 Xxxxxx XxxxxXXxXxxxxx xxx Xxxx
15.30-17.00 Xxxx XxxxxXX
16.45 Xxxx xxx XxxxxXX xxxxxxx
17.15-18.15 Xxxx XxxxxXx

Tuesday, May 9, 2006
====================
14.50 Xxxx xxx Xxxxxxxxxxxxxxxxxxxxx xxxxxxx
15.30-16.00 Xxxx

Wednesday, May 10, 2006
=======================
20.00-21.15 Xxxxxx Xxxxxx


------

Defining foo-mode as above, and visiting the above example file, the
last "Wednesday, May 10, 2006" does not get font-locked. If the
"15.30-16.00" line in the immediately previous Tuesday section is not
there, it works as it should.

Alternatively, if the "\n=+$" part is removed from the font-lock
keywords, it works as it should. That made me think it might be a
multiline font-lock pattern issue. Hence I added the setting of
font-lock-multiline in the mode definition (the diary does not have
this), but that did not help.


TIA for any help.


PS For clarity, the font-lock definition can be replaced by:

(setq foo-font-lock-keywords
      (list
       (cons
        (format "%s, %s %s, %s"
                (regexp-opt '("Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
                              "Saturday" "Sunday") t)
                (regexp-opt '("January" "February" "March" "April" "May" "June"
                              "July" "August" "September" "October" "November"
                              "December") t)
                "[0-9]+" "[0-9]+\n=+$")
        font-lock-keyword-face)))

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-05-21 10:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-16  7:22 diary font-lock issue Glenn Morris
2006-05-16 15:50 ` martin rudalics
2006-05-16 17:56   ` Glenn Morris
2006-05-16 21:42     ` martin rudalics
2006-05-17 15:11     ` Stefan Monnier
2006-05-17 15:05 ` Stefan Monnier
2006-05-17 19:11   ` Glenn Morris
2006-05-17 21:15     ` Stefan Monnier
2006-05-21 10:39   ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).